Added inbound_no_agents_no_dial campaign options

git-svn-id: svn://192.168.202.10@2898 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2018-01-31 05:08:15 +00:00
parent e665b55be8
commit 57b61c962e
7 changed files with 403 additions and 251 deletions
+4
View File
@@ -249,6 +249,10 @@ OTHER CHANGES:
65. Added "Anyone Callback Inactive Lists" System Setting option to determine
how ANYONE scheduled callbacks from inactive lists should be handled.
66. Added "Inbound No-Agents No-Dial" Campaign setting, checks if any agents are
ready and waiting for phone calls from listed In-Groups before allowing
outbound auto-dialing.
+328 -241
View File
@@ -125,6 +125,7 @@
# 170325-1106 - Added optional vicidial_drop_log logging
# 170527-2347 - Fix for rare inbound logging issue #1017
# 170915-1817 - Added support for per server routing prefix needed for Asterisk 13+
# 180130-1346 - Added inbound_no_agents_no_dial campaign options
#
### begin parsing run-time options ###
@@ -142,6 +143,7 @@ if (length($ARGV[0])>1)
print "allowed run time options:\n";
print " [-t] = test\n";
print " [-debug] = verbose debug messages\n";
print " [-debugX] = Extra verbose debug messages\n";
print " [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n";
print "\n";
exit;
@@ -163,6 +165,10 @@ if (length($ARGV[0])>1)
{
$DB=1; # Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute
}
if ($args =~ /-debugX/i)
{
$DBX=1; # Extra Debug flag, set to 0 for no debug messages, On an active system this will generate hundreds of lines of output per minute
}
if ($args =~ /-t/i)
{
$TEST=1;
@@ -383,6 +389,11 @@ while($one_day_interval > 0)
@DBIPdial_method=@MT;
@DBIPuse_custom_cid=@MT;
@DBIPinbound_queue_no_dial=@MT;
@DBIPinbound_no_agents_no_dial=@MT;
@DBIPinbound_no_agents_no_dial_threshold=@MT;
@DBIPinbound_no_agents_no_dial_trigger=@MT;
@DBIPinand_agent_ready_count=@MT;
@DBIPinand_users=@MT;
@DBIPavailable_only_tally=@MT;
@DBIPavailable_only_tally_threshold=@MT;
@DBIPavailable_only_tally_threshold_agents=@MT;
@@ -625,7 +636,7 @@ while($one_day_interval > 0)
### grab the dial_level and multiply by active agents to get your goalcalls
$DBIPadlevel[$user_CIPct]=0;
$stmtA = "SELECT auto_dial_level,local_call_time,dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,closer_campaigns,omit_phone_code,available_only_ratio_tally,auto_alt_dial,campaign_allow_inbound,queue_priority,dial_method,use_custom_cid,inbound_queue_no_dial,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,adaptive_dl_diff_target,dl_diff_target_method FROM vicidial_campaigns where campaign_id='$DBIPcampaign[$user_CIPct]'";
$stmtA = "SELECT auto_dial_level,local_call_time,dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,closer_campaigns,omit_phone_code,available_only_ratio_tally,auto_alt_dial,campaign_allow_inbound,queue_priority,dial_method,use_custom_cid,inbound_queue_no_dial,available_only_tally_threshold,available_only_tally_threshold_agents,dial_level_threshold,dial_level_threshold_agents,adaptive_dl_diff_target,dl_diff_target_method,inbound_no_agents_no_dial_container,inbound_no_agents_no_dial_threshold FROM vicidial_campaigns where campaign_id='$DBIPcampaign[$user_CIPct]'";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -658,6 +669,9 @@ while($one_day_interval > 0)
$DBIPdial_level_threshold_agents[$user_CIPct] = $aryA[19];
$DBIPadaptive_dl_diff_target[$user_CIPct] = $aryA[20];
$DBIPdl_diff_target_method[$user_CIPct] = $aryA[21];
$DBIPinbound_no_agents_no_dial[$user_CIPct] = $aryA[22];
$DBIPinbound_no_agents_no_dial_threshold[$user_CIPct] = $aryA[23];
if ($DBIPdl_diff_target_method[$user_CIPct] =~ /ADAPT_CALC_ONLY/)
{
if ( ($DBIPadaptive_dl_diff_target[$user_CIPct] < 0) || ($DBIPadaptive_dl_diff_target[$user_CIPct] > 0) )
@@ -812,6 +826,71 @@ while($one_day_interval > 0)
else
{$DBIPexistcalls_IN[$user_CIPct]=0;}
### Check for inbound no-agents no-dial
$DBIPinbound_no_agents_no_dial_trigger[$user_CIPct]=0;
if ($DBX)
{
print "INBOUND NO-AGENTS NO-DIAL CHECK START($DBIPcampaign[$user_CIPct]): $DBIPinbound_no_agents_no_dial[$user_CIPct]|$DBIPinbound_no_agents_no_dial_threshold[$user_CIPct]\n";
}
if ( ($DBIPinbound_no_agents_no_dial[$user_CIPct] !~ /DISABLED/) && (length($DBIPinbound_no_agents_no_dial[$user_CIPct]) > 0) && ($DBIPinbound_no_agents_no_dial_threshold[$user_CIPct] > 0) )
{
$DBIPinand_container_entry[$user_CIPct]='';
$stmtA = "SELECT container_entry FROM vicidial_settings_containers where container_id='$DBIPinbound_no_agents_no_dial[$user_CIPct]';";
$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;
$DBIPinand_container_entry[$user_CIPct] = $aryA[0];
$DBIPinand_container_entry[$user_CIPct] =~ s/\n/','/gi;
$DBIPinand_container_entry[$user_CIPct] =~ s/\r|\t| |''|,$|^,//gi;
$DBIPinand_container_entry[$user_CIPct] =~ s/,,/,/gi;
$DBIPinand_container_entry[$user_CIPct] =~ s/,''//gi;
$DBIPinand_container_entry[$user_CIPct] =~ s/','$//gi;
}
$sthA->finish();
if (length($DBIPinand_container_entry[$user_CIPct]) > 2)
{
$DBIPinbound_no_agents_no_dial_trigger[$user_CIPct]=1;
$DBIPinand_users[$user_CIPct]='';
$stmtA = "SELECT distinct(user) FROM vicidial_live_inbound_agents where group_id IN('$DBIPinand_container_entry[$user_CIPct]');";
$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;
$DBIPinand_users[$user_CIPct] .= "'$aryA[0]',";
$DBIPinand_users[$user_CIPct] =~ s/,$//gi;
}
$sthA->finish();
if (length($DBIPinand_users[$user_CIPct]) > 2)
{
$DBIPinand_agent_ready_count[$user_CIPct]=0;
$stmtA = "SELECT count(*) FROM vicidial_live_agents where user IN($DBIPinand_users[$user_CIPct]) and status IN('READY','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;
$DBIPinand_agent_ready_count[$user_CIPct] = $aryA[0];
if ($DBIPinand_agent_ready_count[$user_CIPct] >= $DBIPinbound_no_agents_no_dial_threshold[$user_CIPct])
{
$DBIPinbound_no_agents_no_dial_trigger[$user_CIPct]=0;
}
}
$sthA->finish();
}
}
}
$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');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -1042,281 +1121,289 @@ while($one_day_interval > 0)
}
else
{
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: CALLING";
&event_logger;
$call_CMPIPct=0;
$lead_id_call_list='|';
my $UDaffected_rows=0;
if ($call_CMPIPct < $DBIPmakecalls[$user_CIPct])
if ($DBIPinbound_no_agents_no_dial_trigger[$user_CIPct] > 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";
$UDaffected_rows = $dbhA->do($stmtA);
print "hopper rows updated to QUEUE: |$UDaffected_rows|\n";
if ($UDaffected_rows)
$event_string="$DBIPcampaign[$user_CIPct] ($DBIPinand_agent_ready_count[$user_CIPct] <> $DBIPinbound_no_agents_no_dial_threshold[$user_CIPct]) $DBIPinand_users[$user_CIPct] '$DBIPinand_container_entry[$user_CIPct]' $DBIPinbound_no_agents_no_dial_trigger[$user_CIPct]: INBOUND NO-AGENT NO DIAL, NO DIALING ($DBIPinbound_no_agents_no_dial[$user_CIPct])";
&event_logger;
}
else
{
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: CALLING";
&event_logger;
$call_CMPIPct=0;
$lead_id_call_list='|';
my $UDaffected_rows=0;
if ($call_CMPIPct < $DBIPmakecalls[$user_CIPct])
{
$lead_id=''; $phone_code=''; $phone_number=''; $called_count='';
while ($call_CMPIPct < $UDaffected_rows)
$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";
$UDaffected_rows = $dbhA->do($stmtA);
print "hopper rows updated to QUEUE: |$UDaffected_rows|\n";
if ($UDaffected_rows)
{
$stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBIPcampaign[$user_CIPct]' and status='QUEUE' and user='VDAD_$server_ip' order by priority desc,hopper_id LIMIT 1";
print "|$stmtA|\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
$rec_countCUSTDATA=0;
while ($sthArows > $rec_count)
$lead_id=''; $phone_code=''; $phone_number=''; $called_count='';
while ($call_CMPIPct < $UDaffected_rows)
{
@aryA = $sthA->fetchrow_array;
$lead_id = $aryA[0];
$alt_dial = $aryA[1];
$rec_count++;
}
$sthA->finish();
if ($lead_id_call_list =~ /\|$lead_id\|/)
{
print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n";
if ($SYSLOG)
{
open(DUPout, ">>$PATHlogs/VDAD_DUPLICATE.$file_date")
|| die "Can't open $PATHlogs/VDAD_DUPLICATE.$file_date: $!\n";
print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n";
close(DUPout);
}
}
else
{
$stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'";
print "|$stmtA|\n";
$UQaffected_rows = $dbhA->do($stmtA);
print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n";
### Gather lead data
$stmtA = "SELECT list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,address3,alt_phone,called_count,security_phrase FROM vicidial_list where lead_id='$lead_id';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
$rec_countCUSTDATA=0;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$list_id = $aryA[0];
$gmt_offset_now = $aryA[1];
$called_since_last_reset = $aryA[2];
$phone_code = $aryA[3];
$phone_number = $aryA[4];
$address3 = $aryA[5];
$alt_phone = $aryA[6];
$called_count = $aryA[7];
$security_phrase = $aryA[8];
$rec_countCUSTDATA++;
$rec_count++;
}
$sthA->finish();
if ($rec_countCUSTDATA)
{
$campaign_cid_override='';
### gather list_id overrides
$stmtA = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';";
$stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBIPcampaign[$user_CIPct]' and status='QUEUE' and user='VDAD_$server_ip' order by priority desc,hopper_id LIMIT 1";
print "|$stmtA|\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsL=$sthA->rows;
if ($sthArowsL > 0)
$sthArows=$sthA->rows;
$rec_count=0;
$rec_countCUSTDATA=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$campaign_cid_override = $aryA[0];
$lead_id = $aryA[0];
$alt_dial = $aryA[1];
$rec_count++;
}
$sthA->finish();
### update called_count
$called_count++;
if ($called_since_last_reset =~ /^Y/)
if ($lead_id_call_list =~ /\|$lead_id\|/)
{
print "!!!!!!!!!!!!!!!!duplicate lead_id for this run: |$lead_id| $lead_id_call_list\n";
if ($SYSLOG)
{
if ($called_since_last_reset =~ /^Y$/) {$CSLR = 'Y1';}
else
{
$called_since_last_reset =~ s/^Y//gi;
$called_since_last_reset++;
$CSLR = "Y$called_since_last_reset";
}
open(DUPout, ">>$PATHlogs/VDAD_DUPLICATE.$file_date")
|| die "Can't open $PATHlogs/VDAD_DUPLICATE.$file_date: $!\n";
print DUPout "$now_date-----$lead_id_call_list-----$lead_id\n";
close(DUPout);
}
else {$CSLR = 'Y';}
$LLCT_DATE_offset = ($LOCAL_GMT_OFF - $gmt_offset_now);
$LLCT_DATE_offset_epoch = ( $secX - ($LLCT_DATE_offset * 3600) );
($Lsec,$Lmin,$Lhour,$Lmday,$Lmon,$Lyear,$Lwday,$Lyday,$Lisdst) = localtime($LLCT_DATE_offset_epoch);
$Lyear = ($Lyear + 1900);
$Lmon++;
if ($Lmon < 10) {$Lmon = "0$Lmon";}
if ($Lmday < 10) {$Lmday = "0$Lmday";}
if ($Lhour < 10) {$Lhour = "0$Lhour";}
if ($Lmin < 10) {$Lmin = "0$Lmin";}
if ($Lsec < 10) {$Lsec = "0$Lsec";}
$LLCT_DATE = "$Lyear-$Lmon-$Lmday $Lhour:$Lmin:$Lsec";
}
else
{
$stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'";
print "|$stmtA|\n";
$UQaffected_rows = $dbhA->do($stmtA);
print "hopper row updated to INCALL: |$UQaffected_rows|$lead_id|\n";
if ( ($alt_dial =~ /ALT|ADDR3|X/) && ($DBIPautoaltdial[$user_CIPct] =~ /ALT|ADDR|X/) )
### Gather lead data
$stmtA = "SELECT list_id,gmt_offset_now,called_since_last_reset,phone_code,phone_number,address3,alt_phone,called_count,security_phrase FROM vicidial_list where lead_id='$lead_id';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
$rec_countCUSTDATA=0;
if ($sthArows > 0)
{
if ( ($alt_dial =~ /ALT/) && ($DBIPautoaltdial[$user_CIPct] =~ /ALT/) )
@aryA = $sthA->fetchrow_array;
$list_id = $aryA[0];
$gmt_offset_now = $aryA[1];
$called_since_last_reset = $aryA[2];
$phone_code = $aryA[3];
$phone_number = $aryA[4];
$address3 = $aryA[5];
$alt_phone = $aryA[6];
$called_count = $aryA[7];
$security_phrase = $aryA[8];
$rec_countCUSTDATA++;
$rec_count++;
}
$sthA->finish();
if ($rec_countCUSTDATA)
{
$campaign_cid_override='';
### gather list_id overrides
$stmtA = "SELECT campaign_cid_override FROM vicidial_lists where list_id='$list_id';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsL=$sthA->rows;
if ($sthArowsL > 0)
{
$alt_phone =~ s/\D//gi;
$phone_number = $alt_phone;
@aryA = $sthA->fetchrow_array;
$campaign_cid_override = $aryA[0];
}
if ( ($alt_dial =~ /ADDR3/) && ($DBIPautoaltdial[$user_CIPct] =~ /ADDR3/) )
$sthA->finish();
### update called_count
$called_count++;
if ($called_since_last_reset =~ /^Y/)
{
$address3 =~ s/\D//gi;
$phone_number = $address3;
}
if ( ($alt_dial =~ /X/) && ($DBIPautoaltdial[$user_CIPct] =~ /X/) )
{
if ($alt_dial =~ /LAST/)
{
$stmtA = "SELECT phone_code,phone_number FROM vicidial_list_alt_phones where lead_id='$lead_id' order by alt_phone_count desc limit 1;";
}
if ($called_since_last_reset =~ /^Y$/) {$CSLR = 'Y1';}
else
{
$Talt_dial = $alt_dial;
$Talt_dial =~ s/\D//gi;
$stmtA = "SELECT phone_code,phone_number FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Talt_dial';";
$called_since_last_reset =~ s/^Y//gi;
$called_since_last_reset++;
$CSLR = "Y$called_since_last_reset";
}
}
else {$CSLR = 'Y';}
$LLCT_DATE_offset = ($LOCAL_GMT_OFF - $gmt_offset_now);
$LLCT_DATE_offset_epoch = ( $secX - ($LLCT_DATE_offset * 3600) );
($Lsec,$Lmin,$Lhour,$Lmday,$Lmon,$Lyear,$Lwday,$Lyday,$Lisdst) = localtime($LLCT_DATE_offset_epoch);
$Lyear = ($Lyear + 1900);
$Lmon++;
if ($Lmon < 10) {$Lmon = "0$Lmon";}
if ($Lmday < 10) {$Lmday = "0$Lmday";}
if ($Lhour < 10) {$Lhour = "0$Lhour";}
if ($Lmin < 10) {$Lmin = "0$Lmin";}
if ($Lsec < 10) {$Lsec = "0$Lsec";}
$LLCT_DATE = "$Lyear-$Lmon-$Lmday $Lhour:$Lmin:$Lsec";
if ( ($alt_dial =~ /ALT|ADDR3|X/) && ($DBIPautoaltdial[$user_CIPct] =~ /ALT|ADDR|X/) )
{
if ( ($alt_dial =~ /ALT/) && ($DBIPautoaltdial[$user_CIPct] =~ /ALT/) )
{
$alt_phone =~ s/\D//gi;
$phone_number = $alt_phone;
}
if ( ($alt_dial =~ /ADDR3/) && ($DBIPautoaltdial[$user_CIPct] =~ /ADDR3/) )
{
$address3 =~ s/\D//gi;
$phone_number = $address3;
}
if ( ($alt_dial =~ /X/) && ($DBIPautoaltdial[$user_CIPct] =~ /X/) )
{
if ($alt_dial =~ /LAST/)
{
$stmtA = "SELECT phone_code,phone_number FROM vicidial_list_alt_phones where lead_id='$lead_id' order by alt_phone_count desc limit 1;";
}
else
{
$Talt_dial = $alt_dial;
$Talt_dial =~ s/\D//gi;
$stmtA = "SELECT phone_code,phone_number FROM vicidial_list_alt_phones where lead_id='$lead_id' and alt_phone_count='$Talt_dial';";
}
$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;
$phone_code = $aryA[0];
$phone_number = $aryA[1];
$phone_number =~ s/\D//gi;
}
$sthA->finish();
}
$stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR',called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'";
}
else
{
$stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'";
}
$affected_rows = $dbhA->do($stmtA);
$stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id'";
$affected_rows = $dbhA->do($stmtA);
$CCID_on=0; $CCID='';
$local_DEF = 'Local/';
$local_AMP = '@';
$Local_out_prefix = '9';
$Local_dial_timeout = '60';
if ($DBIPdialtimeout[$user_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$user_CIPct];}
$Local_dial_timeout = ($Local_dial_timeout * 1000);
if (length($DBIPdialprefix[$user_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$user_CIPct]";}
if (length($DBIPvdadexten[$user_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$user_CIPct]";}
else {$VDAD_dial_exten = "$answer_transfer_agent";}
# add the routing prefix if using Asterisk 13
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} > 11))
{
$VDAD_dial_exten = $routing_prefix . $VDAD_dial_exten;
}
if (length($DBIPcampaigncid[$user_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$user_CIPct]"; $CCID_on++;}
if (length($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;}
if ($DBIPuse_custom_cid[$user_CIPct] =~ /Y/)
{
$temp_CID = $security_phrase;
$temp_CID =~ s/\D//gi;
if (length($temp_CID) > 6)
{$CCID = "$temp_CID"; $CCID_on++;}
}
if ($DBIPuse_custom_cid[$user_CIPct] =~ /AREACODE/)
{
$temp_CID='';
$temp_vcca='';
$temp_ac='';
$temp_ac_two = substr("$phone_number", 0, 2);
$temp_ac_three = substr("$phone_number", 0, 3);
$temp_ac_four = substr("$phone_number", 0, 4);
$temp_ac_five = substr("$phone_number", 0, 5);
$stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$DBIPcampaign[$user_CIPct]' and areacode IN('$temp_ac_two','$temp_ac_three','$temp_ac_four','$temp_ac_five') and active='Y' order by CAST(areacode as SIGNED INTEGER) asc, call_count_today desc limit 100000;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
$act=0;
while ($sthArows > $act)
{
@aryA = $sthA->fetchrow_array;
$phone_code = $aryA[0];
$phone_number = $aryA[1];
$phone_number =~ s/\D//gi;
$temp_vcca = $aryA[0];
$temp_ac = $aryA[1];
$act++;
}
$sthA->finish();
if ($act > 0)
{
$sthA->finish();
$stmtA="UPDATE vicidial_campaign_cid_areacodes set call_count_today=(call_count_today + 1) where campaign_id='$DBIPcampaign[$user_CIPct]' and areacode='$temp_ac' and outbound_cid='$temp_vcca';";
$affected_rows = $dbhA->do($stmtA);
}
else
{$sthA->finish();}
$temp_CID = $temp_vcca;
$temp_CID =~ s/\D//gi;
if (length($temp_CID) > 6)
{$CCID = "$temp_CID"; $CCID_on++;}
}
$stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR',called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'";
}
else
{
$stmtA = "UPDATE vicidial_list set called_since_last_reset='$CSLR', called_count='$called_count',user='VDAD',last_local_call_time='$LLCT_DATE' where lead_id='$lead_id'";
}
$affected_rows = $dbhA->do($stmtA);
if ($DBIPdialprefix[$user_CIPct] =~ /x/i) {$Local_out_prefix = '';}
$stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id'";
$affected_rows = $dbhA->do($stmtA);
$CCID_on=0; $CCID='';
$local_DEF = 'Local/';
$local_AMP = '@';
$Local_out_prefix = '9';
$Local_dial_timeout = '60';
if ($DBIPdialtimeout[$user_CIPct] > 4) {$Local_dial_timeout = $DBIPdialtimeout[$user_CIPct];}
$Local_dial_timeout = ($Local_dial_timeout * 1000);
if (length($DBIPdialprefix[$user_CIPct]) > 0) {$Local_out_prefix = "$DBIPdialprefix[$user_CIPct]";}
if (length($DBIPvdadexten[$user_CIPct]) > 0) {$VDAD_dial_exten = "$DBIPvdadexten[$user_CIPct]";}
else {$VDAD_dial_exten = "$answer_transfer_agent";}
# add the routing prefix if using Asterisk 13
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} > 11))
{
$VDAD_dial_exten = $routing_prefix . $VDAD_dial_exten;
}
if (length($DBIPcampaigncid[$user_CIPct]) > 6) {$CCID = "$DBIPcampaigncid[$user_CIPct]"; $CCID_on++;}
if (length($campaign_cid_override) > 6) {$CCID = "$campaign_cid_override"; $CCID_on++;}
if ($DBIPuse_custom_cid[$user_CIPct] =~ /Y/)
{
$temp_CID = $security_phrase;
$temp_CID =~ s/\D//gi;
if (length($temp_CID) > 6)
{$CCID = "$temp_CID"; $CCID_on++;}
}
if ($DBIPuse_custom_cid[$user_CIPct] =~ /AREACODE/)
{
$temp_CID='';
$temp_vcca='';
$temp_ac='';
$temp_ac_two = substr("$phone_number", 0, 2);
$temp_ac_three = substr("$phone_number", 0, 3);
$temp_ac_four = substr("$phone_number", 0, 4);
$temp_ac_five = substr("$phone_number", 0, 5);
$stmtA = "SELECT outbound_cid,areacode FROM vicidial_campaign_cid_areacodes where campaign_id='$DBIPcampaign[$user_CIPct]' and areacode IN('$temp_ac_two','$temp_ac_three','$temp_ac_four','$temp_ac_five') and active='Y' order by CAST(areacode as SIGNED INTEGER) asc, call_count_today desc limit 100000;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$act=0;
while ($sthArows > $act)
if ($RECcount)
{
@aryA = $sthA->fetchrow_array;
$temp_vcca = $aryA[0];
$temp_ac = $aryA[1];
$act++;
}
if ($act > 0)
{
$sthA->finish();
$stmtA="UPDATE vicidial_campaign_cid_areacodes set call_count_today=(call_count_today + 1) where campaign_id='$DBIPcampaign[$user_CIPct]' and areacode='$temp_ac' and outbound_cid='$temp_vcca';";
$affected_rows = $dbhA->do($stmtA);
if ( (length($RECprefix)>0) && ($called_count < $RECcount) )
{$Local_out_prefix .= "$RECprefix";}
}
$PADlead_id = sprintf("%010s", $lead_id); while (length($PADlead_id) > 10) {chop($PADlead_id);}
if ($lists_update !~ /'$list_id'/) {$lists_update .= "'$list_id',"; $LUcount++;}
$lead_id_call_list .= "$lead_id|";
if (length($alt_dial)<1) {$alt_dial='MAIN';}
### whether to omit phone_code or not
if ($DBIPomitcode[$user_CIPct] > 0)
{$Ndialstring = "$Local_out_prefix$phone_number";}
else
{$sthA->finish();}
$temp_CID = $temp_vcca;
$temp_CID =~ s/\D//gi;
if (length($temp_CID) > 6)
{$CCID = "$temp_CID"; $CCID_on++;}
}
if ($DBIPdialprefix[$user_CIPct] =~ /x/i) {$Local_out_prefix = '';}
if ($RECcount)
{
if ( (length($RECprefix)>0) && ($called_count < $RECcount) )
{$Local_out_prefix .= "$RECprefix";}
}
$PADlead_id = sprintf("%010s", $lead_id); while (length($PADlead_id) > 10) {chop($PADlead_id);}
if ($lists_update !~ /'$list_id'/) {$lists_update .= "'$list_id',"; $LUcount++;}
$lead_id_call_list .= "$lead_id|";
if (length($alt_dial)<1) {$alt_dial='MAIN';}
### whether to omit phone_code or not
if ($DBIPomitcode[$user_CIPct] > 0)
{$Ndialstring = "$Local_out_prefix$phone_number";}
else
{$Ndialstring = "$Local_out_prefix$phone_code$phone_number";}
if (length($ext_context) < 1) {$ext_context='default';}
### use manager middleware-app to connect the next call to the meetme room
# VmddhhmmssLLLLLLLLLL
$VqueryCID = "V$CIDdate$PADlead_id";
if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";}
else {$CIDstring = "$VqueryCID";}
### insert a NEW record to the vicidial_manager table to be processed
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DBIPaddress[$user_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $DBIPcampaign[$user_CIPct]|$lead_id|$phone_code|$phone_number|OUT|$alt_dial|$DBIPqueue_priority[$user_CIPct]')";
$affected_rows = $dbhA->do($stmtA);
$event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
&event_logger;
### insert a SENT record to the vicidial_auto_calls table
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type,alt_dial,queue_priority,last_update_time) values('$DBIPaddress[$user_CIPct]','$DBIPcampaign[$user_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT','$alt_dial','$DBIPqueue_priority[$user_CIPct]','$SQLdate')";
$affected_rows = $dbhA->do($stmtA);
### insert log record into vicidial_dial_log table
$stmtA = "INSERT INTO vicidial_dial_log SET caller_code='$VqueryCID',lead_id='$lead_id',server_ip='$DBIPaddress[$user_CIPct]',call_date='$SQLdate',extension='$VDAD_dial_exten',channel='$local_DEF$Ndialstring$local_AMP$ext_context',timeout='$Local_dial_timeout',outbound_cid='$CIDstring',context='$ext_context';";
$affected_rows = $dbhA->do($stmtA);
### sleep for a five hundredths of a second to not flood the server with new calls
# usleep(1*50*1000);
usleep(1*$per_call_delay*1000);
$calls_placed++;
{$Ndialstring = "$Local_out_prefix$phone_code$phone_number";}
if (length($ext_context) < 1) {$ext_context='default';}
### use manager middleware-app to connect the next call to the meetme room
# VmddhhmmssLLLLLLLLLL
$VqueryCID = "V$CIDdate$PADlead_id";
if ($CCID_on) {$CIDstring = "\"$VqueryCID\" <$CCID>";}
else {$CIDstring = "$VqueryCID";}
### insert a NEW record to the vicidial_manager table to be processed
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DBIPaddress[$user_CIPct]','','Originate','$VqueryCID','Exten: $VDAD_dial_exten','Context: $ext_context','Channel: $local_DEF$Ndialstring$local_AMP$ext_context','Priority: 1','Callerid: $CIDstring','Timeout: $Local_dial_timeout','','','','VDACnote: $DBIPcampaign[$user_CIPct]|$lead_id|$phone_code|$phone_number|OUT|$alt_dial|$DBIPqueue_priority[$user_CIPct]')";
$affected_rows = $dbhA->do($stmtA);
$event_string = "| number call dialed|$DBIPcampaign[$user_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
&event_logger;
### insert a SENT record to the vicidial_auto_calls table
$stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,status,lead_id,callerid,phone_code,phone_number,call_time,call_type,alt_dial,queue_priority,last_update_time) values('$DBIPaddress[$user_CIPct]','$DBIPcampaign[$user_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUT','$alt_dial','$DBIPqueue_priority[$user_CIPct]','$SQLdate')";
$affected_rows = $dbhA->do($stmtA);
### insert log record into vicidial_dial_log table
$stmtA = "INSERT INTO vicidial_dial_log SET caller_code='$VqueryCID',lead_id='$lead_id',server_ip='$DBIPaddress[$user_CIPct]',call_date='$SQLdate',extension='$VDAD_dial_exten',channel='$local_DEF$Ndialstring$local_AMP$ext_context',timeout='$Local_dial_timeout',outbound_cid='$CIDstring',context='$ext_context';";
$affected_rows = $dbhA->do($stmtA);
### sleep for a five hundredths of a second to not flood the server with new calls
# usleep(1*50*1000);
usleep(1*$per_call_delay*1000);
$calls_placed++;
}
}
$call_CMPIPct++;
}
$call_CMPIPct++;
}
}
}
+1
View File
@@ -2440,6 +2440,7 @@ foreach(@campaign_id)
else
{
$lead_filter_sql[$i] =~ s/^and|and$|^or|or$|^ and|and $|^ or|or $//gi;
$lead_filter_sql[$i] =~ s/\r|\n|\t/ /gi;
$lead_filter_sql[$i] = "and ($lead_filter_sql[$i])";
if ($DB) {print " lead filter $lead_filter_id[$i] defined for $campaign_id[$i]\n";}
if ($DBX) {print " |$lead_filter_sql[$i]|\n";}
@@ -993,7 +993,9 @@ scheduled_callbacks_email_alert ENUM('Y', 'N') default 'N',
max_inbound_calls_outcome ENUM('DEFAULT','ALLOW_AGENTDIRECT','ALLOW_MI_PAUSE','ALLOW_AGENTDIRECT_AND_MI_PAUSE') default 'DEFAULT',
manual_auto_next_options ENUM('DEFAULT','PAUSE_NO_COUNT') default 'DEFAULT',
agent_screen_time_display ENUM('DISABLED','ENABLED_BASIC','ENABLED_FULL','ENABLED_BILL_BREAK_LUNCH_COACH') default 'DISABLED',
next_dial_my_callbacks ENUM('DISABLED','ENABLED') default 'DISABLED'
next_dial_my_callbacks ENUM('DISABLED','ENABLED') default 'DISABLED',
inbound_no_agents_no_dial_container VARCHAR(40) default '---DISABLED---',
inbound_no_agents_no_dial_threshold SMALLINT(5) default '0'
) ENGINE=MyISAM;
CREATE TABLE vicidial_lists (
@@ -2300,7 +2302,7 @@ server_ip VARCHAR(15) NOT NULL,
trigger_time DATETIME,
user VARCHAR(20),
trigger_lines TEXT,
trigger_results TEXT,
trigger_results MEDIUMTEXT,
index (trigger_id),
index (trigger_time)
) ENGINE=MyISAM;
@@ -3473,7 +3475,7 @@ KEY ajax_dbtime_key (db_time)
CREATE TABLE vicidial_settings_containers (
container_id VARCHAR(40) PRIMARY KEY NOT NULL,
container_notes VARCHAR(255) default '',
container_type ENUM('OTHER','PERL_CLI','EMAIL_TEMPLATE','AGI') default 'OTHER',
container_type VARCHAR(40) default 'OTHER',
user_group VARCHAR(20) default '---ALL---',
container_entry MEDIUMTEXT
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
@@ -4130,4 +4132,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1532',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1533',db_schema_update_date=NOW(),reload_timestamp=NOW();
+9
View File
@@ -492,3 +492,12 @@ index (run_time)
DELETE from cid_channels_recent;
UPDATE system_settings SET db_schema_version='1532',db_schema_update_date=NOW() where db_schema_version < 1532;
ALTER TABLE vicidial_process_trigger_log MODIFY trigger_results MEDIUMTEXT;
ALTER TABLE vicidial_campaigns ADD inbound_no_agents_no_dial_container VARCHAR(40) default '---DISABLED---';
ALTER TABLE vicidial_campaigns ADD inbound_no_agents_no_dial_threshold SMALLINT(5) default '0';
ALTER TABLE vicidial_settings_containers MODIFY container_type VARCHAR(40) default 'OTHER';
UPDATE system_settings SET db_schema_version='1533',db_schema_update_date=NOW() where db_schema_version < 1533;
File diff suppressed because one or more lines are too long
+11
View File
@@ -148,6 +148,7 @@
# 171224-1027 - Added lists-default_xfer_group entry
# 180108-2115 - Added campaigns-next_dial_my_callbacks entry
# 180111-1547 - Added settings-anyone_callback_inactive_lists entry
# 180130-2303 - Added inbound_no_agents_no_dial entries
#
require("dbconnect_mysqli.php");
@@ -1112,6 +1113,16 @@ if ($SSoutbound_autodial_active > 0)
<BR>
<B><?php echo _QXZ("Inbound Queue No Dial"); ?> -</B><?php echo _QXZ("This feature if set to ENABLED allows you to prevent outbound auto-dialing of this campaign if there are any inbound calls waiting in queue that are part of the allowed inbound groups set in this campaign. Setting this to ALL_SERVERS will change the algorithm to calculate all inbound calls as active calls on this server even if they are on another server which will reduce the chance of placing unnecessary outbound calls if you have calls coming in on another server. Default is DISABLED.") . ' ' . _QXZ("If the selected option includes CHAT, then no outbound auto-dialing will take place while an inbound customer chat is waiting."); ?>
<BR>
<A NAME="campaigns-inbound_no_agents_no_dial_container">
<BR>
<B><?php echo _QXZ("Inbound No-Agents No-Dial"); ?> -</B><?php echo _QXZ("If set to something other than ---DISABLED---, the selected INGROUP_LIST type of Settings Container will be used to determine if any agents are ready and waiting for phone calls from at least one of the listed In-Groups. If there are less inbound agents available than the Threshold setting below, then no outbound calls will be placed for this campaign. Default is DISABLED."); ?>
<BR>
<A NAME="campaigns-inbound_no_agents_no_dial_threshold">
<BR>
<B><?php echo _QXZ("Inbound No-Agents No-Dial Threshold"); ?> -</B><?php echo _QXZ("If the Inbound No-Agents No-Dial option is enabled above, then this setting will be used to determine if the campaign will be allowed to place outbound auto-dial calls, if this number is greater than the number of inbound agents available. Default is 0, for disabled."); ?>
<BR>
<A NAME="campaigns-auto_alt_dial">
<BR>