LICENSE: GPLv2 ### require("dbconnect.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];} elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];} if (isset($_GET["reset_counter"])) {$reset_counter=$_GET["reset_counter"];} elseif (isset($_POST["reset_counter"])) {$reset_counter=$_POST["reset_counter"];} if (isset($_GET["submit"])) {$submit=$_GET["submit"];} elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); $timeONEhoursAGO = ($STARTtime - 3600); $epochHALFhoursAGO = ($STARTtime - 1860); $timeONEhoursAGO = date("Y-m-d H:i:s",$timeONEhoursAGO); $timeHALFhoursAGO = date("Y-m-d H:i:s",$epochHALFhoursAGO); $reset_counter++; if ($reset_counter > 7) { $reset_counter=0; $stmt="update park_log set status='HUNGUP' where hangup_time is not null;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} if ($DB) { $stmt="delete from park_log where status='TALKING' and grab_time < '$timeONEhoursAGO' and (hangup_time is null or hangup_time='');"; $rslt=mysql_query($stmt, $link); echo "$stmt\n"; $stmt="delete from park_log where status='PARKED' and parked_time < '$timeHALFhoursAGO' and (hangup_time is null or hangup_time='');"; $rslt=mysql_query($stmt, $link); echo "$stmt\n"; } } ?> \n"; echo"\n"; echo "VICIDIAL: Time On Park\n"; echo "
\n\n";

echo "VICIDIAL: Time On Park                       $NOW_TIME\n\n";
echo "+------------+-----------------+---------------------+---------+\n";
echo "| CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
echo "+------------+-----------------+---------------------+---------+\n";

#$link=mysql_connect("localhost", "cron", "1234");
# $linkX=mysql_connect("localhost", "cron", "1234");
#mysql_select_db("asterisk");

$stmt="select extension,user,channel,channel_group,parked_time,UNIX_TIMESTAMP(parked_time) from park_log where status ='PARKED' and server_ip='$server_ip' order by uniqueid;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$parked_to_print = mysql_num_rows($rslt);
	if ($parked_to_print > 0)
	{
	$i=0;
	while ($i < $parked_to_print)
		{
		$row=mysql_fetch_row($rslt);

		$channel =			sprintf("%-10s", $row[2]);
		$number_dialed =	sprintf("%-15s", $row[3]);
		$start_time =		sprintf("%-19s", $row[4]);
		$call_time_S = ($STARTtime - $row[5]);

		$call_time_M = ($call_time_S / 60);
		$call_time_M = round($call_time_M, 2);
		$call_time_M_int = intval("$call_time_M");
		$call_time_SEC = ($call_time_M - $call_time_M_int);
		$call_time_SEC = ($call_time_SEC * 60);
		$call_time_SEC = round($call_time_SEC, 0);
		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
		$call_time_MS = "$call_time_M_int:$call_time_SEC";
		$call_time_MS =		sprintf("%7s", $call_time_MS);
		$G = '';		$EG = '';
		if ($call_time_M_int >= 1) {$G=''; $EG='';}
		if ($call_time_M_int >= 6) {$G=''; $EG='';}

		echo "| $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";

		$i++;
		}

		echo "+------------+-----------------+---------------------+---------+\n";
		echo "  $i callers waiting on server $server_ip\n\n";

		echo "             - 1 minute or more on hold\n";
		echo "             - Over 5 minutes on hold\n";

		}
	else
	{
	echo "****************************************************************\n";
	echo "****************************************************************\n";
	echo "******************** NO LIVE CALLS WAITING *********************\n";
	echo "****************************************************************\n";
	echo "****************************************************************\n";
	}

###################################################################################
###### TIME ON INBOUND CALLS
###################################################################################
echo "\n\n";
echo "----------------------------------------------------------------------------------------";
echo "\n\n";
echo "VICIDIAL: Agents Time On Inbound Calls                             $NOW_TIME\n\n";
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
echo "| STATION    | USER   | CHANNEL    | GROUP           | START TIME          | MINUTES |\n";
echo "+------------|--------+------------+-----------------+---------------------+---------+\n";


$stmt="select extension,user,channel,channel_group,grab_time,UNIX_TIMESTAMP(grab_time) from park_log where status ='TALKING' and server_ip='$server_ip' order by uniqueid;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$talking_to_print = mysql_num_rows($rslt);
	if ($talking_to_print > 0)
	{
	$i=0;
	while ($i < $talking_to_print)
		{
		$row=mysql_fetch_row($rslt);

		$extension =		sprintf("%-10s", $row[0]);
		$user =				sprintf("%-6s", $row[1]);
		$channel =			sprintf("%-10s", $row[2]);
		$number_dialed =	sprintf("%-15s", $row[3]);
		$start_time =		sprintf("%-19s", $row[4]);
		$call_time_S = ($STARTtime - $row[5]);

		$call_time_M = ($call_time_S / 60);
		$call_time_M = round($call_time_M, 2);
		$call_time_M_int = intval("$call_time_M");
		$call_time_SEC = ($call_time_M - $call_time_M_int);
		$call_time_SEC = ($call_time_SEC * 60);
		$call_time_SEC = round($call_time_SEC, 0);
		if ($call_time_SEC < 10) {$call_time_SEC = "0$call_time_SEC";}
		$call_time_MS = "$call_time_M_int:$call_time_SEC";
		$call_time_MS =		sprintf("%7s", $call_time_MS);
		$G = '';		$EG = '';
		if ($call_time_M_int >= 12) {$G=''; $EG='';}
		if ($call_time_M_int >= 31) {$G=''; $EG='';}

		echo "| $G$extension$EG | $G$user$EG | $G$channel$EG | $G$number_dialed$EG | $G$start_time$EG | $G$call_time_MS$EG |\n";

		$i++;
		}

		echo "+------------|--------+------------+-----------------+---------------------+---------+\n";
		echo "  $i agents on calls on server $server_ip\n\n";

		echo "             - 12 minutes or more on call\n";
		echo "             - Over 30 minutes on call\n";

	}
	else
	{
	echo "**************************************************************************************\n";
	echo "**************************************************************************************\n";
	echo "********************************* NO AGENTS ON CALLS *********************************\n";
	echo "**************************************************************************************\n";
	echo "**************************************************************************************\n";
	}


?>