diff --git a/agc_2-X/trunk/agi/park_call_IVR_cf_collect.agi b/agc_2-X/trunk/agi/park_call_IVR_cf_collect.agi index d0925319..a16ba6d4 100644 --- a/agc_2-X/trunk/agi/park_call_IVR_cf_collect.agi +++ b/agc_2-X/trunk/agi/park_call_IVR_cf_collect.agi @@ -28,6 +28,8 @@ # Example Park Call AGI IVR field: # park_call_IVR_cf_collect.agi,en---please_enter_id_number---you-entered---confirm_id_number---auth-thankyou---buzz---2---outside-transfer---TEST_IN---test2 # +# NOTE: For Asterisk 1.4, use a pipe instead of a comma in the Park Call AGI IVR field +# # Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # changes: diff --git a/agc_2-X/trunk/agi/park_call_IVR_example.agi b/agc_2-X/trunk/agi/park_call_IVR_example.agi index cd9d76c1..4b8cad88 100644 --- a/agc_2-X/trunk/agi/park_call_IVR_example.agi +++ b/agc_2-X/trunk/agi/park_call_IVR_example.agi @@ -25,6 +25,8 @@ # Example Park Call AGI IVR field: # park_call_IVR_example.agi|en---please_enter_id_number---you-entered---confirm_id_number---auth-thankyou---buzz---2---outside-transfer---TEST_IN # +# NOTE: For Asterisk 1.8 and higher, use a comma instead of a pipe in the Park Call AGI IVR field +# # Copyright (C) 2010 Matt Florell LICENSE: AGPLv2 # # changes: diff --git a/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl b/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl index 6084c54a..5dc63fea 100644 --- a/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl +++ b/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl @@ -48,6 +48,7 @@ # 170209-1213 - Added vicidial_api_urls table rolling and purging to all vicidial_api_log sections # 170325-1108 - Added vicidial_drop_log table rolling # 170508-1212 - Added vicidial_rt_monitor_log table rolling +# 170809-1926 - Added rolling of user_call_log if over 1000000 records # $CALC_TEST=0; @@ -1635,6 +1636,58 @@ if (!$T) } + ##### user_call_log + $user_call_log_count_mil=0; + $stmtA = "SELECT count(*) from user_call_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $user_call_log_count = $aryA[0]; + } + $sthA->finish(); + $user_call_log_count_mil = ($user_call_log_count - 1000000); + + $stmtA = "SELECT count(*) from user_call_log_archive;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $user_call_log_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "\nProcessing user_call_log table... ($user_call_log_count|$user_call_log_archive_count)\n";} + $stmtA = "INSERT IGNORE INTO user_call_log_archive SELECT * from user_call_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows inserted into user_call_log_archive table \n";} + + $rv = $sthA->err(); + if ( (!$rv) && ($user_call_log_count_mil > 0) ) + { + $stmtA = "DELETE FROM user_call_log WHERE call_date < '$del_time' order by user_call_log_id limit $user_call_log_count_mil;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + if (!$Q) {print "$sthArows rows deleted from user_call_log table \n";} + + $stmtA = "optimize table user_call_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + + $stmtA = "optimize table user_call_log_archive;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + + ##### vicidial_log_noanswer $stmtA = "SELECT count(*) from vicidial_log_noanswer;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; diff --git a/agc_2-X/trunk/bin/AST_update.pl b/agc_2-X/trunk/bin/AST_update.pl index 9618c15d..f2e0237c 100644 --- a/agc_2-X/trunk/bin/AST_update.pl +++ b/agc_2-X/trunk/bin/AST_update.pl @@ -67,9 +67,10 @@ # 150610-1200 - Added support for AMI version 1.3 # 170329-2125 - Updated system load stats collection for Linux kernel 2.6+ # 170406-1528 - Fix for stats calculation +# 170809-2144 - Fix for Cross-Cluster phones where phone_type has "trunk" in it # -$build = '170406-1528'; +$build = '170809-2144'; # constants $SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds @@ -367,7 +368,7 @@ if ($Q < 1) {print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n";} $IAX2_client_count=0; $IAX2_client_list='|'; -$stmtA = "SELECT extension FROM phones where protocol='IAX2' and server_ip='$server_ip'"; +$stmtA = "SELECT extension FROM phones where protocol='IAX2' and server_ip='$server_ip' and phone_type NOT LIKE \"%trunk%\";"; if($DB){print STDERR "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -720,7 +721,7 @@ while($one_day_interval > 0) {print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n";} $IAX2_client_count=0; $IAX2_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol='IAX2' and server_ip='$server_ip'"; + $stmtA = "SELECT extension FROM phones where protocol='IAX2' and server_ip='$server_ip' and phone_type NOT LIKE \"%trunk%\";"; if($DB){print STDERR "|$stmtA|\n";} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; diff --git a/agc_2-X/trunk/docs/CROSS_CLUSTER_COMMUNICATION.txt b/agc_2-X/trunk/docs/CROSS_CLUSTER_COMMUNICATION.txt index 7d9dafb2..c6d9123e 100644 --- a/agc_2-X/trunk/docs/CROSS_CLUSTER_COMMUNICATION.txt +++ b/agc_2-X/trunk/docs/CROSS_CLUSTER_COMMUNICATION.txt @@ -1,4 +1,4 @@ -CROSS-CLUSTER COMMUNICATION Started: 2011-05-27 Updated: 2017-06-09 +CROSS-CLUSTER COMMUNICATION Started: 2011-05-27 Updated: 2017-08-09 -------------------------------- @@ -11,7 +11,7 @@ Below is a description of a simple cross-cluster option, which is to send lead d - This call will go through an IAX trunk between the two systems into an internal DID on the destination cluster Set up an IAX "carrier" on the originating cluster and an IAX "phone" on the destination cluster to link the two together. - (Note: the phone entry on the destination cluster must have the Outbound CallerID and Fullname fields blank) + (Note: the phone entry on the destination cluster must have the Outbound CallerID and Fullname fields blank, and the Phone Type must have "trunk" in it) The destination phone entry needs to use "trunkinbound" as it's phone and exten context - Agent on the originating cluster will do a blind-transfer or dial-with-customer to a custom dialplan number that goes to the destination cluster diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 1dac53f9..2b295ec2 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -3964,6 +3964,9 @@ CREATE TABLE vicidial_campaign_hour_counts_archive LIKE vicidial_campaign_hour_c CREATE TABLE vicidial_carrier_hour_counts_archive LIKE vicidial_carrier_hour_counts; +CREATE TABLE user_call_log_archive LIKE user_call_log; +ALTER TABLE user_call_log_archive MODIFY user_call_log_id INT(9) UNSIGNED NOT NULL; + GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; @@ -4038,4 +4041,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1510',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1511',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql index 3d963336..07c70d40 100644 --- a/agc_2-X/trunk/extras/upgrade_2.14.sql +++ b/agc_2-X/trunk/extras/upgrade_2.14.sql @@ -321,3 +321,8 @@ unique index vclhc_hour (date_hour, type) CREATE TABLE vicidial_carrier_hour_counts_archive LIKE vicidial_carrier_hour_counts; UPDATE system_settings SET db_schema_version='1510',db_schema_update_date=NOW() where db_schema_version < 1510; + +CREATE TABLE user_call_log_archive LIKE user_call_log; +ALTER TABLE user_call_log_archive MODIFY user_call_log_id INT(9) UNSIGNED NOT NULL; + +UPDATE system_settings SET db_schema_version='1511',db_schema_update_date=NOW() where db_schema_version < 1511; diff --git a/agc_2-X/trunk/www/agc/conf_exten_check.php b/agc_2-X/trunk/www/agc/conf_exten_check.php index b2b33f7f..4ebacede 100644 --- a/agc_2-X/trunk/www/agc/conf_exten_check.php +++ b/agc_2-X/trunk/www/agc/conf_exten_check.php @@ -856,7 +856,7 @@ if ($ACTION == 'refresh') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03045',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysqli_fetch_row($rslt); $live_channelCOUNT=$row[0]; - if($live_channelCOUNT == 0) + if ( ($live_channelCOUNT == 0) and (strlen($Alead_id) > 0) ) { $DEADxfer++; $stmt="UPDATE user_call_log SET xfer_hungup='XFER_3WAYHangup', xfer_hungup_datetime=NOW() where lead_id='$Alead_id' and user='$user' and call_type LIKE \"%3WAY%\" order by user_call_log_id desc limit 1;"; diff --git a/agc_2-X/trunk/www/vicidial/fcstats_detail.php b/agc_2-X/trunk/www/vicidial/fcstats_detail.php index 711e2b77..1d0fa88e 100644 --- a/agc_2-X/trunk/www/vicidial/fcstats_detail.php +++ b/agc_2-X/trunk/www/vicidial/fcstats_detail.php @@ -37,6 +37,7 @@ # 161021-1326 - Rewrote most of this report to show detail records # 170227-1718 - Fix for default HTML report format, issue #997 # 170409-1555 - Added IP List validation code +# 170809-2115 - Added phone and province to detail output, fixed ASCII display issues # $startMS = microtime(); @@ -255,7 +256,7 @@ else $webserver_id = mysqli_insert_id($link); } -$stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |$group, $query_date, $end_date, $shift, $file_download, $report_display_type|', url='$LOGfull_url', webserver='$webserver_id';"; +$stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |" . implode("-", $group) . ", $query_date, $end_date, $shift, $file_download, $report_display_type|', url='$LOGfull_url', webserver='$webserver_id';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $report_log_id = mysqli_insert_id($link); @@ -537,17 +538,6 @@ $HTML_text.="o_cal.a_tpl.yearscroll = false;\n"; $HTML_text.="// o_cal.a_tpl.weekstart = 1; // Monday week start\n"; $HTML_text.="\n"; -$HTML_text.=""; -$HTML_text.="Ingroup: \n"; - $HTML_text.="

"; $HTML_text.="Display: \n"; + +$HTML_text.=""; +$HTML_text.="Ingroup:
\n"; + $HTML_text.=""; $HTML_text.=" "._QXZ("Campaigns").":
"; @@ -614,7 +616,7 @@ if ($archives_available=="Y") } $HTML_text.=""._QXZ("Show fronter/closer summary")."

\n"; $HTML_text.="

\n"; -$HTML_text.=""._QXZ("DOWNLOAD")." | "._QXZ("MODIFY")." | "._QXZ("REPORTS")."
\n"; +$HTML_text.=""._QXZ("DOWNLOAD")." | "._QXZ("MODIFY")." | "._QXZ("REPORTS")."
\n"; $HTML_text.=""; @@ -703,7 +705,7 @@ if ($campaign_ct>0 || $user_group_ct>0 || $user_ct>0) { */ $complete_xfer_log=array(); - $xfer_log_stmt="select * from vicidial_xfer_log where campaign_id='" . mysqli_real_escape_string($link, $group) . "' and call_date>='$query_date_BEGIN' and call_date<='$query_date_END' $user_SQL"; + $xfer_log_stmt="select * from vicidial_xfer_log where campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and call_date>='$query_date_BEGIN' and call_date<='$query_date_END' $user_SQL"; if ($DB) {$HTML_text.="$xfer_log_stmt\n";} $xfer_log_rslt=mysql_to_mysqli($xfer_log_stmt, $link); while ($xfer_row=mysqli_fetch_array($xfer_log_rslt)) { @@ -712,6 +714,12 @@ if ($campaign_ct>0 || $user_group_ct>0 || $user_ct>0) { $closer=$xfer_row["closer"]; $campaign_id=""; + $lead_stmt="select * from vicidial_list where lead_id='$xfer_row[lead_id]'"; + $lead_rslt=mysql_to_mysqli($lead_stmt, $link); + $lead_row=mysqli_fetch_array($lead_rslt); + $phone_number=$lead_row["phone_number"]; + $province=$lead_row["province"]; + $fronter_log_stmt="select call_date, user_group, campaign_id from vicidial_log where lead_id='$xfer_row[lead_id]' and user='$xfer_row[user]' and call_date>='$xfer_row[call_date]'-INTERVAL 30 MINUTE and call_date<='$xfer_row[call_date]' $campaign_SQL $user_group_SQL order by call_date desc limit 1"; $fronter_log_rslt=mysql_to_mysqli($fronter_log_stmt, $link); if ($DB) {$HTML_text.="$fronter_log_stmt\n";} @@ -755,9 +763,9 @@ if ($campaign_ct>0 || $user_group_ct>0 || $user_ct>0) { } if ($campaign_id) { - array_push($temp_array, "$call_date", "$lead_id", "$user", "$user_group", "$campaign_id", "$ingroup"); + array_push($temp_array, "$call_date", "$lead_id", "$phone_number", "$province", "$user", "$user_group", "$campaign_id", "$ingroup"); - $closer_xfer_log_stmt="select uniqueid, campaign_id, call_date, status from vicidial_closer_log where campaign_id='" . mysqli_real_escape_string($link, $group) . "' and call_date>='$xfer_row[call_date]' and call_date<='$xfer_row[call_date]'+INTERVAL 1 HOUR and xfercallid='$xfercallid' and user='$closer' $user_SQL $user_group_SQL order by call_date asc limit 1"; + $closer_xfer_log_stmt="select uniqueid, campaign_id, call_date, status from vicidial_closer_log where campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and call_date>='$xfer_row[call_date]' and call_date<='$xfer_row[call_date]'+INTERVAL 1 HOUR and xfercallid='$xfercallid' and user='$closer' $user_SQL $user_group_SQL order by call_date asc limit 1"; $closer_xfer_log_rslt=mysql_to_mysqli($closer_xfer_log_stmt, $link); if ($DB) {$HTML_text.="$closer_xfer_log_stmt\n";} if (mysqli_num_rows($closer_xfer_log_rslt)>0) { @@ -792,11 +800,11 @@ if (count($complete_xfer_log)>0) {usort($complete_xfer_log, "cmp");} if (count($complete_xfer_log)>0) { - $output_header="+---------------------+-----------+----------------------+----------------------+------------+----------------------+------------+----------------------+----------------------+----------------------+---------------------+--------+\n"; + $output_header="+---------------------+-----------+----------------------+----------------------+----------------------+----------------------+------------+----------------------+------------+----------------------+----------------------+----------------------+---------------------+--------+\n"; $HTML_text.="\n"; $HTML_text.=$output_header; - $HTML_text.="| CALL DATE (INITIAL) | LEAD ID | USER | USER GROUP - FRONTER | FRONT CAMP | INBOUND/XFER GROUP | RECVD CAMP | RCVD GROUP | USER | USER GROUP - CLOSER | RECEIPT DATE | STATUS |\n"; - $CSV_text1="\"CALL DATE (INITIAL)\",\"LEAD ID\",\"USER\",\"USER GROUP - FRONTER\",\"FRONT CAMP\",\"INBOUND/XFER GROUP\",\"RECVD CAMP\",\"RCVD GROUP\",\"USER\",\"USER GROUP - CLOSER\",\"RECEIPT DATE\",\"STATUS\"\n"; + $HTML_text.="| CALL DATE (INITIAL) | LEAD ID | PHONE NUMBER | PROVINCE | USER | USER GROUP - FRONTER | FRONT CAMP | INBOUND/XFER GROUP | RECVD CAMP | RCVD GROUP | USER | USER GROUP - CLOSER | RECEIPT DATE | STATUS |\n"; + $CSV_text1="\"CALL DATE (INITIAL)\",\"LEAD ID\",\"PHONE NUMBER\",\"PROVINCE\",\"USER\",\"USER GROUP - FRONTER\",\"FRONT CAMP\",\"INBOUND/XFER GROUP\",\"RECVD CAMP\",\"RCVD GROUP\",\"USER\",\"USER GROUP - CLOSER\",\"RECEIPT DATE\",\"STATUS\"\n"; $HTML_text.=$output_header; for($i=0; $i0) { $HTML_text.="".sprintf("%-9s", $complete_xfer_log[$i][1])." | "; $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][2])." | "; $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][3])." | "; - $HTML_text.=sprintf("%-10s", $complete_xfer_log[$i][4])." | "; + $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][4])." | "; $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][5])." | "; $HTML_text.=sprintf("%-10s", $complete_xfer_log[$i][6])." | "; $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][7])." | "; - $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][8])." | "; + $HTML_text.=sprintf("%-10s", $complete_xfer_log[$i][8])." | "; $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][9])." | "; - $HTML_text.=sprintf("%-19s", $complete_xfer_log[$i][10])." | "; - $HTML_text.=sprintf("%-6s", $complete_xfer_log[$i][11])." |\n"; - for ($j=0; $j<=11; $j++) { + $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][10])." | "; + $HTML_text.=sprintf("%-20s", $complete_xfer_log[$i][11])." | "; + $HTML_text.=sprintf("%-19s", $complete_xfer_log[$i][12])." | "; + $HTML_text.=sprintf("%-6s", $complete_xfer_log[$i][13])." |\n"; + for ($j=0; $j<=13; $j++) { $CSV_text1.="\"".$complete_xfer_log[$i][$j]."\","; } $CSV_text1=preg_replace("/,$/", "", $CSV_text1); @@ -831,7 +841,7 @@ $HTML_text.=_QXZ("In-Group Fronter-Closer Stats Report",57)." $NOW_TIME\n"; $HTML_text.="\n"; $HTML_text.="---------- "._QXZ("TOTALS FOR")." $query_date_BEGIN "._QXZ("to")." $query_date_END\n"; -$sale_dispo_stmt="select distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in (SELECT campaign_id from vicidial_campaigns where closer_campaigns LIKE \"% " . mysqli_real_escape_string($link, $group) . " %\" $LOGallowed_campaignsSQL) UNION select distinct status from vicidial_statuses where sale='Y'"; +$sale_dispo_stmt="select distinct status from vicidial_campaign_statuses where sale='Y' and campaign_id in (SELECT campaign_id from vicidial_campaigns where closer_campaigns LIKE \"% " . implode(" %\" OR closer_campaigns LIKE \"% ", array_map('mysql_real_escape_string', $group)) . " %\" $LOGallowed_campaignsSQL) UNION select distinct status from vicidial_statuses where sale='Y'"; if ($DB) {$HTML_text.="$sale_dispo_stmt\n";} $sale_dispo_rslt=mysql_to_mysqli($sale_dispo_stmt, $link); $sale_dispos="'SALE'"; $sale_dispo_str="|SALE"; @@ -842,7 +852,7 @@ while ($ssrow=mysqli_fetch_row($sale_dispo_rslt)) { $sale_dispo_str.="|"; if ($DB) {$HTML_text.=_QXZ("Sale dispo string").": $sale_dispo_str\n";} -$stmt="select count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and status in ($sale_dispos);"; +$stmt="select count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and status in ($sale_dispos);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} $row=mysqli_fetch_row($rslt); @@ -879,9 +889,9 @@ $CSV_fronter_footer=""; $ASCII_text="\n"; $ASCII_text.="---------- "._QXZ("FRONTER STATS")."\n"; -$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n"; -$ASCII_text.="| "._QXZ("AGENT",24)." | "._QXZ("XFERS",6)." |"._QXZ("SALE",7)."%| "._QXZ("SALE",4)." | "._QXZ("DROP",4)." |"._QXZ("OTHER",5)." |\n"; -$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; +$ASCII_text.="| "._QXZ("AGENT",24)." | "._QXZ("XFERS",6)." | "._QXZ("SALE",7)."% | "._QXZ("SALE",7)." | "._QXZ("DROP",7)." | "._QXZ("OTHER",5)." |\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; ######## GRAPHING ######### $graph_stats=array(); @@ -893,7 +903,7 @@ $max_drops=1; $max_other=1; ########################### -$stmt="select user,count(*) from ".$vicidial_xfer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and user is not null $summary_user_xfer_log_SQL group by user;"; +$stmt="select user,count(*) from ".$vicidial_xfer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and user is not null $summary_user_xfer_log_SQL group by user;"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} @@ -939,7 +949,7 @@ while ($i < $users_to_print) {$full_name[$i] = ' ';} $DROP=0; $OTHER=0; $sales=0; - $stmt="select vc.status,count(*) from ".$vicidial_xfer_log_table." vx, ".$vicidial_closer_log_table." vc where vx.call_date >= '$query_date_BEGIN' and vx.call_date <= '$query_date_END' and vc.call_date >= '$query_date_BEGIN' and vc.call_date <= '$query_date_END' and vc.campaign_id='" . mysqli_real_escape_string($link, $group) . "' and vx.campaign_id='" . mysqli_real_escape_string($link, $group) . "' and vx.user='$userRAW[$i]' and vc.lead_id=vx.lead_id and vc.xfercallid=vx.xfercallid group by vc.status;"; + $stmt="select vc.status,count(*) from ".$vicidial_xfer_log_table." vx, ".$vicidial_closer_log_table." vc where vx.call_date >= '$query_date_BEGIN' and vx.call_date <= '$query_date_END' and vc.call_date >= '$query_date_BEGIN' and vc.call_date <= '$query_date_END' and vc.campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and vx.campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and vx.user='$userRAW[$i]' and vc.lead_id=vx.lead_id and vc.xfercallid=vx.xfercallid group by vc.status;"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} @@ -975,12 +985,12 @@ while ($i < $users_to_print) $graph_stats[$i][4]=$DROP; $graph_stats[$i][5]=$OTHER; - $DROP = sprintf("%4s", $DROP); - $OTHER = sprintf("%4s", $OTHER); - $sales = sprintf("%4s", $sales); - $Spct = sprintf("%6s", $Spct); + $DROP = sprintf("%7s", $DROP); + $OTHER = sprintf("%5s", $OTHER); + $sales = sprintf("%7s", $sales); + $Spct = sprintf("%7s", $Spct); - $ASCII_text.="| $user[$i] - $full_name[$i] | $USERcalls[$i] | $Spct%| $sales | $DROP | $OTHER |\n"; + $ASCII_text.="| ".sprintf("%-24s", substr("$user[$i] - $full_name[$i]", 0, 24))." | $USERcalls[$i] | $Spct% | $sales | $DROP | $OTHER |\n"; $CSV_fronter_lines.="\"$user[$i] - $full_name[$i]\",\"$USERcalls[$i]\",\"$Spct%\",\"$sales\",\"$DROP\",\"$OTHER\"\n"; $i++; @@ -990,16 +1000,16 @@ while ($i < $users_to_print) $totSpct = MathZDC($TOTsales, $TOTcalls)*100; $totSpct = round($totSpct, 2); $totSpct = sprintf("%01.2f", $totSpct); -$totSpct = sprintf("%6s", $totSpct); +$totSpct = sprintf("%7s", $totSpct); $TOTagents = sprintf("%6s", $i); $TOTcalls = sprintf("%6s", $TOTcalls); -$TOTsales = sprintf("%5s", $TOTsales); -$totDROP = sprintf("%5s", $totDROP); +$TOTsales = sprintf("%7s", $TOTsales); +$totDROP = sprintf("%7s", $totDROP); $totOTHER = sprintf("%5s", $totOTHER); -$stmt="select avg(queue_seconds) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "';"; +$stmt="select avg(queue_seconds) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "');"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} $row=mysqli_fetch_row($rslt); @@ -1016,11 +1026,11 @@ $AVGwait_MS = "$AVGwait_M_int:$AVGwait_S"; $AVGwait = sprintf("%6s", $AVGwait_MS); -$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n"; -$ASCII_text.="| "._QXZ("TOTAL FRONTERS",14).": $TOTagents | $TOTcalls | $totSpct%|$TOTsales |$totDROP |$totOTHER |\n"; -$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n"; -$ASCII_text.="| "._QXZ("Average time in Queue for customers",52,"r").": $AVGwait |\n"; -$ASCII_text.="+--------------------------+--------+--------+------+------+------+\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; +$ASCII_text.="| "._QXZ("TOTAL FRONTERS",14).": $TOTagents | $TOTcalls | $totSpct% | $TOTsales | $totDROP | $totOTHER |\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; +$ASCII_text.="| "._QXZ("Average time in Queue for customers",61,"r").": $AVGwait |\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; $CSV_fronter_footer.="\""._QXZ("TOTAL FRONTERS").": $TOTagents\",\"$TOTcalls\",\"$totSpct%\",\"$TOTsales\",\"$totDROP\",\"$totOTHER\"\n"; $CSV_fronter_footer.="\""._QXZ("Average time in Queue for customers").": $AVGwait\"\n\n\n"; @@ -1122,9 +1132,9 @@ $CSV_closer_footer=""; $ASCII_text.="\n"; $ASCII_text.="---------- "._QXZ("CLOSER STATS")."\n"; -$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n"; -$ASCII_text.="| "._QXZ("AGENT",24)." | "._QXZ("CALLS",6)." | "._QXZ("SALE",4)." | "._QXZ("DROP",4)." |"._QXZ("OTHER",5)." | "._QXZ("CONV",4)." %|\n"; -$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; +$ASCII_text.="| "._QXZ("AGENT",24)." | "._QXZ("CALLS",6)." | "._QXZ("SALE",8)." | "._QXZ("DROP",7)." | "._QXZ("OTHER",7)." | "._QXZ("CONV",4)." %|\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; $CSV_closer_header="\""._QXZ("CLOSER STATS")."\"\n"; $CSV_closer_header.="\""._QXZ("AGENT")."\",\""._QXZ("CALLS")."\",\""._QXZ("SALE")."\",\""._QXZ("DROP")."\",\""._QXZ("OTHER")."\",\""._QXZ("CONV")." %\"\n"; @@ -1138,7 +1148,7 @@ $max_sales2=1; $max_conv_pct=1; ########################### -$stmt="select user,count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and user is not null $summary_user_closer_log_SQL group by user;"; +$stmt="select user,count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and user is not null $summary_user_closer_log_SQL group by user;"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} @@ -1181,7 +1191,7 @@ while ($i < $users_to_print) {$full_name[$i] = ' ';} $DROP=0; $OTHER=0; $sales=0; $uTOP=0; $uBOT=0; $points=0; - $stmt="select status,count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id='" . mysqli_real_escape_string($link, $group) . "' and user='$userRAW[$i]' group by status;"; + $stmt="select status,count(*) from ".$vicidial_closer_log_table." where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id in ('" . implode("','", array_map('mysql_real_escape_string', $group)) . "') and user='$userRAW[$i]' group by status;"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$ASCII_text.="$stmt\n";} @@ -1241,11 +1251,12 @@ while ($i < $users_to_print) $graph_stats[$i][4]=$OTHER; $graph_stats[$i][5]=$Cpct; - $DROP = sprintf("%4s", $DROP); - $OTHER = sprintf("%4s", $OTHER); - $sales = sprintf("%4s", $sales); + $calls = sprintf("%6s", $USERcalls[$i]); + $DROP = sprintf("%7s", $DROP); + $OTHER = sprintf("%7s", $OTHER); + $sales = sprintf("%8s", $sales); - $ASCII_text.="| $user[$i] - $full_name[$i] | $USERcalls[$i] | $sales | $DROP | $OTHER |$Cpct%|\n"; + $ASCII_text.="| ".sprintf("%-24s", substr("$user[$i] - $full_name[$i]", 0, 24))." | $calls | $sales | $DROP | $OTHER |$Cpct%|\n"; $CSV_closer_lines.="\"$user[$i] - $full_name[$i]\",\"$USERcalls[$i]\",\"$sales\",\"$DROP\",\"$OTHER\",\"$Cpct%\"\n"; $i++; @@ -1255,7 +1266,7 @@ while ($i < $users_to_print) $totCpct = MathZDC($TOTsales, ( ($TOTcalls - 0) - $totDROP) )*100; $totCpct = round($totCpct, 2); $totCpct = sprintf("%01.2f", $totCpct); -$totCpct = sprintf("%6s", $totCpct); +$totCpct = sprintf("%5s", $totCpct); $ppc = MathZDC($totPOINTS, ( ($TOTcalls - $totOTHER) - $totDROP) ); $ppc = round($ppc, 2); @@ -1274,13 +1285,13 @@ $BOT = sprintf("%3s", $BOT); $TOTagents = sprintf("%6s", $i); $TOTcalls = sprintf("%6s", $TOTcalls); -$totDROP = sprintf("%5s", $totDROP); -$totOTHER = sprintf("%5s", $totOTHER); -$TOTsales = sprintf("%5s", $TOTsales); +$totDROP = sprintf("%7s", $totDROP); +$totOTHER = sprintf("%7s", $totOTHER); +$TOTsales = sprintf("%8s", $TOTsales); -$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n"; -$ASCII_text.="| "._QXZ("TOTAL CLOSERS",13).": $TOTagents | $TOTcalls |$TOTsales |$totDROP |$totOTHER |$totCpct%|\n"; -$ASCII_text.="+--------------------------+--------+------+------+------+-------+\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; +$ASCII_text.="| "._QXZ("TOTAL CLOSERS",13).": $TOTagents | $TOTcalls | $TOTsales | $totDROP | $totOTHER | $totCpct%|\n"; +$ASCII_text.="+--------------------------+--------+----------+---------+---------+-------+\n"; $CSV_closer_footer.="\""._QXZ("TOTAL CLOSERS").": $TOTagents\",\"$TOTcalls\",\"$totA1\",\"$totDROP\",\"$totOTHER\",\"$TOTsales\",\"$totCpct%\"\n";