From 53ad49115fdc42ffbfccec39e8de4c49f8197bcc Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 30 Dec 2015 02:19:42 +0000 Subject: [PATCH] Added daily breakdown option to the Agent Performance Detail report Added archive search option to several reports git-svn-id: svn://192.168.202.10@2446 3d104415-ff17-0410-8863-d5cf3c621b8a --- www/vicidial/AST_LISTS_campaign_stats.php | 74 +++-- www/vicidial/AST_agent_days_detail.php | 37 ++- www/vicidial/AST_agent_days_time.php | 39 ++- www/vicidial/AST_agent_performance_detail.php | 292 +++++++++++++++--- www/vicidial/AST_agent_time_sheet.php | 43 ++- .../AST_campaign_status_list_report.php | 40 ++- www/vicidial/AST_email_log_report.php | 60 +++- .../AST_performance_comparison_report.php | 43 ++- www/vicidial/AST_team_performance_detail.php | 50 ++- www/vicidial/AST_usergroup_login_report.php | 37 ++- .../called_counts_multilist_report.php | 57 +++- www/vicidial/user_stats.php | 87 ++++-- 12 files changed, 718 insertions(+), 141 deletions(-) diff --git a/www/vicidial/AST_LISTS_campaign_stats.php b/www/vicidial/AST_LISTS_campaign_stats.php index 456fa583..b78af1be 100644 --- a/www/vicidial/AST_LISTS_campaign_stats.php +++ b/www/vicidial/AST_LISTS_campaign_stats.php @@ -23,6 +23,7 @@ # 141114-0828 - Finalized adding QXZ translation to all admin files # 141230-1444 - Added code for on-the-fly language translations display # 150516-1302 - Fixed Javascript element problem, Issue #857 +# 151229-2009 - Added archive search option # $startMS = microtime(); @@ -47,6 +48,8 @@ if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} $report_name = 'Lists Campaign Statuses Report'; $db_source = 'M'; @@ -72,6 +75,22 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$table_name="vicidial_list"; +$archive_table_name=use_archive_table($table_name); +if ($archive_table_name!=$table_name) {$archives_available="Y";} + +if ($search_archived_data) + { + $vicidial_list_table=use_archive_table("vicidial_list"); + } +else + { + $vicidial_list_table="vicidial_list"; + } +############# + if ($non_latin < 1) { $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); @@ -318,7 +337,7 @@ while ($i < $statcats_to_print) } $category_statuses=substr($category_statuses, 0, -1); - $category_stmt="select count(*) from vicidial_list where status in ($category_statuses) and list_id IN($lists_id_str)"; + $category_stmt="select count(*) from ".$vicidial_list_table." where status in ($category_statuses) and list_id IN($lists_id_str)"; if ($DB) {echo "$category_stmt\n";} $category_rslt=mysql_to_mysqli($category_stmt, $link); $category_row=mysqli_fetch_row($category_rslt); @@ -434,8 +453,13 @@ $MAIN.=_QXZ("Display as").":
"; $MAIN.="  "; -$MAIN.="

\n"; -$MAIN.="\n"; + +if ($archives_available=="Y") + { + $MAIN.="

"._QXZ("Search archived data")."\n"; + } + +$MAIN.="

\n"; $MAIN.="         "; $MAIN.=""; if (strlen($group[0]) > 1) @@ -473,7 +497,7 @@ else $TOTALleads = 0; $OUToutput .= "\n"; - $OUToutput .= "---------- "._QXZ("LIST ID SUMMARY",19)." "._QXZ("DOWNLOAD")."\n"; + $OUToutput .= "---------- "._QXZ("LIST ID SUMMARY",19)." "._QXZ("DOWNLOAD")."\n"; $OUToutput .= "+------------------------------------------+------------+----------+\n"; $OUToutput .= "| "._QXZ("LIST",40)." | "._QXZ("LEADS",10)." | "._QXZ("ACTIVE",8)." |\n"; $OUToutput .= "+------------------------------------------+------------+----------+\n"; @@ -497,7 +521,7 @@ else } $lists_id_str=substr($lists_id_str,0,-1); - $stmt="select count(*),list_id from vicidial_list where list_id IN($lists_id_str) group by list_id;"; + $stmt="select count(*),list_id from ".$vicidial_list_table." where list_id IN($lists_id_str) group by list_id;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $listids_to_print = mysqli_num_rows($rslt); @@ -595,7 +619,7 @@ else $GRAPH.=""._QXZ("CALLS")."\n"; $GRAPH.="\n"; - $stmt="select count(*) from vicidial_list where status IN($human_answered_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($human_answered_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $HA_results = mysqli_num_rows($rslt); @@ -607,7 +631,7 @@ else if ($HA_count>$max_calls) {$max_calls=$HA_count;} $HA_percent = ( MathZDC($HA_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($sale_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($sale_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $SALE_results = mysqli_num_rows($rslt); @@ -619,7 +643,7 @@ else if ($SALE_count>$max_calls) {$max_calls=$SALE_count;} $SALE_percent = ( MathZDC($SALE_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($dnc_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($dnc_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $DNC_results = mysqli_num_rows($rslt); @@ -631,7 +655,7 @@ else if ($DNC_count>$max_calls) {$max_calls=$DNC_count;} $DNC_percent = ( MathZDC($DNC_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($customer_contact_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($customer_contact_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $CC_results = mysqli_num_rows($rslt); @@ -643,7 +667,7 @@ else if ($C_count>$max_calls) {$max_calls=$CC_count;} $CC_percent = ( MathZDC($CC_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($not_interested_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($not_interested_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $NI_results = mysqli_num_rows($rslt); @@ -655,7 +679,7 @@ else if ($NI_count>$max_calls) {$max_calls=$NI_count;} $NI_percent = ( MathZDC($NI_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($unworkable_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($unworkable_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $UW_results = mysqli_num_rows($rslt); @@ -667,7 +691,7 @@ else if ($UW_count>$max_calls) {$max_calls=$UW_count;} $UW_percent = ( MathZDC($UW_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($scheduled_callback_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($scheduled_callback_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $SC_results = mysqli_num_rows($rslt); @@ -679,7 +703,7 @@ else if ($SC_count>$max_calls) {$max_calls=$SC_count;} $SC_percent = ( MathZDC($SC_count, $TOTALleads) * 100); } - $stmt="select count(*) from vicidial_list where status IN($completed_statuses) and list_id IN($list_id_SQL);"; + $stmt="select count(*) from ".$vicidial_list_table." where status IN($completed_statuses) and list_id IN($list_id_SQL);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $COMP_results = mysqli_num_rows($rslt); @@ -712,7 +736,7 @@ else $OUToutput .= "\n"; $OUToutput .= "\n"; - $OUToutput .= "---------- "._QXZ("STATUS FLAGS SUMMARY:",24)." ("._QXZ("and % of leads in selected lists").") "._QXZ("DOWNLOAD")."\n"; + $OUToutput .= "---------- "._QXZ("STATUS FLAGS SUMMARY:",24)." ("._QXZ("and % of leads in selected lists").") "._QXZ("DOWNLOAD")."\n"; $OUToutput .= "+------------------+------------+----------+\n"; $OUToutput .= "| "._QXZ("Human Answer",16)." | $HA_count | $HA_percent% |\n"; $OUToutput .= "| "._QXZ("Sale",16)." | $SALE_count | $SALE_percent% |\n"; @@ -778,7 +802,7 @@ else ######### STATUS CATEGORY STATS $OUToutput .= "\n"; - $OUToutput .= "---------- "._QXZ("CUSTOM STATUS CATEGORY STATS",32)." "._QXZ("DOWNLOAD")."\n"; + $OUToutput .= "---------- "._QXZ("CUSTOM STATUS CATEGORY STATS",32)." "._QXZ("DOWNLOAD")."\n"; $OUToutput .= "+----------------------+------------+--------------------------------+\n"; $OUToutput .= "| "._QXZ("CATEGORY",20)." | "._QXZ("CALLS",10)." | "._QXZ("DESCRIPTION",30)." |\n"; $OUToutput .= "+----------------------+------------+--------------------------------+\n"; @@ -844,7 +868,7 @@ else $TOTALleads = 0; $OUToutput .= "\n"; - $OUToutput .= "---------- "._QXZ("PER LIST DETAIL STATS",25)." "._QXZ("DOWNLOAD")."\n"; + $OUToutput .= "---------- "._QXZ("PER LIST DETAIL STATS",25)." "._QXZ("DOWNLOAD")."\n"; $OUToutput .= "\n"; $CSV_text4.="\""._QXZ("PER LIST DETAIL STATS")."\"\n\n"; @@ -894,7 +918,7 @@ else $COMP_count=0; $COMP_percent=0; - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($human_answered_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($human_answered_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $HA_results = mysqli_num_rows($rslt); @@ -905,7 +929,7 @@ else $HA_percent = ( MathZDC($HA_count, $LISTIDcalls[$i]) * 100); } if ($HA_count>$max_flags) {$max_flags=$HA_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($sale_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($sale_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $SALE_results = mysqli_num_rows($rslt); @@ -916,7 +940,7 @@ else $SALE_percent = ( MathZDC($SALE_count, $LISTIDcalls[$i]) * 100); } if ($SALE_count>$max_flags) {$max_flags=$SALE_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($dnc_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($dnc_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $DNC_results = mysqli_num_rows($rslt); @@ -927,7 +951,7 @@ else $DNC_percent = ( MathZDC($DNC_count, $LISTIDcalls[$i]) * 100); } if ($DNC_count>$max_flags) {$max_flags=$DNC_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($customer_contact_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($customer_contact_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $CC_results = mysqli_num_rows($rslt); @@ -938,7 +962,7 @@ else $CC_percent = ( MathZDC($CC_count, $LISTIDcalls[$i]) * 100); } if ($CC_count>$max_flags) {$max_flags=$CC_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($not_interested_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($not_interested_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $NI_results = mysqli_num_rows($rslt); @@ -949,7 +973,7 @@ else $NI_percent = ( MathZDC($NI_count, $LISTIDcalls[$i]) * 100); } if ($NI_count>$max_flags) {$max_flags=$NI_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($unworkable_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($unworkable_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $UW_results = mysqli_num_rows($rslt); @@ -960,7 +984,7 @@ else $UW_percent = ( MathZDC($UW_count, $LISTIDcalls[$i]) * 100); } if ($UW_count>$max_flags) {$max_flags=$UW_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($scheduled_callback_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($scheduled_callback_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $SC_results = mysqli_num_rows($rslt); @@ -971,7 +995,7 @@ else $SC_percent = ( MathZDC($SC_count, $LISTIDcalls[$i]) * 100); } if ($SC_count>$max_flags) {$max_flags=$SC_count;} - $stmt="select count(*) from vicidial_list where list_id='$LISTIDlists[$i]' and status IN($completed_statuses);"; + $stmt="select count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' and status IN($completed_statuses);"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $COMP_results = mysqli_num_rows($rslt); @@ -1034,7 +1058,7 @@ else $CSV_text4.="\""._QXZ("Completed").":\",\"$COMP_count\",\"$COMP_percent%\"\n\n"; $CSV_text4.="\""._QXZ("STATUS BREAKDOWN").":\",\"\",\""._QXZ("COUNT")."\"\n"; - $stmt="select status,count(*) from vicidial_list where list_id='$LISTIDlists[$i]' group by status order by status;"; + $stmt="select status,count(*) from ".$vicidial_list_table." where list_id='$LISTIDlists[$i]' group by status order by status;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $liststatussum_to_print = mysqli_num_rows($rslt); diff --git a/www/vicidial/AST_agent_days_detail.php b/www/vicidial/AST_agent_days_detail.php index 456a0f06..42a5f94e 100644 --- a/www/vicidial/AST_agent_days_detail.php +++ b/www/vicidial/AST_agent_days_detail.php @@ -26,6 +26,7 @@ # 141114-0021 - Finalized adding QXZ translation to all admin files # 141230-1526 - Added code for on-the-fly language translations display # 150516-1307 - Fixed Javascript element problem, Issue #857 +# 151227-1718 - Added option to search archive records instead of main # $startMS = microtime(); @@ -58,6 +59,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} if (strlen($shift)<2) {$shift='ALL';} @@ -85,6 +88,26 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_agent_log"); +for ($t=0; $t0) #$customer_interactive_statuses = '|NI|DNC|CALLBK|AP|SALE|COMP|HAP1|HAP2|HBED|DIED|'; #$customer_interactive_statuses = '|NI|DNC|CALLBK|XFER|C2|B7|B8|C1|'; -$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS"; +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS&search_archived_data=$search_archived_data"; if ($file_download < 1) { @@ -440,7 +463,7 @@ else $date_namesARY[0]=''; $k=0; - $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date,status order by date,status desc limit 500000;"; + $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date,status order by date,status desc limit 500000;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $rows_to_print = mysqli_num_rows($rslt); @@ -909,8 +932,14 @@ echo "\n"; echo "\n"; echo "\n"; echo "\n"; -echo "

\n"; -echo "\n"; +echo "\n"; + +if ($archives_available=="Y") + { + echo ""._QXZ("Search archived data")."\n"; + } + +echo "

\n"; echo "         "; echo ""; if (strlen($user) > 1) diff --git a/www/vicidial/AST_agent_days_time.php b/www/vicidial/AST_agent_days_time.php index 19c88b36..9027b30c 100644 --- a/www/vicidial/AST_agent_days_time.php +++ b/www/vicidial/AST_agent_days_time.php @@ -6,6 +6,7 @@ # CHANGES # # 150114-2158 - First build based on AST_agent_days_detail.php +# 151227-1718 - Added option to search archive records instead of main # $startMS = microtime(); @@ -38,6 +39,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} if (strlen($shift)<2) {$shift='ALL';} @@ -65,6 +68,26 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_agent_log"); +for ($t=0; $t0) #$customer_interactive_statuses = '|NI|DNC|CALLBK|AP|SALE|COMP|HAP1|HAP2|HBED|DIED|'; #$customer_interactive_statuses = '|NI|DNC|CALLBK|XFER|C2|B7|B8|C1|'; -$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS"; +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date&shift=$shift&DB=$DB&user=$user$groupQS&search_archived_data=$search_archived_data"; if ($file_download < 1) { @@ -420,7 +443,7 @@ else $date_namesARY[0]=''; $k=0; - $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls from vicidial_users,vicidial_agent_log where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date order by date desc limit 500000;"; + $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date order by date desc limit 500000;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $rows_to_print = mysqli_num_rows($rslt); @@ -456,7 +479,7 @@ else $VALstart_time = "$date[$i] 00:00:00"; $VALstop_time = "$date[$i] 23:59:59"; - $stmt="select event_time,lead_id,campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,status,sub_status,user_group from vicidial_agent_log where user='$user' and event_time >= '$VALstart_time' and event_time <= '$VALstop_time' and ( (pause_sec > 0) or (wait_sec > 0) or (talk_sec > 0) or (dispo_sec > 0) ) order by event_time desc limit 10000;"; + $stmt="select event_time,lead_id,campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,status,sub_status,user_group from ".$vicidial_agent_log_table." where user='$user' and event_time >= '$VALstart_time' and event_time <= '$VALstop_time' and ( (pause_sec > 0) or (wait_sec > 0) or (talk_sec > 0) or (dispo_sec > 0) ) order by event_time desc limit 10000;"; if ($DB) {$MAIN.="agent activity|$stmt|";} $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -646,8 +669,14 @@ echo "\n"; echo "\n"; echo "\n"; echo "\n"; -echo "

\n"; -echo "\n"; +echo "\n"; + +if ($archives_available=="Y") + { + echo ""._QXZ("Search archived data")."\n"; + } + +echo "

\n"; echo "         "; echo ""; if (strlen($user) > 1) diff --git a/www/vicidial/AST_agent_performance_detail.php b/www/vicidial/AST_agent_performance_detail.php index cc7364c7..b0e60e42 100644 --- a/www/vicidial/AST_agent_performance_detail.php +++ b/www/vicidial/AST_agent_performance_detail.php @@ -52,6 +52,7 @@ # 150728-1230 - Fix for non-latin display issue #858 # 150909-0728 - Fix for time display issue for downloads, issue #886 # 151112-1338 - Added ability to search archive logs and show defunct users +# 151229-2015 - Added feature to break down agent stats by day # $startMS = microtime(); @@ -90,6 +91,8 @@ if (isset($_GET["show_percentages"])) {$show_percentages=$_GET["show_percentag elseif (isset($_POST["show_percentages"])) {$show_percentages=$_POST["show_percentages"];} if (isset($_GET["time_in_sec"])) {$time_in_sec=$_GET["time_in_sec"];} elseif (isset($_POST["time_in_sec"])) {$time_in_sec=$_POST["time_in_sec"];} +if (isset($_GET["breakdown_by_date"])) {$breakdown_by_date=$_GET["breakdown_by_date"];} + elseif (isset($_POST["breakdown_by_date"])) {$breakdown_by_date=$_POST["breakdown_by_date"];} if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} if (isset($_GET["show_defunct_users"])) {$show_defunct_users=$_GET["show_defunct_users"];} @@ -452,7 +455,7 @@ else if ($DB) {$HTML_text.="$user_group_string|$user_group_ct|$user_groupQS|$i
";} -$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date$groupQS$user_groupQS&shift=$shift&DB=$DB&show_percentages=$show_percentages&time_in_sec=$time_in_sec&search_archived_data=$search_archived_data&show_defunct_users=$show_defunct_users"; +$LINKbase = "$PHP_SELF?query_date=$query_date&end_date=$end_date$groupQS$user_groupQS&shift=$shift&DB=$DB&show_percentages=$show_percentages&time_in_sec=$time_in_sec&search_archived_data=$search_archived_data&show_defunct_users=$show_defunct_users&breakdown_by_date=$breakdown_by_date"; $NWB = "   \"HELP\""; @@ -566,9 +569,10 @@ $HTML_text.="\n"; $HTML_text.="\n"; $HTML_text.="\n"; $HTML_text.="\n"; -$HTML_text.="

\n"; +$HTML_text.="
\n"; $HTML_text.=""._QXZ("Show %s")."
\n"; $HTML_text.=""._QXZ("Time in seconds")."
\n"; +$HTML_text.=""._QXZ("Show date breakdown")."
\n"; $HTML_text.=""._QXZ("Search archived data")."
\n"; $HTML_text.=""._QXZ("Show defunct users")."\n"; $HTML_text.=""; @@ -589,7 +593,6 @@ $HTML_text.="\n\n"; $HTML_text.="
\n";
 
-
 if (!$group)
 	{
 	$HTML_text.="\n";
@@ -628,20 +631,36 @@ $HTML_text.="---------- "._QXZ("AGENTS Details")." -------------\n\n";
 
 
 
-
-
 $statuses='-';
 $statusesTXT='';
 $statusesHEAD='';
 
+## Breakdown by date text
+if ($breakdown_by_date) 
+	{
+	$BBD_header="------------+";
+	$BBD_text=" | "._QXZ("CALL DATE",10); 
+	$BBD_filler=" | ".sprintf("%-10s", " "); 
+	$BBD_csv=_QXZ("CALL DATE",10)."\",\""; 
+	$BBD_csv_filler="\",\""; 
+	}
+else 
+	{
+	$BBD_header="";
+	$BBD_text="";
+	$BBD_filler=""; 
+	$BBD_csv="";
+	$BBD_csv_filler="";
+	}
+
+
 $CSV_header="\""._QXZ("Agent Performance Detail",47)." $NOW_TIME\"\n";
 $CSV_header.="\""._QXZ("Time range").": $query_date_BEGIN "._QXZ("to")." $query_date_END\"\n\n";
 $CSV_header.="\"---------- "._QXZ("AGENTS Details")." -------------\"\n";
-
 if ($show_percentages) {
-	$CSV_header.='"'._QXZ("USER NAME").'","'._QXZ("ID").'","'._QXZ("CURRENT USER GROUP").'","'._QXZ("MOST RECENT USER GROUP").'","'._QXZ("CALLS").'","'._QXZ("TIME").'","'._QXZ("PAUSE").'","'._QXZ("PAUSE").' %","'._QXZ("PAUSAVG").'","'._QXZ("WAIT").'","'._QXZ("WAIT").' %","'._QXZ("WAITAVG").'","'._QXZ("TALK").'","'._QXZ("TALK").' %","'._QXZ("TALKAVG").'","'._QXZ("DISPO").'","'._QXZ("DISPO").' %","'._QXZ("DISPAVG").'","'._QXZ("DEAD").'","'._QXZ("DEAD").' %","'._QXZ("DEADAVG").'","'._QXZ("CUSTOMER").'","'._QXZ("CUSTOMER").' %","'._QXZ("CUSTAVG").'"';
+	$CSV_header.='"'._QXZ("USER NAME").'","'._QXZ("ID").'","'._QXZ("CURRENT USER GROUP").'","'._QXZ("MOST RECENT USER GROUP").'","'.$BBD_csv._QXZ("CALLS").'","'._QXZ("TIME").'","'._QXZ("PAUSE").'","'._QXZ("PAUSE").' %","'._QXZ("PAUSAVG").'","'._QXZ("WAIT").'","'._QXZ("WAIT").' %","'._QXZ("WAITAVG").'","'._QXZ("TALK").'","'._QXZ("TALK").' %","'._QXZ("TALKAVG").'","'._QXZ("DISPO").'","'._QXZ("DISPO").' %","'._QXZ("DISPAVG").'","'._QXZ("DEAD").'","'._QXZ("DEAD").' %","'._QXZ("DEADAVG").'","'._QXZ("CUSTOMER").'","'._QXZ("CUSTOMER").' %","'._QXZ("CUSTAVG").'"';
 } else {
-	$CSV_header.='"'._QXZ("USER NAME").'","'._QXZ("ID").'","'._QXZ("CURRENT USER GROUP").'","'._QXZ("MOST RECENT USER GROUP").'","'._QXZ("CALLS").'","'._QXZ("TIME").'","'._QXZ("PAUSE").'","'._QXZ("PAUSAVG").'","'._QXZ("WAIT").'","'._QXZ("WAITAVG").'","'._QXZ("TALK").'","'._QXZ("TALKAVG").'","'._QXZ("DISPO").'","'._QXZ("DISPAVG").'","'._QXZ("DEAD").'","'._QXZ("DEADAVG").'","'._QXZ("CUSTOMER").'","'._QXZ("CUSTAVG").'"';
+	$CSV_header.='"'._QXZ("USER NAME").'","'._QXZ("ID").'","'._QXZ("CURRENT USER GROUP").'","'._QXZ("MOST RECENT USER GROUP").'","'.$BBD_csv._QXZ("CALLS").'","'._QXZ("TIME").'","'._QXZ("PAUSE").'","'._QXZ("PAUSAVG").'","'._QXZ("WAIT").'","'._QXZ("WAITAVG").'","'._QXZ("TALK").'","'._QXZ("TALKAVG").'","'._QXZ("DISPO").'","'._QXZ("DISPAVG").'","'._QXZ("DEAD").'","'._QXZ("DEADAVG").'","'._QXZ("CUSTOMER").'","'._QXZ("CUSTAVG").'"';
 }
 
 
@@ -769,14 +788,14 @@ while ($stat_row=mysqli_fetch_row($stat_rslt)) {
 
 	if ($show_defunct_users=="checked")
 		{
-		$stmt="SELECT count(*) as calls,sum(talk_sec) as talk,'' as full_name,user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), '' as user_group from ".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and status='$current_status' $group_SQL $user_agent_log_SQL $user_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;";
+		$stmt="SELECT count(*) as calls,sum(talk_sec) as talk,'' as full_name,user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), '' as user_group from ".$agent_log_table.",date(event_time) as call_date where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and status='$current_status' $group_SQL $user_agent_log_SQL $user_SQL group by user,full_name,user_group,status,call_date order by full_name,user,status desc limit 500000;";
 		}
 	else
 		{
-		$stmt="SELECT count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), vicidial_users.user_group from vicidial_users,".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$agent_log_table.".user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and status='$current_status' $group_SQL $user_group_SQL $user_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;";
+		$stmt="SELECT count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), vicidial_users.user_group,date(event_time) as call_date from vicidial_users,".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$agent_log_table.".user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and status='$current_status' $group_SQL $user_group_SQL $user_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;";
 		}
 	$rslt=mysql_to_mysqli($stmt, $link);
-	if ($DB) {$HTML_text.="$stmt\n";}
+	if ($DB) {$HTML_text.="$stmt\n";} 
 	$rows_to_print+=mysqli_num_rows($rslt);
 
 	$stat_rows_to_print = mysqli_num_rows($rslt);
@@ -821,6 +840,7 @@ while ($stat_row=mysqli_fetch_row($stat_rslt)) {
 		$status[$q] =		strtoupper($row[7]);
 		$dead_sec[$q] =		$row[8];
 		$user_group[$q] =	$user_group_val;
+		$call_date[$q] =		$row[10];
 		$customer_sec[$q] =	($talk_sec[$q] - $dead_sec[$q]);
 
 		if (strlen($status[$q])>0) {$userTOTcalls[$row[3]]+=$row[0];}
@@ -867,15 +887,14 @@ $CSV_header.="\n";
 $CSV_lines='';
 
 $ASCII_text.=_QXZ("CALL STATS BREAKDOWN").": ("._QXZ("Statistics related to handling of calls only").")     ["._QXZ("DOWNLOAD")."]\n";
-
 if ($show_percentages) {
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
-	$ASCII_text.="| "._QXZ("USER NAME",15)." | "._QXZ("ID",8)." | "._QXZ("CURRENT USER GROUP",20)." | "._QXZ("MOST RECENT USER GRP",20)." | "._QXZ("CALLS",6)." | "._QXZ("TIME",9)." | "._QXZ("PAUSE",8)." | "._QXZ("PAUSE",8)." % |"._QXZ("PAUSAVG",7)." | "._QXZ("WAIT",8)." | "._QXZ("WAIT",8)." % |"._QXZ("WAITAVG",7)." | "._QXZ("TALK",8)." | "._QXZ("TALK",8)." % |"._QXZ("TALKAVG",7)." | "._QXZ("DISPO",8)." | "._QXZ("DISPO",8)." % |"._QXZ("DISPAVG",7)." | "._QXZ("DEAD",7)." | "._QXZ("DEAD",8)." % |"._QXZ("DEADAVG",7)." | "._QXZ("CUSTOMER",8)." | "._QXZ("CUSTOMER",8)." % |"._QXZ("CUSTAVG",7)." |$statusesHTML\n";
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
+	$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
+	$ASCII_text.="| "._QXZ("USER NAME",15)." | "._QXZ("ID",8)." | "._QXZ("CURRENT USER GROUP",20)." | "._QXZ("MOST RECENT USER GRP",20).$BBD_text." | "._QXZ("CALLS",6)." | "._QXZ("TIME",9)." | "._QXZ("PAUSE",8)." | "._QXZ("PAUSE",8)." % |"._QXZ("PAUSAVG",7)." | "._QXZ("WAIT",8)." | "._QXZ("WAIT",8)." % |"._QXZ("WAITAVG",7)." | "._QXZ("TALK",8)." | "._QXZ("TALK",8)." % |"._QXZ("TALKAVG",7)." | "._QXZ("DISPO",8)." | "._QXZ("DISPO",8)." % |"._QXZ("DISPAVG",7)." | "._QXZ("DEAD",7)." | "._QXZ("DEAD",8)." % |"._QXZ("DEADAVG",7)." | "._QXZ("CUSTOMER",8)." | "._QXZ("CUSTOMER",8)." % |"._QXZ("CUSTAVG",7)." |$statusesHTML\n";
+	$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
 } else {
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
-	$ASCII_text.="| "._QXZ("USER NAME",15)." | "._QXZ("ID",8)." | "._QXZ("CURRENT USER GROUP",20)." | "._QXZ("MOST RECENT USER GRP",20)." | "._QXZ("CALLS",6)." | "._QXZ("TIME",9)." | "._QXZ("PAUSE",8)." |"._QXZ("PAUSAVG",7)." | "._QXZ("WAIT",8)." |"._QXZ("WAITAVG",7)." | "._QXZ("TALK",8)." |"._QXZ("TALKAVG",7)." | "._QXZ("DISPO",8)." |"._QXZ("DISPAVG",7)." | "._QXZ("DEAD",8)." |"._QXZ("DEADAVG",7)." | "._QXZ("CUSTOMER",8)." |"._QXZ("CUSTAVG",7)." |$statusesHTML\n";
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+	$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+	$ASCII_text.="| "._QXZ("USER NAME",15)." | "._QXZ("ID",8)." | "._QXZ("CURRENT USER GROUP",20)." | "._QXZ("MOST RECENT USER GRP",20).$BBD_text." | "._QXZ("CALLS",6)." | "._QXZ("TIME",9)." | "._QXZ("PAUSE",8)." |"._QXZ("PAUSAVG",7)." | "._QXZ("WAIT",8)." |"._QXZ("WAITAVG",7)." | "._QXZ("TALK",8)." |"._QXZ("TALKAVG",7)." | "._QXZ("DISPO",8)." |"._QXZ("DISPAVG",7)." | "._QXZ("DEAD",8)." |"._QXZ("DEADAVG",7)." | "._QXZ("CUSTOMER",8)." |"._QXZ("CUSTAVG",7)." |$statusesHTML\n";
+	$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
 }
 
 
@@ -885,14 +904,206 @@ while ($m < $k)
 	{
 	$Suser=$usersARY[$m];
 
+	if ($breakdown_by_date) 
+		{
+		$Toutput_sub="";
+		$CSV_lines_sub="";
+
+		$SstatusesHTML='';
+		$CSVstatuses='';
+
+		$Stalk_sec_pct=0;
+		$Spause_sec_pct=0;
+		$Swait_sec_pct=0;
+		$Sdispo_sec_pct=0;
+		$Sdead_sec_pct=0;
+
+		$date_stmt="select distinct date(event_time) as call_date from ".$agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and user='$Suser' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_agent_log_SQL $user_agent_log_SQL order by call_date asc limit 500000;";
+		if ($DB) {$ASCII_text.=$date_stmt."\n";}
+		$date_rslt=mysql_to_mysqli($date_stmt, $link);
+		while($date_row=mysqli_fetch_row($date_rslt)) 
+			{
+			$call_dateX=$date_row[0];
+
+			$cd_stmt="SELECT count(*) as calls,sum(talk_sec) as talk,'' as full_name,user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), '' as user_group from ".$agent_log_table." where date(event_time)='$call_dateX' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and user='$Suser' $group_SQL $user_agent_log_SQL $user_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;";
+			$cd_rslt=mysql_to_mysqli($cd_stmt, $link); 
+			if ($DB) {$ASCII_text.=$cd_stmt."\n";}
+
+			$x=0;
+			while ($cd_row=mysqli_fetch_row($cd_rslt)) 
+				{
+				$calls_sub[$x] =		$cd_row[0];
+				$talk_sec_sub[$x] =		$cd_row[1];
+				$user_sub[$x] =			$cd_row[3];
+				$pause_sec_sub[$x] =	$cd_row[4];
+				$wait_sec_sub[$x] =		$cd_row[5];
+				$dispo_sec_sub[$x] =	$cd_row[6];
+				$status_sub[$x] =		strtoupper($cd_row[7]);
+				$dead_sec_sub[$x] =		$cd_row[8];
+				$customer_sec_sub[$x] =	($talk_sec_sub[$x] - $dead_sec_sub[$x]);
+				$x++;
+				}
+			
+
+			$Stime=0;
+			$Scalls=0;
+			$Stalk_sec=0;
+			$Spause_sec=0;
+			$Swait_sec=0;
+			$Sdispo_sec=0;
+			$Sdead_sec=0;
+			$Scustomer_sec=0;
+			$o=0;
+			$SstatusesHTML='';
+			$CSVstatuses='';
+			while ($o < $j)
+				{
+				$Sstatus=$statusesARY[$o];
+				$Scall_date=$call_date[$o];
+				$SstatusTXT='';
+
+				$i=0; $status_found=0;
+				while ($i < $x)
+					{
+					if ($Sstatus=="$status_sub[$i]")
+						{
+						$Scalls =		($Scalls + $calls_sub[$i]);
+						$Stalk_sec =	($Stalk_sec + $talk_sec_sub[$i]);
+						$Spause_sec =	($Spause_sec + $pause_sec_sub[$i]);
+						$Swait_sec =	($Swait_sec + $wait_sec_sub[$i]);
+						$Sdispo_sec =	($Sdispo_sec + $dispo_sec_sub[$i]);
+						$Sdead_sec =	($Sdead_sec + $dead_sec_sub[$i]);
+						$Scustomer_sec =	($Scustomer_sec + $customer_sec_sub[$i]);
+						$SstatusTXT = sprintf("%8s", $calls_sub[$i]);
+						$SstatusesHTML .= " $SstatusTXT |";
+
+						$CSVstatuses.=",\"$calls_sub[$i]\"";
+
+						if ($show_percentages) 
+							{
+							$SstatusTXT_pct=sprintf("%8s", sprintf("%0.2f", MathZDC(100*$calls[$i], $userTOTcalls[$Suser])));
+							$SstatusesHTML .= " $SstatusTXT_pct % |";
+							$CSVstatuses.=",\"$SstatusTXT_pct %\"";
+							}
+
+						$status_found++;
+						}
+					$i++;
+					}
+				if ($status_found < 1)
+					{
+					$SstatusesHTML .= "        0 |";
+					$CSVstatuses.=",\"0\"";
+					if ($show_percentages) 
+						{
+						$SstatusesHTML .= "     0.00 % |";
+						$CSVstatuses.=",\"0.00 %\"";
+						}
+					}
+				### END loop through each stat line ###
+				$o++;
+				}
+
+			$Stime = ($Stalk_sec + $Spause_sec + $Swait_sec + $Sdispo_sec);
+			
+			$Stalk_avg = MathZDC($Stalk_sec, $Scalls);
+			$Spause_avg = MathZDC($Spause_sec, $Scalls);
+			$Swait_avg = MathZDC($Swait_sec, $Scalls);
+			$Sdispo_avg = MathZDC($Sdispo_sec, $Scalls);
+			$Sdead_avg = MathZDC($Sdead_sec, $Scalls);
+			$Scustomer_avg = MathZDC($Scustomer_sec, $Scalls);
+
+			$RAWuser = $Suser;
+			$RAWcalls = $Scalls;
+			$Scalls =	sprintf("%6s", $Scalls);
+			$Sfull_nameRAW = $Sfull_name;
+			$SuserRAW = $Suser;
+
+			$pfUSERtime_MS =			sec_convert($Stime,$TIME_H_agentperfdetail); 
+			$pfUSERtotTALK_MS =			sec_convert($Stalk_sec,$TIME_H_agentperfdetail); 
+			$pfUSERtotTALK_MS_pct =		sprintf("%0.2f", MathZDC(100*$Stalk_sec, $Stime));
+			$pfUSERavgTALK_MS =			sec_convert($Stalk_avg,$TIME_M_agentperfdetail); 
+			$USERtotPAUSE_MS =			sec_convert($Spause_sec,$TIME_H_agentperfdetail); 
+			$pfUSERtotPAUSE_MS_pct =	sprintf("%0.2f", MathZDC(100*$Spause_sec, $Stime));
+			$USERavgPAUSE_MS =			sec_convert($Spause_avg,$TIME_M_agentperfdetail); 
+			$USERtotWAIT_MS =			sec_convert($Swait_sec,$TIME_H_agentperfdetail); 
+			$pfUSERtotWAIT_MS_pct =		sprintf("%0.2f", MathZDC(100*$Swait_sec, $Stime));
+			$USERavgWAIT_MS =			sec_convert($Swait_avg,$TIME_M_agentperfdetail); 
+			$USERtotDISPO_MS =			sec_convert($Sdispo_sec,$TIME_H_agentperfdetail); 
+			$pfUSERtotDISPO_MS_pct =	sprintf("%0.2f", MathZDC(100*$Sdispo_sec, $Stime));
+			$USERavgDISPO_MS =			sec_convert($Sdispo_avg,$TIME_M_agentperfdetail); 
+			$USERtotDEAD_MS =			sec_convert($Sdead_sec,$TIME_H_agentperfdetail); 
+			$pfUSERtotDEAD_MS_pct =		sprintf("%0.2f", MathZDC(100*$Sdead_sec, $Stime));
+			$USERavgDEAD_MS =			sec_convert($Sdead_avg,$TIME_M_agentperfdetail); 
+			$USERtotCUSTOMER_MS	=		sec_convert($Scustomer_sec,$TIME_H_agentperfdetail);
+			$pfUSERtotCUSTOMER_MS_pct =	sprintf("%0.2f", MathZDC(100*$Scustomer_sec, $Stime));
+			$USERavgCUSTOMER_MS =		sec_convert($Scustomer_avg,$TIME_M_agentperfdetail); 
+
+			$pfUSERtime_MS =			sprintf("%9s", $pfUSERtime_MS);
+			$pfUSERtotTALK_MS =			sprintf("%8s", $pfUSERtotTALK_MS);
+			$pfUSERtotTALK_MS_pct =		sprintf("%8s", $pfUSERtotTALK_MS_pct);
+			$pfUSERavgTALK_MS =			sprintf("%6s", $pfUSERavgTALK_MS);
+			$pfUSERtotPAUSE_MS =		sprintf("%8s", $USERtotPAUSE_MS);
+			$pfUSERtotPAUSE_MS_pct =	sprintf("%8s", $pfUSERtotPAUSE_MS_pct);
+			$pfUSERavgPAUSE_MS =		sprintf("%6s", $USERavgPAUSE_MS);
+			$pfUSERtotWAIT_MS =			sprintf("%8s", $USERtotWAIT_MS);
+			$pfUSERtotWAIT_MS_pct =		sprintf("%8s", $pfUSERtotWAIT_MS_pct);
+			$pfUSERavgWAIT_MS =			sprintf("%6s", $USERavgWAIT_MS);
+			$pfUSERtotDISPO_MS =		sprintf("%8s", $USERtotDISPO_MS);
+			$pfUSERtotDISPO_MS_pct =	sprintf("%8s", $pfUSERtotDISPO_MS_pct);
+			$pfUSERavgDISPO_MS =		sprintf("%6s", $USERavgDISPO_MS);
+			$pfUSERtotDEAD_MS =			sprintf("%8s", $USERtotDEAD_MS);
+			$pfUSERtotDEAD_MS_pct =		sprintf("%8s", $pfUSERtotDEAD_MS_pct);
+			$pfUSERavgDEAD_MS =			sprintf("%6s", $USERavgDEAD_MS);
+			$pfUSERtotCUSTOMER_MS =		sprintf("%8s", $USERtotCUSTOMER_MS);
+			$pfUSERtotCUSTOMER_MS_pct =	sprintf("%8s", $pfUSERtotCUSTOMER_MS_pct);
+			$pfUSERavgCUSTOMER_MS =		sprintf("%6s", $USERavgCUSTOMER_MS);
+			$PAUSEtotal[$m] = $pfUSERtotPAUSE_MS;
+
+			if ($non_latin < 1)
+				{
+				$Scall_date=	sprintf("%-10s", $call_dateX);
+				$Sfull_name=	sprintf("%-15s", " "); 
+				$Suser_group=	sprintf("%-20s", " "); 
+				$Slast_user_group=	sprintf("%-20s", " "); 
+				$Suser_sub =		sprintf("%-8s", " ");
+				}
+			else
+				{	
+				$Scall_date=	sprintf("%-10s", $call_dateX);
+				$Sfull_name=	sprintf("%-45s", " "); 
+				$Suser_group=	sprintf("%-60s", " "); 
+				$Slast_user_group=	sprintf("%-60s", " "); 
+				$Suser_sub =	sprintf("%-24s", " ");
+				}
+
+			if ($show_percentages) {
+				$Toutput_sub .= "| $Sfull_name | $Suser_sub | $Suser_group | $Slast_user_group | $Scall_date | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERtotPAUSE_MS_pct % | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERtotWAIT_MS_pct % | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERtotTALK_MS_pct % | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERtotDISPO_MS_pct % | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERtotDEAD_MS_pct % | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERtotCUSTOMER_MS_pct % | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
+			} else {
+				$Toutput_sub .= "| $Sfull_name | $Suser_sub | $Suser_group | $Slast_user_group | $Scall_date | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
+			}
+
+
+			$CSV_lines_sub.="\"\",";
+			if ($show_percentages) {
+				$CSV_lines_sub.=preg_replace('/\s/', '', "\"\",\"\",\"\",\"$Scall_date\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERtotPAUSE_MS_pct\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERtotWAIT_MS_pct\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERtotTALK_MS_pct\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERtotDISPO_MS_pct\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERtotDEAD_MS_pct\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERtotCUSTOMER_MS_pct\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses");
+			} else {
+				$CSV_lines_sub.=preg_replace('/\s/', '', "\"\",\"\",\"\",\"$Scall_date\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses");
+			}
+			$CSV_lines_sub.="\n";
+
+			}
+		if ($show_percentages) 
+			{
+			$Toutput_sub.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
+			} 
+		else 
+			{
+			$Toutput_sub.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+			}
+		}
+
 	$Slast_user_group=$recent_user_groups[$Suser];
-#	$recent_UG_stmt="SELECT max(event_time) as most_recent_event, user_group from vicidial_agent_log where user='$Suser' and event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_agent_log_SQL group by user_group order by most_recent_event desc limit 1";
-#	if ($DB) {$HTML_text.="$recent_UG_stmt\n";}
-#	$recent_UG_rslt=mysql_to_mysqli($recent_UG_stmt, $link);
-#	while ($UG_row=mysqli_fetch_row($recent_UG_rslt)) {
-#		$Slast_user_group=$UG_row[1];
-#		$recent_user_groups[$Suser]=$UG_row[1];
-#	}
 
 	$Sfull_name=$user_namesARY[$m];
 	$Suser_group=$user_groupsARY[$m];
@@ -994,6 +1205,7 @@ while ($m < $k)
 
 	if ($non_latin < 1)
 		{
+		$Scall_date=	sprintf("%-10s", " ");
 		$Sfull_name=	sprintf("%-15s", $Sfull_name); 
 		while(strlen($Sfull_name)>15) {$Sfull_name = substr("$Sfull_name", 0, -1);}
 		$Suser_group=	sprintf("%-20s", $Suser_group); 
@@ -1005,6 +1217,7 @@ while ($m < $k)
 		}
 	else
 		{	
+		$Scall_date=	sprintf("%-10s", " ");
 		$Sfull_name=	sprintf("%-45s", $Sfull_name); 
 		while(mb_strlen($Sfull_name,'utf-8')>15) {$Sfull_name = mb_substr("$Sfull_name", 0, -1,'utf-8');}
 		$Suser_group=	sprintf("%-60s", $Suser_group); 
@@ -1088,19 +1301,22 @@ while ($m < $k)
 	$PAUSEtotal[$m] = $pfUSERtotPAUSE_MS;
 
 	if ($show_percentages) {
-		$Toutput = "| $Sfull_name | $Suser | $Suser_group | $Slast_user_group | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERtotPAUSE_MS_pct % | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERtotWAIT_MS_pct % | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERtotTALK_MS_pct % | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERtotDISPO_MS_pct % | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERtotDEAD_MS_pct % | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERtotCUSTOMER_MS_pct % | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
+		$Toutput = "| $Sfull_name | $Suser | $Suser_group | $Slast_user_group$BBD_filler | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERtotPAUSE_MS_pct % | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERtotWAIT_MS_pct % | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERtotTALK_MS_pct % | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERtotDISPO_MS_pct % | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERtotDEAD_MS_pct % | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERtotCUSTOMER_MS_pct % | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
 	} else {
-		$Toutput = "| $Sfull_name | $Suser | $Suser_group | $Slast_user_group | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
+		$Toutput = "| $Sfull_name | $Suser | $Suser_group | $Slast_user_group$BBD_filler | $Scalls | $pfUSERtime_MS | $pfUSERtotPAUSE_MS | $pfUSERavgPAUSE_MS | $pfUSERtotWAIT_MS | $pfUSERavgWAIT_MS | $pfUSERtotTALK_MS | $pfUSERavgTALK_MS | $pfUSERtotDISPO_MS | $pfUSERavgDISPO_MS | $pfUSERtotDEAD_MS | $pfUSERavgDEAD_MS | $pfUSERtotCUSTOMER_MS | $pfUSERavgCUSTOMER_MS |$SstatusesHTML\n";
 	}
 
+	$Toutput.=$Toutput_sub;
 
 	$CSV_lines.="\"$Sfull_nameRAW\",";
 	if ($show_percentages) {
-		$CSV_lines.=preg_replace('/\s/', '', "\"$SuserRAW\",\"$Suser_group\",\"$Slast_user_group\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERtotPAUSE_MS_pct\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERtotWAIT_MS_pct\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERtotTALK_MS_pct\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERtotDISPO_MS_pct\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERtotDEAD_MS_pct\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERtotCUSTOMER_MS_pct\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses");
+		$CSV_lines.=preg_replace('/\s/', '', "\"$SuserRAW\",\"$Suser_group\",\"$Slast_user_group$BBD_csv_filler\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERtotPAUSE_MS_pct\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERtotWAIT_MS_pct\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERtotTALK_MS_pct\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERtotDISPO_MS_pct\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERtotDEAD_MS_pct\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERtotCUSTOMER_MS_pct\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses");
 	} else {
-		$CSV_lines.=preg_replace('/\s/', '', "\"$SuserRAW\",\"$Suser_group\",\"$Slast_user_group\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses");
+		$CSV_lines.=preg_replace('/\s/', '', "\"$SuserRAW\",\"$Suser_group\",\"$Slast_user_group$BBD_csv_filler\",\"$Scalls\",\"$pfUSERtime_MS\",\"$pfUSERtotPAUSE_MS\",\"$pfUSERavgPAUSE_MS\",\"$pfUSERtotWAIT_MS\",\"$pfUSERavgWAIT_MS\",\"$pfUSERtotTALK_MS\",\"$pfUSERavgTALK_MS\",\"$pfUSERtotDISPO_MS\",\"$pfUSERavgDISPO_MS\",\"$pfUSERtotDEAD_MS\",\"$pfUSERavgDEAD_MS\",\"$pfUSERtotCUSTOMER_MS\",\"$pfUSERavgCUSTOMER_MS\"$CSVstatuses");
 	}
 	$CSV_lines.="\n";
+	$CSV_lines.=$CSV_lines_sub;
+
 
 	$TOPsorted_output[$m] = $Toutput;
 
@@ -1257,13 +1473,19 @@ if ($file_download == 0 || !$file_download)
 	}
 
 if ($show_percentages) {
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
-	$ASCII_text.="|  "._QXZ("TOTALS",33)." "._QXZ("AGENTS",32,"r").":$TOT_AGENTS | $TOTcalls| $TOTtime_MS|$TOTtotPAUSE_MS| $TOTtotPAUSE_MS_pct % | $TOTavgPAUSE_MS |$TOTtotWAIT_MS| $TOTtotWAIT_MS_pct % | $TOTavgWAIT_MS |$TOTtotTALK_MS| $TOTtotTALK_MS_pct % | $TOTavgTALK_MS |$TOTtotDISPO_MS| $TOTtotDISPO_MS_pct % | $TOTavgDISPO_MS |$TOTtotDEAD_MS| $TOTtotDEAD_MS_pct % | $TOTavgDEAD_MS |$TOTtotCUSTOMER_MS| $TOTtotCUSTOMER_MS_pct % | $TOTavgCUSTOMER_MS |$SUMstatusesHTML\n";
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
+	if (!$breakdown_by_date) # Prevent additional line from being printed - has to be here, won't work above in if-breakdown-by-date loop when results are sorted
+		{
+		$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
+		}
+	$ASCII_text.="|  "._QXZ("TOTALS",33)." "._QXZ("AGENTS",32,"r").":$TOT_AGENTS$BBD_filler | $TOTcalls| $TOTtime_MS|$TOTtotPAUSE_MS| $TOTtotPAUSE_MS_pct % | $TOTavgPAUSE_MS |$TOTtotWAIT_MS| $TOTtotWAIT_MS_pct % | $TOTavgWAIT_MS |$TOTtotTALK_MS| $TOTtotTALK_MS_pct % | $TOTavgTALK_MS |$TOTtotDISPO_MS| $TOTtotDISPO_MS_pct % | $TOTavgDISPO_MS |$TOTtotDEAD_MS| $TOTtotDEAD_MS_pct % | $TOTavgDEAD_MS |$TOTtotCUSTOMER_MS| $TOTtotCUSTOMER_MS_pct % | $TOTavgCUSTOMER_MS |$SUMstatusesHTML\n";
+	$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+----------+------------+--------+$statusesHEAD\n";
 } else {
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
-	$ASCII_text.="|  "._QXZ("TOTALS",33)." "._QXZ("AGENTS",32,"r").":$TOT_AGENTS | $TOTcalls| $TOTtime_MS|$TOTtotPAUSE_MS| $TOTavgPAUSE_MS |$TOTtotWAIT_MS| $TOTavgWAIT_MS |$TOTtotTALK_MS| $TOTavgTALK_MS |$TOTtotDISPO_MS| $TOTavgDISPO_MS |$TOTtotDEAD_MS| $TOTavgDEAD_MS |$TOTtotCUSTOMER_MS| $TOTavgCUSTOMER_MS |$SUMstatusesHTML\n";
-	$ASCII_text.="+-----------------+----------+----------------------+----------------------+--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+	if (!$breakdown_by_date) # Prevent additional line from being printed - has to be here, won't work above in if-breakdown-by-date loop when results are sorted
+		{
+		$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
+		}
+	$ASCII_text.="|  "._QXZ("TOTALS",33)." "._QXZ("AGENTS",32,"r").":$TOT_AGENTS$BBD_filler | $TOTcalls| $TOTtime_MS|$TOTtotPAUSE_MS| $TOTavgPAUSE_MS |$TOTtotWAIT_MS| $TOTavgWAIT_MS |$TOTtotTALK_MS| $TOTavgTALK_MS |$TOTtotDISPO_MS| $TOTavgDISPO_MS |$TOTtotDEAD_MS| $TOTavgDEAD_MS |$TOTtotCUSTOMER_MS| $TOTavgCUSTOMER_MS |$SUMstatusesHTML\n";
+	$ASCII_text.="+-----------------+----------+----------------------+----------------------+".$BBD_header."--------+-----------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+----------+--------+$statusesHEAD\n";
 }
 
 for ($e=0; $e 0)
 ##### END SETTINGS LOOKUP #####
 ###########################################
 
+### ARCHIVED DATA CHECK CONFIGURATION
+$archives_available="N";
+$log_tables_array=array("vicidial_timeclock_log", "vicidial_agent_log");
+for ($t=0; $t   \n";
 $MAIN.=_QXZ("Date").": \n";
 $MAIN.=_QXZ("User ID").": \n";
+
+if ($archives_available=="Y") 
+	{
+	$MAIN.=""._QXZ("Search archived data")."

\n"; + } + $MAIN.="\n"; $MAIN.="\n\n"; @@ -330,7 +361,7 @@ $CSV_text_header.="\""._QXZ("AGENT TIME SHEET").": $agent - $full_name\"\n\n"; if ($calls_summary) { - $stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from vicidial_agent_log where event_time <= '" . mysqli_real_escape_string($link, $query_date_END) . "' and event_time >= '" . mysqli_real_escape_string($link, $query_date_BEGIN) . "' and user='" . mysqli_real_escape_string($link, $agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;"; + $stmt="select count(*) as calls,sum(talk_sec) as talk,avg(talk_sec),sum(pause_sec),avg(pause_sec),sum(wait_sec),avg(wait_sec),sum(dispo_sec),avg(dispo_sec) from ".$vicidial_agent_log_table." where event_time <= '" . mysqli_real_escape_string($link, $query_date_END) . "' and event_time >= '" . mysqli_real_escape_string($link, $query_date_BEGIN) . "' and user='" . mysqli_real_escape_string($link, $agent) . "' and pause_sec<48800 and wait_sec<48800 and talk_sec<48800 and dispo_sec<48800 limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $row=mysqli_fetch_row($rslt); @@ -357,7 +388,7 @@ if ($calls_summary) $pfWAIT_AVG_MS = sprintf("%6s", $WAIT_AVG_MS); $pfWRAPUP_AVG_MS = sprintf("%6s", $WRAPUP_AVG_MS); - $MAIN.=_QXZ("TOTAL CALLS TAKEN",17).": $row[0] ["._QXZ("DOWNLOAD")."]\n"; + $MAIN.=_QXZ("TOTAL CALLS TAKEN",17).": $row[0] ["._QXZ("DOWNLOAD")."]\n"; $MAIN.=_QXZ("TALK TIME:",24)." $pfTALK_TIME_HMS "._QXZ("AVERAGE",11,"r").": $pfTALK_AVG_MS\n"; $MAIN.=_QXZ("PAUSE TIME:",24)." $pfPAUSE_TIME_HMS "._QXZ("AVERAGE",11,"r").": $pfPAUSE_AVG_MS\n"; $MAIN.=_QXZ("WAIT TIME:",24)." $pfWAIT_TIME_HMS "._QXZ("AVERAGE",11,"r").": $pfWAIT_AVG_MS\n"; @@ -378,7 +409,7 @@ else } -$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysqli_real_escape_string($link, $query_date_END) . "' and event_time >= '" . mysqli_real_escape_string($link, $query_date_BEGIN) . "' and user='" . mysqli_real_escape_string($link, $agent) . "' order by event_time limit 1;"; +$stmt="select event_time,UNIX_TIMESTAMP(event_time) from ".$vicidial_agent_log_table." where event_time <= '" . mysqli_real_escape_string($link, $query_date_END) . "' and event_time >= '" . mysqli_real_escape_string($link, $query_date_BEGIN) . "' and user='" . mysqli_real_escape_string($link, $agent) . "' order by event_time limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $row=mysqli_fetch_row($rslt); @@ -388,7 +419,7 @@ $start = $row[1]; $CSV_login.="\"\",\""._QXZ("FIRST LOGIN").":\",\"$row[0]\"\n"; -$stmt="select event_time,UNIX_TIMESTAMP(event_time) from vicidial_agent_log where event_time <= '" . mysqli_real_escape_string($link, $query_date_END) . "' and event_time >= '" . mysqli_real_escape_string($link, $query_date_BEGIN) . "' and user='" . mysqli_real_escape_string($link, $agent) . "' order by event_time desc limit 1;"; +$stmt="select event_time,UNIX_TIMESTAMP(event_time) from ".$vicidial_agent_log_table." where event_time <= '" . mysqli_real_escape_string($link, $query_date_END) . "' and event_time >= '" . mysqli_real_escape_string($link, $query_date_BEGIN) . "' and user='" . mysqli_real_escape_string($link, $agent) . "' order by event_time desc limit 1;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $row=mysqli_fetch_row($rslt); @@ -421,7 +452,7 @@ $EQepoch = mktime(23, 59, 59, $EQday_ARY[1], $EQday_ARY[2], $EQday_ARY[0]); $MAIN.="\n"; -$MAIN.=""._QXZ("TIMECLOCK LOGIN/LOGOUT TIME").": ["._QXZ("DOWNLOAD")."]\n"; +$MAIN.=""._QXZ("TIMECLOCK LOGIN/LOGOUT TIME").": ["._QXZ("DOWNLOAD")."]\n"; $MAIN.="\n"; $MAIN.="\n"; @@ -430,7 +461,7 @@ $CSV_text2.=$CSV_login; $CSV_text2.="\""._QXZ("TIMECLOCK LOGIN/LOGOUT TIME").":\"\n"; $CSV_text2.="\"\",\""._QXZ("ID")."\",\""._QXZ("EDIT")."\",\""._QXZ("EVENT")."\",\""._QXZ("DATE")."\",\""._QXZ("IP ADDRESS")."\",\""._QXZ("GROUP")."\",\""._QXZ("HOURS:MINUTES")."\"\n"; - $stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from vicidial_timeclock_log where user='$agent' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';"; + $stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from ".$vicidial_timeclock_log_table." where user='$agent' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';"; if ($DB>0) {$MAIN.="|$stmt|";} $rslt=mysql_to_mysqli($stmt, $link); $events_to_print = mysqli_num_rows($rslt); diff --git a/www/vicidial/AST_campaign_status_list_report.php b/www/vicidial/AST_campaign_status_list_report.php index 0528d9fa..cf79c702 100644 --- a/www/vicidial/AST_campaign_status_list_report.php +++ b/www/vicidial/AST_campaign_status_list_report.php @@ -20,6 +20,7 @@ # 141114-0848 - Finalized adding QXZ translation to all admin files # 141230-1516 - Added code for on-the-fly language translations display # 150516-1312 - Fixed Javascript element problem, Issue #857 +# 151219-0107 - Added option for searching archived data # $startMS = microtime(); @@ -50,6 +51,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} $report_name="Campaign Status List Report"; $NOW_DATE = date("Y-m-d"); @@ -63,7 +66,6 @@ if (!isset($end_date_T)) {$end_date_T="23:59:59";} $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} -if ($archive_tbl) {$agent_log_table="vicidial_agent_log_archive";} else {$agent_log_table="vicidial_agent_log";} $qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { @@ -78,6 +80,30 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_log", "vicidial_closer_log", "vicidial_agent_log"); +for ($t=0; $t"; $HTML_text.="\n

"; + +if ($archives_available=="Y") + { + $HTML_text.=""._QXZ("Search archived data")."

\n"; + } + $HTML_text.="\n"; $HTML_text.="
"._QXZ("ID")." "._QXZ("EDIT")." "._QXZ("EVENT")." "._QXZ("DATE")." "._QXZ("IP ADDRESS")." "._QXZ("GROUP").""._QXZ("HOURS:MINUTES")."
        "; $HTML_text.="          \n"; -$HTML_text.=""._QXZ("DOWNLOAD")." |"; +$HTML_text.=""._QXZ("DOWNLOAD")." |"; $HTML_text.=" "._QXZ("REPORTS")." \n"; $HTML_text.="\n"; $HTML_text.="
"; @@ -407,7 +439,7 @@ while($i < $group_ct) if (strlen($inbound_groups)>0) { $inbound_groups=preg_replace("/\s/", "', '", $inbound_groups); - $inbound_SQL="and vicidial_closer_log.campaign_id in ('$inbound_groups')"; + $inbound_SQL="and ".$vicidial_closer_log_table.".campaign_id in ('$inbound_groups')"; } else { @@ -435,7 +467,7 @@ while($i < $group_ct) $CSV_text.="\""._QXZ("List ID")." #$list_id: $list_name\"\n"; - $stat_stmt="SELECT vicidial_log.status, vicidial_log.uniqueid, vicidial_log.length_in_sec as duration, cast(vicidial_agent_log.talk_sec as signed)-cast(vicidial_agent_log.dead_sec as signed) as handle_time from vicidial_log LEFT OUTER JOIN vicidial_agent_log on vicidial_log.lead_id=vicidial_agent_log.lead_id and vicidial_log.uniqueid=vicidial_agent_log.uniqueid where vicidial_log.call_date>='$query_date' and vicidial_log.call_date<='$end_date' and vicidial_log.list_id='$list_id' UNION SELECT vicidial_closer_log.status, vicidial_closer_log.uniqueid, vicidial_closer_log.length_in_sec as duration, cast(vicidial_agent_log.talk_sec as signed)-cast(vicidial_agent_log.dead_sec as signed) as handle_time from vicidial_closer_log LEFT OUTER JOIN vicidial_agent_log on vicidial_closer_log.lead_id=vicidial_agent_log.lead_id and vicidial_closer_log.uniqueid=vicidial_agent_log.uniqueid where call_date>='$query_date' and call_date<='$end_date' and list_id='$list_id' order by status"; + $stat_stmt="SELECT ".$vicidial_log_table.".status, ".$vicidial_log_table.".uniqueid, ".$vicidial_log_table.".length_in_sec as duration, cast(".$vicidial_agent_log_table.".talk_sec as signed)-cast(".$vicidial_agent_log_table.".dead_sec as signed) as handle_time from ".$vicidial_log_table." LEFT OUTER JOIN ".$vicidial_agent_log_table." on ".$vicidial_log_table.".lead_id=".$vicidial_agent_log_table.".lead_id and ".$vicidial_log_table.".uniqueid=".$vicidial_agent_log_table.".uniqueid where ".$vicidial_log_table.".call_date>='$query_date' and ".$vicidial_log_table.".call_date<='$end_date' and ".$vicidial_log_table.".list_id='$list_id' UNION SELECT ".$vicidial_closer_log_table.".status, ".$vicidial_closer_log_table.".uniqueid, ".$vicidial_closer_log_table.".length_in_sec as duration, cast(".$vicidial_agent_log_table.".talk_sec as signed)-cast(".$vicidial_agent_log_table.".dead_sec as signed) as handle_time from ".$vicidial_closer_log_table." LEFT OUTER JOIN ".$vicidial_agent_log_table." on ".$vicidial_closer_log_table.".lead_id=".$vicidial_agent_log_table.".lead_id and ".$vicidial_closer_log_table.".uniqueid=".$vicidial_agent_log_table.".uniqueid where call_date>='$query_date' and call_date<='$end_date' and list_id='$list_id' order by status"; if ($DB) {$HTML_text.="|$stat_stmt|\n";} # $ASCII_text.=$stat_stmt."\n"; $stat_rslt=mysql_to_mysqli($stat_stmt, $link); diff --git a/www/vicidial/AST_email_log_report.php b/www/vicidial/AST_email_log_report.php index a41ec5ed..520ea553 100644 --- a/www/vicidial/AST_email_log_report.php +++ b/www/vicidial/AST_email_log_report.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 # # report of emails handled by the system # @@ -16,6 +16,7 @@ # 140918-0615 - Fixed bug #789 # 141113-2048 - Finalized adding QXZ translation to all admin files # 141230-1504 - Added code for on-the-fly language translations display +# 151219-0117 - Added option for searching archived data # $startMS = microtime(); @@ -61,6 +62,8 @@ if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} $report_name = 'Email Log Report'; @@ -86,6 +89,30 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_email_list", "vicidial_closer_log", "vicidial_email_log"); +for ($t=0; $t"._QXZ("IVR REPORT")." | \n"; } $MAIN.=""._QXZ("REPORTS")." | "; -$MAIN.="


\n"; +$MAIN.="

"; + + +if ($archives_available=="Y") + { + $MAIN.=""._QXZ("Search archived data")."

\n"; + } + + +$MAIN.="
\n"; $MAIN.="
\n"; @@ -470,7 +506,7 @@ $query_date_END = "$end_date 23:59:59"; $rpt_title=_QXZ("Showing emails")." $email_title "._QXZ("that were")." $date_title "._QXZ("from")." $query_date_BEGIN "._QXZ("to")." $query_date_END\n\n"; $MAIN.=$rpt_title; -$MAIN.=_QXZ("Email log results").": $group_string $NOW_TIME "._QXZ("DOWNLOAD")."\n"; +$MAIN.=_QXZ("Email log results").": $group_string $NOW_TIME "._QXZ("DOWNLOAD")."\n"; $CSV_text1.="\""._QXZ("Showing emails")." $email_title "._QXZ("that were")." $date_title "._QXZ("from")." $query_date_BEGIN "._QXZ("to")." $query_date_END\"\n\n"; if ($email_type=="received") @@ -481,16 +517,16 @@ if ($email_type=="received") if ($date_type=="email_date") { # $stmt="select vel.* from vicidial_email_list vel where $date_type>='$query_date_BEGIN' and $date_type<='$query_date_END' and group_id in ($group_SQL) order by $date_type asc"; - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status from vicidial_email_list vel where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vel.group_id in ($group_SQL) order by vel.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status from ".$vicidial_email_list_table." vel where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vel.group_id in ($group_SQL) order by vel.$date_type asc"; } else if ($date_type=="call_date") { # $stmt="select vel.*, vcl.call_date, from vicidial_email_list vel, vicidial_closer_log vcl where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vcl.$date_type asc"; - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status from vicidial_email_list vel where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vcl.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status from ".$vicidial_email_list_table." vel where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vcl.$date_type asc"; } else if ($date_type=="date_answered") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.user as sending_user, vl.message as sent_message from vicidial_email_list vel, vicidial_closer_log vcl, vicidial_email_log vl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vel.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.user as sending_user, vl.message as sent_message from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl, ".$vicidial_email_log_table." vl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vel.$date_type asc"; } } else if ($email_type=="viewed") @@ -500,15 +536,15 @@ else if ($email_type=="viewed") $CSV_text1.="\""._QXZ("DATE EMAIL RECEIVED")."\",\""._QXZ("ADDRESS FROM")."\",\""._QXZ("SENDER NAME")."\",\""._QXZ("MESSAGE")."\",\""._QXZ("DATE EMAIL VIEWED")."\",\""._QXZ("STATUS")."\"\n"; if ($date_type=="email_date") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date from vicidial_email_list vel, vicidial_closer_log vcl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vel.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vel.$date_type asc"; } else if ($date_type=="call_date") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date from vicidial_email_list vel, vicidial_closer_log vcl where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vcl.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vcl.$date_type asc"; } else if ($date_type=="date_answered") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date from vicidial_email_list vel, vicidial_closer_log vcl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vel.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) order by vel.$date_type asc"; } } else if ($email_type=="answered") @@ -518,15 +554,15 @@ else if ($email_type=="answered") $CSV_text1.="\""._QXZ("DATE EMAIL RECEIVED")."\",\""._QXZ("ADDRESS FROM")."\",\""._QXZ("SENDER NAME")."\",\""._QXZ("MESSAGE")."\",\""._QXZ("DATE EMAIL VIEWED")."\",\""._QXZ("DATE EMAIL ANSWERED")."\",\""._QXZ("USER")."\",\""._QXZ("RESPONSE")."\",\""._QXZ("STATUS")."\"\n"; if ($date_type=="email_date") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.email_log_id, vl.user as sending_user, vl.message as sent_message from vicidial_email_list vel, vicidial_closer_log vcl, vicidial_email_log vl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vel.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.email_log_id, vl.user as sending_user, vl.message as sent_message from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl, ".$vicidial_email_log_table." vl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vel.$date_type asc"; } else if ($date_type=="call_date") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.email_log_id, vl.user as sending_user, vl.message as sent_message from vicidial_email_list vel, vicidial_closer_log vcl, vicidial_email_log vl where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vcl.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.email_log_id, vl.user as sending_user, vl.message as sent_message from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl, ".$vicidial_email_log_table." vl where vcl.$date_type>='$query_date_BEGIN' and vcl.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vcl.$date_type asc"; } else if ($date_type=="date_answered") { - $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.email_log_id, vl.user as sending_user, vl.message as sent_message from vicidial_email_list vel, vicidial_closer_log vcl, vicidial_email_log vl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vel.$date_type asc"; + $stmt="select vel.email_row_id, vel.lead_id, vel.email_date, vel.email_from, vel.email_from_name, convert(vel.message using 'UTF8') as message, vel.status, vcl.call_date, vl.email_date as date_response_sent, vl.email_log_id, vl.user as sending_user, vl.message as sent_message from ".$vicidial_email_list_table." vel, ".$vicidial_closer_log_table." vcl, ".$vicidial_email_log_table." vl where vel.$date_type>='$query_date_BEGIN' and vel.$date_type<='$query_date_END' and vcl.uniqueid=vel.uniqueid and vel.group_id in ($group_SQL) and vel.email_row_id=vl.email_row_id order by vel.$date_type asc"; } } #echo $stmt."\n"; diff --git a/www/vicidial/AST_performance_comparison_report.php b/www/vicidial/AST_performance_comparison_report.php index d55dabb1..bc74c030 100644 --- a/www/vicidial/AST_performance_comparison_report.php +++ b/www/vicidial/AST_performance_comparison_report.php @@ -12,6 +12,7 @@ # 141128-0905 - Code cleanup for QXZ functions # 141230-0939 - Added code for on-the-fly language translations display # 150516-1314 - Fixed Javascript element problem, Issue #857 +# 151227-1746 - Added option for searching archived data # $startMS = microtime(); @@ -48,6 +49,8 @@ if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_ elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} if (isset($_GET["show_percentages"])) {$show_percentages=$_GET["show_percentages"];} elseif (isset($_POST["show_percentages"])) {$show_percentages=$_POST["show_percentages"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} if (strlen($shift)<2) {$shift='ALL';} @@ -75,6 +78,26 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_agent_log"); +for ($t=0; $t\"HELP\""; @@ -522,8 +545,14 @@ $HTML_text.=""; $HTML_text.=_QXZ("Display as").":
"; $HTML_text.="

\n"; -$HTML_text.="$NWB#agent_performance_detail$NWE\n"; +$HTML_text.="\n"; + +if ($archives_available=="Y") + { + $HTML_text.=""._QXZ("Search archived data")."\n"; + } + +$HTML_text.="

$NWB#agent_performance_detail$NWE\n"; $HTML_text.="         "; $HTML_text.="          \n"; @@ -583,7 +612,7 @@ else # Get full list of agents for the past 30 days - $initial_user_stmt="select distinct vicidial_agent_log.user, full_name from vicidial_agent_log, vicidial_users where event_time <= '$query_date $time_END' and event_time >= '$thirtydaysago $time_BEGIN' $group_SQL $user_group_SQL $user_SQL and vicidial_agent_log.user=vicidial_users.user order by full_name asc"; + $initial_user_stmt="select distinct ".$vicidial_agent_log_table.".user, full_name from ".$vicidial_agent_log_table.", vicidial_users where event_time <= '$query_date $time_END' and event_time >= '$thirtydaysago $time_BEGIN' $group_SQL $user_group_SQL $user_SQL and ".$vicidial_agent_log_table.".user=vicidial_users.user order by full_name asc"; if ($DB) {echo $initial_user_stmt;} $initial_user_rslt=mysql_to_mysqli($initial_user_stmt, $link); while ($user_row=mysqli_fetch_array($initial_user_rslt)) @@ -661,7 +690,7 @@ else ######### - $stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), vicidial_users.user_group from vicidial_users,vicidial_agent_log where event_time <= '$query_date $time_END' and event_time >= '$rpt_date $time_BEGIN' and vicidial_users.user=vicidial_agent_log.user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_SQL $user_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;"; + $stmt="select count(*) as calls,sum(talk_sec) as talk,full_name,vicidial_users.user,sum(pause_sec),sum(wait_sec),sum(dispo_sec),status,sum(dead_sec), vicidial_users.user_group from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date $time_END' and event_time >= '$rpt_date $time_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 $group_SQL $user_group_SQL $user_SQL group by user,full_name,user_group,status order by full_name,user,status desc limit 500000;"; if ($DB) {print "\n";} $rslt=mysql_to_mysqli($stmt, $link); $rows_to_print = mysqli_num_rows($rslt); diff --git a/www/vicidial/AST_team_performance_detail.php b/www/vicidial/AST_team_performance_detail.php index 9dd971ab..df7ba4e9 100644 --- a/www/vicidial/AST_team_performance_detail.php +++ b/www/vicidial/AST_team_performance_detail.php @@ -24,6 +24,7 @@ # 141114-0728 - Finalized adding QXZ translation to all admin files # 141230-1424 - Added code for on-the-fly language translations display # 150516-1315 - Fixed Javascript element problem, Issue #857 +# 151219-0139 - Added option for searching archived data # $startMS = microtime(); @@ -56,6 +57,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} $report_name = 'Team Performance Detail'; @@ -68,7 +71,6 @@ $JS_onload="onload = function() {\n"; $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} -if ($archive_tbl) {$agent_log_table="vicidial_agent_log_archive";} else {$agent_log_table="vicidial_agent_log";} $qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { @@ -83,6 +85,27 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_list", "vicidial_agent_log"); +for ($t=0; $t\n"; -$HTML_text.="
"._QXZ("Dates").":
"; +$HTML_text.="
"; $HTML_text.="\n"; $HTML_text.="\n"; $HTML_text.="Date Range:
\n"; @@ -480,6 +503,13 @@ $HTML_text.="\n"; $HTML_text.="   "; + +if ($archives_available=="Y") + { + $HTML_text.="

"._QXZ("Search archived data")."\n"; + } + + $HTML_text.="
"._QXZ("Campaigns").":
"; $HTML_text.="\n"; $HTML_text.="
        "; $HTML_text.="          \n"; -$HTML_text.=""._QXZ("DOWNLOAD")." |"; +$HTML_text.=""._QXZ("DOWNLOAD")." |"; $HTML_text.=" "._QXZ("REPORTS")." \n"; $HTML_text.="\n"; $HTML_text.="
"; @@ -552,7 +582,7 @@ $HTML_text.="\n\n"; if ( ($SUBMIT=="SUBMIT") or ($SUBMIT==_QXZ("SUBMIT")) ) { # Sale counts per rep - $stmt="select max(event_time), vicidial_agent_log.user, vicidial_agent_log.lead_id, vicidial_list.status as current_status from vicidial_agent_log, vicidial_list where event_time>='$query_date' and event_time<='$end_date' $group_SQL and vicidial_agent_log.status in (select status from vicidial_campaign_statuses where sale='Y' $group_SQL UNION select status from vicidial_statuses where sale='Y') and vicidial_agent_log.lead_id=vicidial_list.lead_id group by vicidial_agent_log.user, vicidial_agent_log.lead_id"; + $stmt="select max(event_time), ".$vicidial_agent_log_table.".user, ".$vicidial_agent_log_table.".lead_id, ".$vicidial_list_table.".status as current_status from ".$vicidial_agent_log_table.", ".$vicidial_list_table." where event_time>='$query_date' and event_time<='$end_date' $group_SQL and ".$vicidial_agent_log_table.".status in (select status from vicidial_campaign_statuses where sale='Y' $group_SQL UNION select status from vicidial_statuses where sale='Y') and ".$vicidial_agent_log_table.".lead_id=".$vicidial_list_table.".lead_id group by ".$vicidial_agent_log_table.".user, ".$vicidial_agent_log_table.".lead_id"; if ($DB) {$ASCII_text.="$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); while ($row=mysqli_fetch_array($rslt)) @@ -575,7 +605,7 @@ if ( ($SUBMIT=="SUBMIT") or ($SUBMIT==_QXZ("SUBMIT")) ) # Get actual talk time for all calls made by the user for this particular lead. If cancelled and incomplete sales are to have their times # counted towards sales talk time, move the below lines OUTSIDE the curly bracket below, so the query runs regardless of what "type" of # sale it is. - $sale_time_stmt="select sum(talk_sec)-sum(dead_sec) from vicidial_agent_log where user='$user' and lead_id='$lead_id' $group_SQL"; + $sale_time_stmt="select sum(talk_sec)-sum(dead_sec) from ".$vicidial_agent_log_table." where user='$user' and lead_id='$lead_id' $group_SQL"; if ($DB) {$ASCII_text.="$sale_time_stmt\n";} $sale_time_rslt=mysql_to_mysqli($sale_time_stmt, $link); $sale_time_row=mysqli_fetch_row($sale_time_rslt); @@ -670,7 +700,7 @@ if ( ($SUBMIT=="SUBMIT") or ($SUBMIT==_QXZ("SUBMIT")) ) $GRAPH_text.=""._QXZ("TEAM").": $user_group[$i] - $group_name"; #### USER COUNTS - $user_stmt="select distinct vicidial_users.full_name, vicidial_users.user from vicidial_users, vicidial_agent_log where vicidial_users.user_group='$user_group[$i]' and vicidial_users.user=vicidial_agent_log.user and vicidial_agent_log.user_group='$user_group[$i]' and vicidial_agent_log.event_time>='$query_date' and vicidial_agent_log.event_time<='$end_date' and vicidial_agent_log.campaign_id in ($group_SQL_str) order by full_name, user"; + $user_stmt="select distinct vicidial_users.full_name, vicidial_users.user from vicidial_users, ".$vicidial_agent_log_table." where vicidial_users.user_group='$user_group[$i]' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user_group='$user_group[$i]' and ".$vicidial_agent_log_table.".event_time>='$query_date' and ".$vicidial_agent_log_table.".event_time<='$end_date' and ".$vicidial_agent_log_table.".campaign_id in ($group_SQL_str) order by full_name, user"; if ($DB) {$ASCII_text.="$user_stmt\n";} $user_rslt=mysql_to_mysqli($user_stmt, $link); if (mysqli_num_rows($user_rslt)>0) @@ -747,7 +777,7 @@ if ( ($SUBMIT=="SUBMIT") or ($SUBMIT==_QXZ("SUBMIT")) ) $cancel_array[$user]+=0; # For agents with no QCCANC logged # Leads - $lead_stmt="select count(distinct lead_id) from vicidial_agent_log where lead_id is not null and event_time>='$query_date' and event_time<='$end_date' $group_SQL and user='$user' and user_group='$user_group[$i]'"; + $lead_stmt="select count(distinct lead_id) from ".$vicidial_agent_log_table." where lead_id is not null and event_time>='$query_date' and event_time<='$end_date' $group_SQL and user='$user' and user_group='$user_group[$i]'"; if ($DB) {$ASCII_text.="$lead_stmt\n";} $lead_rslt=mysql_to_mysqli($lead_stmt, $link); $lead_row=mysqli_fetch_row($lead_rslt); @@ -760,7 +790,7 @@ if ( ($SUBMIT=="SUBMIT") or ($SUBMIT==_QXZ("SUBMIT")) ) $callback_row=mysqli_fetch_row($callback_rslt); $callbacks=$callback_row[0]; - $stat_stmt="select val.status, val.sub_status, vs.customer_contact, sum(val.talk_sec), sum(val.pause_sec), sum(val.wait_sec), sum(val.dispo_sec), sum(val.dead_sec), count(*) from vicidial_agent_log val, vicidial_statuses vs where val.user='$user' and val.user_group='$user_group[$i]' and val.event_time>='$query_date' and val.event_time<='$end_date' and val.status=vs.status and vs.status in (select status from vicidial_statuses) and val.campaign_id in ($group_SQL_str) group by status, customer_contact UNION select val.status, val.sub_status, vs.customer_contact, sum(val.talk_sec), sum(val.pause_sec), sum(val.wait_sec), sum(val.dispo_sec), sum(val.dead_sec), count(*) from vicidial_agent_log val, vicidial_campaign_statuses vs where val.campaign_id in ($group_SQL_str) and val.user='$user' and val.user_group='$user_group[$i]' and val.event_time>='$query_date' and val.event_time<='$end_date' and val.status=vs.status and val.campaign_id=vs.campaign_id and vs.status in (select distinct status from vicidial_campaign_statuses where ".substr($group_SQL, 4).") group by status, customer_contact"; + $stat_stmt="select val.status, val.sub_status, vs.customer_contact, sum(val.talk_sec), sum(val.pause_sec), sum(val.wait_sec), sum(val.dispo_sec), sum(val.dead_sec), count(*) from ".$vicidial_agent_log_table." val, vicidial_statuses vs where val.user='$user' and val.user_group='$user_group[$i]' and val.event_time>='$query_date' and val.event_time<='$end_date' and val.status=vs.status and vs.status in (select status from vicidial_statuses) and val.campaign_id in ($group_SQL_str) group by status, customer_contact UNION select val.status, val.sub_status, vs.customer_contact, sum(val.talk_sec), sum(val.pause_sec), sum(val.wait_sec), sum(val.dispo_sec), sum(val.dead_sec), count(*) from ".$vicidial_agent_log_table." val, vicidial_campaign_statuses vs where val.campaign_id in ($group_SQL_str) and val.user='$user' and val.user_group='$user_group[$i]' and val.event_time>='$query_date' and val.event_time<='$end_date' and val.status=vs.status and val.campaign_id=vs.campaign_id and vs.status in (select distinct status from vicidial_campaign_statuses where ".substr($group_SQL, 4).") group by status, customer_contact"; if ($DB) {$ASCII_text.="$stat_stmt\n";} $stat_rslt=mysql_to_mysqli($stat_stmt, $link); while ($stat_row=mysqli_fetch_row($stat_rslt)) @@ -861,7 +891,7 @@ if ( ($SUBMIT=="SUBMIT") or ($SUBMIT==_QXZ("SUBMIT")) ) $CSV_status_text=""; for ($q=0; $q='$query_date' and val.event_time<='$end_date' and val.status=vs.status and vs.status='$call_status[$q]' and val.campaign_id in ($group_SQL_str) UNION select count(distinct uniqueid) as stat_ct From ".$vicidial_agent_log_table." val, vicidial_campaign_statuses vs where val.user='$user' and val.user_group='$user_group[$i]' and val.event_time>='$query_date' and val.event_time<='$end_date' and val.status=vs.status and vs.status='$call_status[$q]' and val.campaign_id in ($group_SQL_str)) as counts"; $stat_rslt=mysql_to_mysqli($stat_stmt, $link); $stat_row=mysqli_fetch_row($stat_rslt); $ASCII_text.=" ".sprintf("%6s", $stat_row[0])." |"; diff --git a/www/vicidial/AST_usergroup_login_report.php b/www/vicidial/AST_usergroup_login_report.php index 2165f66f..feaa8d06 100644 --- a/www/vicidial/AST_usergroup_login_report.php +++ b/www/vicidial/AST_usergroup_login_report.php @@ -18,6 +18,7 @@ # 141113-2339 - Finalized adding QXZ translation to all admin files # 141230-1413 - Added code for on-the-fly language translations display # 150516-1316 - Fixed Javascript element problem, Issue #857 +# 151229-2014 - Added archive search option # $startMS = microtime(); @@ -40,6 +41,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} $report_name = 'User Group Login Report'; $db_source = 'M'; @@ -64,6 +67,26 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_user_log"); +for ($t=0; $t\n"; + +if ($archives_available=="Y") + { + $HTML_text.=""._QXZ("Search archived data")."\n"; + } + +$HTML_text.="

\n"; $HTML_text.="
        "; $HTML_text.="          \n"; -$HTML_text.=""._QXZ("DOWNLOAD")." |"; +$HTML_text.=""._QXZ("DOWNLOAD")." |"; $HTML_text.=" "._QXZ("REPORTS")." \n"; $HTML_text.="\n"; $HTML_text.="
"; @@ -340,11 +369,11 @@ if ($SUBMIT) $rslt=mysql_to_mysqli($stmt, $link); while ($row=mysqli_fetch_array($rslt)) { - $date_stmt="select min(event_date) as min_date, max(event_date) as max_date from vicidial_user_log where user='$row[user]' and event='LOGIN' and event_date>='$day30range'"; + $date_stmt="select min(event_date) as min_date, max(event_date) as max_date from ".$vicidial_user_log_table." where user='$row[user]' and event='LOGIN' and event_date>='$day30range'"; $date_rslt=mysql_to_mysqli($date_stmt, $link); $date_row=mysqli_fetch_array($date_rslt); - $data_stmt="select campaign_id, server_ip, computer_ip, user_group, substring(extension,1,20) as ext, extension, browser, phone_login, server_phone, phone_ip from vicidial_user_log where user='$row[user]' and event_date='$date_row[max_date]' and event='LOGIN'"; + $data_stmt="select campaign_id, server_ip, computer_ip, user_group, substring(extension,1,20) as ext, extension, browser, phone_login, server_phone, phone_ip from ".$vicidial_user_log_table." where user='$row[user]' and event_date='$date_row[max_date]' and event='LOGIN'"; $data_rslt=mysql_to_mysqli($data_stmt, $link); while ($data_row=mysqli_fetch_array($data_rslt)) { diff --git a/www/vicidial/called_counts_multilist_report.php b/www/vicidial/called_counts_multilist_report.php index 7af3ed7d..1aeb4a13 100644 --- a/www/vicidial/called_counts_multilist_report.php +++ b/www/vicidial/called_counts_multilist_report.php @@ -1,7 +1,7 @@ , Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2015 Joe Johnson , Matt Florell LICENSE: AGPLv2 # # This is a report designed for showing called counts similar to the results # at the bottom of each list detail screen, but for multiple lists and using @@ -13,6 +13,7 @@ # 140311-1940 - First build based upon admin.php & AST_VDADstats.php # 141114-0045 - Finalized adding QXZ translation to all admin files # 141230-1346 - Added code for on-the-fly language translations display +# 151229-2050 - Added archive search option # $startMS = microtime(); @@ -49,6 +50,8 @@ if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["report_display_type"])) {$report_display_type=$_GET["report_display_type"];} elseif (isset($_POST["report_display_type"])) {$report_display_type=$_POST["report_display_type"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} if (strlen($shift)<2) {$shift='ALL';} if (strlen($bottom_graph)<2) {$bottom_graph='NO';} @@ -78,6 +81,32 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_list", "vicidial_log", "vicidial_closer_log", "user_call_log"); +for ($t=0; $t0) { - $list_id_SQLandVLJOIN .= " and vicidial_list.list_id IN($list_id_SQL)"; - $list_id_SQLandVCLJOIN .= " and vicidial_list.list_id IN($list_id_SQL)"; - $list_id_SQLandUCLJOIN .= " and vicidial_list.list_id IN($list_id_SQL)"; + $list_id_SQLandVLJOIN .= " and ".$vicidial_list_table.".list_id IN($list_id_SQL)"; + $list_id_SQLandVCLJOIN .= " and ".$vicidial_list_table.".list_id IN($list_id_SQL)"; + $list_id_SQLandUCLJOIN .= " and ".$vicidial_list_table.".list_id IN($list_id_SQL)"; $list_id_SQL = "where list_id IN($list_id_SQL)"; $list_id_SQLand = "and list_id IN($list_id_SQL)"; } @@ -571,7 +600,13 @@ $MAIN.=_QXZ("Lists").": ("._QXZ("optional, possibly slow").")\n"; +if ($archives_available=="Y") + { + $MAIN.="
"._QXZ("Search archived data")."\n"; + } + + +$MAIN.="

\n"; $MAIN.="

"._QXZ("reset").""; $MAIN.="         "; $MAIN.=""; @@ -597,7 +632,7 @@ if (strlen($QUERY_STRING) > 5) if (!$override_date) { $date_range_title=" "._QXZ("FOR LEADS CALLED")." $query_date "._QXZ("THROUGH")." $end_date"; - $stmt="select distinct vicidial_list.lead_id from vicidial_list, vicidial_log where vicidial_log.call_date>='$query_date 00:00:00' and vicidial_log.call_date<='$end_date 23:59:59' $list_id_SQLandVLJOIN UNION select distinct vicidial_list.lead_id from vicidial_list, vicidial_closer_log where vicidial_closer_log.call_date>='$query_date 00:00:00' and vicidial_closer_log.call_date<='$end_date 23:59:59' $list_id_SQLandVCLJOIN;"; + $stmt="select distinct ".$vicidial_list_table.".lead_id from ".$vicidial_list_table.", ".$vicidial_log_table." where ".$vicidial_log_table.".call_date>='$query_date 00:00:00' and ".$vicidial_log_table.".call_date<='$end_date 23:59:59' $list_id_SQLandVLJOIN UNION select distinct ".$vicidial_list_table.".lead_id from ".$vicidial_list_table.", ".$vicidial_closer_log_table." where ".$vicidial_closer_log_table.".call_date>='$query_date 00:00:00' and ".$vicidial_closer_log_table.".call_date<='$end_date 23:59:59' $list_id_SQLandVCLJOIN;"; $rslt=mysql_to_mysqli($stmt, $link); if (!$rslt) {$MAIN.="
**".mysqli_error($link)."
$stmt";} if ($DB) {$MAIN.="$stmt

";} @@ -617,7 +652,7 @@ if (strlen($QUERY_STRING) > 5) } } - $stmt="select status, if(called_count >= 100, 100, called_count), count(*) from vicidial_list $list_id_SQL $lead_id_str group by status, if(called_count >= 100, 100, called_count) order by status,called_count;"; + $stmt="select status, if(called_count >= 100, 100, called_count), count(*) from ".$vicidial_list_table." $list_id_SQL $lead_id_str group by status, if(called_count >= 100, 100, called_count) order by status,called_count;"; $rslt=mysql_to_mysqli($stmt, $link); if (!$rslt) {$MAIN.="
**".mysqli_error($link)."
$stmt";} if ($DB) {$MAIN.="$stmt

";} @@ -657,7 +692,7 @@ if (strlen($QUERY_STRING) > 5) $CSV_text=""; $MAIN.="
\n"; - $MAIN.="
"._QXZ("CALLED COUNTS WITHIN LIST(S)")." $list_id_title_str$date_range_title:           ["._QXZ("DOWNLOAD")."]
\n"; + $MAIN.="
"._QXZ("CALLED COUNTS WITHIN LIST(S)")." $list_id_title_str$date_range_title:           ["._QXZ("DOWNLOAD")."]
\n"; $CSV_text.=_QXZ("CALLED COUNTS WITHIN LIST(S)")." $list_id_title_str$date_range_title:\n"; $MAIN.="\n"; $MAIN.=""; diff --git a/www/vicidial/user_stats.php b/www/vicidial/user_stats.php index 938a5011..c5c92c1d 100644 --- a/www/vicidial/user_stats.php +++ b/www/vicidial/user_stats.php @@ -47,6 +47,7 @@ # 141114-0025 - Finalized adding QXZ translation to all admin files # 141229-1836 - Added code for on-the-fly language translations display # 150804-0749 - Added call status as option, Issue #883 +# 151227-1839 - Added option to search archived data # $startMS = microtime(); @@ -89,6 +90,8 @@ if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} if (isset($_GET["pause_code_rpt"])) {$pause_code_rpt=$_GET["pause_code_rpt"];} elseif (isset($_POST["pause_code_rpt"])) {$pause_code_rpt=$_POST["pause_code_rpt"];} +if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} + elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### @@ -113,6 +116,48 @@ if ($qm_conf_ct > 0) ##### END SETTINGS LOOKUP ##### ########################################### +### ARCHIVED DATA CHECK CONFIGURATION +$archives_available="N"; +$log_tables_array=array("vicidial_log", "vicidial_agent_log", "vicidial_closer_log", "vicidial_user_log", "vicidial_timeclock_log", "vicidial_user_closer_log", "vicidial_email_log", "call_log", "recording_log", "user_call_log", "vicidial_lead_search_log", "vicidial_agent_skip_log"); +for ($t=0; $t   $MAIN.="
"._QXZ("STATUS").""._QXZ("STATUS NAME")."
  \n"; -$download_link="$PHP_SELF?DB=$DB&pause_code_rpt=$pause_code_rpt&did_id=$did_id&did=$did&begin_date=$begin_date&end_date=$end_date&user=$user&submit=$submit\n"; +$download_link="$PHP_SELF?DB=$DB&pause_code_rpt=$pause_code_rpt&did_id=$did_id&did=$did&begin_date=$begin_date&end_date=$end_date&user=$user&submit=$submit&search_archived_data=$search_archived_data\n"; $MAIN.="
\n"; $MAIN.="\n"; @@ -443,6 +488,12 @@ if (strlen($user)>1) else {$MAIN.="       \n";} $MAIN.=_QXZ("Call status").": \n"; + +if ($archives_available=="Y") + { + $MAIN.=""._QXZ("Search archived data")."\n"; + } + $MAIN.="\n"; @@ -471,7 +522,7 @@ $MAIN.="
\n"; if ($pause_code_rpt >= 1) { - $stmt="SELECT vicidial_agent_log.campaign_id,event_time,talk_sec,pause_sec,sec_to_time(pause_sec) as pause_length,wait_sec,dispo_sec,dead_sec,sub_status, vicidial_users.user_group from vicidial_users,vicidial_agent_log,vicidial_pause_codes where sub_status is not null and event_time <= '$end_date 23:59:59' and event_time >= '$begin_date 00:00:00' and vicidial_agent_log.user='$user' and vicidial_agent_log.user=vicidial_users.user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and vicidial_agent_log.sub_status=vicidial_pause_codes.pause_code and vicidial_agent_log.campaign_id=vicidial_pause_codes.campaign_id order by event_time asc limit 500000;"; + $stmt="SELECT ".$vicidial_agent_log_table.".campaign_id,event_time,talk_sec,pause_sec,sec_to_time(pause_sec) as pause_length,wait_sec,dispo_sec,dead_sec,sub_status, vicidial_users.user_group from vicidial_users,".$vicidial_agent_log_table.",vicidial_pause_codes where sub_status is not null and event_time <= '$end_date 23:59:59' and event_time >= '$begin_date 00:00:00' and ".$vicidial_agent_log_table.".user='$user' and ".$vicidial_agent_log_table.".user=vicidial_users.user and pause_sec<65000 and wait_sec<65000 and talk_sec<65000 and dispo_sec<65000 and ".$vicidial_agent_log_table.".sub_status=vicidial_pause_codes.pause_code and ".$vicidial_agent_log_table.".campaign_id=vicidial_pause_codes.campaign_id order by event_time asc limit 500000;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $rows_to_print = mysqli_num_rows($rslt); @@ -525,7 +576,7 @@ else $CSV_text1.="\""._QXZ("AGENT TALK TIME AND STATUS")."\"\n"; $CSV_text1.="\"\",\""._QXZ("STATUS")."\",\""._QXZ("COUNT")."\",\""._QXZ("HOURS:MM:SS")."\"\n"; - $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_log where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status group by status order by status"; + $stmt="SELECT count(*),status, sum(length_in_sec) from ".$vicidial_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status group by status order by status"; $rslt=mysql_to_mysqli($stmt, $link); $VLstatuses_to_print = mysqli_num_rows($rslt); $total_calls=0; @@ -540,7 +591,7 @@ else $o++; } - $stmt="SELECT count(*),status, sum(length_in_sec) from vicidial_closer_log where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status group by status order by status"; + $stmt="SELECT count(*),status, sum(length_in_sec) from ".$vicidial_closer_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status group by status order by status"; $rslt=mysql_to_mysqli($stmt, $link); $VCLstatuses_to_print = mysqli_num_rows($rslt); $o=0; @@ -611,7 +662,7 @@ else $CSV_text2.="\""._QXZ("AGENT LOGIN/LOGOUT TIME")."\"\n"; $CSV_text2.="\"\",\""._QXZ("EVENT")."\",\""._QXZ("DATE")."\",\""._QXZ("CAMPAIGN")."\",\""._QXZ("GROUP")."\",\""._QXZ("HOURS:MM:SS")."\",\""._QXZ("SESSION")."\",\""._QXZ("SERVER")."\",\""._QXZ("PHONE")."\",\""._QXZ("COMPUTER")."\",\""._QXZ("PHONE_LOGIN")."\",\""._QXZ("PHONE_IP")."\"\n"; - $stmt="SELECT event,event_epoch,event_date,campaign_id,user_group,session_id,server_ip,extension,computer_ip,phone_login,phone_ip from vicidial_user_log where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date;"; + $stmt="SELECT event,event_epoch,event_date,campaign_id,user_group,session_id,server_ip,extension,computer_ip,phone_login,phone_ip from ".$vicidial_user_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date;"; $rslt=mysql_to_mysqli($stmt, $link); $events_to_print = mysqli_num_rows($rslt); @@ -715,7 +766,7 @@ else $CSV_text3.="\""._QXZ("TIMECLOCK LOGIN/LOGOUT TIME")."\"\n"; $CSV_text3.="\"\",\""._QXZ("ID")."\",\""._QXZ("EDIT")."\",\""._QXZ("EVENT")."\",\""._QXZ("DATE")."\",\""._QXZ("IPADDRESS")."\",\""._QXZ("GROUP")."\",\""._QXZ("HOURS:MM:SS")."\"\n"; - $stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from vicidial_timeclock_log where user='" . mysqli_real_escape_string($link, $user) . "' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';"; + $stmt="SELECT event,event_epoch,user_group,login_sec,ip_address,timeclock_id,manager_user from ".$vicidial_timeclock_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and event_epoch >= '$SQepoch' and event_epoch <= '$EQepoch';"; if ($DB>0) {$MAIN.="|$stmt|";} $rslt=mysql_to_mysqli($stmt, $link); $events_to_print = mysqli_num_rows($rslt); @@ -799,7 +850,7 @@ else $CSV_text4.="\""._QXZ("CLOSER IN-GROUP SELECTION LOGS")."\"\n"; $CSV_text4.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("CAMPAIGN")."\",\""._QXZ("BLEND")."\",\""._QXZ("GROUPS")."\",\""._QXZ("MANAGER")."\"\n"; - $stmt="SELECT user,campaign_id,event_date,blended,closer_campaigns,manager_change from vicidial_user_closer_log where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date desc limit 1000;"; + $stmt="SELECT user,campaign_id,event_date,blended,closer_campaigns,manager_change from ".$vicidial_user_closer_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date desc limit 1000;"; $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -846,10 +897,10 @@ else else {$CSV_text5.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("LENGTH")."\",\""._QXZ("STATUS")."\",\""._QXZ("PHONE")."\",\""._QXZ("CAMPAIGN")."\",\""._QXZ("GROUP")."\",\""._QXZ("LIST")."\",\""._QXZ("LEAD")."\",\""._QXZ("HANGUP REASON")."\"\n";} - $stmt="SELECT uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from vicidial_log where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status order by call_date desc limit 10000;"; + $stmt="SELECT uniqueid,lead_id,list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,status,phone_code,phone_number,user,comments,processed,user_group,term_reason,alt_dial from ".$vicidial_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status order by call_date desc limit 10000;"; if ($firstlastname_display_user_stats > 0) { - $stmt="SELECT uniqueid,vlog.lead_id,vlog.list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,vlog.status,vlog.phone_code,vlog.phone_number,vlog.user,vlog.comments,processed,user_group,term_reason,alt_dial,first_name,last_name from vicidial_log vlog, vicidial_list vlist where vlog.user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' and vlog.lead_id=vlist.lead_id $VLquery_call_status order by call_date desc limit 10000;"; + $stmt="SELECT uniqueid,vlog.lead_id,vlog.list_id,campaign_id,call_date,start_epoch,end_epoch,length_in_sec,vlog.status,vlog.phone_code,vlog.phone_number,vlog.user,vlog.comments,processed,user_group,term_reason,alt_dial,first_name,last_name from ".$vicidial_log_table." vlog, vicidial_list vlist where vlog.user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' and vlog.lead_id=vlist.lead_id $VLquery_call_status order by call_date desc limit 10000;"; } if ($DB) {$MAIN.="outbound calls|$stmt|";} $rslt=mysql_to_mysqli($stmt, $link); @@ -925,7 +976,7 @@ else $CSV_text5.="\""._QXZ("OUTBOUND EMAILS FOR THIS TIME PERIOD: (10000 record limit)")."\"\n"; $CSV_text5.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("USER")."\",\""._QXZ("CAMPAIGN")."\",\""._QXZ("EMAIL TO")."\",\""._QXZ("ATTACHMENT")."\",\""._QXZ("LEAD")."\",\""._QXZ("MESSAGE")."\"\n"; - $stmt="SELECT email_log_id,email_row_id,lead_id,email_date,user,email_to,message,campaign_id,attachments from vicidial_email_log where user='" . mysqli_real_escape_string($link, $user) . "' and email_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and email_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by email_date desc limit 10000;"; + $stmt="SELECT email_log_id,email_row_id,lead_id,email_date,user,email_to,message,campaign_id,attachments from ".$vicidial_email_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and email_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and email_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by email_date desc limit 10000;"; $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -985,16 +1036,16 @@ else $CSV_text6.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("LENGTH")."\",\""._QXZ("STATUS")."\",\""._QXZ("PHONE")."\",\""._QXZ("CAMPAIGN")."\",\""._QXZ("WAIT(S)")."\",\""._QXZ("AGENT(S)")."\",\""._QXZ("LIST")."\",\""._QXZ("LEAD")."\",\""._QXZ("HANGUP REASON")."\"\n"; } - $stmt="SELECT call_date,length_in_sec,status,phone_number,campaign_id,queue_seconds,list_id,lead_id,term_reason,closecallid from vicidial_closer_log where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status order by call_date desc limit 10000;"; + $stmt="SELECT call_date,length_in_sec,status,phone_number,campaign_id,queue_seconds,list_id,lead_id,term_reason,closecallid from ".$vicidial_closer_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $query_call_status order by call_date desc limit 10000;"; if ($did > 0) { - $stmt="SELECT start_time,length_in_sec,0,caller_code,0,0,0,extension,0,0 from call_log where channel_group='DID_INBOUND' and number_dialed='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by start_time desc limit 10000;"; + $stmt="SELECT start_time,length_in_sec,0,caller_code,0,0,0,extension,0,0 from ".$call_log_table." where channel_group='DID_INBOUND' and number_dialed='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by start_time desc limit 10000;"; } else { if ($firstlastname_display_user_stats > 0) { - $stmt="SELECT call_date,length_in_sec,vlog.status,vlog.phone_number,campaign_id,queue_seconds,vlog.list_id,vlog.lead_id,term_reason,closecallid,first_name,last_name from vicidial_closer_log vlog, vicidial_list vlist where vlog.user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' and vlog.lead_id=vlist.lead_id $VLquery_call_status order by call_date desc limit 10000;"; + $stmt="SELECT call_date,length_in_sec,vlog.status,vlog.phone_number,campaign_id,queue_seconds,vlog.list_id,vlog.lead_id,term_reason,closecallid,first_name,last_name from ".$vicidial_closer_log_table." vlog, vicidial_list vlist where vlog.user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' and vlog.lead_id=vlist.lead_id $VLquery_call_status order by call_date desc limit 10000;"; } } if ($DB) {$MAIN.="inbound calls|$stmt|";} @@ -1095,7 +1146,7 @@ else $CSV_text7.="\""._QXZ("AGENT ACTIVITY FOR THIS TIME PERIOD: (10000 record limit)")."\"\n"; $CSV_text7.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("PAUSE")."\",\""._QXZ("WAIT")."\",\""._QXZ("TALK")."\",\""._QXZ("DISPO")."\",\""._QXZ("DEAD")."\",\""._QXZ("CUSTOMER")."\",\""._QXZ("STATUS")."\",\""._QXZ("LEAD")."\",\""._QXZ("CAMPAIGN")."\",\""._QXZ("PAUSE CODE")."\"\n"; - $stmt="SELECT event_time,lead_id,campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,status,sub_status,user_group from vicidial_agent_log where user='" . mysqli_real_escape_string($link, $user) . "' and event_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' and ( (pause_sec > 0) or (wait_sec > 0) or (talk_sec > 0) or (dispo_sec > 0) ) $query_call_status order by event_time desc limit 10000;"; + $stmt="SELECT event_time,lead_id,campaign_id,pause_sec,wait_sec,talk_sec,dispo_sec,dead_sec,status,sub_status,user_group from ".$vicidial_agent_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and event_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' and ( (pause_sec > 0) or (wait_sec > 0) or (talk_sec > 0) or (dispo_sec > 0) ) $query_call_status order by event_time desc limit 10000;"; if ($DB) {$MAIN.="agent activity|$stmt|";} $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -1225,7 +1276,7 @@ else $CS_vicidial_id_list_SQL = "and vicidial_id IN($CS_vicidial_id_list)"; } - $stmt="SELECT recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from recording_log where user='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $CS_vicidial_id_list_SQL order by recording_id desc limit 10000;"; + $stmt="SELECT recording_id,channel,server_ip,extension,start_time,start_epoch,end_time,end_epoch,length_in_sec,length_in_min,filename,location,lead_id,user,vicidial_id from ".$recording_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and start_time >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and start_time <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' $CS_vicidial_id_list_SQL order by recording_id desc limit 10000;"; $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -1302,7 +1353,7 @@ else $CSV_text9.="\""._QXZ("MANUAL OUTBOUND CALLS FOR THIS TIME PERIOD: (10000 record limit)")."\"\n"; $CSV_text9.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("CALL TYPE")."\",\""._QXZ("SERVER")."\",\""._QXZ("PHONE")."\",\""._QXZ("DIALED")."\",\""._QXZ("LEAD")."\",\""._QXZ("CALLERID")."\",\""._QXZ("ALIAS")."\",\""._QXZ("PRESET")."\",\""._QXZ("C3HU")."\"\n"; - $stmt="SELECT call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id,preset_name,customer_hungup,customer_hungup_seconds from user_call_log where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by call_date desc limit 10000;"; + $stmt="SELECT call_date,call_type,server_ip,phone_number,number_dialed,lead_id,callerid,group_alias_id,preset_name,customer_hungup,customer_hungup_seconds from ".$user_call_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and call_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and call_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by call_date desc limit 10000;"; $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -1384,7 +1435,7 @@ else $CSV_text10.="\""._QXZ("LEAD SEARCHES FOR THIS TIME PERIOD: (10000 record limit)")."\"\n"; $CSV_text10.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("TYPE")."\",\""._QXZ("RESULTS")."\",\""._QXZ("SEC")."\",\""._QXZ("QUERY")."\"\n"; - $stmt="SELECT event_date,source,results,seconds,search_query from vicidial_lead_search_log where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date desc limit 10000;"; + $stmt="SELECT event_date,source,results,seconds,search_query from ".$vicidial_lead_search_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date desc limit 10000;"; $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt); @@ -1425,7 +1476,7 @@ else $CSV_text11.="\""._QXZ("PREVIEW LEAD SKIPS FOR THIS TIME PERIOD: (10000 record limit)")."\"\n"; $CSV_text11.="\"\",\"#\",\""._QXZ("DATE/TIME")."\",\""._QXZ("LEAD ID")."\",\""._QXZ("STATUS")."\",\""._QXZ("COUNT")."\",\""._QXZ("CAMPAIGN")."\"\n"; - $stmt="SELECT user,event_date,lead_id,campaign_id,previous_status,previous_called_count from vicidial_agent_skip_log where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date desc limit 10000;"; + $stmt="SELECT user,event_date,lead_id,campaign_id,previous_status,previous_called_count from ".$vicidial_agent_skip_log_table." where user='" . mysqli_real_escape_string($link, $user) . "' and event_date >= '" . mysqli_real_escape_string($link, $begin_date) . " 0:00:01' and event_date <= '" . mysqli_real_escape_string($link, $end_date) . " 23:59:59' order by event_date desc limit 10000;"; $rslt=mysql_to_mysqli($stmt, $link); $logs_to_print = mysqli_num_rows($rslt);