<%namespace name="dialogH" file="jm2l:templates/Logistique/Dialog_Heberg.mako"/>
<%namespace name="dialogC" file="jm2l:templates/Logistique/Dialog_Covoit.mako"/>
<%namespace name="dialogM" file="jm2l:templates/Logistique/Dialog_Matos.mako"/>
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
##                     Faire une Proposition
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<%def name="AddProposal(Type, form)"> \
<%
if Type=='H':
    CurTitle = u"un hébergement"
    CurIcon = "icon-home"
elif Type=='C':
    CurTitle = "un co-voiturage"
    CurIcon = "icon-road"
elif Type=='M':
    CurTitle = u"un prêt de matériel"
    CurIcon = "icon-shopping-cart"
%> \
    <!-- Modal -->
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="AddProp${Type}ModalLabel"> Je propose ${CurTitle} !</h3>
    </div>
    <div class="modal-body">
        %if 'exch_id' in form._fields.keys():
            <form id="ModalForm" action="javascript:DoPost('/2015/modal/Prop${Type}/${form.exch_id.data}');">
        %else:
            <form id="ModalForm" action="javascript:DoPost('/2015/modal/Prop${Type}/0');">         
        %endif
            <p>Je propose mes service pour ${CurTitle}</p>
            % if Type=='H':
                ${dialogH.Heberg_Proposal(form)}
            % elif Type=='C':
                ${dialogC.Covoit_Proposal(form)}
            % elif Type=='M':
                ${dialogM.Matos_Proposal(form)}
            % endif
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Fermer</button>
        <button class="btn btn-primary" onclick="javascript:document.forms['ModalForm'].submit();">
        <i class="${CurIcon} icon-white"></i> Proposer !</button>
    </div>
</%def> \
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
##                     Faire une Demande
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<%def name="AddAsk(Type, form)"> \
<%
if Type=='H':
    CurTitle = u"un hébergement"
    CurIcon = "icon-home"
elif Type=='C':
    CurTitle = "un co-voiturage"
    CurIcon = "icon-road"
elif Type=='M':
    CurTitle = u"un prêt de matériel"
    CurIcon = "icon-shopping-cart"
%>
    <!-- Modal -->
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="AddAsk${Type}ModalLabel"> Je demande ${CurTitle} !</h3>
    </div>
    <div class="modal-body"> 
    % if 'exch_id' in form._fields.keys():
        <form id="ModalForm" action="javascript:DoPost('/2015/modal/Ask${Type}/${form.exch_id.data}');">
    % else:
       <form id="ModalForm" action="javascript:DoPost('/2015/modal/Ask${Type}/0');">
    %endif       
            <p>Je demande ${CurTitle}</p>
            % if Type=='H':
                ${dialogH.Heberg_Ask(form)}
            % elif Type=='C':
                ${dialogC.Covoit_Ask(form)}
            % elif Type=='M':
                ${dialogM.Matos_Ask(form)}
            % endif
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Fermer</button>
        <button class="btn btn-primary" onclick="javascript:document.forms['ModalForm'].submit();">
        <i class="${CurIcon} icon-white"></i> Demander !</button>
    </div>
</%def> \
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
##                     Afficher les détails
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<%def name="Show(Type, Exch)"> \
<%
if Exch.exch_type=='H':
    CurTitle = u"de l'hébergement"
    CurIcon = "icon-home"
elif Exch.exch_type=='C':
    CurTitle = "du co-voiturage"
    CurIcon = "icon-road"
elif Exch.exch_type=='M':
    CurTitle = u"du prêt de matériel"
    CurIcon = "icon-shopping-cart"
%>
    <!-- Modal -->
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <i class="${CurIcon}"></i> <strong>Détails ${CurTitle}</strong>
    </div>
    <div class="modal-body">
        % if Type=='H':
            ${dialogH.ShowH(Exch)}
        % elif Type=='C':
            ${dialogC.ShowC(Exch)}
        % elif Type=='M':
            ${dialogM.ShowM(Exch)}
        % endif
        % if Exch.exch_state=='Ask':
            <form id="ModalForm" action="javascript:DoPost('/2015/exchange/Ask${Type}/${Exch.exch_id}/deal');"></form>
        % elif Exch.exch_state=='Proposal':
            <form id="ModalForm" action="javascript:DoPost('/2015/exchange/Prop${Type}/${Exch.exch_id}/deal');"></form>
        % endif        
    </div>
    <div class="modal-footer">
        % if not Exch.exch_done and (Exch.asker_id is None or Exch.provider_id is None):
            % if Exch.exch_state=='Proposal' and Exch.provider_id!=request.user.uid:
                <button class="btn btn-info" data-dismiss="modal" aria-hidden="true"
                    onclick="javascript:document.forms['ModalForm'].submit();">
                    % if Type=='H':
                        Je lui demande pour dormir chez lui/elle !
                    % elif Type=='C':
                        Je lui demande de venir me chercher !
                    % elif Type=='M':
                        Je lui demande de me prêter son matériel !
                    % endif
                </button>
            % elif Exch.exch_state=='Ask' and Exch.asker_id!=request.user.uid:
                <button class="btn btn-info" data-dismiss="modal" aria-hidden="true"
                    onclick="javascript:document.forms['ModalForm'].submit();">
                    % if Type=='H':
                        Je propose de l'héberger !
                    % elif Type=='C':
                        Je propose de venir le/la chercher !
                    % elif Type=='M':
                        Je lui propose mon matériel !
                    % endif
                </button>
            % endif
        % endif
        <button class="btn" data-dismiss="modal" aria-hidden="true">Fermer</button>
    </div>
</%def> \
