<?php
session_start();
$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->getSCCTicketDetailStats($userId,$pageAccessLevel, $status, $startDateTime, $endDateTime);
$data = "";

 $cmpt = 1;
					 $total = count($res) ;
					 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>';
						$data = $data.
						        '{
									"Date": "'.$res[$i]['event_datetime_d'].'",
									"CallerPhone":"'.$svaTool->escapeJsonString($res[$i]['mobile1_phone_v']).'",
									"CallerName": "'.$svaTool->escapeJsonString($res[$i]['customerName']).'",
									"AgentName": "'.$res[$i]['first_name_v'].' '.$res[$i]['last_name_v'].'",
									"TicketNumber":"'.$svaTool->escapeJsonString($embedTicketNumber).'",
									"CallReason": "'.$svaTool->escapeJsonString($res[$i]['motif_name_v']).'",
									"ReasonDtls": "'.$svaTool->escapeJsonString($res[$i]['ticket_reason_desc_v']).'",
									"Email": "'.$svaTool->escapeJsonString($res[$i]['email_id_v']).'",
									"Type": "'.$res[$i]['type_v'].'",
									"ClosureDate": "'.$res[$i]['closure_date_d'].'",
									"Channel": "'.$res[$i]['char_field_5'].'",
									"Status": "'.$res[$i]['status_n'].'"
								 }
					         	';
						 
						 if($i+1 <  $total ) $data = $data.",";
						 
					 }
					 
			echo "[$data]";

?>

