File: /home/posscale/subdomains/ccm/files/home/post.php
<?
switch($_POST['action'])
{
case "overall_report":
ob_end_clean();
ob_start();
?>
<fieldset style="margin:5px; border:1px dashed #666666;">
<legend>
Results
<span style="color:#FF6600;">from:</span> <?=date("g:i a F j Y", strtotime($_POST['report_from']))?>
<span style="color:#FF6600;">to:</span> <?=date("g:i a F j Y", strtotime($_POST['report_to']))?>
</legend>
<div>
<fieldset style="margin:5px; border:1px dashed #666666;">
<legend>General Stats</legend>
<table>
<tr>
<th></th>
<th><h1>Outbound</h1></th>
<th><h1>Inbound</h1></th>
<th><h1>Both</h1></th>
</tr>
<tr>
<th align="right">Total Calls:</th>
<td align="center"><?=$total_out?></td>
<td align="center"><?=$total_in?></td>
<td align="center"><?=$calls['mysql_num_rows']?></td>
</tr>
<tr>
<th align="right">Total Duration:</th>
<td align="center"><?=sec2hms($total_out_duration)?></td>
<td align="center"><?=sec2hms($total_in_duration)?></td>
<td align="center"><?=sec2hms($total_duration)?></td>
</tr>
<tr>
<th align="right">Average Duration:</th>
<td align="center"><?=sec2hms($average_out_duration)?></td>
<td align="center"><?=sec2hms($average_in_duration)?></td>
<td align="center"><?=sec2hms($average_duration)?></td>
</tr>
<tr>
<th align="right">Longest Call:</th>
<td align="center"><?=sec2hms($long_call_out)?></td>
<td align="center"><?=sec2hms($long_call_in)?></td>
<td align="center"><?=sec2hms($long_call)?></td>
</tr>
<tr>
<th align="right">Shortest Call:</th>
<td align="center"><?=sec2hms($short_call_out)?></td>
<td align="center"><?=sec2hms($short_call_in)?></td>
<td align="center"><?=sec2hms($short_call)?></td>
</tr>
</table>
</fieldset>
</div>
<div style="clear:both;">
<fieldset style="margin:5px; border:1px dashed #666666;">
<legend>Comparison Graph</legend>
<div style="background-color:#CC9900;">
<div class="graph_1" style="float:left; height:14px; padding-left:10px; width:100px;">Total Calls</div>
<div class="graph_2" style="float:left; height:14px; padding-left:10px; width:100px;">Total Inbound</div>
<div class="graph_3" style="float:left; height:14px; padding-left:10px; width:100px;">Total Outbound</div>
<div class="graph_4" style="float:left; height:14px; padding-left:10px; width:100px;">Total Duration</div>
<div class="graph_5" style="float:left; height:14px; padding-left:10px; width:100px;">Duration Inbound</div>
<div class="graph_6" style="float:left; height:14px; padding-left:10px; width:100px;">Duration Outbound</div>
</div>
<div style="clear:left;">
<div style="height:10px; clear:left;"></div>
<?
foreach($extension_results as $pbx_id=> $ext_data)
{
$pbx_name = db_query_1("SELECT name FROM pbx WHERE id=".$pbx_id);
foreach($ext_data as $ext_no=> $data)
{
$height_mult = 2;
$bar_width = 10;
$ext_name = db_query_1("SELECT name FROM extensions WHERE pbx_id=".$pbx_id." AND ext=".$ext_no);
$ext_nick = db_query_1("SELECT nickname FROM extensions WHERE pbx_id=".$pbx_id." AND ext=".$ext_no);
$graph_height = 1 + ($height_mult*100);
$this_total_calls = 1 + floor(($data['total_calls']/$highest_total_calls)*100)*$height_mult;
$this_total_calls_in = 1 + floor(($data['total_calls_in']/$highest_total_calls_in)*100)*$height_mult;
$this_total_calls_out = 1 + floor(($data['total_calls_out']/$highest_total_calls_out)*100)*$height_mult;
$this_total_duration = 1 + floor(($data['total_duration']/$highest_total_duration)*100)*$height_mult;
$this_total_duration_in = 1 + floor(($data['total_duration_in']/$highest_total_duration_in)*100)*$height_mult;
$this_total_duration_out = 1 + floor(($data['total_duration_out']/$highest_total_duration_out)*100)*$height_mult;
$this_average_duration = '';
$this_average_duration_in = '';
$this_average_duration_out = '';
$tool_tip_welcome = "<strong>".$pbx_name."</strong><br>".$ext_no." (".$ext_name.")<hr size=1>";
?>
<div style="float:left; width:<?=$bar_width*6?>px;">
<div onMouseover="$(this).style.backgroundColor='#000000'; ddrivetip('<?=$tool_tip_welcome?> Total Calls: <h1><?=$data['total_calls']+0?></h1>');" onMouseout="$(this).style.backgroundColor=''; hideddrivetip();" style="width:<?=$bar_width?>px; float:left; display:block; height:<?=$graph_height ?>px;">
<div class="graph_1" style="width:<?=$bar_width?>px; margin-top:<?=$graph_height-$this_total_calls;?>px; height:<?=$this_total_calls;?>px;"></div>
</div>
<div onMouseover="$(this).style.backgroundColor='#000000'; ddrivetip('<?=$tool_tip_welcome?> Total Inbound Calls: <h1><?=$data['total_calls_in']+0?></h1>');" onMouseout="$(this).style.backgroundColor=''; hideddrivetip();" style="width:<?=$bar_width?>px; float:left; display:block; height:<?=$graph_height ?>px;">
<div class="graph_2" style="width:<?=$bar_width?>px; margin-top:<?=$graph_height-$this_total_calls_in;?>px; height:<?=$this_total_calls_in;?>px;"></div>
</div>
<div onMouseover="$(this).style.backgroundColor='#000000'; ddrivetip('<?=$tool_tip_welcome?> Total Outbound Calls: <h1><?=$data['total_calls_out']+0?></h1>');" onMouseout="$(this).style.backgroundColor=''; hideddrivetip();" style="width:<?=$bar_width?>px; float:left; display:block; height:<?=$graph_height ?>px;">
<div class="graph_3" style="width:<?=$bar_width?>px; margin-top:<?=$graph_height-$this_total_calls_out;?>px; height:<?=$this_total_calls_out;?>px;"></div>
</div>
<div onMouseover="$(this).style.backgroundColor='#000000'; ddrivetip('<?=$tool_tip_welcome?> Total Duration: <h1><?=sec2hms($data['total_duration']+0)?></h1>');" onMouseout="$(this).style.backgroundColor=''; hideddrivetip();" style="width:<?=$bar_width?>px; float:left; display:block; height:<?=$graph_height ?>px;">
<div class="graph_4" style="width:<?=$bar_width?>px; margin-top:<?=$graph_height-$this_total_duration;?>px; height:<?=$this_total_duration;?>px;"></div>
</div>
<div onMouseover="$(this).style.backgroundColor='#000000'; ddrivetip('<?=$tool_tip_welcome?> Total Inbound Duration: <h1><?=sec2hms($data['total_duration_in']+0)?></h1>');" onMouseout="$(this).style.backgroundColor=''; hideddrivetip();" style="width:<?=$bar_width?>px; float:left; display:block; height:<?=$graph_height ?>px;">
<div class="graph_5" style="width:<?=$bar_width?>px; margin-top:<?=$graph_height-$this_total_duration_in;?>px; height:<?=$this_total_duration_in;?>px;"></div>
</div>
<div onMouseover="$(this).style.backgroundColor='#000000'; ddrivetip('<?=$tool_tip_welcome?> Total Outbound Duration: <h1><?=sec2hms($data['total_duration_out']+0)?></h1>');" onMouseout="$(this).style.backgroundColor=''; hideddrivetip();" style="width:<?=$bar_width?>px; float:left; display:block; height:<?=$graph_height ?>px;">
<div class="graph_6" style="width:<?=$bar_width?>px; margin-top:<?=$graph_height-$this_total_duration_out;?>px; height:<?=$this_total_duration_out;?>px;"></div>
</div>
<div style="float:left; width:<?=$bar_width*6?>px; text-align:center; border:1px solid #FFFFFF; border-bottom:none;"><abbr title="<?=$pbx_name.": ".$ext_no." (".$ext_name.")"?>"><?=$ext_nick?></abbr></div>
</div>
<div style="width:5px; float:left; display:block; margin:0px; margin-top:auto; height:10px;"></div>
<?
}
}
?>
</div>
</fieldset>
</div>
<div style="clear:left">
<fieldset style="margin:5px; border:1px dashed #666666;">
<legend>List of calls</legend>
<table>
<tr bgcolor="#000000">
<th><-></th>
<th>Date</th>
<th>Time</th>
<th>Duration</th>
<th>Extension</th>
<th>Number</th>
</tr>
<?
for($i=0; $i<$calls['mysql_num_rows']; $i++)
{
?>
<tr bgcolor="<? if(1&$i){ echo '#666666'; }else{ echo '#444444';} ?>">
<td align="center"><?=$calls['direction'][$i]?></td>
<td align="center"><?=date("F j Y", $calls['time'][$i]-$calls['duration'][$i])?></td>
<td align="center"><?=date("g:i a", $calls['time'][$i]-$calls['duration'][$i])?></td>
<td align="center"><?=sec2hms($calls['duration'][$i])?></td>
<td align="center"><?=$calls['ext'][$i]?></td>
<td align="center"><?=$calls['number'][$i]?></td>
</tr>
<?
}
?>
</fieldset>
</fieldset>
</div>
<?
exit();
break;
}
?>