diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi index c242a515..0dc5c5f9 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -4114,6 +4114,14 @@ if ($drop_timer > $DROP_TIME) $dbhP=$dbhA; $mysql_count='01051'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id"; &agi_output;} + if ( ($DBdrop_call_seconds < 0) && ($drop_action =~ /IN_GROUP/) ) + { + $stmtA = "INSERT IGNORE INTO vicidial_shared_drops (callerid,server_ip,campaign_id,status,lead_id,uniqueid,channel,phone_code,phone_number,call_time,call_type,stage,last_update_time,alt_dial,drop_time) SELECT callerid,server_ip,campaign_id,status,lead_id,uniqueid,channel,phone_code,phone_number,call_time,call_type,stage,last_update_time,alt_dial,now() from vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "-- SHARED drop record inserted: |$affected_rows|$VDADcampaign|"; &agi_output;} + } + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='01052'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl index cc5fb938..e3e51cd5 100644 --- a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl @@ -15,7 +15,7 @@ # - Auto reset lists at defined times # - Auto restarts Asterisk process if enabled in servers settings # -# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # CHANGES # 61011-1348 - First build @@ -144,9 +144,10 @@ # 200623-2304 - Added Answer Signal options # 201123-1651 - Added reset of vicidial_lead_call_daily_counts table # 201218-2054 - Added reset of vicidial_agent_dial_campaigns table +# 210207-1200 - Added purging of vicidial_shared_log log entries # -$build = '201218-2054'; +$build = '210207-1200'; $DB=0; # Debug flag $teodDB=0; # flag to log Timeclock End of Day processes to log file @@ -1343,6 +1344,12 @@ if ($timeclock_end_of_day_NOW > 0) $affected_rows = $dbhA->do($stmtA); if($DB){print STDERR "\n|$affected_rows vicidial_auto_calls old records deleted|\n";} if ($teodDB) {$event_string = "vicidial_auto_calls old records deleted($TDSQLdate): $affected_rows"; &teod_logger;} + + $stmtA = "delete from vicidial_shared_drops where last_update_time < \"$TDSQLdate\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$affected_rows vicidial_shared_drops old records deleted|\n";} + if ($teodDB) {$event_string = "vicidial_shared_drops old records deleted($TDSQLdate): $affected_rows"; &teod_logger;} } $stmtA = "optimize table vicidial_live_inbound_agents;"; @@ -1372,6 +1379,15 @@ if ($timeclock_end_of_day_NOW > 0) if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} $sthA->finish(); + $stmtA = "optimize table vicidial_shared_drops;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + @aryA = $sthA->fetchrow_array; + if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} + $sthA->finish(); + $stmtA = "update vicidial_user_list_new_lead SET new_count=0;"; if($DBX){print STDERR "\n|$stmtA|\n";} $affected_rows = $dbhA->do($stmtA); @@ -1901,6 +1917,24 @@ if ($timeclock_end_of_day_NOW > 0) ##### END vicidial_security_event_log end of day process removing records older than 7 days ##### + ##### BEGIN vicidial_shared_log end of day process removing records older than 7 days ##### + $stmtA = "DELETE from vicidial_shared_log where log_time < \"$SDSQLdate\";"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + if($DB){print STDERR "\n|$affected_rows vicidial_shared_log records older than 7 days purged|\n";} + if ($teodDB) {$event_string = "vicidial_shared_log records older than 7 days purged: |$stmtA|$affected_rows|"; &teod_logger;} + + $stmtA = "optimize table vicidial_shared_log;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + @aryA = $sthA->fetchrow_array; + if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} + $sthA->finish(); + ##### END vicidial_shared_log end of day process removing records older than 7 days ##### + + ##### BEGIN vicidial_lead_messages end of day process removing records older than 1 day ##### $stmtA = "DELETE FROM vicidial_lead_messages WHERE call_date < \"$RMSQLdate\";"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; diff --git a/agc_2-X/trunk/bin/AST_VDadapt.pl b/agc_2-X/trunk/bin/AST_VDadapt.pl index 49206223..4c6539af 100644 --- a/agc_2-X/trunk/bin/AST_VDadapt.pl +++ b/agc_2-X/trunk/bin/AST_VDadapt.pl @@ -6,7 +6,7 @@ # adjusts the auto_dial_level for vicidial adaptive-predictive campaigns. # gather call stats for campaigns and in-groups # -# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # 60823-1302 - First build from AST_VDhopper.pl @@ -54,8 +54,10 @@ # 200811-1600 - Include live agents from other campaigns if they have the campaign Drop-InGroup selected and drop sec < 0 # 201106-2141 - Added calculation and caching of park_log stats per campaign/in-group # 201214-0857 - Added SHARED_ campaign agent rotation functions +# 210207-1205 - Added more logging and debug code for SHARED agent campaigns # +$build='210207-1205'; # constants $DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute $US='__'; @@ -2381,6 +2383,12 @@ sub shared_agent_process $stmtA = "UPDATE vicidial_campaign_stats_debug SET entry_time='$now_date',debug_output='$debug_shared_output' where campaign_id='--ALL--' and server_ip='SHARED';"; $affected_rows = $dbhA->do($stmtA); + if ($SSallow_shared_dial > 1) + { + $stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$SHARED_agents_ct',total_calls='0',debug_output='BUILD: $build\n$debug_shared_output',campaign_id='--ALL--',server_ip='SHARED';"; + $affected_rows = $dbhA->do($stmtA); + } + ### If there are active SHARED_ campaigns and agents set to take calls from the drop-in-groups of those campaigns, then start processing SHARED_ agents if ( ($SHARED_campaigns_ct > 0) and ($SHARED_agents_ct > 0) ) { @@ -2446,6 +2454,7 @@ sub shared_agent_process $cp_ct=0; $agent_shared_output .= "\nSHARED Campaigns:\n"; + $total_shared_calls_counter=0; while($SHARED_campaigns_ct > $cp_ct) { $shared_camp_output="$SHARED_campaigns[$cp_ct] Drop In-Group: $SHARED_campaigns_drop_ig[$cp_ct] Shared Agents: $SHARED_campaigns_agnt_ct[$cp_ct] (Dial Agents: $SHARED_campaigns_agnt_dl[$cp_ct])"; @@ -2455,12 +2464,37 @@ sub shared_agent_process $stmtA = "UPDATE vicidial_campaign_stats_debug SET entry_time='$now_date',adapt_output='$shared_camp_output' where campaign_id='$SHARED_campaigns[$cp_ct]' and server_ip='SHARED';"; $affected_rows = $dbhA->do($stmtA); + ### see how many total VDAD calls are going on right now for this shared campaign + $temp_calls_counter=0; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where campaign_id IN('$SHARED_campaigns_drop_ig[$cp_ct]','$SHARED_campaigns[$cp_ct]') and status IN('SENT','RINGING','LIVE','XFER','CLOSER','IVR');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $temp_calls_counter = $aryA[0]; + $total_shared_calls_counter = ($total_shared_calls_counter + $temp_calls_counter); + } + $sthA->finish(); + + if ($SSallow_shared_dial > 1) + { + $stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$SHARED_campaigns_agnt_dl[$cp_ct]',total_calls='$temp_calls_counter',adapt_output='BUILD: $build\n$shared_camp_output',campaign_id='$SHARED_campaigns[$cp_ct]',server_ip='SHARED';"; + $affected_rows = $dbhA->do($stmtA); + } $cp_ct++; } # update debug output $stmtA = "UPDATE vicidial_campaign_stats_debug SET entry_time='$now_date',adapt_output='$agent_shared_output' where campaign_id='--ALL--' and server_ip='SHARED';"; $affected_rows = $dbhA->do($stmtA); + + if ($SSallow_shared_dial > 1) + { + $stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$SHARED_agents_ct',total_calls='$total_shared_calls_counter',adapt_output='BUILD: $build\n$agent_shared_output',campaign_id='--ALL--',server_ip='SHARED';"; + $affected_rows = $dbhA->do($stmtA); + } } } } diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index 4094924c..f5fd3a91 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -25,7 +25,7 @@ # It is good practice to keep this program running by placing the associated # KEEPALIVE script running every minute to ensure this program is always running # -# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # CHANGELOG: # 50125-1201 - Changed dial timeout to 120 seconds from 180 seconds @@ -136,8 +136,10 @@ # 200825-0032 - Include live agents from other campaigns if they have the campaign Drop-InGroup selected and drop sec < 0 # 201122-0928 - Added code for dialy call count limits # 201218-2224 - Added code for SHARED agent campaigns +# 210207-0952 - Added more logging, debug code and fixes for SHARED agent campaigns # +$build='210207-0952'; ### begin parsing run-time options ### if (length($ARGV[0])>1) { @@ -255,6 +257,7 @@ if (!$JAMdebugFILE) {$JAMdebugFILE = "$PATHlogs/vdad-JAM.$year-$mon-$mday";} use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second use Time::Local; +use POSIX; use DBI; ### connect to MySQL database defined in the conf file @@ -308,7 +311,7 @@ $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### -$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,outbound_autodial_active,queuemetrics_loginout,queuemetrics_addmember_enabled,queuemetrics_pause_type,enable_drop_lists,call_quota_lead_ranking,timeclock_end_of_day FROM system_settings;"; +$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,outbound_autodial_active,queuemetrics_loginout,queuemetrics_addmember_enabled,queuemetrics_pause_type,enable_drop_lists,call_quota_lead_ranking,timeclock_end_of_day,allow_shared_dial FROM system_settings;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -328,6 +331,7 @@ if ($sthArows > 0) $enable_drop_lists = $aryA[10]; $SScall_quota_lead_ranking = $aryA[11]; $timeclock_end_of_day = $aryA[12]; + $allow_shared_dial = $aryA[13]; } $sthA->finish(); ##### END QUEUEMETRICS LOGGING LOOKUP ##### @@ -395,6 +399,7 @@ while($one_day_interval > 0) @DBlive_campaign_rank=@MT; @DBlive_campaign_sort=@MT; @DBlive_campaign_sorted=@MT; + @DBlive_campaign_level=@MT; @DBlive_dial_campaign=@MT; @DBlive_conf_exten=@MT; @DBlive_status=@MT; @@ -460,6 +465,7 @@ while($one_day_interval > 0) @DBIPdrop_inbound_group=@MT; @DBshare_camp=@MT; @DBshare_camp_rank=@MT; + @DBshare_dial_level=@MT; $active_line_counter=0; $user_counter=0; $user_campaigns = '|'; @@ -521,12 +527,22 @@ while($one_day_interval > 0) ############################################# ##### Gather SHARED campaigns info $debug_shared_output=''; + $initial_debug_shared_output=''; $shared_SQL=''; $shared_callsTOTAL=0; $shared_callsSERVER=0; + $shared_dropsTOTAL=0; + $shared_dropsSERVER=0; + $shared_agentsTOTAL=0; + $shared_agentsSERVER=0; + $share_dial_level_total=0; + $share_dial_level_average=0; + $share_dial_max=0; + $shared_campaigns_list='|'; + $agent_shared_campaigns_ct=0; if ($allow_shared_dial > 0) { - $stmtA = "SELECT campaign_id,drop_inbound_group,shared_dial_rank FROM vicidial_campaigns where active='Y' and dial_method IN('SHARED_RATIO','SHARED_ADAPT_HARD_LIMIT','SHARED_ADAPT_TAPERED','SHARED_ADAPT_AVERAGE') order by shared_dial_rank desc;"; + $stmtA = "SELECT campaign_id,drop_inbound_group,shared_dial_rank,auto_dial_level FROM vicidial_campaigns where active='Y' and dial_method IN('SHARED_RATIO','SHARED_ADAPT_HARD_LIMIT','SHARED_ADAPT_TAPERED','SHARED_ADAPT_AVERAGE') order by shared_dial_rank desc;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -536,15 +552,26 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $DBshare_camp[$rec_count] = $aryA[0]; $DBshare_camp_rank[$rec_count] = $aryA[2]; + $DBshare_dial_level[$rec_count] = $aryA[3]; + $shared_campaigns_list .= "$aryA[0]|"; if (length($DBshare_camp_rank[$rec_count])<2) {$DBshare_camp_rank[$rec_count] = "0$DBshare_camp_rank[$rec_count]";} $shared_SQL .= "'$aryA[0]','$aryA[1]',"; - $debug_shared_output .= "$aryA[0] Drop-In-Group: $aryA[1] Shared-Rank: $DBshare_camp_rank[$rec_count]\n"; + $debug_shared_output .= "$aryA[0] Drop-In-Group: $aryA[1] Shared-Rank: $DBshare_camp_rank[$rec_count] Dial Level: $DBshare_dial_level[$rec_count]\n"; $rec_count++; } chop($shared_SQL); if (length($shared_SQL)<2) {$shared_SQL="'-NONE-'";} + $stmtA = "SELECT count(*) FROM vicidial_shared_drops where campaign_id IN($shared_SQL) and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $shared_dropsTOTAL = $aryA[0]; + } $stmtA = "SELECT count(*) FROM vicidial_auto_calls where campaign_id IN($shared_SQL);"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -552,9 +579,18 @@ while($one_day_interval > 0) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $shared_callsTOTAL = $aryA[0]; + $shared_callsTOTAL = ($aryA[0] + $shared_dropsTOTAL); } + $stmtA = "SELECT count(*) FROM vicidial_shared_drops where campaign_id IN($shared_SQL) and server_ip='$VARserver_ip' and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $shared_dropsSERVER = $aryA[0]; + } $stmtA = "SELECT count(*) FROM vicidial_auto_calls where campaign_id IN($shared_SQL) and server_ip='$VARserver_ip';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -562,15 +598,34 @@ while($one_day_interval > 0) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $shared_callsSERVER = $aryA[0]; + $shared_callsSERVER = ($aryA[0] + $shared_dropsSERVER); } - $event_string="SHARED-AGENT CAMPAIGNS ON SYSTEM: $rec_count TOTAL CALLS: $shared_callsTOTAL SERVER CALLS: $shared_callsSERVER"; + $stmtA = "SELECT count(*) FROM vicidial_live_agents where dial_campaign_id IN($shared_SQL) and status IN($active_agents) and outbound_autodial='Y' and last_update_time > '$BDtsSQLdate' order by last_call_time"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $shared_agentsTOTAL = $aryA[0]; + } + + $stmtA = "SELECT count(*) FROM vicidial_live_agents where dial_campaign_id IN($shared_SQL) and status IN($active_agents) and outbound_autodial='Y' and server_ip='$server_ip' and last_update_time > '$BDtsSQLdate' order by last_call_time"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $shared_agentsSERVER = $aryA[0]; + } + + $event_string="SHARED-AGENT CAMPAIGNS ON SYSTEM: $rec_count TOTAL CALLS: $shared_callsTOTAL($shared_dropsTOTAL) SERVER CALLS: $shared_callsSERVER($shared_dropsSERVER)\n TOTAL AGENTS: $shared_agentsTOTAL SERVER AGENTS: $shared_agentsSERVER"; + $debug_shared_output .= "$event_string\n"; &event_logger; - # update debug output - $stmtA = "UPDATE vicidial_campaign_stats_debug SET entry_time='$now_date',debug_output='$event_string\n$debug_shared_output' where campaign_id='-SHARE-' and server_ip='$VARserver_ip';"; - $affected_rows = $dbhA->do($stmtA); + $initial_debug_shared_output = $debug_shared_output; } $debug_shared_output=''; @@ -594,6 +649,7 @@ while($one_day_interval > 0) $DBlive_last_call_epoch[$user_counter] = $aryA[7]; $DBlive_campaign_rank[$user_counter] = 0; $DBlive_campaign_sort[$user_counter] = 0; + $DBlive_campaign_level[$user_counter] = 0; if (length($DBlive_dial_campaign[$user_counter]) > 0) { @@ -615,6 +671,7 @@ while($one_day_interval > 0) if ($DBlive_campaign[$user_counter] eq $DBshare_camp[$temp_ct]) { $DBlive_campaign_rank[$user_counter] = $DBshare_camp_rank[$temp_ct]; + $DBlive_campaign_level[$user_counter] = $DBshare_dial_level[$temp_ct]; } $temp_ct++; } @@ -623,6 +680,11 @@ while($one_day_interval > 0) if ($campaigns_update !~ /'$DBlive_campaign[$user_counter]'/) {$campaigns_update .= "'$DBlive_campaign[$user_counter]',"; $CPcount++;} $user_campaigns .= "$DBlive_campaign[$user_counter]|"; $user_campaignsSQL .= ",'$DBlive_campaign[$user_counter]'"; + if ( ($allow_shared_dial > 0) && ($shared_campaigns_list =~ /\|$DBlive_campaign[$user_counter]\|/i) ) + { + $share_dial_level_total = ($share_dial_level_total + $DBlive_campaign_level[$user_counter]); + $agent_shared_campaigns_ct++; + } $DBcampaigns[$user_campaigns_counter] = $DBlive_campaign[$user_counter]; $user_campaigns_counter++; } @@ -643,6 +705,19 @@ while($one_day_interval > 0) $sthA->finish(); ### see how many total VDAD calls are going on right now for max limiter + $temp_dropsSERVER=0; + if ($allow_shared_dial > 0) + { + $stmtA = "SELECT count(*) FROM vicidial_shared_drops where status IN('SENT','RINGING','LIVE','XFER','CLOSER','IVR') and server_ip='$VARserver_ip' and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $temp_dropsSERVER = $aryA[0]; + } + } $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$server_ip' and status IN('SENT','RINGING','LIVE','XFER','CLOSER','IVR');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -650,7 +725,7 @@ while($one_day_interval > 0) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $active_line_counter = $aryA[0]; + $active_line_counter = ($aryA[0] + $temp_dropsSERVER); } $sthA->finish(); @@ -665,6 +740,63 @@ while($one_day_interval > 0) &event_logger; } + ### Calculate maximum share campaigns total calls and log debug shared campaign output + if ($allow_shared_dial > 0) + { + if ( ($user_campaigns_counter > 0) && ($share_dial_level_total > 0) ) + { + $share_dial_level_average = ($share_dial_level_total / $agent_shared_campaigns_ct); + $share_dial_max = ($share_dial_level_average * $shared_agentsTOTAL); + $share_dial_max = ceil($share_dial_max); + } + $temp_max_warning=''; + if ($shared_callsTOTAL > $share_dial_max) + { + $max_debug_string=''; + if ($allow_shared_dial > 2) + { + $stmtA = "SELECT callerid,server_ip,campaign_id,status,lead_id,phone_number,call_time,call_type FROM vicidial_shared_drops where campaign_id IN($shared_SQL) and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $temp_ct=0; + while ($sthArows > $temp_ct) + { + @aryA = $sthA->fetchrow_array; + $temp_ct++; + $max_debug_string .= "SD $temp_ct $aryA[0] $aryA[1] $aryA[2] $aryA[3] $aryA[4] $aryA[5] $aryA[6] $aryA[7]\n"; + } + $stmtA = "SELECT callerid,server_ip,campaign_id,status,lead_id,phone_number,call_time,call_type FROM vicidial_auto_calls where campaign_id IN($shared_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $temp_ct=0; + while ($sthArows > $temp_ct) + { + @aryA = $sthA->fetchrow_array; + $temp_ct++; + $max_debug_string .= " $temp_ct $aryA[0] $aryA[1] $aryA[2] $aryA[3] $aryA[4] $aryA[5] $aryA[6] $aryA[7]\n"; + } + } + + $temp_max_warning = "\nSHARED MAX OVER LIMIT! $shared_callsTOTAL > $share_dial_max \n$max_debug_string"; + } + + $event_string="SHARED-AGENT CAMPAIGNS DIAL LEVEL LIMITS: Shared campaigns with active agents: $agent_shared_campaigns_ct DL AVG: $share_dial_level_average SHARED MAX CALLS: $share_dial_max$temp_max_warning"; + $initial_debug_shared_output .= "$event_string\n"; + &event_logger; + + # update debug output + $stmtA = "UPDATE vicidial_campaign_stats_debug SET entry_time='$now_date',debug_output='$initial_debug_shared_output' where campaign_id='-SHARE-' and server_ip='$VARserver_ip';"; + $affected_rows = $dbhA->do($stmtA); + + if ($allow_shared_dial > 1) + { + $stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$shared_agentsSERVER',total_calls='$shared_callsSERVER',debug_output='BUILD: $build\n$initial_debug_shared_output',campaign_id='-SHARE-',server_ip='$VARserver_ip';"; + $affected_rows = $dbhA->do($stmtA); + } + } + ### sort campaigns by shared campaign rank, then last agent call handle time @DBIPcampaign_sorted = sort { $a cmp $b } @DBIPcampaign_sort; @@ -961,11 +1093,14 @@ while($one_day_interval > 0) {$DBIPcount[$user_CIPct]=0;} $DBIPgoalcalls[$user_CIPct] = ($DBIPadlevel[$user_CIPct] * $DBIPcount[$user_CIPct]); + $tally_xfer_line_counter=0; + $temp_drop_IG=''; + if ($DBIPdrop_action[$user_CIPct] =~ /IN_GROUP/i) + {$temp_drop_IG=",'$DBIPdrop_inbound_group[$user_CIPct]'";} if ($active_only > 0) { - $tally_xfer_line_counter=0; ### see how many VDAD calls are live as XFERs to agents - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and campaign_id='$DBIPcampaign[$user_CIPct]' and status IN('XFER','CLOSER');"; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and campaign_id IN('$DBIPcampaign[$user_CIPct]'$temp_drop_IG) and status IN('XFER','CLOSER');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1135,14 +1270,28 @@ while($one_day_interval > 0) } } - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type IN('OUT','OUTBALANCE')) and server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER','CLOSER');"; + $temp_dropsSERVER=0; + if ($allow_shared_dial > 0) + { + $stmtA = "SELECT count(*) FROM vicidial_shared_drops where (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type IN('OUT','OUTBALANCE')) and server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER','CLOSER') and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $temp_dropsSERVER = $aryA[0]; + } + } + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where (campaign_id IN('$DBIPcampaign[$user_CIPct]'$temp_drop_IG) and call_type IN('IN','OUT','OUTBALANCE')) and server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER','CLOSER');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; + if ($DBX) {print "$sthArows|$stmtA\n";} if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $DBIPexistcalls_OUT[$user_CIPct] = $aryA[0]; + $DBIPexistcalls_OUT[$user_CIPct] = ($aryA[0] + $temp_dropsSERVER); } $sthA->finish(); @@ -1204,10 +1353,53 @@ while($one_day_interval > 0) } } + $sharedMAX_msg=''; if ($DBIPmakecalls[$user_CIPct] > 0) - {$active_line_counter = ($DBIPmakecalls[$user_CIPct] + $active_line_counter);} + { + $active_line_counter = ($DBIPmakecalls[$user_CIPct] + $active_line_counter); - $event_string="$user_CIPct_sort $user_CIPct $DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct] [$DBIPexistcalls_IN[$user_CIPct] + $DBIPexistcalls_OUT[$user_CIPct]|$DBIPexistcalls_IN_ALL[$user_CIPct]|$DBIPexistcalls_IN_LIVE[$user_CIPct]|$DBIPexistcalls_QUEUE_LIVE[$user_CIPct]]) $active_line_counter $MVT_msg"; + if ($DBIPdial_method[$user_CIPct] =~ /SHARED_/i) + { + $temp_shared_make_calls = ($shared_callsTOTAL + $DBIPmakecalls[$user_CIPct]); + if ($temp_shared_make_calls > $share_dial_max) + { + $temp_goal_diff = ($temp_shared_make_calls - $share_dial_max); + $new_goal_calls = ($DBIPmakecalls[$user_CIPct] - $temp_goal_diff); + if ($new_goal_calls < 0) {$new_goal_calls=0;} + $sharedMAX_msg = "\nSHARED MAX CALLS EXCEEDED! Shared Calls: $shared_callsTOTAL Shared Max: $share_dial_max Camp Goal Calls: $DBIPmakecalls[$user_CIPct] New Goal Calls: $new_goal_calls"; + $DBIPmakecalls[$user_CIPct] = $new_goal_calls; + } + } + } + + $max_debug_string=''; + if ($allow_shared_dial > 2) + { + $stmtA = "SELECT callerid,server_ip,campaign_id,status,lead_id,phone_number,call_time,call_type FROM vicidial_shared_drops where campaign_id IN($shared_SQL) and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $temp_ct=0; + while ($sthArows > $temp_ct) + { + @aryA = $sthA->fetchrow_array; + $temp_ct++; + $max_debug_string .= "SD $temp_ct $aryA[0] $aryA[1] $aryA[2] $aryA[3] $aryA[4] $aryA[5] $aryA[6] $aryA[7]\n"; + } + $stmtA = "SELECT callerid,server_ip,campaign_id,status,lead_id,phone_number,call_time,call_type FROM vicidial_auto_calls where campaign_id IN($shared_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $temp_ct=0; + while ($sthArows > $temp_ct) + { + @aryA = $sthA->fetchrow_array; + $temp_ct++; + $max_debug_string .= " $temp_ct $aryA[0] $aryA[1] $aryA[2] $aryA[3] $aryA[4] $aryA[5] $aryA[6] $aryA[7]\n"; + } + } + + $event_string="$user_CIPct_sort $user_CIPct $DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct] [$DBIPexistcalls_IN[$user_CIPct] + $DBIPexistcalls_OUT[$user_CIPct]|$DBIPexistcalls_IN_ALL[$user_CIPct]|$DBIPexistcalls_IN_LIVE[$user_CIPct]|$DBIPexistcalls_QUEUE_LIVE[$user_CIPct]]) $active_line_counter $MVT_msg $sharedMAX_msg \n$max_debug_string"; $debug_string .= "$event_string\n"; &event_logger; @@ -1252,6 +1444,19 @@ while($one_day_interval > 0) else {$waiting_calls_IN=0;} + $temp_dropsTOTAL=0; + if ($allow_shared_dial > 0) + { + $stmtA = "SELECT count(*) FROM vicidial_shared_drops where (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type IN('OUT','OUTBALANCE')) and status IN('LIVE') and drop_time > \"$FVtsSQLdate\";"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $temp_dropsTOTAL = $aryA[0]; + } + } $stmtA = "SELECT count(*) FROM vicidial_auto_calls where (campaign_id='$DBIPcampaign[$user_CIPct]' and call_type IN('OUT','OUTBALANCE')) and status IN('LIVE');"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1259,25 +1464,24 @@ while($one_day_interval > 0) if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $waiting_calls_OUT = $aryA[0]; + $waiting_calls_OUT = ($aryA[0] + $temp_dropsTOTAL); } $sthA->finish(); # check for drop-ingroup calls active in the system if ( ($DBIPdrop_call_seconds[$user_CIPct] < 0) && ($DBIPdrop_action[$user_CIPct] =~ /IN_GROUP/i) && ($DBIPdrop_inbound_group[$user_CIPct] !~ /^---NONE---$/) && (length($DBIPdrop_inbound_group[$user_CIPct]) > 0) && ($new_agent_multicampaign > 0) ) { - $stmtA = "SELECT count(*) FROM vicidial_auto_calls where (campaign_id='$DBIPdrop_inbound_group[$user_CIPct]' and call_type IN('IN','OUT','OUTBALANCE')) and status IN('LIVE');"; + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where (campaign_id='$DBIPdrop_inbound_group[$user_CIPct]' and call_type IN('IN','OUT','OUTBALANCE')) and ( (status IN('LIVE')) or ( (status IN('CLOSER')) and (call_time > \"$FVtsSQLdate\") ) );"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $event_string=" $DBIPcampaign[$user_CIPct] Drop In-Group calls: $aryA[0] ($waiting_calls_OUT)\n"; + $waiting_calls_OUT = ($aryA[0] + $waiting_calls_OUT); + $event_string=" $DBIPcampaign[$user_CIPct] Drop In-Group calls: $aryA[0] (New Waiting Calls: $waiting_calls_OUT)\n"; $debug_string .= "$event_string\n"; &event_logger; - - $waiting_calls_OUT = ($aryA[0] + $waiting_calls_OUT); } $sthA->finish(); } @@ -1373,6 +1577,12 @@ while($one_day_interval > 0) $stmtA="INSERT IGNORE INTO vicidial_campaign_stats_debug SET server_ip='$server_ip',campaign_id='$DBIPcampaign[$user_CIPct]',entry_time='$now_date',debug_output='$debug_string' ON DUPLICATE KEY UPDATE entry_time='$now_date',debug_output='$debug_string';"; $affected_rows = $dbhA->do($stmtA); + if ($allow_shared_dial > 1) + { + $stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$total_agents',total_calls='$waiting_calls_OUT',debug_output='DIALING PROCESS DEBUG OUTPUT:\n$event_string\n$debug_string',server_ip='$server_ip',campaign_id='$DBIPcampaign[$user_CIPct]';"; + $affected_rows = $dbhA->do($stmtA); + } + $user_CIPct_sort++; } @@ -1411,7 +1621,16 @@ while($one_day_interval > 0) $call_CMPIPct=0; $lead_id_call_list='|'; my $UDaffected_rows=0; - if ($call_CMPIPct < $DBIPmakecalls[$user_CIPct]) + + $shared_clear=1; + if ( ($DBIPdial_method[$user_CIPct] =~ /SHARED_/i) && ($shared_callsTOTAL > $share_dial_max) ) + { + $event_string="SHARED CAMPAIGN DIAL MAX EXCEEDED, NO DIALING! ($shared_callsTOTAL > $share_dial_max)"; + &event_logger; + $shared_clear=0; + } + + if ( ($call_CMPIPct < $DBIPmakecalls[$user_CIPct]) && ($shared_clear > 0) ) { $stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$server_ip' where campaign_id='$DBIPcampaign[$user_CIPct]' and status='READY' order by priority desc,hopper_id LIMIT $DBIPmakecalls[$user_CIPct]"; print "|$stmtA|\n"; @@ -1930,6 +2149,7 @@ while($one_day_interval > 0) @KLstatus = @MT; @KLcalltime = @MT; $kill_vac=0; + $dead_call_ct=0; $stmtA = "SELECT callerid,server_ip,channel,uniqueid,status,call_time FROM vicidial_auto_calls where server_ip='$server_ip' order by call_time;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -2956,10 +3176,6 @@ while($one_day_interval > 0) } } ##### END AUTO ALT PHONE DIAL SECTION ##### - - - - } else { @@ -2973,12 +3189,13 @@ while($one_day_interval > 0) $event_string = "| M dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|$CLcall_type|$CLlast_update_time < $XDtarget|$affected_rowsX|"; &event_logger; - + $dead_call_ct++; } else { $event_string = "| dead call vac XFERd do nothing|$CLlead_id|$CLphone_number|$CLstatus|"; &event_logger; + $dead_call_ct++; } } } @@ -2986,6 +3203,7 @@ while($one_day_interval > 0) { $event_string = "| dead call vac INBOUND do nothing|$CLlead_id|$CLphone_number|$CLstatus|"; &event_logger; + $dead_call_ct++; } } } @@ -3248,6 +3466,17 @@ while($one_day_interval > 0) } } + + ### Delete old shared campaign drop records + $stmtA = "DELETE FROM vicidial_shared_drops where server_ip='$server_ip' and drop_time < \"$BDtsSQLdate\";"; + $SDaffected_rows = $dbhA->do($stmtA); + if ($SDaffected_rows > 0) + { + $event_string = "| old shared drop records DELETED $SDaffected_rows|$BDtsSQLdate|"; + &event_logger; + } + + ### For debugging purposes, try to grab Jammed calls and log them to jam logfile if ($useJAMdebugFILE) { @@ -4616,6 +4845,15 @@ while($one_day_interval > 0) # update debug output $stmtA = "UPDATE vicidial_campaign_stats_debug SET entry_time='$now_date',adapt_output='$debug_shared_output' where campaign_id='-SHARE-' and server_ip='$VARserver_ip';"; $affected_rows = $dbhA->do($stmtA); + + if ($allow_shared_dial > 1) + { + $temp_dead_debug=''; + if ($dead_call_ct > 0) + {$temp_dead_debug="DEAD Call Count: $dead_call_ct";} + $stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$shared_dial_camp_override',debug_output='BUILD: $build\n$debug_shared_output$temp_dead_debug',campaign_id='-SHARE-',server_ip='$VARserver_ip';"; + $affected_rows = $dbhA->do($stmtA); + } } @@ -4685,6 +4923,17 @@ sub get_time_now #get the current date and time and epoch for logging call lengt $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; while (length($CIDdate) > 9) {$CIDdate =~ s/^.//gi;} # 0902235959 changed to 902235959 + $FVtarget = ($secX - 5); + ($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime($FVtarget); + $Fyear = ($Fyear + 1900); + $Fmon++; + if ($Fmon < 10) {$Fmon = "0$Fmon";} + if ($Fmday < 10) {$Fmday = "0$Fmday";} + if ($Fhour < 10) {$Fhour = "0$Fhour";} + if ($Fmin < 10) {$Fmin = "0$Fmin";} + if ($Fsec < 10) {$Fsec = "0$Fsec";} + $FVtsSQLdate = "$Fyear-$Fmon-$Fmday $Fhour:$Fmin:$Fsec"; + $BDtarget = ($secX - 10); ($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget); $Byear = ($Byear + 1900); diff --git a/agc_2-X/trunk/docs/AGENT_MULTI-CAMPAIGN_DIALING.txt b/agc_2-X/trunk/docs/AGENT_MULTI-CAMPAIGN_DIALING.txt index a998b557..ffb8375e 100644 --- a/agc_2-X/trunk/docs/AGENT_MULTI-CAMPAIGN_DIALING.txt +++ b/agc_2-X/trunk/docs/AGENT_MULTI-CAMPAIGN_DIALING.txt @@ -1,4 +1,4 @@ -AGENT MULTI-CAMPAIGN DIALING DOC Started: 2020-08-24 Updated: 2021-01-02 +AGENT MULTI-CAMPAIGN DIALING DOC Started: 2020-08-24 Updated: 2021-02-07 NOTE: Requires VICIdial svn/trunk code revision 3284 or higher to work properly!!! @@ -130,7 +130,9 @@ How a "SHARED_..." dial methods work: 2. Change the dialing algorithm(for campaigns with a "SHARED_" dial method only) to prevent over-dialing as agents are rotated from dialing-campaign to dialing-campaign. 3. The agent-dialing-campaign-rotation process attempts to balance agents by time(round-robin-like) across the campaigns that they are assigned to take calls from. 4. New database fields/tables were added to store the temporary dialing campaign designations for each agent and what other campaigns they had just been assigned to -5. Add shared debug output to existing Admin Utilities "Campaign Debug Report" that will show everything that is going on for shared campaigns in the process of agent rotation and shared outbound dialing +5. Added shared debug output to existing Admin Utilities "Campaign Debug Report" that will show everything that is going on for shared campaigns in the process of agent rotation and shared outbound dialing +6. Added optional debugging and a new "vicidial_shared_log" DB table as well as "Shared Debug Page" to help with troubleshooting of the SHARED dialing processes + *NOTE: the optional extra debugging is enabled by changing the "Shared Agent Campaign Dialing" System Setting to '2' or higher. Agent rotation steps, added to the AST_VDadapt.pl script: (see new database changes below for details on the DB storage of this data) - runs once every 1 minute @@ -191,14 +193,14 @@ The following are instructions for how to set up a "SHARED_" set of campaigns: * NOTES: - The "SHARED_..." campaign dial method does not require the use of Remote Agents at all, and the live agents do need to select to take blended (outbound) calls or no calls will be placed for them as they rotate through the shared agent campaigns. -- For SHARED agent campaigns, there will be an additional campaign setting: "Shared Dial Rank", which will allow you to prioritize the dialing of your shared campaigns as calls are placed for them. +- For SHARED agent campaigns, there is an additional campaign setting: "Shared Dial Rank", which will allow you to prioritize the dialing of your shared campaigns as calls are placed for them. DATABASE CHANGES: !!!!!! FOR DOCUMENTATION PURPOSES ONLY !!!!! -ALTER TABLE system_settings ADD allow_shared_dial ENUM('0','1') default '0'; +ALTER TABLE system_settings ADD allow_shared_dial ENUM('0','1','2','3','4','5','6') default '0'; ALTER TABLE vicidial_campaigns ADD shared_dial_rank TINYINT(3) default '99'; ALTER TABLE vicidial_campaigns MODIFY dial_method ENUM('MANUAL','RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE','INBOUND_MAN','SHARED_RATIO','SHARED_ADAPT_HARD_LIMIT','SHARED_ADAPT_TAPERED','SHARED_ADAPT_AVERAGE') default 'MANUAL'; @@ -217,3 +219,35 @@ index (campaign_id) CREATE UNIQUE INDEX vadc_key on vicidial_agent_dial_campaigns(campaign_id, user); +CREATE TABLE vicidial_shared_log ( +campaign_id VARCHAR(20) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +log_time DATETIME, +total_agents SMALLINT(5) default '0', +total_calls SMALLINT(5) default '0', +debug_output TEXT, +adapt_output TEXT, +index (campaign_id), +index (log_time) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_shared_drops ( +callerid VARCHAR(20), +server_ip VARCHAR(15) NOT NULL, +campaign_id VARCHAR(20), +status ENUM('SENT','RINGING','LIVE','XFER','PAUSED','CLOSER','BUSY','DISCONNECT','IVR') default 'PAUSED', +lead_id INT(9) UNSIGNED NOT NULL, +uniqueid VARCHAR(20), +channel VARCHAR(100), +phone_code VARCHAR(10), +phone_number VARCHAR(18), +call_time DATETIME, +call_type ENUM('IN','OUT','OUTBALANCE') default 'OUT', +stage VARCHAR(20) default 'START', +last_update_time DATETIME, +alt_dial VARCHAR(6) default 'NONE', +drop_time DATETIME, +index (callerid), +index (call_time), +index (drop_time) +) ENGINE=MyISAM; diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 585f897e..105ed21e 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -1883,7 +1883,7 @@ enable_international_dncs ENUM('0','1') default '0', web_loader_phone_strip VARCHAR(10) default 'DISABLED', manual_dial_phone_strip VARCHAR(10) default 'DISABLED', daily_call_count_limit ENUM('0','1') default '0', -allow_shared_dial ENUM('0','1') default '0', +allow_shared_dial ENUM('0','1','2','3','4','5','6') default '0', agent_search_method ENUM('0','1','2','3','4','5','6') default '0' ) ENGINE=MyISAM; @@ -4378,6 +4378,39 @@ index (campaign_id) CREATE UNIQUE INDEX vadc_key on vicidial_agent_dial_campaigns(campaign_id, user); +CREATE TABLE vicidial_shared_log ( +campaign_id VARCHAR(20) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +log_time DATETIME, +total_agents SMALLINT(5) default '0', +total_calls SMALLINT(5) default '0', +debug_output TEXT, +adapt_output TEXT, +index (campaign_id), +index (log_time) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_shared_drops ( +callerid VARCHAR(20), +server_ip VARCHAR(15) NOT NULL, +campaign_id VARCHAR(20), +status ENUM('SENT','RINGING','LIVE','XFER','PAUSED','CLOSER','BUSY','DISCONNECT','IVR') default 'PAUSED', +lead_id INT(9) UNSIGNED NOT NULL, +uniqueid VARCHAR(20), +channel VARCHAR(100), +phone_code VARCHAR(10), +phone_number VARCHAR(18), +call_time DATETIME, +call_type ENUM('IN','OUT','OUTBALANCE') default 'OUT', +stage VARCHAR(20) default 'START', +last_update_time DATETIME, +alt_dial VARCHAR(6) default 'NONE', +drop_time DATETIME, +index (callerid), +index (call_time), +index (drop_time) +) ENGINE=MyISAM; + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; @@ -4711,4 +4744,4 @@ INSERT INTO vicidial_settings_containers VALUES ('INTERNATIONAL_DNC_IMPORT','Pro UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1615',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1616',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql index 2eae5a54..32e8bfb4 100644 --- a/agc_2-X/trunk/extras/upgrade_2.14.sql +++ b/agc_2-X/trunk/extras/upgrade_2.14.sql @@ -1365,7 +1365,7 @@ ALTER TABLE vicidial_campaigns ADD transfer_button_launch VARCHAR(12) default 'N UPDATE system_settings SET db_schema_version='1613',db_schema_update_date=NOW() where db_schema_version < 1613; -ALTER TABLE system_settings ADD allow_shared_dial ENUM('0','1') default '0'; +ALTER TABLE system_settings ADD allow_shared_dial ENUM('0','1','2','3','4','5','6') default '0'; ALTER TABLE vicidial_campaigns ADD shared_dial_rank TINYINT(3) default '99'; ALTER TABLE vicidial_campaigns MODIFY dial_method ENUM('MANUAL','RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVERAGE','INBOUND_MAN','SHARED_RATIO','SHARED_ADAPT_HARD_LIMIT','SHARED_ADAPT_TAPERED','SHARED_ADAPT_AVERAGE') default 'MANUAL'; @@ -1393,3 +1393,40 @@ ALTER TABLE vicidial_campaigns ADD agent_search_method VARCHAR(2) default ''; ALTER TABLE vicidial_inbound_groups ADD agent_search_method VARCHAR(2) default ''; UPDATE system_settings SET db_schema_version='1615',db_schema_update_date=NOW() where db_schema_version < 1615; + +ALTER TABLE system_settings MODIFY allow_shared_dial ENUM('0','1','2','3','4','5','6') default '0'; + +CREATE TABLE vicidial_shared_log ( +campaign_id VARCHAR(20) NOT NULL, +server_ip VARCHAR(15) NOT NULL, +log_time DATETIME, +total_agents SMALLINT(5) default '0', +total_calls SMALLINT(5) default '0', +debug_output TEXT, +adapt_output TEXT, +index (campaign_id), +index (log_time) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_shared_drops ( +callerid VARCHAR(20), +server_ip VARCHAR(15) NOT NULL, +campaign_id VARCHAR(20), +status ENUM('SENT','RINGING','LIVE','XFER','PAUSED','CLOSER','BUSY','DISCONNECT','IVR') default 'PAUSED', +lead_id INT(9) UNSIGNED NOT NULL, +uniqueid VARCHAR(20), +channel VARCHAR(100), +phone_code VARCHAR(10), +phone_number VARCHAR(18), +call_time DATETIME, +call_type ENUM('IN','OUT','OUTBALANCE') default 'OUT', +stage VARCHAR(20) default 'START', +last_update_time DATETIME, +alt_dial VARCHAR(6) default 'NONE', +drop_time DATETIME, +index (callerid), +index (call_time), +index (drop_time) +) ENGINE=MyISAM; + +UPDATE system_settings SET db_schema_version='1616',db_schema_update_date=NOW() where db_schema_version < 1616; diff --git a/agc_2-X/trunk/www/vicidial/AST_dial_log_report.php b/agc_2-X/trunk/www/vicidial/AST_dial_log_report.php index 9516f14f..3292b4fd 100644 --- a/agc_2-X/trunk/www/vicidial/AST_dial_log_report.php +++ b/agc_2-X/trunk/www/vicidial/AST_dial_log_report.php @@ -195,6 +195,7 @@ else } ############# +$query_date = preg_replace('/[^-_0-9a-zA-Z]/', '', $query_date); if ($non_latin < 1) { diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index d0039cc4..c2c4c537 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -122,7 +122,7 @@ $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; $QUERY_STRING = getenv("QUERY_STRING"); -$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Callmenu Survey Report, Outbound Lead Source Report, Fronter - Closer Report, Fronter - Closer Detail Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Inbound Status Summary, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Group Detail Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Carrier Log Report, Campaign Debug, Asterisk Debug, Hangup Cause Report, Lists Pass Report, Called Counts List IDs Report, Agent Debug Log Report, Agent Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring Log Report, AMD Log Report, SIP Event Report, Caller ID Log Report'; +$Vreports = 'NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Callmenu Survey Report, Outbound Lead Source Report, Fronter - Closer Report, Fronter - Closer Detail Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Inbound Status Summary, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Group Detail Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Carrier Log Report, Campaign Debug, Shared Debug, Asterisk Debug, Hangup Cause Report, Lists Pass Report, Called Counts List IDs Report, Agent Debug Log Report, Agent Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring Log Report, AMD Log Report, SIP Event Report, Caller ID Log Report'; $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summary, Real-Time Whiteboard Report, Inbound Report, Inbound Report by DID, Inbound Service Level Report, Inbound Summary Hourly Report, Inbound Daily Report, Inbound DID Report, Inbound DID Summary Report, Agent DID Report, Inbound Email Report, Inbound Chat Report, Inbound IVR Report, Inbound Forecasting Report, Advanced Forecasting Report, Outbound Calling Report, Outbound Summary Interval Report, Outbound IVR Report, Callmenu Survey Report, Outbound Lead Source Report, Fronter - Closer Report, Fronter - Closer Detail Report, Lists Campaign Statuses Report, Lists Statuses Report, Campaign Status List Report, Export Calls Report, Export Leads Report, Agent Time Detail, Agent Status Detail, Agent Inbound Status Summary, Agent Performance Detail, Team Performance Detail, Performance Comparison Report, Single Agent Daily, Single Agent Daily Time, User Group Login Report, User Group Hourly Report, User Group Detail Hourly Report, User Timeclock Report, User Group Timeclock Status Report, User Timeclock Detail Report, Server Performance Report, Administration Change Log, List Update Stats, User Stats, User Time Sheet, Download List, Dialer Inventory Report, Custom Reports Links, CallCard Search, Maximum System Stats, Maximum Stats Detail, Search Leads Logs, Email Log Report, Lists Pass Report, Called Counts List IDs Report, Front Page System Summary, Report Page Servers Summary, Admin Utilities Page, Agent Debug Log Report, Agent Parked Call Report, Agent-Manager Chat Log, Recording Access Log Report, API Log Report, Real-Time Monitoring Log Report, AMD Log Report, SIP Event Report, Caller ID Log Report'; @@ -5432,12 +5432,13 @@ if ($SSscript_remove_js > 0) # 210102-1651 - Added SHARED agent features for outbound dialing campaigns # 210103-0856 - Added agent_search_method override settings # 210124-0947 - Added copy_user Non-Agent API function +# 210207-0915 - Added Shared Debug Page to admin utilities # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-784a'; -$build = '210124-0947'; +$admin_version = '2.14-785a'; +$build = '210207-0915'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -39784,7 +39785,7 @@ if ($ADD==311111111111111) echo ""._QXZ("Outbound Auto-Dial Active").": $NWB#settings-outbound_autodial_active$NWE\n"; - echo ""._QXZ("Shared Agent Campaign Dialing").": $NWB#settings-allow_shared_dial$NWE\n"; + echo ""._QXZ("Shared Agent Campaign Dialing").": $NWB#settings-allow_shared_dial$NWE\n"; echo ""._QXZ("Agent Search Method Override").": $NWB#settings-agent_search_method$NWE\n"; @@ -44949,6 +44950,7 @@ if ($ADD==999994) echo "
  • "._QXZ("Servers Versions")."\n"; echo "

    \n"; echo "
  • "._QXZ("Campaign Debug Page")."\n"; + echo "
  • "._QXZ("Shared Debug Page")."\n"; echo "
  • "._QXZ("Dial Log Report")."\n"; echo "
  • "._QXZ("Carrier Log Report")."\n"; echo "
  • "._QXZ("Caller ID Log Report")."\n"; diff --git a/agc_2-X/trunk/www/vicidial/shared_debug.php b/agc_2-X/trunk/www/vicidial/shared_debug.php new file mode 100644 index 00000000..3e26ef6f --- /dev/null +++ b/agc_2-X/trunk/www/vicidial/shared_debug.php @@ -0,0 +1,388 @@ + LICENSE: AGPLv2 +# +# CHANGES +# 210207-0913 - First build +# + +$startMS = microtime(); + +$report_name='Shared Debug'; + +require("dbconnect_mysqli.php"); +require("functions.php"); + +$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; +$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; +$PHP_SELF=$_SERVER['PHP_SELF']; +if (isset($_GET["DB"])) {$DB=$_GET["DB"];} + elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} +if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} + elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} +if (isset($_GET["query_date_T"])) {$query_date_T=$_GET["query_date_T"];} + elseif (isset($_POST["query_date_T"])) {$query_date_T=$_POST["query_date_T"];} +if (isset($_GET["stage"])) {$stage=$_GET["stage"];} + elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} +if (isset($_GET["submit"])) {$submit=$_GET["submit"];} + elseif (isset($_POST["submit"])) {$submit=$_POST["submit"];} +if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} + elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} + +############################################# +##### START SYSTEM_SETTINGS LOOKUP ##### +$stmt = "SELECT use_non_latin,webroot_writable,outbound_autodial_active,user_territories_active,enable_languages,language_method,allow_shared_dial FROM system_settings;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$qm_conf_ct = mysqli_num_rows($rslt); +if ($qm_conf_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $non_latin = $row[0]; + $webroot_writable = $row[1]; + $SSoutbound_autodial_active = $row[2]; + $user_territories_active = $row[3]; + $SSenable_languages = $row[4]; + $SSlanguage_method = $row[5]; + $SSallow_shared_dial = $row[6]; + } +##### END SETTINGS LOOKUP ##### +########################################### + +$query_date = preg_replace('/[^-_0-9a-zA-Z]/', '', $query_date); +$query_date_T = preg_replace('/[^- \:_0-9a-zA-Z]/', '', $query_date_T); +$stage = preg_replace('/[^-_0-9a-zA-Z]/', '', $stage); + +if ($non_latin < 1) + { + $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); + $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); + } +else + { + $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); + $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); + } + +$stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$sl_ct = mysqli_num_rows($rslt); +if ($sl_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VUselected_language = $row[0]; + } + +$auth=0; +$reports_auth=0; +$admin_auth=0; +$auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'',1,0); +if ($auth_message == 'GOOD') + {$auth=1;} + +if ($auth > 0) + { + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $admin_auth=$row[0]; + + $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $reports_auth=$row[0]; + + if ($reports_auth < 1) + { + $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ( ($reports_auth > 0) and ($admin_auth < 1) ) + { + $ADD=999999; + $reports_only_user=1; + } + } +else + { + $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); + if ($auth_message == 'LOCK') + { + $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } + Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; + exit; + } + +$stmt="SELECT modify_campaigns,user_group from vicidial_users where user='$PHP_AUTH_USER';"; +$rslt=mysql_to_mysqli($stmt, $link); +$row=mysqli_fetch_row($rslt); +$LOGmodify_campaigns = $row[0]; +$LOGuser_group = $row[1]; + +if ($LOGmodify_campaigns < 1) + { + Header ("Content-type: text/html; charset=utf-8"); + echo _QXZ("You do not have permissions for campaign debugging").": |$PHP_AUTH_USER|\n"; + exit; + } + + +##### BEGIN log visit to the vicidial_report_log table ##### +$LOGip = getenv("REMOTE_ADDR"); +$LOGbrowser = getenv("HTTP_USER_AGENT"); +$LOGscript_name = getenv("SCRIPT_NAME"); +$LOGserver_name = getenv("SERVER_NAME"); +$LOGserver_port = getenv("SERVER_PORT"); +$LOGrequest_uri = getenv("REQUEST_URI"); +$LOGhttp_referer = getenv("HTTP_REFERER"); +$LOGbrowser=preg_replace("/\'|\"|\\\\/","",$LOGbrowser); +$LOGrequest_uri=preg_replace("/\'|\"|\\\\/","",$LOGrequest_uri); +$LOGhttp_referer=preg_replace("/\'|\"|\\\\/","",$LOGhttp_referer); +if (preg_match("/443/i",$LOGserver_port)) {$HTTPprotocol = 'https://';} + else {$HTTPprotocol = 'http://';} +if (($LOGserver_port == '80') or ($LOGserver_port == '443') ) {$LOGserver_port='';} +else {$LOGserver_port = ":$LOGserver_port";} +$LOGfull_url = "$HTTPprotocol$LOGserver_name$LOGserver_port$LOGrequest_uri"; + +$LOGhostname = php_uname('n'); +if (strlen($LOGhostname)<1) {$LOGhostname='X';} +if (strlen($LOGserver_name)<1) {$LOGserver_name='X';} + +$stmt="SELECT webserver_id FROM vicidial_webservers where webserver='$LOGserver_name' and hostname='$LOGhostname' LIMIT 1;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$webserver_id_ct = mysqli_num_rows($rslt); +if ($webserver_id_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $webserver_id = $row[0]; + } +else + { + ##### insert webserver entry + $stmt="INSERT INTO vicidial_webservers (webserver,hostname) values('$LOGserver_name','$LOGhostname');"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $affected_rows = mysqli_affected_rows($link); + $webserver_id = mysqli_insert_id($link); + } + +$stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name', url='$LOGfull_url', webserver='$webserver_id';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_to_mysqli($stmt, $link); +$report_log_id = mysqli_insert_id($link); +##### END log visit to the vicidial_report_log table ##### + +if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) + { + mysqli_close($link); + $use_slave_server=1; + $db_source = 'S'; + require("dbconnect_mysqli.php"); + $MAIN.="\n"; + } + +$NOW_DATE = date("Y-m-d"); +$NOW_TIME = date("Y-m-d H:i:s"); +$STARTtime = date("U"); +if (!isset($query_date)) {$query_date = $NOW_DATE;} +if (!isset($server_ip)) {$server_ip = '10.10.10.15';} + +?> + + + + + +\n"; + echo ""._QXZ("Shared Debug Detail Start")."\n"; + echo "
    \n";
    +	echo "
    \n"; + echo "\n"; + exit; + } +if ($stage == 'detail') + { + echo "\n"; + echo ""._QXZ("Shared Debug Detail")."\n"; + echo "
    \n";
    +		echo _QXZ("Shared Agent Campaign Log Entries").":     $query_date_T\n";
    +
    +	$stmt="select log_time,campaign_id,server_ip,total_agents,total_calls,debug_output,adapt_output from vicidial_shared_log where log_time='$query_date_T' and ( (debug_output!='') or (adapt_output!='') ) order by log_time desc,server_ip desc,campaign_id,total_agents limit 1000;";
    +	$rslt=mysql_to_mysqli($stmt, $link);
    +	if ($DB) {echo "$stmt\n";}
    +	$debugs_to_print = mysqli_num_rows($rslt);
    +	$i=0;
    +	while ($debugs_to_print > $i)
    +		{
    +		$row=mysqli_fetch_row($rslt);
    +		echo "Time:     $row[0]\n";
    +		echo "Campaign: $row[1]\n";
    +		echo "Server:   $row[2]\n";
    +		echo "Agents:   $row[3]\n";
    +		echo "Calls:    $row[4]\n";
    +		if (strlen($row[5])>0) {echo "Debug1:   $row[5]\n";}
    +		if (strlen($row[6])>0) {echo "Debug2:   $row[6]\n";}
    +		echo "\n";
    +
    +		$i++;
    +		}
    +
    +	$old_log_time =	$query_date_T;
    +	$stmt="select log_time from vicidial_shared_log where log_time < \"$query_date_T\" and ( (debug_output!='') or (adapt_output!='') ) and campaign_id='--ALL--' order by log_time desc limit 1;";
    +	$rslt=mysql_to_mysqli($stmt, $link);
    +	if ($DB) {echo "$stmt\n";}
    +	$logs_to_print = mysqli_num_rows($rslt);
    +	if ($logs_to_print > 0)
    +		{
    +		$row=mysqli_fetch_row($rslt);
    +		$old_log_time =		$row[0];
    +		}
    +
    +	echo "\n"._QXZ("Older Shared Agent Campaign Log Entries").":     $row[0]\n\n";
    +
    +	$stmt="select log_time,campaign_id,server_ip,total_agents,total_calls,debug_output,adapt_output from vicidial_shared_log where log_time < \"$query_date_T\" and log_time > \"$old_log_time\" and ( (debug_output!='') or (adapt_output!='') ) order by log_time desc,server_ip desc,campaign_id,total_agents limit 10000;";
    +	$rslt=mysql_to_mysqli($stmt, $link);
    +	if ($DB) {echo "$stmt\n";}
    +	$debugs_to_print = mysqli_num_rows($rslt);
    +	$i=0;
    +	while ($debugs_to_print > $i)
    +		{
    +		$row=mysqli_fetch_row($rslt);
    +		echo "Time:     $row[0]\n";
    +		echo "Campaign: $row[1]\n";
    +		echo "Server:   $row[2]\n";
    +		echo "Agents:   $row[3]\n";
    +		echo "Calls:    $row[4]\n";
    +		if (strlen($row[5])>0) {echo "Debug1:   $row[5]\n";}
    +		if (strlen($row[6])>0) {echo "Debug2:   $row[6]\n";}
    +		echo "\n";
    +
    +		$i++;
    +		}
    +
    +	echo "
    \n"; + echo "\n"; + exit; + } +else + { + echo "\n"; + echo "\n"; + echo "\n"; + echo ""._QXZ("Shared Debug")."\n"; + + $short_header=1; + + require("admin_header.php"); + + echo "\n\n"; + echo "
    "; + echo "
    \n"; + echo ""; + echo "\n"; + echo "\n"; + echo "
    \n\n"; + echo "
    \n"; + + echo "
    \n\n";
    +
    +
    +	if (!$query_date)
    +		{
    +		echo "\n\n";
    +		echo _QXZ("PLEASE SELECT A DATE ABOVE AND CLICK SUBMIT")."\n";
    +		}
    +
    +	else
    +		{
    +		echo "\n";
    +		echo "---- "._QXZ("SHARED LOG ENTRIES").":\n     $NOW_TIME\n";
    +		echo "\n";
    +		echo "BUFFER ENTRIES\n";
    +
    +		$stmt="select distinct log_time,total_agents from vicidial_shared_log where log_time >= \"$query_date 00:00:00\" and log_time <= \"$query_date 23:59:59\" and ( (debug_output!='') or (adapt_output!='') ) and campaign_id='--ALL--' order by log_time desc limit 100000;";
    +		$rslt=mysql_to_mysqli($stmt, $link);
    +		if ($DB) {echo "$stmt\n";}
    +		$logs_to_print = mysqli_num_rows($rslt);
    +		$lct=0;
    +		while ($logs_to_print > $lct)
    +			{
    +			$row=mysqli_fetch_row($rslt);
    +			$log_time =			$row[0];
    +			$total_agents =		$row[1];
    +
    +			echo "$log_time - $total_agents\n";
    +			$lct++;
    +			}
    +		}
    +
    +	if ($db_source == 'S')
    +		{
    +		mysqli_close($link);
    +		$use_slave_server=0;
    +		$db_source = 'M';
    +		require("dbconnect_mysqli.php");
    +		}
    +
    +	$endMS = microtime();
    +	$startMSary = explode(" ",$startMS);
    +	$endMSary = explode(" ",$endMS);
    +	$runS = ($endMSary[0] - $startMSary[0]);
    +	$runM = ($endMSary[1] - $startMSary[1]);
    +	$TOTALrun = ($runS + $runM);
    +
    +	$stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';";
    +	if ($DB) {echo "|$stmt|\n";}
    +	$rslt=mysql_to_mysqli($stmt, $link);
    +
    +	?>
    +
    +	
    + +
    + +
    + + +