<%namespace name="Modals" file="jm2l:templates/modals.mako"/>
<%namespace name="helpers" file="jm2l:templates/helpers.mako"/>
<%def name="profil_wrapper(uprofil, profil_form)">

##<form id="ProfilForm" action="javascript:DoPost('/2015/modal/Place/${form.place_id.data}');">
% if uprofil!=request.user and request.user.uid==1:
    <form id="ProfilForm" action="/MesJM2L?user=${uprofil.uid}" method="POST">
% else:
    <form id="ProfilForm" action="/MesJM2L" method="POST">
% endif

<div class="row-fluid">
    <div class="span8">
    <a href="/sign/jm2l/${uprofil.my_hash}">Mon lien de connection</a> - 
    <a href="/user/${request.user.slug}">Mon profil public</a><br>
    <h3>${profil_form.prenom.data} ${profil_form.nom.data}</h3>
<%
DicFormA = {
    'nom':     {'PlaceHolder':u"Mon Nom",               'ContainerClass':"span6", 'next':False},
    'prenom':  {'PlaceHolder':u"Mon Prénom",            'ContainerClass':"span6", 'next':True},
    'pseudo':  {'PlaceHolder':u"Mon Pseudo",            'ContainerClass':"span6", 'next':False},
    'mail':    {'PlaceHolder':u"mon.mail@fqdn.tld",     'ContainerClass':"span6", 'next':True},
    'phone':   {'PlaceHolder':u"0612345678",            'ContainerClass':"span6", 'next':False},
    'website': {'PlaceHolder':u"http://ma-page-web.moi",'ContainerClass':"span6", 'next':True},
    'gpg_key': {'PlaceHolder':u"Ma clé gpg",            'ContainerClass':"span6", 'next':False},
    'soc_link':{'PlaceHolder':u"#jm2l sur irc.freenode.org",'ContainerClass':"span6", 'next':True}, 
    'bio':        {'Ignore':True},
    'tiersship':  {'Ignore':True},
    'id':  {'Ignore':True},
    'user_id':  {'Ignore':True},
    }

DicFormB = {
    'nom':     {'Ignore':True },
    'prenom':  {'Ignore':True },
    'pseudo':  {'Ignore':True },
    'mail':    {'Ignore':True },
    'phone':   {'Ignore':True },
    'website': {'Ignore':True },    
    'gpg_key':    {'Ignore':True},
    'soc_link':   {'Ignore':True},    
    'bio':     {'PlaceHolder':u"Ma Bilibiographie", "ckeditor":1, 'ContainerClass':"span11", 'next':False },
    'tiersship':  {'Ignore':True}
    }


DicForm2 = {
    'nom':     {'PlaceHolder':u"Mon Nom",               "FieldStyle":"width:16em;", 'ContainerStyle':"float:left;"},
    'prenom':  {'PlaceHolder':u"Mon Prénom",            "FieldStyle":"width:16em;"},
    'pseudo':  {'PlaceHolder':u"Mon Pseudo",            "FieldStyle":"width:16em;", 'ContainerStyle':"float:left;"},
    'mail':    {'PlaceHolder':u"mon.mail@fqdn.tld",     "FieldStyle":"width:16em;"},
    'phone':   {'PlaceHolder':u"0612345678",            "FieldStyle":"width:16em;", 'ContainerStyle':"float:left;"},
    'website': {'PlaceHolder':u"http://ma-page-web.moi","FieldStyle":"width:16em;"},    
    'gpg_key': {'PlaceHolder':u"Ma clé gpg",            "FieldStyle":"width:90%;"},
    'soc_link':{'PlaceHolder':u"#jm2l sur irc.freenode.org","FieldStyle":"width:90%;"},    
    'bio':     {'PlaceHolder':u"Ma Bilibiographie",     "FieldStyle":"width:95%;min-height:150px;", "fieldset":True, "ckeditor":1 },
    'tiersship':  {'Ignore':True}    
    }

%>
    ${helpers.DisplayRespForm(profil_form, DicFormA)}
    </div>
    <div class="span4">
        ${helpers.show_my_pictures(uprofil)}
    </div>
</div>
    
${helpers.DisplayRespForm(profil_form, DicFormB)}
    <fieldset>
    <legend>Activité</legend>
    Saisissez ci-dessous les entités que vous souhaiter représenter pendant l'événement.
    (Association, GULL, Entreprise, Logiciel, ...).<br>
    Si elle n'existe pas dans la liste proposée, vous pouvez <a href="/entity"> en ajouter une. </a>

    <div class="repeat">
        <table class="wrapper table" width="100%">
            <thead>
              <tr class="row">
                <th style="width:4em;text-align:center;">Année</th>
                <th style="width:19em;text-align:center;">Entité</th>
                <th style="text-align:center";>Rôle</th>
                <th style="width:6em;text-align:center;">Action</th>            
              </tr>            
            </thead>
            <tbody class="container">
            <tr class="row template" style="line-height:2.2em;">
                <td style="text-align:center;">
                    <input type="hidden" style="width:20em;" class="form-control" name="tiersship-{{row-count-placeholder}}-year_uid" 
                        value="2015" /> 2015
                </td>
                <td style="text-align: center;">
                    <input type="hidden" class="form-control" name="tiersship-{{row-count-placeholder}}-user_uid" 
                        value="${uprofil.uid}" style="width:4em;" />                
                    <input type="hidden" class="form-control" style="width:20em;" name="tiersship-{{row-count-placeholder}}-tiers_uid"
                        id="tiersship-{{row-count-placeholder}}-tiers_uid" />
                </td>
                <td style="text-align:center;">
                    <input style="width:100%;margin:-7px;" type="text" class="form-control" name="tiersship-{{row-count-placeholder}}-role" 
                        value="" />
                </td>                
                <td>
                    <span class="remove btn btn-mini btn-danger">
                        <i class="icon-remove-sign icon-white"></i> Suppr.
                    </span>
                </td>            
            </tr>
            % for num, dicdata in enumerate(profil_form._fields.get("tiersship").data):
            <tr class="row" style="padding:5px;line-height:2.2em;">
                <td style="text-align:center;">
                    <input type="hidden" class="form-control" name="tiersship-${num}-year_uid" 
                        value="${dicdata.get('year_uid')}" style="width:4em;" />
                    ${dicdata.get('year_uid')}
                </td>
                <td style="text-align:center;">
                    <input type="hidden" class="form-control" name="tiersship-${num}-user_uid" 
                        value="${dicdata.get('user_uid')}" style="width:4em;" />
                    <input type="hidden" class="form-control" name="tiersship-${num}-tiers_uid" 
                        value="${dicdata.get('tiers_uid')}" style="width:4em;" />
                    <% 
                    entity = DBTiers.by_id(dicdata.get('tiers_uid'))
                    %>
                    % if entity:
                    <small>${entity.get_entity_type.entity_subtype}</small>
                    <a href="/entity/${entity.get_entity_type.entity_type}/${entity.slug}">${entity.name}</a>
                    % endif
                </td>
                <td style="text-align:center;">
                    <input style="width:100%;margin:-7px;" type="text" class="form-control" name="tiersship-${num}-role" 
                        value="${dicdata.get('role')}" />
                </td>
                <td>
                    <span class="remove btn btn-mini btn-danger">
                        <i class="icon-remove-sign icon-white"></i> Suppr.
                    </span>
                </td>
            </tr>
            % endfor
            </tbody>
            <tfoot>
              <tr>
                <td colspan="5" style="text-align:center;line-height: 3em;">
                    <span class="add btn btn-mini btn-primary"><i class="icon-plus-sign icon-white"></i> Je fais partie de ...</span>
                </td>
              </tr>            
            </tfoot>
        </table>
    </div>
    </fieldset>

<div class="span2 offset5">
    <input class="btn btn-primary" type="submit" value="Enregistrer !" />
</div>
    </form>

</%def>
