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

//$currentBaseDir = dirname($_SERVER['PHP_SELF']);
//echo $currentBaseDir ;

$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir']."core.php");
$res = $dba->getSCCTicketDetails(-1, $_SESSION['ownerId'],$_SESSION['right'], -1, NULL, NULL);


?>
 <style>
        body {
            font-size: 140%;
        }

        table.dataTable th {
            white-space: nowrap;
        } 
        table.dataTable td {
            white-space: wrap;
        }
    </style>
<div id="<?php echo $toDiv; ?>">
<div  class="container-fluid" style="background-color:#F3F3F3; overflow:auto"  >

    <table width="100%"  >



        <td align="center">

          

                <table width="100%" border="0" cellspacing="1" cellpadding="1">



              <tr>

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







                    <tr>

                        <td colspan="2" align="center" valign="top"></td>

                    </tr>

                    <tr height="40">

                        <td height="19" colspan="2"  valign="top" align="left">

       

                                <div id="routeType1" >

                                    <fieldset >

                                      <legend><em>Liste des tickets </em></legend>



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

                            <!--                    <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" tabindex="10">
    Launch demo modal
</button>   -->

                                            <tr>

                                                <td align="left"><table width="100%" border="0">
                                                <tr>
                                                  <td align="center"> 
                                                  <div class="containerIcons"> 
                                                  <div>
    <button id="refreshPage" class="btn" onclick="getPage('<?php echo $_SERVER['PHP_SELF']; ?>','<?php echo $toDiv; ?>')"   title="Rafraichir"><i class="cus-page-refresh"></i>Rafraichir</button>

	  <button id="addTicketBtn" class="btn" data-href="<?php echo $currentBaseDir; ?>/add_ticket.php?toDiv=<?php echo $toDiv; ?>&rpage=<?php echo $_SERVER['PHP_SELF']; ?>"  title="Créer un ticket"><i class="cus-add"></i>Nouveau Ticket</button>
      
        <button id="impTicketBtn" class="btn" data-href="<?php echo $currentBaseDir; ?>/add_ticket_batch.php?toDiv=<?php echo $toDiv; ?>&rpage=<?php echo $_SERVER['PHP_SELF']; ?>"  title="Importer des  tickets"><i class="cus-table-row-insert"></i>Importer</button>
      
       
	 <!-- <button class="btn" disabled="disabled"><i class="cus-page-white-edit"></i> Modifier</button>
	  <button class="btn"><i class="cus-disk"></i> Enregistrer</button>
	  <button class="btn" disabled="disabled"><i class="cus-delete"></i> Supprimer</button> -->
	</div> </div></td>
                                                </tr>
                                              </table></td>
                                            </tr>
                                            <tr>
                                              <td align="left">
                                              
                                              
                                              
                                            
                                              
                                              <table id="tblTickets" class="table table-striped table-hover dt-responsive" width="100%" cellspacing="0">
        <thead>
            <tr>
               <!-- <th align="left" width="3">&nbsp;</th>-->
                <th align="left" width="1%">&nbsp;</th>
                <th align="left" width="1%">&nbsp;</th>
                <th align="left" width="1%">&nbsp;</th>
                <th width="18" align="left">Date</th>
                <th width="15" align="left">N°Appelant</th>
                <th width="25" align="left">Agent</th>
                <th width="25" align="left">Identifiant client</th>
                <th width="7" align="left">N°Ticket</th>
                <th width="30" align="left">Motif d'appel</th>
                <th width="18" align="left">Requête client</th>
                <th width="18" align="left">Date Acquittement</th>
                <th width="18" align="left">Date de clôture</th>
                <th width="18" align="left">Type</th>
                <th width="18" align="left">Agence</th>
                <th width="18" align="left">Description requête client</th>
                <th width="18" align="left">Commentaire du conseiller client</th>
                <th width="5" align="left">Statut</th>
                </tr>
        </thead>
               <tbody>
        
        <?php

            $cmpt = 1;

            for ($i = 0; $i < count($res); $i++) {

        ?>




            <tr>
              <!--  <td align="left"><input type="checkbox" name="ticketFullId" value="<?php echo $res[$i]['item_id_n']; ?>" /></td> -->
                <td align="left"><?php if($res[$i]['status_n']!='Clos') { ?><a href="#" data-href="<?php echo $currentBaseDir; ?>/edit_incoming_ticket.php?item=<?php echo $res[$i]['item_id_n']; ?>&toDiv=<?php echo $toDiv; ?>&rpage=<?php echo $_SERVER['PHP_SELF']; ?>"  title="Modifier" class="cus-application-form-edit" ></a><?php } ?></td>
                <td align="left"><a href="#" data-href="<?php echo $currentBaseDir; ?>/show_comments_list.php?item=<?php echo $res[$i]['ticket_number_v']; ?>&toDiv=<?php echo $toDiv; ?>&rpage=<?php echo $_SERVER['PHP_SELF']; ?>"  title="Voir les commentaires" class="cus-comment" ></a></td>
                <td align="left"><a href="#" data-href="<?php echo $currentBaseDir; ?>/view_incoming_ticket.php?item=<?php echo $res[$i]['item_id_n']; ?>&toDiv=<?php echo $toDiv; ?>&rpage=<?php echo $_SERVER['PHP_SELF']; ?>"  title="Ouvrir le ticket" class="cus-application-view-list" ></a></td>
                <td align="left"><?php echo $res[$i]['event_datetime_d']; ?></td>
                <td align="left"><?php echo $res[$i]['mobile1_phone_v']; ?></td>
                <td align="left"><?php echo $res[$i]['user_name_v']; ?></td>
                <td align="left"><?php echo $res[$i]['first_name_v']. " ".$res[$i]['last_name_v']; ?></td>
                <td align="left"><?php echo $res[$i]['ticket_number_v']; ?></td>
                <td align="left"><?php echo $res[$i]['motif_name_v']; ?></td>
                <td align="left"><?php echo $res[$i]['ticket_reason_desc_v']; ?></td>
                 <td align="left"><?php echo $res[$i]['aknowledge_date_d']; ?></td>
                  <td align="left"><?php echo $res[$i]['closure_date_d']; ?></td>
                  <td align="left"><?php echo $res[$i]['char_field_5']; ?></td>
                  <td align="left"><?php echo $res[$i]['char_field_7']; ?></td>
                  <td align="left"><?php echo $res[$i]['clientComment']; ?></td>
                  <td align="left"><?php echo $res[$i]['agentComment']; ?></td>
                <td align="left"><?php echo $res[$i]['status_n']; ?></td>
                </tr>
            
         <?php }   ?>
        </tbody>

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









                                  </fieldset>

                                </div> 

                        </td>

                    </tr>



                </table>


        </td>

        </tr>





    </table>

</div>

</div>
<div id="loader" ></div>
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="plugins/datatables/dataTables.buttons.min.js"></script>
<script src="plugins/datatables/buttons.html5.min.js"></script>
<script type="text/javascript" src="js/jquery.loading.min.js"></script>

  <script type="text/javascript" >   
  
  $( document ).ready(function() {
	
	$('#tblTickets').DataTable( {
   "responsive": true,
   "scrollY": 200,
   "scrollX": 200,
    dom: 'Bfrtip',
								buttons: [
							            {
										extend: 'csv',
										title: "export<?php echo date('YmdHis'); ?>" 
									   }
								],
  "language": {
    "search": "Recherche:",
	"emptyTable" : "Table vide",
	"zeroRecords":    "Table vide",
	"lengthMenu":     "Nombre de lignes  _MENU_ ",

	"info":           "Affichage de  _START_ &aacute; _END_ sur  _TOTAL_ entr&eacute;es",
	"paginate": {
        "first":      "D&eacute;but",
        "last":       "Fin",
        "next":       "Suivant",
        "previous":   "Pr&eacute;c&eacute;dent"
    },
	"infoEmpty":      "Affichage de  0 &agrave; 0 sur  0 entr&eacute;es"
  }
});
 
					
   
});
    

</script>



<script id="ajax" type="text/javascript">

var $modal = $('#myModal');
var $myLargeModal = $('#myLargeModal');



$('#addTicketBtn').on('click', function(){
  // create the backdrop and wait for next modal to be triggered
 // $('body').modalmanager('loading');
   $('#loader').loading({
		  message : "Chargement...",
		  theme : 'dark'
		  
		});
    var dataURL = $(this).attr('data-href');
	 var modalTitle = $(this).attr('title'); 
	 $('.modal-title').html(modalTitle) ;
	  $('#loader').loading('stop'); 
	 $('.modal-body').load(dataURL ,function(){
        $modal.modal({
		 backdrop:'static',
		 keyboard: false
		});
    }); 

 
});

$('#impTicketBtn').on('click', function(){
  // create the backdrop and wait for next modal to be triggered
 // $('body').modalmanager('loading');
   $('#loader').loading({
		  message : "Chargement...",
		  theme : 'dark'
		  
		});
    var dataURL = $(this).attr('data-href');
	 var modalTitle = $(this).attr('title'); 
	 $('.modal-title').html(modalTitle) ;
	  $('#loader').loading('stop'); 
	 $('.modal-body').load(dataURL ,function(){
        $modal.modal({
		 backdrop:'static',
		 keyboard: false
		});
    }); 

 
});


$("#tblTickets").on('click', '.cus-application-form-edit', function(){
  // create the backdrop and wait for next modal to be triggered
 // $('body').modalmanager('loading');
   $('#loader').loading({
		  message : "Chargement...",
		  theme : 'dark'
		  
		});
    var dataURL = $(this).attr('data-href');
	 var modalTitle = $(this).attr('title'); 
	 $('.modal-title').html(modalTitle) ;
	  $('#loader').loading('stop'); 
	 $('.modal-body').load(dataURL ,function(){
        $modal.modal({
		 backdrop:'static',
		 keyboard: false
		});
    }); 

 
});

$("#tblTickets").on('click', '.cus-application-view-list', function(){
  // create the backdrop and wait for next modal to be triggered
 // $('body').modalmanager('loading');
   $('#loader').loading({
		  message : "Chargement...",
		  theme : 'dark'
		  
		});
    var dataURL = $(this).attr('data-href');
	 var modalTitle = $(this).attr('title'); 
	 $('.modal-title').html(modalTitle) ;
	  $('#loader').loading('stop'); 
	 $('.modal-body').load(dataURL ,function(){
        $modal.modal({
		 backdrop:'static',
		 keyboard: false
		});
    }); 

 
});

$("#tblTickets").on('click', '.cus-comment', function(){
  // create the backdrop and wait for next modal to be triggered
 // $('body').modalmanager('loading');
   $('#loader').loading({
		  message : "Chargement...",
		  theme : 'dark'
		  
		});
    var dataURL = $(this).attr('data-href');
	 var modalTitle = $(this).attr('title'); 
	 $('.modal-title').html(modalTitle) ;
	  $('#loader').loading('stop'); 
	 $('.modal-body').load(dataURL ,function(){
        $myLargeModal.modal({
		 backdrop:'static',
		 keyboard: false
		});
    }); 

 
});


$modal.on('show.bs.modal', function () {
       $(this).find('.modal-body').css({
              width:'auto', //probably not needed
              height:'auto', //probably not needed 
              'max-height':'100%'
       });
});


</script> 
<script type="text/javascript" src="js/jquery.loading.min.js"></script>