<?php session_start();
$pageSequence = $_SESSION['sequence'];
$toDiv = "contentZone" . $pageSequence;
$resultZoneDiv = "resultZone" . $pageSequence;
$_SESSION['sequence']++;
//echo  dirname(__FILE__);  
//echo $_SERVER['DOCUMENT_ROOT'] . "   ".dirname(__FILE__)."  ".str_replace($_SERVER['DOCUMENT_ROOT'],"",dirname(__FILE__)) . " SELF :" .$_SERVER['PHP_SELF']  ;

$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir']."core.php");
//$svaTool = new svaTool();
$profileList = $dba->getProfileListByRight($_SESSION['right']);
//$dbres =  $dba->getMMGTariffdByType(0,$_SESSION['right'], $_SESSION['ownerId']);
//$smscList = $dba->getSMSCListShortAll() ;

/* $groupList = $xwadDbAcess->getGroupByModuleId(1); */
//$senderList = $dba->getMMGSenderIdByUser($_SESSION['ownerId']);


//$tmplCur = $dba->getTemplateById($_SESSION['ownerId'],$startLimit, $cfg['max.elements']);
//$balanceData = $dba->getUserAccountById($_SESSION['ownerId']);


?>

<div id="<?php echo $toDiv; ?>" class="tab-content">



    <table width="100%" border="0" >

        <tr>

            <td> 



                <div id="<?php echo $resultZoneDiv; ?>">  </div></td>

        </tr>



    </table>

    
    <table width="100%"  >

        <td align="center">
            <div style="overflow:auto; height:550px; width:100%">
                <table width="94%" border="0" cellspacing="1" cellpadding="1">

                    <tr>
                        <td align="center" valign="top" ></td>



                    <tr>
                        <td colspan="2" align="center" valign="top"><b style="color:red">
                            </b></td>
                    </tr>
                    <tr height="40">
                        <td height="409" colspan="2" class="connection" valign="top" align="left">
                            <form action="<?php echo $currentBaseDir; ?>/exec_new_user.php" method="post" enctype="multipart/form-data" id="campaignFrm"  toDiv="<?php echo $toDiv; ?>" returnPage="<?php echo $_SERVER['PHP_SELF']; ?>" > 
                                <div id="routeType1" >
                                    <fieldset >
                                      <legend><em>Nouvel utilisateur </em><!-- Paramètre de configuration Modem-->
                                        </legend>

          <table width="100%" border="0">
											
											<tr>
                                                <td width="32%" height="45" align="left">Profil</td>
                              <td width="60%"><select name="profileId" id="profileId" required>
                                                        <option value="-1" selected="selected"> - </option>
                                                        <?php
                                                        //$cfgCount = count($ruleCfg);

                                                       for ($i = 0; $i < count($profileList); $i++) {
                                                            ?>

                                                            <option value="<?php echo $profileList[$i]['profile_id_n']; ?>"> <?php echo $profileList[$i]['profile_name_v']; ?></option>

                                                            <?php
                                                        }
                                                        ?>

                                                    </select></td>
                                                <td width="8%">&nbsp;</td>
                                            </tr>
											
											 <tr>
                                                <td align="left">Login</td>
                                                <td><input type="text" name="login" id="login"  size="50" required /></td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="39" align="left">Nom </td>
                                            <td align="left"><input type="text" name="lastName" id="lastName"  size="50" required /></td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="24" align="left">Prénoms</td>
                                                <td align="left"><input type="text" name="firstName" id="firstName"  size="50" required /></td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="38" align="left">Numéro de téléphone</td>
                                            <td align="left"><input name="msisdn" id="msisdn"  size="30"  type="text"  maxlength ="21" required/></td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="24" align="left">Email</td>
                                                <td align="left"><input type="text" name="email" id="email"  size="50" required/></td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="39" align="left">Mot de passe</td>
                                        <td align="left"><input name="password" id="password"  size="30"  type="password"  required/></td>
                                                <td>&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="31" align="left">Confirmation</td>
                              <td align="left"><input name="confPasswd" id="confPasswd"  size="30"  type="password"  required/></td>
                                                <td>&nbsp;</td>
            </tr>
                                          
                                            <tr>
                                              <td height="31" align="left">&nbsp;</td>
                                              <td align="left">&nbsp;</td>
                                              <td>&nbsp;</td>
                                            </tr>
                                           
											
										

                                            <tr>
                                                <td width="3%" height="91" colspan="5" align="left"><input type="submit" name="send" id="send"  size="30"  value="Ajouter" class="btn btn-success"  />
                                              &nbsp;&nbsp;&nbsp;
<input name="effacer" class="btn btn-danger" type="reset" id="effacer" value="Effacer" /></td>
                                            </tr>
                                        </table>




                                  </fieldset>
                                </div> 
                            </form>




                        </td>
                    </tr>

                </table>
            </div> 
        </td>
        </tr>


    </table>



</div>
<script src="plugins/jQuery/jquery-2.2.3.min.js"></script>
<link rel="stylesheet" href="css/jquery-confirm.min.css">
<script src="js/jquery-confirm.min.js"></script>

<script type="text/javascript">
$( "form" ).submit(function( event ) {

var toDiv =  $( "form" ).attr('toDiv');
var rpage =  $( "form" ).attr('returnPage') ;
	
	//alert(this.id +  " N: " + $( "form" ).attr('toDiv') +  " R :" + $( "form" ).attr('returnPage') );
        $.post($(this).attr("action"), $(this).serialize(), function(data) {
 
		   var obj = jQuery.parseJSON( data);
		   
		   if(obj.errorCode == 0 ) {
			   
			   //alert( obj.errorMessage );
			 
			 //    $.alert( obj.errorMessage );
			 
			 $.alert({
				 icon: 'glyphicon glyphicon-ok',
				 title: 'RESULTAT',
                 content: obj.errorMessage,
                 type: 'green',
                 typeAnimated: true

				});
			    //  alert(data);
            $("#" + toDiv).load(rpage);
            $('#loader').hide();
			   
		   }
		   else {
			   
			   $.alert({
				     icon: 'glyphicon glyphicon-warning-sign',
					 title: 'RESULTAT',
                     content: obj.errorMessage,
                     type: 'red',
                     typeAnimated: true
				});
			   
			  // $.alert( obj.errorMessage );
		   }
         
        });
       // return false; // prevent normal submit
   
	
  event.preventDefault();
});
</script>