<?php
$oJ = v('oJ');
/*
$membre = v('membre'); 
foreach ($membre as $k=>$v) {
    $membre[$k] = no_xss($v);
}
*/
$dis_nom = OPT_FIGER_NOM_PRE === true && $oJ->get_JOU_NOM() != '' ? 'disabled' : null;
$dis_prenom = OPT_FIGER_NOM_PRE === true && $oJ->get_JOU_PRE() != '' ? 'disabled' : null;
$dis_licence = OPT_FIGER_LIC === true && $oJ->get_JOU_LIC() != '' ? 'disabled' : null;

if (v('erreur')) {
    ?>
<div align="center" class="erreur"><?php echo display_erreurs(); ?></div>
<?php } ?>

<h1><?php echo __('em.cpt.titre'); ?></h1>
<h2 align="center"><?php echo sprintf(__('em.cpt.profil'), $oJ->get_JOU_LOGIN()); ?></h2>

<form action="<?php echo php_self();?>" method="post" name="modifier_membre" id="modifier_membre"
      enctype="multipart/form-data">
    <?php echo ZAuth::get_fingerprint(); ?>

    <div style="float: left; text-align:center">
        <?php echo zk_aff_logo_j($oJ->get_JOU_AVATAR()); ?>
        <br/>
        <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo POIDS_IMAGE; ?>">
        <?php echo form('input', array('type' => 'file', 'name' => 'UP_LOGO')); ?><br /><br />
        <input type="checkbox" name="DEL_AVATAR" value="1"/> <?php echo __('em.eq.sup_avatar'); ?>
    </div>
    <table>
        <tr>
            <td class="g"><?php echo __('com.txt.mdp'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'password', 'maxlength' => 32, 'name' => 'JOU_PASS')); ?></td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.confirm'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'password', 'maxlength' => 32, 'name' => 'JOU_PASS2')); ?></td>
        </tr>
        <tr>
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr>
            <td class="g"><?php echo __('com.txt.mail'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'maxlength' => 100, 'name' => 'JOU_MAIL')); ?></td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.confirm'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'maxlength' => 100, 'name' => 'JOU_MAIL2')); ?></td>
        </tr>
        <tr>
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr>
            <td class="g"><?php echo __('com.txt.contact'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'maxlength' => 50, 'name' => 'JOU_CONTACT')); ?></td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.nom'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'maxlength' => 40, 'name' => 'JOU_NOM', $dis_nom => $dis_nom)); ?></td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.prenom'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'maxlength' => 40, 'name' => 'JOU_PRE', $dis_prenom => $dis_prenom)); ?></td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.sexe'); ?></td>
            <td class="d"><?php echo formSelect('JOU_SEXE', array(), v('tSexe')); ?>
            </td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.date_nai'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'name' => 'JOU_DATE_NAI')); ?>
                <?php echo __('com.txt.date_format'); ?>

            </td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.pays'); ?></td>
            <td class="d"><?php echo do_action('liste_pays'); ?></td>
        </tr>

        <tr>
            <td class="g"><?php echo __('com.txt.lieu'); ?></td>
            <td class="d"><?php echo form('input', array('type' => 'text', 'maxlength' => 30, 'name' => 'JOU_LOC')); ?></td>
        </tr>
        <tr>
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr>
            <td class="g"><?php echo __('com.txt.mail_pm'); ?></td>
            <td class="d"><?php echo formSelect('JOU_MAIL_MP', array(), v('tOuiNon')); ?></td>
        </tr>
        <tr>
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left"><?php echo __('com.txt.licence'); ?><br/>
                <?php echo form('textarea', array('name' => 'JOU_LIC', 'class' => 'w100 h50px', 'id' => 'JOU_LIC', $dis_licence => $dis_licence)); ?>
            </td>
        </tr>


        <tr>
            <td colspan="2">
                <hr/>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left"><?php echo __('com.txt.desc'); ?><br/>
                <?php echo form('textarea', array('name' => 'JOU_DESC', 'class' => 'w100 h100px', 'id' => 'JOU_DESC')); ?>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <hr/>
            </td>
        </tr>

		<?php foreach((array)v('Champs') as $champ){ 
	    	$value = isset($_POST['ATTRIBUTS']) && isset($_POST['ATTRIBUTS']['CHA_'.$champ->get_CHA_CLE()])?$_POST['ATTRIBUTS']['CHA_'.$champ->get_CHA_CLE()]:null;
	    	$attributes = array('type'=>'text','name' => 'ATTRIBUTS[CHA_'.$champ->get_CHA_CLE().']', 'id' => 'CHA_'.$champ->get_CHA_CLE(),'value'=>$value, 'class'=>'w100');
	    	if ( trim($value) != '' && !$champ->get_CHA_MOD() ){
	    		$attributes['disabled'] = 'disabled';
	    	}
	    	?>
	    
	    <tr>
	        <td class="g"><label for="CHA_<?php echo $champ->get_CHA_CLE(); ?>"><?php echo $champ->get_CHA_NOM();echo $champ->get_CHA_REQ()?'<b style="color: red; font-size: 1.3em"> *</b>':''; ?></label></td>
	        <td class="d"><?php echo form('input', $attributes); ?></td>
	    </tr>
	    
	    <?php } ?>

        <tr valign="top" align="center">
            <td class="validation" colspan="2"><?php echo formSubmit('Modifier'); ?></td>
        </tr>

    </table>
</form>