<?php
session_start();
$pageSequence = $_SESSION['sequence'];
$toDiv = "contentZone" . $pageSequence;
$resultZoneDiv = "resultZone" . $pageSequence;
$tableZone = "#tableZone" . $pageSequence;
$tblName = "tblReport" . $pageSequence;
$btAdd = "btnAdd" . $pageSequence;
$btDel = "btnDel" . $pageSequence;
$btDelObj = "btnDelObj" . $pageSequence;
$dataSection = "dataSection" . $pageSequence;
$frmName = "form" . $pageSequence;
$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir'] . "core.php");

$svaTool = new svaTool();

$errorCode = 0;

$password = NULL;
$confPasswd = NULL;
$startDateTime = addslashes($_REQUEST['startDateTime']);
$endDateTime = addslashes($_REQUEST['endDateTime']);
$userId = addslashes($_REQUEST['userId']);
$status = addslashes($_REQUEST['statut']);
$pageAccessLevel = $_REQUEST['pageAccessLevel'];
$toDiv = "content-wrapper";
//print_r($_REQUEST);
//$res =  $dba->getGlobalStats( $userId,$_SESSION['right'], $status, $startDateTime, $endDateTime) ;
$res = $dba->getSCCTicketDetailStatsReclamation($userId, $pageAccessLevel, $status, $startDateTime, $endDateTime);
$data = "";
//print_r($result);
//$result = $dba->getSCCInprogressTicketDetails($_SESSION['ownerId'], false, $status) ;
//print_r($result);

$cmpt = 1;
$total = count($res);
?>


<div class="btn-group">

    <button class="btn  btn-sm dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bars"></i> Exporter</button>
    <ul class="dropdown-menu exp-drop" role="menu">
        <li>
            <a href="#" onclick="$('#<?php echo $tblName; ?>').tableExport({type: 'excel', escape: 'false',htmlContent:'true'});" > ,
                <img src="assets/dist/img/xls.png" width="24" alt="logo"> XLS</a>
        </li>
        <li>
            <a href="#" onclick="$('#<?php echo $tblName; ?>').tableExport({type: 'csv', escape: 'false', htmlContent:'true' });"> 
                <img src="assets/dist/img/csv.png" width="24" alt="logo"> CSV</a>
        </li>
        <li>
            <a href="#" onclick="$('#<?php echo $tblName; ?>').tableExport({type: 'csv', escape: 'false', htmlContent:'true' });"> 
                <img src="assets/dist/img/txt.png" width="24" alt="logo"> TXT</a>
        </li>

        <li class="divider"></li> 
    </ul>

</div>

<!-- ./Plugin content:powerpoint,txt,pdf,png,word,xl -->
<div class="table-responsive">

    <table id="<?php echo $tblName; ?>"  width="100%" height="100%" class="table table-striped table-bordered" >
        <thead>
            <tr>
                <th>Date</th>
                <th>N° Appelant</th>
                <th>Identifiant Client</th>
                <th>Agent</th>
                <th>N°Ticket</th>
                <th>Motif Appel</th>
                <th>Detail</th>
                <th>Email</th>
                <th>Type</th>
                <th>Date Clôture</th>
                <th>Canal</th>
                <th>Statut</th>
            </tr>
        </thead>
        <tbody>
<?php
for ($i = 0; $i < $total; $i++) {
   // $embedTicketNumber = '<a href="#"  onclick="view_ticket_details(\'open_view_std_incoming_ticket.php?item=' . $res[$i]['item_id_n'] . '\')"  title="Ouvrir le ticket" class="view-ticket" >' . $res[$i]['ticket_number_v'] . '</a>';
    $embedTicketNumberNews = '<a href="#"  onclick="view_ticket_details(\'open_view_std_'. $res[$i]['page_link_v'].'.php?item=' . $res[$i]['item_id_n'] . '\')"  title="Ouvrir le ticket" class="view-ticket" >' . $res[$i]['ticket_number_v'] . '</a>';
   // $embedTicketNumberNew = "open_view_std_" . $res[$i]['page_link_v'].".php";
    ?>
                <tr>
                    <td><?php echo $res[$i]['event_datetime_d']; ?></td>
                    <td><?php echo $res[$i]['mobile1_phone_v']; ?></td>
                    <td><?php echo $res[$i]['customerName']; ?></td>
                    <td><?php echo $res[$i]['first_name_v'] . ' ' . $res[$i]['last_name_v']; ?></td>
                    <td><?php echo $embedTicketNumberNews; ?></td>
                    <td><?php echo $res[$i]['motif_name_v']; ?></td>
                    <td><?php echo $res[$i]['ticket_reason_desc_v']; ?></td>
                    <td><?php echo $res[$i]['email_id_v']; ?></td>
                    <td><?php echo $res[$i]['type_v']; ?></td>
                    <td><?php echo $res[$i]['closure_date_d']; ?></td>
                    <td><?php echo $res[$i]['char_field_5']; ?></td>
                    <td><?php echo $res[$i]['status_n']; ?></td>
                </tr> 

<?php } ?>
        </tbody>
    </table>



</div>


<script type="text/javascript" >
    $(document).ready(function () {





        var dataUrl = "<?php echo $currentBaseDir; ?>/return_json_default.php?json=[]";
        table = $('#<?php echo $tblName; ?>').DataTable();



    });
</script>