<?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']);

$reasonList = $dba->crmGetTicketReasonList(2);


?>

<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_tt_proc.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>Nouveau Ticket</em><!-- Paramètre de configuration Modem-->
                                        </legend>

          <table width="100%" border="0">
											
											<tr>
                                                <td width="21%" height="23" align="right">&nbsp;</td>
                              <td width="29%">&nbsp;</td>
                                                <td width="22%">&nbsp;</td>
                                                <td width="28%">&nbsp;</td>
                                            </tr>
											
											 <tr>
											   <td height="39" align="right">Nom : </td>
											   <td align="left"><input type="text" name="lastName" id="lastName"  size="30" required="required" /></td>
											   <td height="24" align="right">Prénoms : </td>
											   <td align="left"><input type="text" name="firstName" id="firstName"  size="30" required="required" /></td>
                                            </tr>
                                            <tr>
                                              <td height="24" align="right">Numéro de téléphone 1 : </td>
                                              <td align="left"><input name="mobilePhone1" type="text" required="required" id="mobilePhone1"  size="15" maxlength="15" /></td>
                                              <td height="24" align="right">Email :</td>
                                              <td align="left"><input type="text" name="email" id="email"  size="30" required="required"/></td>
                                            </tr>
                                            <tr>
                                              <td height="38" align="right">Numéro de téléphone 2 : </td>
                                              <td align="left"><input name="mobilePhone2" id="mobilePhone2"  size="15"  type="text"  maxlength ="15" required="required"/></td>
                                              <td height="31" align="right">Catégorie du motif des tickets: </td>
                                              <td align="left"><select name="ticketReasonCategory" id="ticketReasonCategory" required>
                                                        <option value="-1" > - Choisir -</option>
                                                        <option value="1" selected="selected"> Non Applicable </option>
                                                     

                                                    </select></td>
                                            </tr>
                                            <tr>
                                              <td height="39" align="right">Genre : </td>
                                              <td align="left"><select name="gender" id="gender" required="required">
                                                <option value="-1" selected="selected"> - Choisir -</option>
                                                <option value="M">Masculin</option>
                                                <option value="F">Feminin</option>
                                              </select></td>
                                              <td align="right">Motif du ticket : </td>
                                                <td><select name="ticketReason" id="ticketReason" required>
                                                        <option value="-1" selected="selected"> - Choisir - </option>
                                                           <?php
														    for ($i=0; $i<count($reasonList) ; $i++) {
														   ?>
                  <option value="<?php echo $reasonList[$i]['motif_id_n'];  ?>"> <?php echo $reasonList[$i]['motif_name_v'];  ?></option>
                            <?php

                            }
                        ?>
 

                            

                 
                                                  

                                                    </select></td>
                                            </tr>
                                            <tr>
                                              <td height="39" align="right">Localisation :</td>
                                              <td align="left"><input name="localisation" id="localisation"  size="30"  type="text"  required="required"/></td>
                                              <td height="39" align="right">&nbsp;</td>
                                              <td align="left">&nbsp;</td>
                                            </tr>
                                            <tr>
                                              <td height="39" align="right">Description du motif : </td>
                                              <td colspan="3" align="left"><textarea name="ticketReasonDesc" id="ticketReasonDesc" rows="3" cols="100"></textarea></td>
                                            </tr>
                                           
											
								<tr>
                                                <td width="21%" height="23" align="right">Clôturer le ticket : </td>
                              <td width="29%"><input type="checkbox" name="ticketStatus" id="ticketStatus" /></td>
                                                <td width="22%">&nbsp;</td>
                                                <td width="28%">&nbsp;</td>
                                            </tr>		

                                            <tr>
                                                <td height="91" colspan="6" align="left"><input type="submit" name="send" id="send"  size="30"  value="Enregistrer" 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 type="text/javascript" src="js/jquery-1.9.1.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>