<?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']);
$direction = addslashes($_REQUEST['type']);
//print_r($_REQUEST);
//$res =  $dba->getGlobalStats( $userId,$_SESSION['right'], $status, $startDateTime, $endDateTime) ;
$res = $dba->getSCCCDRStats($userId,$_SESSION['right'], $direction, $startDateTime, $endDateTime);
$data = "";

 $cmpt = 1;
					 $total = count($res) ;
					 for ($i = 0; $i < $total; $i++) {
						$data = $data.
						        '{
									"Date": "'.$res[$i]['calldate'].'",
									"Caller":"'.$res[$i]['src'].'",
									"Callee": "'.$res[$i]['dst'].'", 
									"CallReason": "'.$res[$i]['motif_name_v'].'",
									"TicketNumber":"'.$res[$i]['ticket_number_v'].'",
									"Duration": "'.gmdate("H:i:s", $res[$i]['duration']).'",
									"Agent": "'.$res[$i]['user_name_v'].'",
									"Direction": "'.$res[$i]['call_direction'].'"
								 }
					         	';
						 
						 if($i+1 <  $total ) $data = $data.",";
						 
					 }
					 
			echo "[$data]";

?>

