<?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']);
$callreasonId = addslashes($_REQUEST['callreasonId']);

//print_r($_REQUEST);
$res =  $dba->getCallReasonStats( $_SESSION['right'], $callreasonId, $startDateTime, $endDateTime) ;
$data = "";

 $cmpt = 1;
					 $total = count($res) ;
					 for ($i = 0; $i < $total; $i++) {
						$data = $data.
						        '{
									"Date": "'.$svaTool->escapeJsonString($res[$i]['eventDateTime']).'",
									"CallReason": "'.$svaTool->escapeJsonString($res[$i]['name']).'",
									"Total": "'.$res[$i]['total'].'"
								 }
					         	';
						 
						 if($i+1 <  $total ) $data = $data.",";
						 
					 }
					 
			echo "[$data]";

?>

