From 2993036a734022995c0b64693f2b87d4b83c8aee Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 7 Nov 2008 09:34:54 +0000 Subject: [PATCH] several small bug fixes added better carryover of campaign script and preset settings into in-group when those in-group settings are blank Added to IVR and CLOSER reports git-svn-id: svn://192.168.202.10@998 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-VDAD_ALL_inbound.agi | 55 +-- agi/agi-VDAD_ALL_outbound.agi | 4 +- www/agc/vdc_db_query.php | 30 +- www/vicidial/AST_CLOSERstats.php | 289 +++++++++--- www/vicidial/AST_IVRstats.php | 743 ++++--------------------------- www/vicidial/admin.php | 2 +- 6 files changed, 363 insertions(+), 760 deletions(-) diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index 4c22b761..92a1ed69 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -1079,7 +1079,7 @@ if ($agent_search_method =~ /^SO|^LO/) my $LOCKaffected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02037'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; - $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension from vicidial_live_agents JOIN vicidial_live_inbound_agents ON vicidial_live_agents.user=vicidial_live_inbound_agents.user WHERE status IN('CLOSER','READY') and server_ip='$VARserver_ip' and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_aco_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension from vicidial_live_agents JOIN vicidial_live_inbound_agents ON vicidial_live_agents.user=vicidial_live_inbound_agents.user WHERE status IN('CLOSER','READY') and lead_id<1 and server_ip='$VARserver_ip' and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_aco_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1098,33 +1098,33 @@ if ($agent_search_method =~ /^SO|^LO/) if ($sthArows > 0) { $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where user='$VDADuser';"; - my $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02039'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $found_agents=$affected_rows; + $Faffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02039'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; + $found_agents=$Faffected_rows; } else { - $affected_rows=0; + $Faffected_rows=0; } $stmtA = "UNLOCK TABLES;"; - my $LOCKaffected_rows = $dbhA->do($stmtA); + $LOCKaffected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02040'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; } else { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where status IN('CLOSER','READY') and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - my $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02041'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $found_agents=$affected_rows; + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid',comments='INBOUND' where status IN('CLOSER','READY') and lead_id<1 and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $Faffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02041'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; + $found_agents=$Faffected_rows; } - if ($AGILOG) {$agi_string = "-- VDAD get agent: |$affected_rows|$channel_group|$stmtA|"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDAD get agent: |$Faffected_rows|$channel_group|$stmtA|"; &agi_output;} if ($found_agents > 0) { if ($aco_sub<1) { $cbc=0; - $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status = 'QUEUE' and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; + $stmtA = "SELECT conf_exten,user,extension FROM vicidial_live_agents where status IN('QUEUE','INCALL') and server_ip='$VARserver_ip' and campaign_id IN($INBOUNDcampsSQL) and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1394,8 +1394,7 @@ if ($agent_search_method =~ /^LO|^LB/) my $LOCKaffected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02057'; $MEL_aff_rows=$LOCKaffected_rows; &mysql_error_logging; - $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip from vicidial_live_agents JOIN vicidial_live_inbound_agents ON vicidial_live_agents.user=vicidial_live_inbound_agents.user WHERE status IN('CLOSER','READY') and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_aco_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $stmtA = "SELECT vicidial_live_agents.conf_exten,vicidial_live_agents.user,vicidial_live_agents.extension,vicidial_live_agents.server_ip from vicidial_live_agents JOIN vicidial_live_inbound_agents ON vicidial_live_agents.user=vicidial_live_inbound_agents.user WHERE status IN('CLOSER','READY') and lead_id<1 and vicidial_live_inbound_agents.group_id='$channel_group' and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_aco_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1412,17 +1411,18 @@ if ($agent_search_method =~ /^LO|^LB/) $VDADserver_ip = "$aryA[3]"; } $sthA->finish(); + if ($AGILOG) {$agi_string = "$VDADuser|$stmtA|"; &agi_output;} if ($sthArows > 0) { $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where user='$VDADuser';"; - my $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02059'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $found_agents=$affected_rows; + $Faffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02059'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; + $found_agents=$Faffected_rows; } else { - $affected_rows=0; + $Faffected_rows=0; } $stmtA = "UNLOCK TABLES;"; @@ -1431,35 +1431,36 @@ if ($agent_search_method =~ /^LO|^LB/) } else { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where status IN('CLOSER','READY') and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; - my $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='02061'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $found_agents=$affected_rows; - if ($AGILOG) {$agi_string = "$affected_rows|$stmtA|"; &agi_output;} + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$insert_lead_id',uniqueid='$unique_id', channel='$channel', callerid='$callerid', call_server_ip='$VARserver_ip',comments='INBOUND' where status IN('CLOSER','READY') and lead_id<1 and campaign_id IN($INBOUNDcampsSQL) and closer_campaigns LIKE \"% $channel_group %\" and last_update_time > '$BDtsSQLdate' $qp_groupWAIT_SQL $qp_groupWAIT_camp_SQL $agent_call_order limit 1;"; + $Faffected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='02061'; $MEL_aff_rows=$Faffected_rows; &mysql_error_logging; + $found_agents=$Faffected_rows; + if ($AGILOG) {$agi_string = "$Faffected_rows|$stmtA|"; &agi_output;} } - if ($AGILOG) {$agi_string = "-- VDAD get agent: |$DROP_TIME|$drop_timer|$affected_rows|$found_agents|update of vla table: $channel_group|\n|$stmtA|"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDAD get agent: |$DROP_TIME|$drop_timer|$Faffected_rows|$found_agents|update of vla table: $channel_group|\n|$stmtA|"; &agi_output;} if ($found_agents > 0) { if ($aco_sub<1) { $cbc=0; - $stmtA = "SELECT conf_exten,user,extension,server_ip FROM vicidial_live_agents where status = 'QUEUE' and campaign_id IN($INBOUNDcampsSQL) and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $stmtA = "SELECT conf_exten,user,extension,server_ip,last_call_time FROM vicidial_live_agents where status IN('QUEUE','INCALL') and campaign_id IN($INBOUNDcampsSQL) and callerid='$callerid' and channel='$channel' order by last_call_time limit 1;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $dbhP=$dbhA; $mysql_count='02062'; $MEL_aff_rows=$sthArows; &mysql_error_logging; $rec_countCUSTDATA=0; - while ($sthArows > $cbc) + if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; $VDADconf_exten = "$aryA[0]"; $VDADuser = "$aryA[1]"; $VDADextension = "$aryA[2]"; $VDADserver_ip = "$aryA[3]"; + $VDADlast_call_time="$aryA[4]"; $cbc++; } $sthA->finish(); + if ($AGILOG) {$agi_string = "$VDADuser|$VDADlast_call_time|$stmtA|"; &agi_output;} } $stmtA = "UPDATE vicidial_auto_calls set status='CLOSER', stage='CLOSER-$drop_timer' where callerid='$callerid';"; $affected_rows = $dbhA->do($stmtA); diff --git a/agi/agi-VDAD_ALL_outbound.agi b/agi/agi-VDAD_ALL_outbound.agi index db4edb17..22d40ca1 100644 --- a/agi/agi-VDAD_ALL_outbound.agi +++ b/agi/agi-VDAD_ALL_outbound.agi @@ -929,7 +929,7 @@ if ($agent_search_method =~ /^SO|^LO/) $sthA->finish(); if ($rec_countWAIT < $concurrent_transfers) { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and server_ip='$VARserver_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and lead_id<1 and server_ip='$VARserver_ip' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='01035'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; @@ -1104,7 +1104,7 @@ else {$concurrent_transfers = $DBconcurrent_transfers;} $sthA->finish(); if ($rec_countWAITrem < $concurrent_transfers) { - $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; + $stmtA = "UPDATE vicidial_live_agents set status='QUEUE',lead_id='$CIDlead_id',uniqueid='$unique_id', channel='$channel', call_server_ip='$VARserver_ip', callerid='$callerid',comments='AUTO' where status = 'READY' and lead_id<1 and campaign_id='$VDADcampaign' and last_update_time > '$BDtsSQLdate' $agent_call_order limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='01042'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index aaf19eac..680fa636 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -170,10 +170,11 @@ # 81104-0134 - Added mysql error logging capability # 81104-1617 - Added multi-retry for some vicidial_live_agents table MySQL queries # 81106-0410 - Added force_timeclock_login option to LoginCampaigns function +# 81107-0424 - Added carryover of script and presets for in-group calls from campaign settings # -$version = '2.0.5-88'; -$build = '81106-0410'; +$version = '2.0.5-89'; +$build = '81107-0424'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=180; $one_mysql_log=0; @@ -2555,6 +2556,27 @@ if ($ACTION == 'VDADcheckINCOMING') $VDCL_ingroup_recording_override = $row[11]; $VDCL_ingroup_rec_filename = $row[12]; + + $stmt = "select campaign_script,xferconf_a_dtmf,xferconf_a_number,xferconf_b_dtmf,xferconf_b_number from vicidial_campaigns where campaign_id='$campaign';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00181',$user,$server_ip,$session_name,$one_mysql_log);} + $VDIG_cidOR_ct = mysql_num_rows($rslt); + if ($VDIG_cidOR_ct > 0) + { + $row=mysql_fetch_row($rslt); + if ( ( (ereg('NONE',$VDCL_ingroup_script)) and (strlen($VDCL_ingroup_script) < 5) ) or (strlen($VDCL_ingroup_script) < 1) ) + {$VDCL_ingroup_script = $row[0];} + if (strlen($VDCL_xferconf_a_dtmf) < 1) + {$VDCL_xferconf_a_dtmf = $row[1];} + if (strlen($VDCL_xferconf_a_number) < 1) + {$VDCL_xferconf_a_number = $row[2];} + if (strlen($VDCL_xferconf_b_dtmf) < 1) + {$VDCL_xferconf_b_dtmf = $row[3];} + if (strlen($VDCL_xferconf_b_number) < 1) + {$VDCL_xferconf_b_number = $row[4];} + } + ### update the comments in vicidial_live_agents record $stmt = "UPDATE vicidial_live_agents set comments='INBOUND' where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "$stmt\n";} @@ -2915,7 +2937,7 @@ if ($ACTION == 'updateDISPO') else { ### update the comments in vicidial_live_agents record - $stmt = "UPDATE vicidial_live_agents set lead_id='',external_hangup=0,external_status='' where user='$user' and server_ip='$server_ip';"; + $stmt = "UPDATE vicidial_live_agents set lead_id=0,external_hangup=0,external_status='' where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00141',$user,$server_ip,$session_name,$one_mysql_log);} @@ -3020,6 +3042,8 @@ if ($ACTION == 'updateDISPO') if ( ($dispo_choice == 'CBHOLD') and (strlen($CallBackDatETimE)>10) ) { $comments = eregi_replace("'",'',$comments); + $comments = eregi_replace("\\",' ',$comments); + $comments = eregi_replace(';','',$comments); $stmt="INSERT INTO vicidial_callbacks (lead_id,list_id,campaign_id,status,entry_time,callback_time,user,recipient,comments,user_group) values('$lead_id','$list_id','$campaign','ACTIVE','$NOW_TIME','$CallBackDatETimE','$user','$recipient','$comments','$user_group');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); diff --git a/www/vicidial/AST_CLOSERstats.php b/www/vicidial/AST_CLOSERstats.php index b5dc38c7..9494ce05 100644 --- a/www/vicidial/AST_CLOSERstats.php +++ b/www/vicidial/AST_CLOSERstats.php @@ -329,6 +329,13 @@ else $average_call_seconds = sprintf("%10s", $average_call_seconds); } $ANSWEREDcalls = sprintf("%10s", $rowy[0]); +if ( ($ANSWEREDcalls < 1) or ($TOTALcalls < 1) ) + {$ANSWEREDpercent = '0';} +else + { + $ANSWEREDpercent = (($ANSWEREDcalls / $TOTALcalls) * 100); + $ANSWEREDpercent = round($ANSWEREDpercent, 0); + } if ( ($rowy[0] < 1) or ($ANSWEREDcalls < 1) ) {$average_answer_seconds = ' 0';} else @@ -341,7 +348,7 @@ else echo "Total calls taken in to this In-Group: $TOTALcalls\n"; echo "Average Call Length for all Calls: $average_call_seconds seconds\n"; -echo "Answered Calls: $ANSWEREDcalls\n"; +echo "Answered Calls: $ANSWEREDcalls $ANSWEREDpercent%\n"; echo "Average queue time for Answered Calls: $average_answer_seconds seconds\n"; echo "Calls taken into the IVR for this In-Group: $IVRcalls\n"; @@ -372,8 +379,15 @@ else $average_hold_seconds = round($average_hold_seconds, 0); $average_hold_seconds = sprintf("%10s", $average_hold_seconds); } +if ( ($ANSWEREDcalls < 1) or ($DROPcalls < 1) ) + {$DROP_ANSWEREDpercent = '0';} +else + { + $DROP_ANSWEREDpercent = (($DROPcalls / $ANSWEREDcalls) * 100); + $DROP_ANSWEREDpercent = round($DROP_ANSWEREDpercent, 0); + } -echo "Total DROP Calls: $DROPcalls $DROPpercent%\n"; +echo "Total DROP Calls: $DROPcalls $DROPpercent% drop/answered: $DROP_ANSWEREDpercent%\n"; echo "Average hold time for DROP Calls: $average_hold_seconds seconds\n"; @@ -520,69 +534,6 @@ echo "+------------------------------------------------------------------------- -############################## -######### CALL ANSWERED TIME BREAKDOWN IN SECONDS - -$BDansweredCALLS = 0; - -echo "\n"; -echo "---------- CALL ANSWERED TIME BREAKDOWN IN SECONDS\n"; -echo "+-------------------------------------------------------------------------------------------+------------+\n"; -echo "| 0 5 10 15 20 25 30 35 40 45 50 55 60 90 +90 | TOTAL |\n"; -echo "+-------------------------------------------------------------------------------------------+------------+\n"; - -$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE') group by queue_seconds;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$reasons_to_print = mysql_num_rows($rslt); -$i=0; -while ($i < $reasons_to_print) - { - $row=mysql_fetch_row($rslt); - - $BDansweredCALLS = ($BDansweredCALLS + $row[0]); - - if ($row[1] == 0) {$ad_0 = ($ad_0 + $row[0]);} - if ( ($row[1] > 0) and ($row{1} <= 5) ) {$ad_5 = ($ad_5 + $row[0]);} - if ( ($row[1] > 5) and ($row{1} <= 10) ) {$ad10 = ($ad10 + $row[0]);} - if ( ($row[1] > 10) and ($row{1} <= 15) ) {$ad15 = ($ad15 + $row[0]);} - if ( ($row[1] > 15) and ($row{1} <= 20) ) {$ad20 = ($ad20 + $row[0]);} - if ( ($row[1] > 20) and ($row{1} <= 25) ) {$ad25 = ($ad25 + $row[0]);} - if ( ($row[1] > 25) and ($row{1} <= 30) ) {$ad30 = ($ad30 + $row[0]);} - if ( ($row[1] > 30) and ($row{1} <= 35) ) {$ad35 = ($ad35 + $row[0]);} - if ( ($row[1] > 35) and ($row{1} <= 40) ) {$ad40 = ($ad40 + $row[0]);} - if ( ($row[1] > 40) and ($row{1} <= 45) ) {$ad45 = ($ad45 + $row[0]);} - if ( ($row[1] > 45) and ($row{1} <= 50) ) {$ad50 = ($ad50 + $row[0]);} - if ( ($row[1] > 50) and ($row{1} <= 55) ) {$ad55 = ($ad55 + $row[0]);} - if ( ($row[1] > 55) and ($row{1} <= 60) ) {$ad60 = ($ad60 + $row[0]);} - if ( ($row[1] > 60) and ($row{1} <= 90) ) {$ad90 = ($ad90 + $row[0]);} - if ($row[1] > 90) {$ad99 = ($ad99 + $row[0]);} - $i++; - } - -$ad_0 = sprintf("%5s", $ad_0); -$ad_5 = sprintf("%5s", $ad_5); -$ad10 = sprintf("%5s", $ad10); -$ad15 = sprintf("%5s", $ad15); -$ad20 = sprintf("%5s", $ad20); -$ad25 = sprintf("%5s", $ad25); -$ad30 = sprintf("%5s", $ad30); -$ad35 = sprintf("%5s", $ad35); -$ad40 = sprintf("%5s", $ad40); -$ad45 = sprintf("%5s", $ad45); -$ad50 = sprintf("%5s", $ad50); -$ad55 = sprintf("%5s", $ad55); -$ad60 = sprintf("%5s", $ad60); -$ad90 = sprintf("%5s", $ad90); -$ad99 = sprintf("%5s", $ad99); - -$BDansweredCALLS = sprintf("%10s", $BDansweredCALLS); - -$answeredTOTALs = "$ad_0 $ad_5 $ad10 $ad15 $ad20 $ad25 $ad30 $ad35 $ad40 $ad45 $ad50 $ad55 $ad60 $ad90 $ad99 | $BDansweredCALLS |"; -echo "| $answeredTOTALs\n"; -echo "+-------------------------------------------------------------------------------------------+------------+\n"; - - ############################## ######### CALL DROP TIME BREAKDOWN IN SECONDS @@ -647,6 +598,214 @@ echo "+------------------------------------------------------------------------- +############################## +######### CALL ANSWERED TIME AND PERCENT BREAKDOWN IN SECONDS + +$BDansweredCALLS = 0; + +echo "\n"; +echo " CALL ANSWERED TIME AND PERCENT BREAKDOWN IN SECONDS\n"; +echo " +-------------------------------------------------------------------------------------------+------------+\n"; +echo " | 0 5 10 15 20 25 30 35 40 45 50 55 60 90 +90 | TOTAL |\n"; +echo "----------+-------------------------------------------------------------------------------------------+------------+\n"; + +$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE') group by queue_seconds;"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$reasons_to_print = mysql_num_rows($rslt); +$i=0; +while ($i < $reasons_to_print) + { + $row=mysql_fetch_row($rslt); + + $BDansweredCALLS = ($BDansweredCALLS + $row[0]); + + ### Get interval totals + if ($row[1] == 0) {$ad_0 = ($ad_0 + $row[0]);} + if ( ($row[1] > 0) and ($row{1} <= 5) ) {$ad_5 = ($ad_5 + $row[0]);} + if ( ($row[1] > 5) and ($row{1} <= 10) ) {$ad10 = ($ad10 + $row[0]);} + if ( ($row[1] > 10) and ($row{1} <= 15) ) {$ad15 = ($ad15 + $row[0]);} + if ( ($row[1] > 15) and ($row{1} <= 20) ) {$ad20 = ($ad20 + $row[0]);} + if ( ($row[1] > 20) and ($row{1} <= 25) ) {$ad25 = ($ad25 + $row[0]);} + if ( ($row[1] > 25) and ($row{1} <= 30) ) {$ad30 = ($ad30 + $row[0]);} + if ( ($row[1] > 30) and ($row{1} <= 35) ) {$ad35 = ($ad35 + $row[0]);} + if ( ($row[1] > 35) and ($row{1} <= 40) ) {$ad40 = ($ad40 + $row[0]);} + if ( ($row[1] > 40) and ($row{1} <= 45) ) {$ad45 = ($ad45 + $row[0]);} + if ( ($row[1] > 45) and ($row{1} <= 50) ) {$ad50 = ($ad50 + $row[0]);} + if ( ($row[1] > 50) and ($row{1} <= 55) ) {$ad55 = ($ad55 + $row[0]);} + if ( ($row[1] > 55) and ($row{1} <= 60) ) {$ad60 = ($ad60 + $row[0]);} + if ( ($row[1] > 60) and ($row{1} <= 90) ) {$ad90 = ($ad90 + $row[0]);} + if ($row[1] > 90) {$ad99 = ($ad99 + $row[0]);} + $i++; + } + +### Calculate cumulative totals +$Cad_0 =$ad_0; +$Cad_5 =($Cad_0 + $ad_5); +$Cad10 =($Cad_5 + $ad10); +$Cad15 =($Cad10 + $ad15); +$Cad20 =($Cad15 + $ad20); +$Cad25 =($Cad20 + $ad25); +$Cad30 =($Cad25 + $ad30); +$Cad35 =($Cad30 + $ad35); +$Cad40 =($Cad35 + $ad40); +$Cad45 =($Cad40 + $ad45); +$Cad50 =($Cad45 + $ad50); +$Cad55 =($Cad50 + $ad55); +$Cad60 =($Cad55 + $ad60); +$Cad90 =($Cad60 + $ad90); +$Cad99 =($Cad90 + $ad99); + +### Calculate interval percentages +$pad_0=0; $pad_5=0; $pad10=0; $pad15=0; $pad20=0; $pad25=0; $pad30=0; $pad35=0; $pad40=0; $pad45=0; $pad50=0; $pad55=0; $pad60=0; $pad90=0; $pad99=0; +$pCad_0=0; $pCad_5=0; $pCad10=0; $pCad15=0; $pCad20=0; $pCad25=0; $pCad30=0; $pCad35=0; $pCad40=0; $pCad45=0; $pCad50=0; $pCad55=0; $pCad60=0; $pCad90=0; $pCad99=0; +if ( ($BDansweredCALLS > 0) and ($TOTALcalls > 0) ) + { + if ($ad_0 > 0) {$pad_0 = (($ad_0 / $TOTALcalls) * 100); $pad_0 = round($pad_0, 0);} + if ($ad_5 > 0) {$pad_5 = (($ad_5 / $TOTALcalls) * 100); $pad_5 = round($pad_5, 0);} + if ($ad10 > 0) {$pad10 = (($ad10 / $TOTALcalls) * 100); $pad10 = round($pad10, 0);} + if ($ad15 > 0) {$pad15 = (($ad15 / $TOTALcalls) * 100); $pad15 = round($pad15, 0);} + if ($ad20 > 0) {$pad20 = (($ad20 / $TOTALcalls) * 100); $pad20 = round($pad20, 0);} + if ($ad25 > 0) {$pad25 = (($ad25 / $TOTALcalls) * 100); $pad25 = round($pad25, 0);} + if ($ad30 > 0) {$pad30 = (($ad30 / $TOTALcalls) * 100); $pad30 = round($pad30, 0);} + if ($ad35 > 0) {$pad35 = (($ad35 / $TOTALcalls) * 100); $pad35 = round($pad35, 0);} + if ($ad40 > 0) {$pad40 = (($ad40 / $TOTALcalls) * 100); $pad40 = round($pad40, 0);} + if ($ad45 > 0) {$pad45 = (($ad45 / $TOTALcalls) * 100); $pad45 = round($pad45, 0);} + if ($ad50 > 0) {$pad50 = (($ad50 / $TOTALcalls) * 100); $pad50 = round($pad50, 0);} + if ($ad55 > 0) {$pad55 = (($ad55 / $TOTALcalls) * 100); $pad55 = round($pad55, 0);} + if ($ad60 > 0) {$pad60 = (($ad60 / $TOTALcalls) * 100); $pad60 = round($pad60, 0);} + if ($ad90 > 0) {$pad90 = (($ad90 / $TOTALcalls) * 100); $pad90 = round($pad90, 0);} + if ($ad99 > 0) {$pad99 = (($ad99 / $TOTALcalls) * 100); $pad99 = round($pad99, 0);} + + if ($Cad_0 > 0) {$pCad_0 = (($Cad_0 / $TOTALcalls) * 100); $pCad_0 = round($pCad_0, 0);} + if ($Cad_5 > 0) {$pCad_5 = (($Cad_5 / $TOTALcalls) * 100); $pCad_5 = round($pCad_5, 0);} + if ($Cad10 > 0) {$pCad10 = (($Cad10 / $TOTALcalls) * 100); $pCad10 = round($pCad10, 0);} + if ($Cad15 > 0) {$pCad15 = (($Cad15 / $TOTALcalls) * 100); $pCad15 = round($pCad15, 0);} + if ($Cad20 > 0) {$pCad20 = (($Cad20 / $TOTALcalls) * 100); $pCad20 = round($pCad20, 0);} + if ($Cad25 > 0) {$pCad25 = (($Cad25 / $TOTALcalls) * 100); $pCad25 = round($pCad25, 0);} + if ($Cad30 > 0) {$pCad30 = (($Cad30 / $TOTALcalls) * 100); $pCad30 = round($pCad30, 0);} + if ($Cad35 > 0) {$pCad35 = (($Cad35 / $TOTALcalls) * 100); $pCad35 = round($pCad35, 0);} + if ($Cad40 > 0) {$pCad40 = (($Cad40 / $TOTALcalls) * 100); $pCad40 = round($pCad40, 0);} + if ($Cad45 > 0) {$pCad45 = (($Cad45 / $TOTALcalls) * 100); $pCad45 = round($pCad45, 0);} + if ($Cad50 > 0) {$pCad50 = (($Cad50 / $TOTALcalls) * 100); $pCad50 = round($pCad50, 0);} + if ($Cad55 > 0) {$pCad55 = (($Cad55 / $TOTALcalls) * 100); $pCad55 = round($pCad55, 0);} + if ($Cad60 > 0) {$pCad60 = (($Cad60 / $TOTALcalls) * 100); $pCad60 = round($pCad60, 0);} + if ($Cad90 > 0) {$pCad90 = (($Cad90 / $TOTALcalls) * 100); $pCad90 = round($pCad90, 0);} + if ($Cad99 > 0) {$pCad99 = (($Cad99 / $TOTALcalls) * 100); $pCad99 = round($pCad99, 0);} + + if ($Cad_0 > 0) {$ApCad_0 = (($Cad_0 / $BDansweredCALLS) * 100); $ApCad_0 = round($ApCad_0, 0);} + if ($Cad_5 > 0) {$ApCad_5 = (($Cad_5 / $BDansweredCALLS) * 100); $ApCad_5 = round($ApCad_5, 0);} + if ($Cad10 > 0) {$ApCad10 = (($Cad10 / $BDansweredCALLS) * 100); $ApCad10 = round($ApCad10, 0);} + if ($Cad15 > 0) {$ApCad15 = (($Cad15 / $BDansweredCALLS) * 100); $ApCad15 = round($ApCad15, 0);} + if ($Cad20 > 0) {$ApCad20 = (($Cad20 / $BDansweredCALLS) * 100); $ApCad20 = round($ApCad20, 0);} + if ($Cad25 > 0) {$ApCad25 = (($Cad25 / $BDansweredCALLS) * 100); $ApCad25 = round($ApCad25, 0);} + if ($Cad30 > 0) {$ApCad30 = (($Cad30 / $BDansweredCALLS) * 100); $ApCad30 = round($ApCad30, 0);} + if ($Cad35 > 0) {$ApCad35 = (($Cad35 / $BDansweredCALLS) * 100); $ApCad35 = round($ApCad35, 0);} + if ($Cad40 > 0) {$ApCad40 = (($Cad40 / $BDansweredCALLS) * 100); $ApCad40 = round($ApCad40, 0);} + if ($Cad45 > 0) {$ApCad45 = (($Cad45 / $BDansweredCALLS) * 100); $ApCad45 = round($ApCad45, 0);} + if ($Cad50 > 0) {$ApCad50 = (($Cad50 / $BDansweredCALLS) * 100); $ApCad50 = round($ApCad50, 0);} + if ($Cad55 > 0) {$ApCad55 = (($Cad55 / $BDansweredCALLS) * 100); $ApCad55 = round($ApCad55, 0);} + if ($Cad60 > 0) {$ApCad60 = (($Cad60 / $BDansweredCALLS) * 100); $ApCad60 = round($ApCad60, 0);} + if ($Cad90 > 0) {$ApCad90 = (($Cad90 / $BDansweredCALLS) * 100); $ApCad90 = round($ApCad90, 0);} + if ($Cad99 > 0) {$ApCad99 = (($Cad99 / $BDansweredCALLS) * 100); $ApCad99 = round($ApCad99, 0);} + } + +### Format variables +$ad_0 = sprintf("%5s", $ad_0); +$ad_5 = sprintf("%5s", $ad_5); +$ad10 = sprintf("%5s", $ad10); +$ad15 = sprintf("%5s", $ad15); +$ad20 = sprintf("%5s", $ad20); +$ad25 = sprintf("%5s", $ad25); +$ad30 = sprintf("%5s", $ad30); +$ad35 = sprintf("%5s", $ad35); +$ad40 = sprintf("%5s", $ad40); +$ad45 = sprintf("%5s", $ad45); +$ad50 = sprintf("%5s", $ad50); +$ad55 = sprintf("%5s", $ad55); +$ad60 = sprintf("%5s", $ad60); +$ad90 = sprintf("%5s", $ad90); +$ad99 = sprintf("%5s", $ad99); +$Cad_0 = sprintf("%5s", $Cad_0); +$Cad_5 = sprintf("%5s", $Cad_5); +$Cad10 = sprintf("%5s", $Cad10); +$Cad15 = sprintf("%5s", $Cad15); +$Cad20 = sprintf("%5s", $Cad20); +$Cad25 = sprintf("%5s", $Cad25); +$Cad30 = sprintf("%5s", $Cad30); +$Cad35 = sprintf("%5s", $Cad35); +$Cad40 = sprintf("%5s", $Cad40); +$Cad45 = sprintf("%5s", $Cad45); +$Cad50 = sprintf("%5s", $Cad50); +$Cad55 = sprintf("%5s", $Cad55); +$Cad60 = sprintf("%5s", $Cad60); +$Cad90 = sprintf("%5s", $Cad90); +$Cad99 = sprintf("%5s", $Cad99); +$pad_0 = sprintf("%4s", $pad_0) . '%'; +$pad_5 = sprintf("%4s", $pad_5) . '%'; +$pad10 = sprintf("%4s", $pad10) . '%'; +$pad15 = sprintf("%4s", $pad15) . '%'; +$pad20 = sprintf("%4s", $pad20) . '%'; +$pad25 = sprintf("%4s", $pad25) . '%'; +$pad30 = sprintf("%4s", $pad30) . '%'; +$pad35 = sprintf("%4s", $pad35) . '%'; +$pad40 = sprintf("%4s", $pad40) . '%'; +$pad45 = sprintf("%4s", $pad45) . '%'; +$pad50 = sprintf("%4s", $pad50) . '%'; +$pad55 = sprintf("%4s", $pad55) . '%'; +$pad60 = sprintf("%4s", $pad60) . '%'; +$pad90 = sprintf("%4s", $pad90) . '%'; +$pad99 = sprintf("%4s", $pad99) . '%'; +$pCad_0 = sprintf("%4s", $pCad_0) . '%'; +$pCad_5 = sprintf("%4s", $pCad_5) . '%'; +$pCad10 = sprintf("%4s", $pCad10) . '%'; +$pCad15 = sprintf("%4s", $pCad15) . '%'; +$pCad20 = sprintf("%4s", $pCad20) . '%'; +$pCad25 = sprintf("%4s", $pCad25) . '%'; +$pCad30 = sprintf("%4s", $pCad30) . '%'; +$pCad35 = sprintf("%4s", $pCad35) . '%'; +$pCad40 = sprintf("%4s", $pCad40) . '%'; +$pCad45 = sprintf("%4s", $pCad45) . '%'; +$pCad50 = sprintf("%4s", $pCad50) . '%'; +$pCad55 = sprintf("%4s", $pCad55) . '%'; +$pCad60 = sprintf("%4s", $pCad60) . '%'; +$pCad90 = sprintf("%4s", $pCad90) . '%'; +$pCad99 = sprintf("%4s", $pCad99) . '%'; +$ApCad_0 = sprintf("%4s", $ApCad_0) . '%'; +$ApCad_5 = sprintf("%4s", $ApCad_5) . '%'; +$ApCad10 = sprintf("%4s", $ApCad10) . '%'; +$ApCad15 = sprintf("%4s", $ApCad15) . '%'; +$ApCad20 = sprintf("%4s", $ApCad20) . '%'; +$ApCad25 = sprintf("%4s", $ApCad25) . '%'; +$ApCad30 = sprintf("%4s", $ApCad30) . '%'; +$ApCad35 = sprintf("%4s", $ApCad35) . '%'; +$ApCad40 = sprintf("%4s", $ApCad40) . '%'; +$ApCad45 = sprintf("%4s", $ApCad45) . '%'; +$ApCad50 = sprintf("%4s", $ApCad50) . '%'; +$ApCad55 = sprintf("%4s", $ApCad55) . '%'; +$ApCad60 = sprintf("%4s", $ApCad60) . '%'; +$ApCad90 = sprintf("%4s", $ApCad90) . '%'; +$ApCad99 = sprintf("%4s", $ApCad99) . '%'; + +$BDansweredCALLS = sprintf("%10s", $BDansweredCALLS); + +### Format and output +$answeredTOTALs = "$ad_0 $ad_5 $ad10 $ad15 $ad20 $ad25 $ad30 $ad35 $ad40 $ad45 $ad50 $ad55 $ad60 $ad90 $ad99 | $BDansweredCALLS |"; +$answeredCUMULATIVE = "$Cad_0 $Cad_5 $Cad10 $Cad15 $Cad20 $Cad25 $Cad30 $Cad35 $Cad40 $Cad45 $Cad50 $Cad55 $Cad60 $Cad90 $Cad99 | $BDansweredCALLS |"; +$answeredINT_PERCENT = "$pad_0 $pad_5 $pad10 $pad15 $pad20 $pad25 $pad30 $pad35 $pad40 $pad45 $pad50 $pad55 $pad60 $pad90 $pad99 | |"; +$answeredCUM_PERCENT = "$pCad_0 $pCad_5 $pCad10 $pCad15 $pCad20 $pCad25 $pCad30 $pCad35 $pCad40 $pCad45 $pCad50 $pCad55 $pCad60 $pCad90 $pCad99 | |"; +$answeredCUM_ANS_PERCENT = "$ApCad_0 $ApCad_5 $ApCad10 $ApCad15 $ApCad20 $ApCad25 $ApCad30 $ApCad35 $ApCad40 $ApCad45 $ApCad50 $ApCad55 $ApCad60 $ApCad90 $ApCad99 | |"; +echo "INTERVAL | $answeredTOTALs\n"; +echo "INT % | $answeredINT_PERCENT\n"; +echo "CUMULATIVE| $answeredCUMULATIVE\n"; +echo "CUM % | $answeredCUM_PERCENT\n"; +echo "CUM ANS % | $answeredCUM_ANS_PERCENT\n"; +echo "----------+-------------------------------------------------------------------------------------------+------------+\n"; + + + + + ############################## ######### CALL HANGUP REASON STATS diff --git a/www/vicidial/AST_IVRstats.php b/www/vicidial/AST_IVRstats.php index f04b4449..fae4e252 100644 --- a/www/vicidial/AST_IVRstats.php +++ b/www/vicidial/AST_IVRstats.php @@ -6,6 +6,7 @@ # CHANGES # # 81026-2026 - First build +# 81107-0341 - Added time range and option and 15-minute increment graph # require("dbconnect.php"); @@ -69,8 +70,8 @@ $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); if (!isset($group)) {$group = '';} -if (!isset($query_date)) {$query_date = $NOW_DATE;} -if (!isset($end_date)) {$end_date = $NOW_DATE;} +if (!isset($query_date)) {$query_date = "$NOW_DATE 00:00:00";} +if (!isset($end_date)) {$end_date = "$NOW_DATE 23:23:59";} $stmt="select group_id from vicidial_inbound_groups;"; $rslt=mysql_query($stmt, $link); @@ -136,6 +137,41 @@ while ($i < $statcats_to_print) \n"; echo "VICIDIAL: IVR Stats\n"; if ($DB > 0) @@ -151,8 +187,8 @@ echo "
\n"; echo "
\n"; echo "\n"; echo "Date Range:
\n"; -echo "\n"; -echo " to \n"; +echo "\n"; +echo " to \n"; echo "
\n"; echo "Inbound Groups: \n"; echo "\n"; @@ -192,6 +228,7 @@ echo "\n"; echo "\n"; echo "\n"; echo "\n"; +echo "\n"; echo "\n"; echo "   \n"; echo "
\n"; @@ -208,28 +245,6 @@ echo "PLEASE SELECT AN IN-GROUP AND DATE RANGE ABOVE AND CLICK SUBMIT\n"; else { -if ($shift == 'AM') - { - $time_BEGIN=$AM_shift_BEGIN; - $time_END=$AM_shift_END; - if (strlen($time_BEGIN) < 6) {$time_BEGIN = "03:45:00";} - if (strlen($time_END) < 6) {$time_END = "15:15:00";} - } -if ($shift == 'PM') - { - $time_BEGIN=$PM_shift_BEGIN; - $time_END=$PM_shift_END; - if (strlen($time_BEGIN) < 6) {$time_BEGIN = "15:15:00";} - if (strlen($time_END) < 6) {$time_END = "23:15:00";} - } -if ($shift == 'ALL') - { - if (strlen($time_BEGIN) < 6) {$time_BEGIN = "00:00:00";} - if (strlen($time_END) < 6) {$time_END = "23:59:59";} - } -$query_date_BEGIN = "$query_date $time_BEGIN"; -$query_date_END = "$end_date $time_END"; - echo "VICIDIAL: IVR Stats: $group_string $NOW_TIME\n"; @@ -264,9 +279,11 @@ $p=0; $r=-1; while ($p < $logs_to_print) { + if ($DB > 0) {echo "$p|$uniqueid[$p]|$comment_b[$p]";} if ($last_uniqueid === "$uniqueid[$p]") { $unique_calls[$r] .= "----------$comment_b[$p]"; + if ($DB > 0) {echo " $r|$unique_calls[$r]\n";} } else { @@ -274,21 +291,24 @@ while ($p < $logs_to_print) $unique_calls[$r] = $comment_b[$p]; $FLOWuniqueid[$r] = "$uniqueid[$p]"; $last_uniqueid = "$uniqueid[$p]"; + if ($DB > 0) {echo " $r|$unique_calls[$r]\n";} } $p++; } ### sort call flows for counting $RAWunique_calls = $unique_calls; -sort($unique_calls); +if ($logs_to_print > 0) + {sort($unique_calls);} ### count each unique call flow $last_Suniqueid=''; $p=-1; $s=0; -while ($s < $r) +while ($s <= $r) { + if ($DB > 0) {echo "$s|$unique_calls[$s]\n";} if ($last_Suniqueid === "$unique_calls[$s]") { $STunique_calls_count[$p]++; @@ -305,22 +325,29 @@ while ($s < $r) ### put call flows and counts together for sorting again +$TOTALcalls=0; $s=0; -while ($s < $p) +while ($s <= $p) { + $TOTALcalls = ($TOTALcalls + $STunique_calls_count[$s]); $STunique_calls_count[$s] = sprintf("%07s", $STunique_calls_count[$s]); $FLOWunique_calls[$s] = "$STunique_calls_count[$s]__________$STunique_calls[$s]"; $s++; } +#### PRINT TOTAL CALLS INTO THIS IVR +echo "\nCalls taken into this IVR: $TOTALcalls\n\n"; + + ### sort call flows for counting -rsort($FLOWunique_calls); +if ($p > 0) + {rsort($FLOWunique_calls);} ### put call flows and counts together for sorting again $RUC_ct = count($RAWunique_calls); $s=0; -while ($s < $p) +while ($s <= $p) { $FLOWsummary = explode('__________',$FLOWunique_calls[$s]); $FLOWsummary[0] = ($FLOWsummary[0] + 0); @@ -346,7 +373,7 @@ echo "+--------+--------+--------+--------+\n"; echo "| IVR | QUEUE | QDROP | QDROP% | CALL PATH\n"; echo "+--------+--------+--------+--------+------------\n"; -while ($s < $p) +while ($s <= $p) { $vcl_statuses = $MT; $FLOWdrop[$s]=0; @@ -391,7 +418,6 @@ while ($s < $p) echo "+--------+--------+--------+--------+\n"; -exit; @@ -405,573 +431,6 @@ exit; - - - -if ($group_ct > 1) - { - echo "\n"; - echo "---------- MULTI-GROUP BREAKDOWN:\n"; - echo "+----------------------+---------+---------+---------+---------+\n"; - echo "| IN-GROUP | CALLS | DROPS | DROP % | IVR |\n"; - echo "+----------------------+---------+---------+---------+---------+\n"; - - $i=0; - while($i < $group_ct) - { - $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]';"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysql_fetch_row($rslt); - - $stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='$group[$i]' and comment_b='START';"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $rowx=mysql_fetch_row($rslt); - - $stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='$group[$i]' and status IN('DROP','XDROP') and (length_in_sec <= 9999 or length_in_sec is null);"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $rowy=mysql_fetch_row($rslt); - - $groupDISPLAY = sprintf("%20s", $group[$i]); - $gTOTALcalls = sprintf("%7s", $row[0]); - $gIVRcalls = sprintf("%7s", $rowx[0]); - $gDROPcalls = sprintf("%7s", $rowy[0]); - if ( ($gDROPcalls < 1) or ($gTOTALcalls < 1) ) - {$gDROPpercent = '0';} - else - { - $gDROPpercent = (($gDROPcalls / $gTOTALcalls) * 100); - $gDROPpercent = round($gDROPpercent, 2); - } - $gDROPpercent = sprintf("%6s", $gDROPpercent); - - echo "| $groupDISPLAY | $gTOTALcalls | $gDROPcalls | $gDROPpercent% | $gIVRcalls |\n"; - $i++; - } - - echo "+----------------------+---------+---------+---------+---------+\n"; - - } - - -echo "\n"; -echo "Time range: $query_date_BEGIN to $query_date_END\n\n"; -echo "---------- TOTALS\n"; - -$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL);"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$row=mysql_fetch_row($rslt); - -$stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a IN($group_SQL) and comment_b='START';"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$rowx=mysql_fetch_row($rslt); - -$TOTALcalls = sprintf("%10s", $row[0]); -$IVRcalls = sprintf("%10s", $rowx[0]); -$TOTALsec = $row[1]; -if ( ($row[0] < 1) or ($TOTALsec < 1) ) - {$average_call_seconds = ' 0';} -else - { - $average_call_seconds = ($TOTALsec / $row[0]); - $average_call_seconds = round($average_call_seconds, 0); - $average_call_seconds = sprintf("%10s", $average_call_seconds); - } - -echo "Total calls taken in to this In-Group: $TOTALcalls\n"; -echo "Average Call Length for all Calls: $average_call_seconds seconds\n"; -echo "Calls taken into the IVR for this In-Group: $IVRcalls\n"; - -echo "\n"; -echo "---------- DROPS\n"; - -$stmt="select count(*),sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status IN('DROP','XDROP') and (length_in_sec <= 9999 or length_in_sec is null);"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$row=mysql_fetch_row($rslt); - -$DROPcalls = sprintf("%10s", $row[0]); -if ( ($DROPcalls < 1) or ($TOTALcalls < 1) ) - {$DROPpercent = '0';} -else - { - $DROPpercent = (($DROPcalls / $TOTALcalls) * 100); - $DROPpercent = round($DROPpercent, 0); - } - -if ( ($row[0] < 1) or ($row[1] < 1) ) - { - $average_hold_seconds = ' 0'; - } -else - { - $average_hold_seconds = ($row[1] / $row[0]); - $average_hold_seconds = round($average_hold_seconds, 0); - $average_hold_seconds = sprintf("%10s", $average_hold_seconds); - } - -echo "Total DROP Calls: $DROPcalls $DROPpercent%\n"; -echo "Average hold time for DROP Calls: $average_hold_seconds seconds\n"; - - -# GET LIST OF ALL STATUSES and create SQL from human_answered statuses -$q=0; -$stmt = "SELECT status,status_name,human_answered,category from vicidial_statuses;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$statuses_to_print = mysql_num_rows($rslt); -$p=0; -while ($p < $statuses_to_print) - { - $row=mysql_fetch_row($rslt); - $status[$q] = $row[0]; - $status_name[$q] = $row[1]; - $human_answered[$q] = $row[2]; - $category[$q] = $row[3]; - $statname_list["$status[$q]"] = "$status_name[$q]"; - $statcat_list["$status[$q]"] = "$category[$q]"; - $q++; - $p++; - } -$stmt = "SELECT status,status_name,human_answered,category from vicidial_campaign_statuses;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$statuses_to_print = mysql_num_rows($rslt); -$p=0; -while ($p < $statuses_to_print) - { - $row=mysql_fetch_row($rslt); - $status[$q] = $row[0]; - $status_name[$q] = $row[1]; - $human_answered[$q] = $row[2]; - $category[$q] = $row[3]; - $statname_list["$status[$q]"] = "$status_name[$q]"; - $statcat_list["$status[$q]"] = "$category[$q]"; - $q++; - $p++; - } - -############################## -######### CALL QUEUE STATS -echo "\n"; -echo "---------- QUEUE STATS\n"; - -$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and (queue_seconds > 0);"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$row=mysql_fetch_row($rslt); - -$QUEUEcalls = sprintf("%10s", $row[0]); -if ( ($QUEUEcalls < 1) or ($TOTALcalls < 1) ) - {$QUEUEpercent = '0';} -else - { - $QUEUEpercent = (($QUEUEcalls / $TOTALcalls) * 100); - $QUEUEpercent = round($QUEUEpercent, 0); - } - -if ( ($row[0] < 1) or ($row[1] < 1) ) - {$average_queue_seconds = ' 0';} -else - { - $average_queue_seconds = ($row[1] / $row[0]); - $average_queue_seconds = round($average_queue_seconds, 2); - $average_queue_seconds = sprintf("%10.2f", $average_queue_seconds); - } - -if ( ($TOTALcalls < 1) or ($row[1] < 1) ) - {$average_total_queue_seconds = ' 0';} -else - { - $average_total_queue_seconds = ($row[1] / $TOTALcalls); - $average_total_queue_seconds = round($average_total_queue_seconds, 2); - $average_total_queue_seconds = sprintf("%10.2f", $average_total_queue_seconds); - } - -echo "Total Calls That entered Queue: $QUEUEcalls $QUEUEpercent%\n"; -echo "Average QUEUE Length for queue calls: $average_queue_seconds seconds\n"; -echo "Average QUEUE Length across all calls: $average_total_queue_seconds seconds\n"; - - - -############################## -######### CALL HOLD TIME BREAKDONW IN SECONDS - -$TOTALcalls = 0; - -echo "\n"; -echo "---------- CALL HOLD TIME BREAKDOWN IN SECONDS\n"; -echo "+-------------------------------------------------------------------------------------------+------------+\n"; -echo "| 0 5 10 15 20 25 30 35 40 45 50 55 60 90 +90 | TOTAL |\n"; -echo "+-------------------------------------------------------------------------------------------+------------+\n"; - -$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) group by queue_seconds;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$reasons_to_print = mysql_num_rows($rslt); -$i=0; -while ($i < $reasons_to_print) - { - $row=mysql_fetch_row($rslt); - - $TOTALcalls = ($TOTALcalls + $row[0]); - - if ($row[1] == 0) {$hd_0 = ($hd_0 + $row[0]);} - if ( ($row[1] > 0) and ($row{1} <= 5) ) {$hd_5 = ($hd_5 + $row[0]);} - if ( ($row[1] > 5) and ($row{1} <= 10) ) {$hd10 = ($hd10 + $row[0]);} - if ( ($row[1] > 10) and ($row{1} <= 15) ) {$hd15 = ($hd15 + $row[0]);} - if ( ($row[1] > 15) and ($row{1} <= 20) ) {$hd20 = ($hd20 + $row[0]);} - if ( ($row[1] > 20) and ($row{1} <= 25) ) {$hd25 = ($hd25 + $row[0]);} - if ( ($row[1] > 25) and ($row{1} <= 30) ) {$hd30 = ($hd30 + $row[0]);} - if ( ($row[1] > 30) and ($row{1} <= 35) ) {$hd35 = ($hd35 + $row[0]);} - if ( ($row[1] > 35) and ($row{1} <= 40) ) {$hd40 = ($hd40 + $row[0]);} - if ( ($row[1] > 40) and ($row{1} <= 45) ) {$hd45 = ($hd45 + $row[0]);} - if ( ($row[1] > 45) and ($row{1} <= 50) ) {$hd50 = ($hd50 + $row[0]);} - if ( ($row[1] > 50) and ($row{1} <= 55) ) {$hd55 = ($hd55 + $row[0]);} - if ( ($row[1] > 55) and ($row{1} <= 60) ) {$hd60 = ($hd60 + $row[0]);} - if ( ($row[1] > 60) and ($row{1} <= 90) ) {$hd90 = ($hd90 + $row[0]);} - if ($row[1] > 90) {$hd99 = ($hd99 + $row[0]);} - $i++; - } - -$hd_0 = sprintf("%5s", $hd_0); -$hd_5 = sprintf("%5s", $hd_5); -$hd10 = sprintf("%5s", $hd10); -$hd15 = sprintf("%5s", $hd15); -$hd20 = sprintf("%5s", $hd20); -$hd25 = sprintf("%5s", $hd25); -$hd30 = sprintf("%5s", $hd30); -$hd35 = sprintf("%5s", $hd35); -$hd40 = sprintf("%5s", $hd40); -$hd45 = sprintf("%5s", $hd45); -$hd50 = sprintf("%5s", $hd50); -$hd55 = sprintf("%5s", $hd55); -$hd60 = sprintf("%5s", $hd60); -$hd90 = sprintf("%5s", $hd90); -$hd99 = sprintf("%5s", $hd99); - -$TOTALcalls = sprintf("%10s", $TOTALcalls); - -echo "| $hd_0 $hd_5 $hd10 $hd15 $hd20 $hd25 $hd30 $hd35 $hd40 $hd45 $hd50 $hd55 $hd60 $hd90 $hd99 | $TOTALcalls |\n"; -echo "+-------------------------------------------------------------------------------------------+------------+\n"; - - - -############################## -######### CALL HANGUP REASON STATS - -$TOTALcalls = 0; - -echo "\n"; -echo "---------- CALL HANGUP REASON STATS\n"; -echo "+----------------------+------------+\n"; -echo "| HANGUP REASON | CALLS |\n"; -echo "+----------------------+------------+\n"; - -$stmt="select count(*),term_reason from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) group by term_reason;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$reasons_to_print = mysql_num_rows($rslt); -$i=0; -while ($i < $reasons_to_print) - { - $row=mysql_fetch_row($rslt); - - $TOTALcalls = ($TOTALcalls + $row[0]); - - $REASONcount = sprintf("%10s", $row[0]);while(strlen($REASONcount)>10) {$REASONcount = substr("$REASONcount", 0, -1);} - $reason = sprintf("%-20s", $row[1]);while(strlen($reason)>20) {$reason = substr("$reason", 0, -1);} -# if (ereg("NONE",$reason)) {$reason = 'NO ANSWER ';} - - echo "| $reason | $REASONcount |\n"; - - $i++; - } - -$TOTALcalls = sprintf("%10s", $TOTALcalls); - -echo "+----------------------+------------+\n"; -echo "| TOTAL: | $TOTALcalls |\n"; -echo "+----------------------+------------+\n"; - - - - -############################## -######### CALL STATUS STATS - -$TOTALcalls = 0; - -echo "\n"; -echo "---------- CALL STATUS STATS\n"; -echo "+--------+----------------------+----------------------+------------+------------+----------+----------+\n"; -echo "| STATUS | DESCRIPTION | CATEGORY | CALLS | TOTAL TIME | AVG TIME |CALLS/HOUR|\n"; -echo "+--------+----------------------+----------------------+------------+------------+----------+----------+\n"; - - -## get counts and time totals for all statuses in this campaign -$stmt="select count(*),status,sum(length_in_sec) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) group by status;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$statuses_to_print = mysql_num_rows($rslt); -$i=0; -while ($i < $statuses_to_print) - { - $row=mysql_fetch_row($rslt); - - $STATUScount = $row[0]; - $RAWstatus = $row[1]; - $r=0; $foundstat=0; - while ($r < $statcats_to_print) - { - if ( ($statcat_list[$RAWstatus] == "$vsc_id[$r]") and ($foundstat < 1) ) - { - $vsc_count[$r] = ($vsc_count[$r] + $STATUScount); - } - $r++; - } - - $TOTALcalls = ($TOTALcalls + $row[0]); - if ( ($STATUScount < 1) or ($TOTALsec < 1) ) - {$STATUSrate = 0;} - else - {$STATUSrate = ($STATUScount / ($TOTALsec / 3600) );} - $STATUSrate = sprintf("%.2f", $STATUSrate); - - $STATUShours_H = ($row[2] / 3600); - $STATUShours_H_int = round($STATUShours_H, 2); - $STATUShours_H_int = intval("$STATUShours_H_int"); - $STATUShours_M = ($STATUShours_H - $STATUShours_H_int); - $STATUShours_M = ($STATUShours_M * 60); - $STATUShours_M_int = round($STATUShours_M, 2); - $STATUShours_M_int = intval("$STATUShours_M_int"); - $STATUShours_S = ($STATUShours_M - $STATUShours_M_int); - $STATUShours_S = ($STATUShours_S * 60); - $STATUShours_S = round($STATUShours_S, 0); - if ($STATUShours_S < 10) {$STATUShours_S = "0$STATUShours_S";} - if ($STATUShours_M_int < 10) {$STATUShours_M_int = "0$STATUShours_M_int";} - $STATUShours = "$STATUShours_H_int:$STATUShours_M_int:$STATUShours_S"; - - $STATUSavg_H = (($row[2] / 3600) / $STATUScount); - $STATUSavg_H_int = round($STATUSavg_H, 2); - $STATUSavg_H_int = intval("$STATUSavg_H_int"); - $STATUSavg_M = ($STATUSavg_H - $STATUSavg_H_int); - $STATUSavg_M = ($STATUSavg_M * 60); - $STATUSavg_M_int = round($STATUSavg_M, 2); - $STATUSavg_M_int = intval("$STATUSavg_M_int"); - $STATUSavg_S = ($STATUSavg_M - $STATUSavg_M_int); - $STATUSavg_S = ($STATUSavg_S * 60); - $STATUSavg_S = round($STATUSavg_S, 0); - if ($STATUSavg_S < 10) {$STATUSavg_S = "0$STATUSavg_S";} - if ($STATUSavg_M_int < 10) {$STATUSavg_M_int = "0$STATUSavg_M_int";} - $STATUSavg = "$STATUSavg_H_int:$STATUSavg_M_int:$STATUSavg_S"; - - $STATUScount = sprintf("%10s", $row[0]);while(strlen($STATUScount)>10) {$STATUScount = substr("$STATUScount", 0, -1);} - $status = sprintf("%-6s", $row[1]);while(strlen($status)>6) {$status = substr("$status", 0, -1);} - $STATUShours = sprintf("%10s", $STATUShours);while(strlen($STATUShours)>10) {$STATUShours = substr("$STATUShours", 0, -1);} - $STATUSavg = sprintf("%8s", $STATUSavg);while(strlen($STATUSavg)>8) {$STATUSavg = substr("$STATUSavg", 0, -1);} - $STATUSrate = sprintf("%8s", $STATUSrate);while(strlen($STATUSrate)>8) {$STATUSrate = substr("$STATUSrate", 0, -1);} - - if ($non_latin < 1) - { - $status_name = sprintf("%-20s", $statname_list[$RAWstatus]); - while(strlen($status_name)>20) {$status_name = substr("$status_name", 0, -1);} - $statcat = sprintf("%-20s", $statcat_list[$RAWstatus]); - while(strlen($statcat)>20) {$statcat = substr("$statcat", 0, -1);} - } - else - { - $status_name = sprintf("%-60s", $statname_list[$RAWstatus]); - while(mb_strlen($status_name,'utf-8')>20) {$status_name = mb_substr("$status_name", 0, -1,'utf-8');} - $statcat = sprintf("%-60s", $statcat_list[$RAWstatus]); - while(mb_strlen($statcat,'utf-8')>20) {$statcat = mb_substr("$statcat", 0, -1,'utf-8');} - } - - - echo "| $status | $status_name | $statcat | $STATUScount | $STATUShours | $STATUSavg | $STATUSrate |\n"; - - $i++; - } - -if ($TOTALcalls < 1) - { - $TOTALhours = '0:00:00'; - $TOTALavg = '0:00:00'; - $TOTALrate = '0.00'; - } -else - { - if ( ($TOTALcalls < 1) or ($TOTALsec < 1) ) - {$TOTALrate = 0;} - else - {$TOTALrate = ($TOTALcalls / ($TOTALsec / 3600) );} - $TOTALrate = sprintf("%.2f", $TOTALrate); - - $TOTALhours_H = ($TOTALsec / 3600); - $TOTALhours_H_int = round($TOTALhours_H, 2); - $TOTALhours_H_int = intval("$TOTALhours_H_int"); - $TOTALhours_M = ($TOTALhours_H - $TOTALhours_H_int); - $TOTALhours_M = ($TOTALhours_M * 60); - $TOTALhours_M_int = round($TOTALhours_M, 2); - $TOTALhours_M_int = intval("$TOTALhours_M_int"); - $TOTALhours_S = ($TOTALhours_M - $TOTALhours_M_int); - $TOTALhours_S = ($TOTALhours_S * 60); - $TOTALhours_S = round($TOTALhours_S, 0); - if ($TOTALhours_S < 10) {$TOTALhours_S = "0$TOTALhours_S";} - if ($TOTALhours_M_int < 10) {$TOTALhours_M_int = "0$TOTALhours_M_int";} - $TOTALhours = "$TOTALhours_H_int:$TOTALhours_M_int:$TOTALhours_S"; - - $TOTALavg_H = (($TOTALsec / 3600) / $TOTALcalls); - $TOTALavg_H_int = round($TOTALavg_H, 2); - $TOTALavg_H_int = intval("$TOTALavg_H_int"); - $TOTALavg_M = ($TOTALavg_H - $TOTALavg_H_int); - $TOTALavg_M = ($TOTALavg_M * 60); - $TOTALavg_M_int = round($TOTALavg_M, 2); - $TOTALavg_M_int = intval("$TOTALavg_M_int"); - $TOTALavg_S = ($TOTALavg_M - $TOTALavg_M_int); - $TOTALavg_S = ($TOTALavg_S * 60); - $TOTALavg_S = round($TOTALavg_S, 0); - if ($TOTALavg_S < 10) {$TOTALavg_S = "0$TOTALavg_S";} - if ($TOTALavg_M_int < 10) {$TOTALavg_M_int = "0$TOTALavg_M_int";} - $TOTALavg = "$TOTALavg_H_int:$TOTALavg_M_int:$TOTALavg_S"; - } -$TOTALcalls = sprintf("%10s", $TOTALcalls); -$TOTALhours = sprintf("%10s", $TOTALhours);while(strlen($TOTALhours)>10) {$TOTALhours = substr("$TOTALhours", 0, -1);} -$TOTALavg = sprintf("%8s", $TOTALavg);while(strlen($TOTALavg)>8) {$TOTALavg = substr("$TOTALavg", 0, -1);} -$TOTALrate = sprintf("%8s", $TOTALrate);while(strlen($TOTALrate)>8) {$TOTALrate = substr("$TOTALrate", 0, -1);} - -echo "+--------+----------------------+----------------------+------------+------------+----------+----------+\n"; -echo "| TOTAL: | $TOTALcalls | $TOTALhours | $TOTALavg | $TOTALrate |\n"; -echo "+------------------------------------------------------+------------+------------+----------+----------+\n"; - - -############################## -######### STATUS CATEGORY STATS - -echo "\n"; -echo "---------- CUSTOM STATUS CATEGORY STATS\n"; -echo "+----------------------+------------+--------------------------------+\n"; -echo "| CATEGORY | CALLS | DESCRIPTION |\n"; -echo "+----------------------+------------+--------------------------------+\n"; - -$TOTCATcalls=0; -$r=0; -while ($r < $statcats_to_print) - { - if ($vsc_id[$r] != 'UNDEFINED') - { - $TOTCATcalls = ($TOTCATcalls + $vsc_count[$r]); - $category = sprintf("%-20s", $vsc_id[$r]); while(strlen($category)>20) {$category = substr("$category", 0, -1);} - $CATcount = sprintf("%10s", $vsc_count[$r]); while(strlen($CATcount)>10) {$CATcount = substr("$CATcount", 0, -1);} - $CATname = sprintf("%-30s", $vsc_name[$r]); while(strlen($CATname)>30) {$CATname = substr("$CATname", 0, -1);} - - echo "| $category | $CATcount | $CATname |\n"; - } - - $r++; - } - -$TOTCATcalls = sprintf("%10s", $TOTCATcalls); while(strlen($TOTCATcalls)>10) {$TOTCATcalls = substr("$TOTCATcalls", 0, -1);} - -echo "+----------------------+------------+--------------------------------+\n"; -echo "| TOTAL | $TOTCATcalls |\n"; -echo "+----------------------+------------+\n"; - - -############################## -######### USER STATS - -$TOTagents=0; -$TOTcalls=0; -$TOTtime=0; -$TOTavg=0; - -echo "\n"; -echo "---------- AGENT STATS\n"; -echo "+--------------------------+------------+----------+--------+\n"; -echo "| AGENT | CALLS | TIME M | AVRG M |\n"; -echo "+--------------------------+------------+----------+--------+\n"; - -$stmt="select vicidial_closer_log.user,full_name,count(*),sum(length_in_sec),avg(length_in_sec) from vicidial_closer_log,vicidial_users where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and vicidial_closer_log.user is not null and length_in_sec is not null and length_in_sec > 0 and vicidial_closer_log.user=vicidial_users.user group by vicidial_closer_log.user;"; -$rslt=mysql_query($stmt, $link); -if ($DB) {echo "$stmt\n";} -$users_to_print = mysql_num_rows($rslt); -$i=0; -while ($i < $users_to_print) - { - $row=mysql_fetch_row($rslt); - - $TOTcalls = ($TOTcalls + $row[2]); - $TOTtime = ($TOTtime + $row[3]); - - $user = sprintf("%-6s", $row[0]); - $full_name = sprintf("%-15s", $row[1]); while(strlen($full_name)>15) {$full_name = substr("$full_name", 0, -1);} - $USERcalls = sprintf("%10s", $row[2]); - $USERtotTALK = $row[3]; - $USERavgTALK = $row[4]; - - $USERtotTALK_M = ($USERtotTALK / 60); - $USERtotTALK_M_int = round($USERtotTALK_M, 2); - $USERtotTALK_M_int = intval("$USERtotTALK_M_int"); - $USERtotTALK_S = ($USERtotTALK_M - $USERtotTALK_M_int); - $USERtotTALK_S = ($USERtotTALK_S * 60); - $USERtotTALK_S = round($USERtotTALK_S, 0); - if ($USERtotTALK_S < 10) {$USERtotTALK_S = "0$USERtotTALK_S";} - $USERtotTALK_MS = "$USERtotTALK_M_int:$USERtotTALK_S"; - $USERtotTALK_MS = sprintf("%8s", $USERtotTALK_MS); - - $USERavgTALK_M = ($USERavgTALK / 60); - $USERavgTALK_M_int = round($USERavgTALK_M, 2); - $USERavgTALK_M_int = intval("$USERavgTALK_M_int"); - $USERavgTALK_S = ($USERavgTALK_M - $USERavgTALK_M_int); - $USERavgTALK_S = ($USERavgTALK_S * 60); - $USERavgTALK_S = round($USERavgTALK_S, 0); - if ($USERavgTALK_S < 10) {$USERavgTALK_S = "0$USERavgTALK_S";} - $USERavgTALK_MS = "$USERavgTALK_M_int:$USERavgTALK_S"; - $USERavgTALK_MS = sprintf("%6s", $USERavgTALK_MS); - - echo "| $user - $full_name | $USERcalls | $USERtotTALK_MS | $USERavgTALK_MS |\n"; - - $i++; - } - -if (!$TOTcalls) {$TOTcalls = 1;} -$TOTavg = ($TOTtime / $TOTcalls); -$TOTavg = round($TOTavg, 0); -$TOTavg_M = ($TOTavg / 60); -$TOTavg_M_int = round($TOTavg_M, 2); -$TOTavg_M_int = intval("$TOTavg_M_int"); -$TOTavg_S = ($TOTavg_M - $TOTavg_M_int); -$TOTavg_S = ($TOTavg_S * 60); -$TOTavg_S = round($TOTavg_S, 0); -if ($TOTavg_S < 10) {$TOTavg_S = "0$TOTavg_S";} -$TOTavg_MS = "$TOTavg_M_int:$TOTavg_S"; -$TOTavg = sprintf("%6s", $TOTavg_MS); - -$TOTtime_M = ($TOTtime / 60); -$TOTtime_M_int = round($TOTtime_M, 2); -$TOTtime_M_int = intval("$TOTtime_M_int"); -$TOTtime_S = ($TOTtime_M - $TOTtime_M_int); -$TOTtime_S = ($TOTtime_S * 60); -$TOTtime_S = round($TOTtime_S, 0); -if ($TOTtime_S < 10) {$TOTtime_S = "0$TOTtime_S";} -$TOTtime_MS = "$TOTtime_M_int:$TOTtime_S"; -$TOTtime = sprintf("%6s", $TOTtime_MS); - -$TOTagents = sprintf("%10s", $i); -$TOTcalls = sprintf("%10s", $TOTcalls); -$TOTtime = sprintf("%8s", $TOTtime); -$TOTavg = sprintf("%6s", $TOTavg); - -echo "+--------------------------+------------+----------+--------+\n"; -echo "| TOTAL Agents: $TOTagents | $TOTcalls | $TOTtime | $TOTavg |\n"; -echo "+--------------------------+------------+----------+--------+\n"; - - ############################## ######### TIME STATS @@ -986,61 +445,41 @@ $i=0; $h=0; while ($i <= 96) { - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id IN($group_SQL);"; + $stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:00:00' and start_time <= '$query_date $h:14:59' and comment_a IN($group_SQL) and comment_b='START';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); $hour_count[$i] = $row[0]; if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} if ($hour_count[$i] > 0) {$last_full_record = $i;} - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:00:00' and call_date <= '$query_date $h:14:59' and campaign_id IN($group_SQL) and status IN('DROP','XDROP');"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysql_fetch_row($rslt); - $drop_count[$i] = $row[0]; $i++; - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id IN($group_SQL);"; + $stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:15:00' and start_time <= '$query_date $h:29:59' and comment_a IN($group_SQL) and comment_b='START';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); $hour_count[$i] = $row[0]; if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} if ($hour_count[$i] > 0) {$last_full_record = $i;} - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:15:00' and call_date <= '$query_date $h:29:59' and campaign_id IN($group_SQL) and status IN('DROP','XDROP');"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysql_fetch_row($rslt); - $drop_count[$i] = $row[0]; $i++; - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id IN($group_SQL);"; + $stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:30:00' and start_time <= '$query_date $h:44:59' and comment_a IN($group_SQL) and comment_b='START';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); $hour_count[$i] = $row[0]; if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} if ($hour_count[$i] > 0) {$last_full_record = $i;} - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:30:00' and call_date <= '$query_date $h:44:59' and campaign_id IN($group_SQL) and status IN('DROP','XDROP');"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysql_fetch_row($rslt); - $drop_count[$i] = $row[0]; $i++; - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id IN($group_SQL);"; + $stmt="select count(*) from live_inbound_log where start_time >= '$query_date $h:45:00' and start_time <= '$query_date $h:59:59' and comment_a IN($group_SQL) and comment_b='START';"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); $hour_count[$i] = $row[0]; if ($hour_count[$i] > $hi_hour_count) {$hi_hour_count = $hour_count[$i];} if ($hour_count[$i] > 0) {$last_full_record = $i;} - $stmt="select count(*) from vicidial_closer_log where call_date >= '$query_date $h:45:00' and call_date <= '$query_date $h:59:59' and campaign_id IN($group_SQL) and status IN('DROP','XDROP');"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $row=mysql_fetch_row($rslt); - $drop_count[$i] = $row[0]; $i++; $h++; } @@ -1054,7 +493,7 @@ else } echo "\n"; -echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS TAKEN INTO THIS IN-GROUP\n"; +echo "GRAPH IN 15 MINUTE INCREMENTS OF TOTAL CALLS TAKEN INTO THIS IVR\n"; $k=1; $Mk=0; @@ -1083,10 +522,10 @@ while ($k <= 102) } -echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n"; -#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | DROPS | TOTAL |\n"; -echo "| HOUR |$call_scale| DROPS | TOTAL |\n"; -echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n"; +echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n"; +#echo "| HOUR | GRAPH IN 15 MINUTE INCREMENTS OF TOTAL INCOMING CALLS FOR THIS GROUP | TOTAL |\n"; +echo "| HOUR |$call_scale| TOTAL |\n"; +echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n"; $ZZ = '00'; $i=0; @@ -1129,39 +568,14 @@ while ($i <= 96) $Xhour_count = ($Ghour_count * $hour_multiplier); $Yhour_count = (99 - $Xhour_count); - $Gdrop_count = $drop_count[$i]; - if ($Gdrop_count < 1) - { - $hour_count[$i] = sprintf("%-5s", $hour_count[$i]); + $hour_count[$i] = sprintf("%-5s", $hour_count[$i]); - echo "|$time|"; - $k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;} - echo "*X"; $char_counter++; - $k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;} - while ($char_counter <= 101) {echo " "; $char_counter++;} - echo "| 0 | $hour_count[$i] |\n"; - - } - else - { - $Xdrop_count = ($Gdrop_count * $hour_multiplier); - - # if ($Xdrop_count >= $Xhour_count) {$Xdrop_count = ($Xdrop_count - 1);} - - $XXhour_count = ( ($Xhour_count - $Xdrop_count) - 1 ); - - $hour_count[$i] = sprintf("%-5s", $hour_count[$i]); - $drop_count[$i] = sprintf("%-5s", $drop_count[$i]); - - echo "|$time|"; - $k=0; while ($k <= $Xdrop_count) {echo ">"; $k++; $char_counter++;} - echo "D"; $char_counter++; - $k=0; while ($k <= $XXhour_count) {echo "*"; $k++; $char_counter++;} - echo "X"; $char_counter++; - $k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;} - while ($char_counter <= 102) {echo " "; $char_counter++;} - echo "| $drop_count[$i] | $hour_count[$i] |\n"; - } + echo "|$time|"; + $k=0; while ($k <= $Xhour_count) {echo "*"; $k++; $char_counter++;} + echo "*X"; $char_counter++; + $k=0; while ($k <= $Yhour_count) {echo " "; $k++; $char_counter++;} + while ($char_counter <= 101) {echo " "; $char_counter++;} + echo "| $hour_count[$i] |\n"; } @@ -1170,7 +584,12 @@ while ($i <= 96) } -echo "+------+-------------------------------------------------------------------------------------------------------+-------+-------+\n\n"; +echo "+------+-------------------------------------------------------------------------------------------------------+-------+\n\n"; + + + + + diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 7975db3f..2092a8af 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -13750,7 +13750,7 @@ if ($ADD==3111) echo "
\n"; - echo "Click here to see a report for this inbound group

\n"; + echo "Click here to see a report for this inbound group

\n"; echo "
\n";