Fixed CPA AMD MESSAGE feature

corrected TMR(service level) calculations in CLOSERstats and AST_VDadapt
Added dccsv10 CLI lead loader file format
Added experimental staggered call distribution to AST_VDauto_dial_FILL.pl

git-svn-id: svn://192.168.202.10@1331 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2010-02-06 20:15:20 +00:00
parent 7988eed4d5
commit 77cab942b3
14 changed files with 757 additions and 363 deletions
+12 -9
View File
@@ -19,7 +19,7 @@
# exten => 8320,1,AGI(VD_amd.agi,${EXTEN}-----YES)
# exten => 8320,2,Hangup
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# changes:
# 60206-1434 first build
@@ -31,6 +31,7 @@
# 71118-0252 - compatibility with Asterisk 1.4, added AA and AM statuses
# 90916-1317 - Changed to audio file playback and TTS playback
# 90924-1533 - Added answering machine message list_id override option
# 100205-1025 - Fixed CPD send to message
#
$script = 'VD_amd.agi';
@@ -292,12 +293,14 @@ else
}
$sthA->finish();
########## UPDATE vicidial_list ##########
$stmtA = "UPDATE vicidial_list set status='AA' where lead_id = '$VD_lead_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
if ($AMDSTATUS !~ /CPD/)
{
########## UPDATE vicidial_list ##########
$stmtA = "UPDATE vicidial_list set status='AA' where lead_id = '$VD_lead_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
}
########## DELETE vicidial_auto_calls entry ##########
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
@@ -310,7 +313,7 @@ else
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$epc_countCUSTDATA=0;
$epc_countCUSTDATA=0;
while ($sthArows > $epc_countCUSTDATA)
{
@aryA = $sthA->fetchrow_array;
@@ -373,7 +376,7 @@ else
}
### check for list_id override
if ($DB_amd_send_to_vmx =~ /Y/)
if ( ($DB_amd_send_to_vmx =~ /Y/) || ($AMDSTATUS =~ /CPD/) )
{
### find list_id for this lead
$stmtA = "SELECT list_id from vicidial_list where lead_id = '$VD_lead_id';";
@@ -46,7 +46,7 @@
#exten => 8366,4,AGI(agi-VDAD_ALL_outbound.agi,SURVEY-----LB-----US_pol_survey_hello-----1238-----8-----US_pol_survey_transfer-----US_thanks_no_contact-----OPTOUT-----DNC)
#exten => 8366,5,Hangup
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# changes:
# 80218-2027 - First Build
@@ -71,6 +71,7 @@
# 90924-1605 - Added drop_inbound_group_override list_id option
# 91112-1101 - Changed ENTERQUEUE to CALLOUTBOUND in QM logging for outbound calls
# 91230-1159 - Change to callee callerID when sending the call to VMAIL
# 100205-1024 - Fixed CPD send to message
#
$script = 'agi-VDAD_ALL_outbound.agi';
@@ -2127,6 +2128,16 @@ sub cpd_end_call
if ( ($cpd_amd_action =~ /MESSAGE/) && ($cpd_result !~ /Fax/i) )
{
$DROPexten = "8320";
$AMDSTATUS_set = $AGI->set_variable('AMDSTATUS', "CPDMACHINE");
$AMDCAUSE_set = $AGI->set_variable('AMDCAUSE', $cpd_result);
}
else
{
$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;
if ($AGILOG) {$agi_string = "-- VDAD CPD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;}
}
$Euniqueid=$uniqueid;
@@ -2143,11 +2154,6 @@ sub cpd_end_call
$dbhP=$dbhA; $mysql_count='01051'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD CPD vicidial_list update: |$affected_rows|$CIDlead_id"; &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;
if ($AGILOG) {$agi_string = "-- VDAD CPD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;}
$stmtA = "UPDATE vicidial_cpd_log SET status='PROCESSED',cpd_seconds='$drop_timer' where callerid='$callerid' and result IN('Answering-Machine','Fax') and status='NEW';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01055'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
@@ -6,7 +6,7 @@
# adjusts the auto_dial_level for vicidial adaptive-predictive campaigns.
# gather call stats for campaigns and in-groups
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 60823-1302 - First build from AST_VDhopper.pl
@@ -33,6 +33,7 @@
# 90628-2001 - Added drop rate group functions
# 91115-0929 - Added auto-kill of script at timeclock reset time of day to facilitate cleaner clearing of daily stats
# 91206-2203 - Added campaign_calldate within last 5 minute as an override to recalculate stats
# 100206-1453 - Fixed calculation of hold_sec stats (service level) for in-groups
#
# constants
@@ -1327,7 +1328,7 @@ sub calculate_drops_inbound
if ($iVCScalls_today[$p] > 0)
{
# TODAY ANSWERS
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1359,7 +1360,7 @@ sub calculate_drops_inbound
$sthA->finish();
# TODAY ANSWER PERCENT OF HOLD SECONDS one and two
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_one;";
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_one and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1369,7 +1370,7 @@ sub calculate_drops_inbound
$answer_sec_pct_rt_stat_one_PCT[$p] = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_two;";
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1380,7 +1381,7 @@ sub calculate_drops_inbound
}
# TODAY TOTAL HOLD TIME FOR ANSWERED CALLS
$stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -12,7 +12,7 @@
#
# Should only be run on one server in a multi-server Asterisk/VICIDIAL cluster
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG:
# 61115-1246 - First build, framework setup, non-functional
@@ -27,6 +27,7 @@
# 90306-1844 - Added configurable calls-per-second option
# 90729-0611 - Added vicidial_balance_rank option
# 90924-1519 - Added List callerid override option
# 100205-1245 - Added optional stagger sending of calls across all available servers in each rank
#
### begin parsing run-time options ###
@@ -41,10 +42,33 @@ if (length($ARGV[0])>1)
if ($args =~ /--help/i)
{
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n\n";
print "allowed run time options:\n";
print " [-t] = test\n";
print " [-debug] = verbose debug messages\n";
print " [-staggered] = experimental staggering of placing calls on large multi-server systems\n";
print " [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n";
print "\n";
exit;
}
else
{
if ($args =~ /-debug/i)
{
$DB=1; # Debug flag, set to 0 for no debug messages
print "\n-- DEBUG --\n\n";
}
if ($args =~ /-t/i)
{
$TEST=1;
$T=1;
}
if ($args =~ /-staggered/i)
{
$staggered=1;
print "\n-- STAGGERED MULTI-SERVER DIAL MODE --\n\n";
}
else
{$staggered=0;}
if ($args =~ /--delay=/i)
{
@data_in = split(/--delay=/,$args);
@@ -56,23 +80,13 @@ if (length($ARGV[0])>1)
{
$loop_delay = '2500';
}
if ($args =~ /-debug/i)
{
$DB=1; # Debug flag, set to 0 for no debug messages
print "\n-- DEBUG --\n\n";
}
if ($args =~ /-t/i)
{
$TEST=1;
$T=1;
}
}
}
else
{
print "no command line options set\n";
$loop_delay = '2500';
$DB=1;
$loop_delay = '2500';
$DB=1;
}
### end parsing run-time options ###
@@ -134,31 +148,30 @@ if (!$VDADLOGfile) {$VDADLOGfile = "$PATHlogs/vdautodial_FILL.$year-$mon-$mday";
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
### connect to MySQL database defined in the conf file
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
### connect to MySQL database defined in the conf file
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBtelnet_host = "$aryA[0]";
$DBtelnet_port = "$aryA[1]";
$DBASTmgrUSERNAME = "$aryA[2]";
$DBASTmgrSECRET = "$aryA[3]";
$DBASTmgrUSERNAMEupdate = "$aryA[4]";
$DBASTmgrUSERNAMElisten = "$aryA[5]";
$DBASTmgrUSERNAMEsend = "$aryA[6]";
$DBmax_vicidial_trunks = "$aryA[7]";
$DBanswer_transfer_agent= "$aryA[8]";
$DBSERVER_GMT = "$aryA[9]";
$DBext_context = "$aryA[10]";
$DBvd_server_logs = "$aryA[11]";
$DBtelnet_host = $aryA[0];
$DBtelnet_port = $aryA[1];
$DBASTmgrUSERNAME = $aryA[2];
$DBASTmgrSECRET = $aryA[3];
$DBASTmgrUSERNAMEupdate = $aryA[4];
$DBASTmgrUSERNAMElisten = $aryA[5];
$DBASTmgrUSERNAMEsend = $aryA[6];
$DBmax_vicidial_trunks = $aryA[7];
$DBanswer_transfer_agent= $aryA[8];
$DBSERVER_GMT = $aryA[9];
$DBext_context = $aryA[10];
$DBvd_server_logs = $aryA[11];
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
@@ -171,8 +184,7 @@ while ($sthArows > $rec_count)
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
else {$SYSLOG = '0';}
}
$sthA->finish();
@@ -182,7 +194,6 @@ $sthA->finish();
$one_day_interval = 12; # 1 month loops for one year
while($one_day_interval > 0)
{
$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
$stat_count=1;
@@ -239,12 +250,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$balance_servers = "$aryA[0]";
$rec_count++;
$balance_servers = $aryA[0];
}
$sthA->finish();
@@ -257,8 +266,8 @@ while($one_day_interval > 0)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBfill_campaign[$camp_counter] = "$aryA[0]";
$DBfill_shortage[$camp_counter] = "$aryA[1]";
$DBfill_campaign[$camp_counter] = $aryA[0];
$DBfill_shortage[$camp_counter] = $aryA[1];
$total_shortage = ($total_shortage + $aryA[1]);
if($DB) {print "$DBfill_campaign[$camp_counter]: $DBfill_shortage[$camp_counter]\n";}
@@ -275,7 +284,7 @@ while($one_day_interval > 0)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$outbound_calls_per_second = "$aryA[0]";
$outbound_calls_per_second = $aryA[0];
}
$sthA->finish();
@@ -307,7 +316,7 @@ while($one_day_interval > 0)
### grab the dial_level and multiply by active agents to get your goalcalls
$DBIPadlevel[$camp_CIPct]=0;
$stmtA = "SELECT dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,omit_phone_code,auto_alt_dial,queue_priority FROM vicidial_campaigns where campaign_id='$DBfill_campaign[$camp_CIPct]'";
$stmtA = "SELECT dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,omit_phone_code,auto_alt_dial,queue_priority FROM vicidial_campaigns where campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -316,31 +325,30 @@ while($one_day_interval > 0)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBIPdialtimeout[$camp_CIPct] = "$aryA[0]";
$DBIPdialprefix[$camp_CIPct] = "$aryA[1]";
$DBIPcampaigncid[$camp_CIPct] = "$aryA[2]";
$DBIPactive[$camp_CIPct] = "$aryA[3]";
$DBIPvdadexten[$camp_CIPct] = "$aryA[4]";
$omit_phone_code = "$aryA[5]";
if ($omit_phone_code =~ /Y/) {$DBIPomitcode[$camp_CIPct] = 1;}
else {$DBIPomitcode[$camp_CIPct] = 0;}
$DBIPautoaltdial[$camp_CIPct] = "$aryA[6]";
$DBIPqueue_priority[$camp_CIPct] = "$aryA[7]";
$DBIPdialtimeout[$camp_CIPct] = $aryA[0];
$DBIPdialprefix[$camp_CIPct] = $aryA[1];
$DBIPcampaigncid[$camp_CIPct] = $aryA[2];
$DBIPactive[$camp_CIPct] = $aryA[3];
$DBIPvdadexten[$camp_CIPct] = $aryA[4];
$omit_phone_code = $aryA[5];
$DBIPautoaltdial[$camp_CIPct] = $aryA[6];
$DBIPqueue_priority[$camp_CIPct] = $aryA[7];
if ($omit_phone_code =~ /Y/) {$DBIPomitcode[$camp_CIPct] = 1;}
else {$DBIPomitcode[$camp_CIPct] = 0;}
$rec_count++;
}
$sthA->finish();
$stmtA = "SELECT balance_trunk_fill FROM vicidial_campaign_stats where campaign_id='$DBfill_campaign[$camp_CIPct]'";
$stmtA = "SELECT balance_trunk_fill FROM vicidial_campaign_stats where campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DB_balance_fill = "$aryA[0]";
$rec_count++;
$DB_balance_fill = $aryA[0];
}
$sthA->finish();
@@ -348,12 +356,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_balance_fill = "$aryA[0]";
$rec_count++;
$VAC_balance_fill = $aryA[0];
}
$sthA->finish();
$DBfill_current_balance[$camp_CIPct] = "$VAC_balance_fill";
@@ -368,7 +374,7 @@ while($one_day_interval > 0)
##### Get a listing of the servers in the campaign that have shortages of trunks
$full_servers='|';
$full_serversSQL='';
$stmtA = "SELECT server_ip FROM vicidial_campaign_server_stats where update_time > '$XDSQLdate' and local_trunk_shortage > 0 and campaign_id='$DBfill_campaign[$camp_CIPct]'";
$stmtA = "SELECT server_ip FROM vicidial_campaign_server_stats where update_time > '$XDSQLdate' and local_trunk_shortage > 0 and campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -391,12 +397,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$AVAIL_balance_servers = "$aryA[0]";
$rec_count++;
$AVAIL_balance_servers = $aryA[0];
}
$sthA->finish();
@@ -426,9 +430,9 @@ while($one_day_interval > 0)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DB_camp_server_server_ip[$DB_camp_servers] = "$aryA[0]";
$DB_camp_server_max_vicidial_trunks[$DB_camp_servers] = "$aryA[1]";
$DB_camp_server_balance_trunks_offlimits[$DB_camp_servers] = "$aryA[2]";
$DB_camp_server_server_ip[$DB_camp_servers] = $aryA[0];
$DB_camp_server_max_vicidial_trunks[$DB_camp_servers] = $aryA[1];
$DB_camp_server_balance_trunks_offlimits[$DB_camp_servers] = $aryA[2];
$DB_camp_servers++;
$rec_count++;
}
@@ -444,18 +448,18 @@ while($one_day_interval > 0)
$DB_camp_server_dedicated_trunks[$server_CIPct]=0;
$DB_camp_server_trunk_restriction[$server_CIPct]=0;
$DB_NONcamp_server_dedicated_trunks[$server_CIPct]=0;
$SERVER_CAMP_temp_avail[$server_CIPct]=0;
$SERVER_CAMP_temp_tally[$server_CIPct]=0;
##### Get the campaign-specific trunk settings for the campaign on this server
$stmtA = "SELECT dedicated_trunks,trunk_restriction FROM vicidial_server_trunks where server_ip='$DB_camp_server_server_ip[$server_CIPct]' and campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DB_camp_server_dedicated_trunks[$server_CIPct] = "$aryA[0]";
$DB_camp_server_trunk_restriction[$server_CIPct] = "$aryA[1]";
$rec_count++;
$DB_camp_server_dedicated_trunks[$server_CIPct] = $aryA[0];
$DB_camp_server_trunk_restriction[$server_CIPct] = $aryA[1];
}
$sthA->finish();
@@ -464,12 +468,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DB_NONcamp_server_dedicated_trunks[$server_CIPct] = "$aryA[0]";
$rec_count++;
$DB_NONcamp_server_dedicated_trunks[$server_CIPct] = $aryA[0];
}
$sthA->finish();
@@ -480,12 +482,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_server_BALcamp = "$aryA[0]";
$rec_count++;
$VAC_server_BALcamp = $aryA[0];
}
$sthA->finish();
@@ -493,12 +493,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_server_camp = "$aryA[0]";
$rec_count++;
$VAC_server_camp = $aryA[0];
}
$sthA->finish();
@@ -506,12 +504,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_server_NONcamp = "$aryA[0]";
$rec_count++;
$VAC_server_NONcamp = $aryA[0];
}
$sthA->finish();
@@ -526,19 +522,19 @@ while($one_day_interval > 0)
{
$DB_camp_server_available[$server_CIPct] = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $DB_camp_server_balance_trunks_offlimits[$server_CIPct]) - $DB_NONcamp_server_dedicated_trunks[$server_CIPct]);
}
$temp_tally = ($DBfill_needed[$camp_CIPct] - $DBfill_tally[$camp_CIPct]);
$temp_avail = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $VAC_server_camp) - $VAC_server_NONcamp);
$SERVER_CAMP_temp_tally[$server_CIPct] = ($DBfill_needed[$camp_CIPct] - $DBfill_tally[$camp_CIPct]);
$SERVER_CAMP_temp_avail[$server_CIPct] = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $VAC_server_camp) - $VAC_server_NONcamp);
$DB_camp_server_available[$server_CIPct] = ($DB_camp_server_available[$server_CIPct] - $VAC_server_BALcamp);
if ($DB_camp_server_available[$server_CIPct] < 0) {$DB_camp_server_available[$server_CIPct]=0;}
if($DB) {print "TEMPVALS: |$temp_tally|$temp_avail|$DB_camp_server_available[$server_CIPct]||\n";}
if ($DB_camp_server_available[$server_CIPct] >= $temp_tally)
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $temp_tally;}
if($DB) {print "TEMPVALS: |$SERVER_CAMP_temp_tally[$server_CIPct]|$SERVER_CAMP_temp_avail[$server_CIPct]|$DB_camp_server_available[$server_CIPct]||\n";}
if ($DB_camp_server_available[$server_CIPct] >= $SERVER_CAMP_temp_tally[$server_CIPct])
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $SERVER_CAMP_temp_tally[$server_CIPct];}
else
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $DB_camp_server_available[$server_CIPct];}
if ($temp_avail < $DB_camp_server_trunks_to_dial[$server_CIPct])
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $temp_avail;}
if ($SERVER_CAMP_temp_avail[$server_CIPct] < $DB_camp_server_trunks_to_dial[$server_CIPct])
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $SERVER_CAMP_temp_avail[$server_CIPct];}
$DBfill_tally[$camp_CIPct] = ($DBfill_tally[$camp_CIPct] + $DB_camp_server_trunks_to_dial[$server_CIPct]);
@@ -572,7 +568,7 @@ while($one_day_interval > 0)
my $UDaffected_rows=0;
if ($call_CMPIPct < $DB_camp_server_trunks_to_dial[$server_CIPct])
{
$stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='READY' order by priority desc,hopper_id LIMIT $DB_camp_server_trunks_to_dial[$server_CIPct]";
$stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='READY' order by priority desc,hopper_id LIMIT $DB_camp_server_trunks_to_dial[$server_CIPct];";
print "|$stmtA|\n";
$UDaffected_rows = $dbhA->do($stmtA);
print "hopper rows updated to QUEUE: |$UDaffected_rows|\n";
@@ -582,19 +578,17 @@ while($one_day_interval > 0)
$lead_id=''; $phone_code=''; $phone_number=''; $called_count='';
while ($call_CMPIPct < $UDaffected_rows)
{
$stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='QUEUE' and user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' order by priority desc,hopper_id LIMIT 1";
$stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='QUEUE' and user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' 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)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$lead_id = "$aryA[0]";
$alt_dial = "$aryA[1]";
$rec_count++;
$lead_id = $aryA[0];
$alt_dial = $aryA[1];
}
$sthA->finish();
@@ -611,7 +605,7 @@ while($one_day_interval > 0)
}
else
{
$stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'";
$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";
@@ -620,7 +614,6 @@ while($one_day_interval > 0)
$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)
{
@@ -635,7 +628,6 @@ while($one_day_interval > 0)
$called_count = $aryA[7];
$rec_countCUSTDATA++;
$rec_count++;
}
$sthA->finish();
@@ -710,22 +702,22 @@ while($one_day_interval > 0)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$phone_code = "$aryA[0]";
$phone_number = "$aryA[1]";
$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'";
$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'";
$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'";
$stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id';";
$affected_rows = $dbhA->do($stmtA);
$CCID_on=0; $CCID='';
@@ -768,20 +760,38 @@ while($one_day_interval > 0)
$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','$DB_camp_server_server_ip[$server_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','','','','')";
$affected_rows = $dbhA->do($stmtA);
$event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
&event_logger;
if ($staggered < 1)
{
### insert a NEW record to the vicidial_manager table to be processed
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DB_camp_server_server_ip[$server_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','','','','')";
$affected_rows = $dbhA->do($stmtA);
### 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) values('$DB_camp_server_server_ip[$server_CIPct]','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
$affected_rows = $dbhA->do($stmtA);
$event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
&event_logger;
### sleep for 2.5 hundredths of a second to not flood the server with new calls
# usleep(1*25*1000);
usleep(1*$per_call_delay*1000);
### 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) values('$DB_camp_server_server_ip[$server_CIPct]','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
$affected_rows = $dbhA->do($stmtA);
}
else
{
##### create dummy records to have their server_ip filled in at the stagger section
$vm_inserts[$staggered_ct] = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','XXXXXXXXXXXXXXX','','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','','','','')";
$vac_inserts[$staggered_ct] = "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) values('XXXXXXXXXXXXXXX','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
$st_logged[$staggered_ct] = "$phone_number|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$gmt_offset_now|$alt_dial|";
$staggered_ct++;
}
if ($staggered < 1)
{
### sleep for 2.5 hundredths of a second to not flood the server with new calls
# usleep(1*25*1000);
usleep(1*$per_call_delay*1000);
}
}
}
$call_CMPIPct++;
@@ -809,6 +819,102 @@ while($one_day_interval > 0)
&event_logger;
}
###############################################################################
###### BEGIN - experimental balanced FILL dialing ($staggered)
###############################################################################
if ( ($staggered > 0) && ($staggered_ct > 0) )
{
$staggered_fill=0;
$stmtA = "SELECT count(*),vicidial_balance_rank FROM servers group by vicidial_balance_rank order by vicidial_balance_rank desc;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$st_ct=0;
while ($sthArows > $st_ct)
{
@aryA = $sthA->fetchrow_array;
$ST_count[$st_ct] = $aryA[0];
$ST_rank[$st_ct] = $aryA[1];
$st_ct++;
}
$sthA->finish();
##### gather available trunks on all servers and place calls
$staggered_rank_ct=0;
while ( ($st_ct > $staggered_rank_ct) && ($staggered_ct > $staggered_fill) )
{
$TOTAL_available=0;
$stmtA = "SELECT server_ip FROM servers where vicidial_balance_rank='$ST_rank[$staggered_rank_ct]' order by server_ip LIMIT $ST_count[$staggered_rank_ct];";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsSIPS=$sthA->rows;
$st_si_ct=0;
while ($sthArowsSIPS > $st_si_ct)
{
@aryA = $sthA->fetchrow_array;
$ST_server_ip[$st_si_ct] = $aryA[0];
$io=0;
foreach(@DB_camp_server_server_ip)
{
if ( ($DB_camp_server_server_ip[$io] =~ /$ST_server_ip[$st_si_ct]/) && (length($DB_camp_server_server_ip[$io]) == length($ST_server_ip[$st_si_ct])) )
{
$ST_available[$st_si_ct] = $SERVER_CAMP_temp_avail[$io];
$ST_tally[$st_si_ct] = $SERVER_CAMP_temp_tally[$io];
$TOTAL_available = ($TOTAL_available + $ST_available[$st_si_ct]);
}
$io++;
}
$st_si_ct++;
}
$sthA->finish();
##### place calls
$failsafe_ct=0;
$RANK_calls_placed=0;
$st_si_loop=0;
while ( ($TOTAL_available > $RANK_calls_placed) && ($failsafe_ct < 99999) )
{
$TEMP_server_ip = $ST_server_ip[$st_si_loop];
$TEMP_vm_insert = $vm_inserts[$staggered_fill];
$TEMP_vac_insert = $vac_inserts[$staggered_fill];
$TEMP_st_logged = $st_logged[$staggered_fill];
$TEMP_vm_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi;
$TEMP_vac_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi;
$affected_rows_vm = $dbhA->do($TEMP_vm_insert);
$affected_rows_vac = $dbhA->do($TEMP_vac_insert);
$event_string = "| number call stagger dialed|$TEMP_server_ip| $TEMP_st_logged";
&event_logger;
### sleep for 2.5 hundredths of a second to not flood the server with new calls
# usleep(1*25*1000);
usleep(1*$per_call_delay*1000);
$RANK_calls_placed++;
$staggered_fill++;
$failsafe_ct++;
$st_si_loop++;
if ($st_si_loop >= $st_si_ct)
{$st_si_loop=0;}
}
$staggered_rank_ct++;
}
}
$staggered_ct=0;
@vm_inserts=@MT;
@vac_inserts=@MT;
@st_logged=@MT;
###############################################################################
###### END - experimental balanced FILL dialing ($staggered)
###############################################################################
$temp_balance_total = ($DBfill_current_balance[$camp_CIPct] + $DBfill_tally[$camp_CIPct]);
if ($DB) {print "CURRENT FILL: $temp_balance_total = ($DBfill_current_balance[$camp_CIPct] + $DBfill_tally[$camp_CIPct])\n";}
$stmtA = "UPDATE vicidial_campaign_stats SET balance_trunk_fill='$temp_balance_total' where campaign_id='$DBfill_campaign[$camp_CIPct]';";
@@ -832,11 +938,6 @@ while($one_day_interval > 0)
}
# so far we have a check of balance servers, a check of shortage servers and we begin traversing the campaigns array
#exit;
@@ -852,6 +953,8 @@ while($one_day_interval > 0)
&event_logger;
}
###############################################################################
###### last, wait for a little bit and repeat the loop
###############################################################################
@@ -877,14 +980,12 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
$DBvd_server_logs = $aryA[0];
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
else {$SYSLOG = '0';}
}
$sthA->finish();
@@ -893,19 +994,17 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBmax_vicidial_trunks = "$aryA[0]";
$DBanswer_transfer_agent= "$aryA[1]";
$DBSERVER_GMT = "$aryA[2]";
$DBext_context = "$aryA[3]";
$DBmax_vicidial_trunks = $aryA[0];
$DBanswer_transfer_agent= $aryA[1];
$DBSERVER_GMT = $aryA[2];
$DBext_context = $aryA[3];
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
$rec_count++;
}
$sthA->finish();
@@ -41,6 +41,7 @@
# 91112-0645 - Added title/alt_phone duplicate checks
# 91129-2202 - removed SELECT STAR and formatting fixes
# 100118-0527 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA)
# 100204-2333 - Added dccsv10 file format
#
$secX = time();
@@ -171,6 +172,9 @@ if (length($ARGV[0])>1)
print "sccsv11:\n";
print "STATE,ID,NAME,ADDRESS,ADDRESS2,CITY,COUNTY,PHONE,FAX,ZIP,COMMENTS\n";
print "AL,16700,Fairfax Retirement Center (Crowder House),1324 25th St,,FAIRFAX,JEFFERSON,(205) 555-0508,,35733,Comments\n\n";
print "dccsv10:\n";
print "VENDOR_ID,FIRST_NAME,LAST_NAME,PHONE_1,PHONE_2,PHONE_3,PHONE_4,PHONE_5,PHONE_6,PHONE_7\n";
print "\"100998\",\"ANGELA \",\"SMITH \",\"3145551212\",\"3145551213\",\"3145551214\",\"0\",\"3145551215\",\"3145551216\",\"0\",\n\n";
exit;
}
@@ -834,6 +838,87 @@ foreach(@FILES)
$format_set++;
}
# This is the format for the dccsv10 lead files
#"100998","ANGELA ","SMITH ","3145551212","3145551213","3145551214","0","3145551215","3145551216","0",
if ( ($format =~ /dccsv10/) && ($format_set < 1) )
{
$raw_number = $number;
chomp($number);
$number =~ s/,"0"//gi;
$number =~ s/\t/\|/gi;
$number =~ s/\'|\t|\r|\n|\l//gi;
$number =~ s/\'|\t|\r|\n|\l//gi;
$number =~ s/\",,,,,,,\"/\|\|\|\|\|\|\|/gi;
$number =~ s/\",,,,,,\"/\|\|\|\|\|\|/gi;
$number =~ s/\",,,,,\"/\|\|\|\|\|/gi;
$number =~ s/\",,,,\"/\|\|\|\|/gi;
$number =~ s/\",,,\"/\|\|\|/gi;
$number =~ s/\",,\"/\|\|/gi;
$number =~ s/\",\"/\|/gi;
$number =~ s/\"//gi;
@m = split(/\|/, $number);
$vendor_lead_code = $m[0]; chomp($vendor_lead_code);
$source_code = '';
$list_id = '929';
$phone_code = '1';
$first_name = $m[1]; chomp($first_name); $first_name =~ s/\s+$//gi;
$middle_initial = '';
$last_name = $m[2]; chomp($last_name); $last_name =~ s/\s+$//gi;
$phone_number = $m[3];
$USarea = substr($phone_number, 0, 3);
$title = '';
$address1 = '';
$address2 = '';
$address3 = $m[5]; chomp($alt_phone); $alt_phone =~ s/\D//gi;
$city = '';
$state = '';
$province = '';
$postal_code = '';
$country = '';
$gender = '';
$date_of_birth = '';
$alt_phone = $m[4]; chomp($alt_phone); $alt_phone =~ s/\D//gi;
$email = '';
$security_phrase = '';
$comments = '';
$called_count = '0';
$status = 'NEW';
$insert_date = $pulldate0;
$rank = '';
$owner = '';
$multi_alt_phones = '';
$r=0;
$map_count=0;
if (length($m[6]) > 9)
{
$ALTm_phone_number[$r] = $m[6];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
if (length($m[7]) > 9)
{
$ALTm_phone_number[$r] = $m[7];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
if (length($m[8]) > 9)
{
$ALTm_phone_number[$r] = $m[8];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
if (length($m[9]) > 9)
{
$ALTm_phone_number[$r] = $m[9];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
$format_set++;
}
# This is the format for the standard lead files
#3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS
if ($format_set < 1)
@@ -1,7 +1,7 @@
<?php
# AST_CLOSERstats.php
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
#
@@ -24,6 +24,7 @@
# 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion
# 90801-0921 - Added in-group name to pulldown
# 91214-0955 - Added INITIAL QUEUE POSITION BREAKDOWN
# 100206-1454 - Fixed TMR(service level) calculation
#
require("dbconnect.php");
@@ -336,7 +337,7 @@ $rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rowy=mysql_fetch_row($rslt);
@@ -432,13 +433,13 @@ if (strlen($group_SQL)>3)
$Sanswer_sec_pct_rt_stat_one = $row[0];
$Sanswer_sec_pct_rt_stat_two = $row[1];
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_one;";
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_one and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$answer_sec_pct_rt_stat_one = $row[0];
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_two;";
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -680,7 +681,7 @@ echo " +---------------------------------------------------------------
echo " | 0 5 10 15 20 25 30 35 40 45 50 55 60 90 +90 | TOTAL |\n";
echo "----------+-------------------------------------------------------------------------------------------+------------+\n";
$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE') group by queue_seconds;";
$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND') group by queue_seconds;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$reasons_to_print = mysql_num_rows($rslt);
@@ -1222,7 +1223,7 @@ while ($j < $calls_to_print)
{
$Ftotal[$i]++;
if (ereg("DROP",$Cstatus[$j])) {$Fdrop[$i]++;}
if (!ereg("DROP|XDROP|HXFER|QVMAIL|HOLDTO|LIVE|QUEUE",$Cstatus[$j]))
if (!ereg("DROP|XDROP|HXFER|QVMAIL|HOLDTO|LIVE|QUEUE|TIMEOT|AFTHRS|NANQUE|INBND",$Cstatus[$j]))
{
$BDansweredCALLS++;
$Fanswer[$i]++;
@@ -481,6 +481,8 @@ if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];}
elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["status_id"])) {$status_id=$_GET["status_id"];}
elseif (isset($_POST["status_id"])) {$status_id=$_POST["status_id"];}
if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];}
elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
@@ -1307,7 +1309,6 @@ if ($non_latin < 1)
$voicemail_dump_exten = ereg_replace("[^0-9]","",$voicemail_dump_exten);
$voicemail_ext = ereg_replace("[^0-9]","",$voicemail_ext);
$voicemail_exten = ereg_replace("[^0-9]","",$voicemail_exten);
$voicemail_id = ereg_replace("[^0-9]","",$voicemail_id);
$wrapup_seconds = ereg_replace("[^0-9]","",$wrapup_seconds);
$use_non_latin = ereg_replace("[^0-9]","",$use_non_latin);
$webroot_writable = ereg_replace("[^0-9]","",$webroot_writable);
@@ -1477,6 +1478,8 @@ if ($non_latin < 1)
$pause_after_each_call = ereg_replace("[^0-9a-zA-Z]","",$pause_after_each_call);
$use_internal_dnc = ereg_replace("[^0-9a-zA-Z]","",$use_internal_dnc);
$use_campaign_dnc = ereg_replace("[^0-9a-zA-Z]","",$use_campaign_dnc);
$voicemail_id = ereg_replace("[^0-9a-zA-Z]","",$voicemail_id);
$status_id = ereg_replace("[^0-9a-zA-Z]","",$status_id);
### DIGITS and Dots
$server_ip = ereg_replace("[^\.0-9]","",$server_ip);
@@ -1551,7 +1554,6 @@ if ($non_latin < 1)
$server_id = ereg_replace("[^-_0-9a-zA-Z]","",$server_id);
$stage = ereg_replace("[^-_0-9a-zA-Z]","",$stage);
$state_rule = ereg_replace("[^-_0-9a-zA-Z]","",$state_rule);
$status = ereg_replace("[^-_0-9a-zA-Z]","",$status);
$trunk_restriction = ereg_replace("[^-_0-9a-zA-Z]","",$trunk_restriction);
$user = ereg_replace("[^-_0-9a-zA-Z]","",$user);
$user_group = ereg_replace("[^-_0-9a-zA-Z]","",$user_group);
@@ -8700,21 +8702,21 @@ if ($ADD==20)
if ($ADD==22)
{
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';";
$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name\n";}
else
{
$stmt="SELECT count(*) from vicidial_statuses where status='$status';";
$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name\n";}
else
{
if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) )
if ( (strlen($campaign_id) < 2) or (strlen($status_id) < 1) or (strlen($status_name) < 2) )
{
echo "<br>CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered\n";
echo "<br>status must be between 1 and 8 characters in length\n";
@@ -8722,16 +8724,16 @@ if ($ADD==22)
}
else
{
echo "<br><B>CAMPAIGN STATUS ADDED: $campaign_id - $status</B>\n";
echo "<br><B>CAMPAIGN STATUS ADDED: $campaign_id - $status_id</B>\n";
$stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status','$status_name','$selectable','$campaign_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status_id','$status_name','$selectable','$campaign_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$rslt=mysql_query($stmt, $link);
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = ereg_replace(';','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGN_STATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGN_STATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status_id';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
@@ -10294,21 +10296,21 @@ if ($ADD==21111111111111)
if ($ADD==221111111111111)
{
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
$stmt="SELECT count(*) from vicidial_campaign_statuses where status='$status';";
$stmt="SELECT count(*) from vicidial_campaign_statuses where status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>SYSTEM STATUS NOT ADDED - there is already a campaign-status in the system with this name: $row[0]\n";}
else
{
$stmt="SELECT count(*) from vicidial_statuses where status='$status';";
$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>SYSTEM STATUS NOT ADDED - there is already a global-status in the system with this name\n";}
else
{
if ( (strlen($status) < 1) or (strlen($status_name) < 2) )
if ( (strlen($status_id) < 1) or (strlen($status_name) < 2) )
{
echo "<br>SYSTEM STATUS NOT ADDED - Please go back and look at the data you entered\n";
echo "<br>status must be between 1 and 8 characters in length\n";
@@ -10316,16 +10318,16 @@ if ($ADD==221111111111111)
}
else
{
echo "<br><B>SYSTEM STATUS ADDED: $status_name - $status</B>\n";
echo "<br><B>SYSTEM STATUS ADDED: $status_name - $status_id</B>\n";
$stmt="INSERT INTO vicidial_statuses (status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status','$status_name','$selectable','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$stmt="INSERT INTO vicidial_statuses (status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status_id','$status_name','$selectable','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$rslt=mysql_query($stmt, $link);
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = ereg_replace(';','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUSES', event_type='ADD', record_id='$status', event_code='ADMIN ADD SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUSES', event_type='ADD', record_id='$status_id', event_code='ADMIN ADD SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
@@ -17087,7 +17089,7 @@ if ($ADD==31)
echo "<br>ADD NEW CUSTOM CAMPAIGN STATUS<BR><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=ADD value=22>\n";
echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
echo "Status: <input type=text name=status size=10 maxlength=8> &nbsp; \n";
echo "Status: <input type=text name=status_id size=8 maxlength=6> &nbsp; \n";
echo "Description: <input type=text name=status_name size=20 maxlength=30> &nbsp; \n";
echo "Selectable: <select size=1 name=selectable><option>Y</option><option>N</option></select> &nbsp; <BR>\n";
echo "Human Answer: <select size=1 name=human_answered><option>Y</option><option SELECTED>N</option></select> &nbsp; \n";
@@ -22595,7 +22597,7 @@ if ($ADD==321111111111111)
echo "<br>ADD NEW SYSTEM STATUS<BR><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=ADD value=221111111111111>\n";
echo "Status: <input type=text name=status size=7 maxlength=6> &nbsp; \n";
echo "Status: <input type=text name=status_id size=7 maxlength=6> &nbsp; \n";
echo "Description: <input type=text name=status_name size=30 maxlength=30><BR>\n";
echo "Selectable: <select size=1 name=selectable><option>Y</option><option>N</option></select> &nbsp; \n";
echo "Human Answer: <select size=1 name=human_answered><option>Y</option><option>N</option></select> &nbsp; \n";
+12 -9
View File
@@ -19,7 +19,7 @@
# exten => 8320,1,AGI(VD_amd.agi,${EXTEN}-----YES)
# exten => 8320,2,Hangup
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# changes:
# 60206-1434 first build
@@ -31,6 +31,7 @@
# 71118-0252 - compatibility with Asterisk 1.4, added AA and AM statuses
# 90916-1317 - Changed to audio file playback and TTS playback
# 90924-1533 - Added answering machine message list_id override option
# 100205-1025 - Fixed CPD send to message
#
$script = 'VD_amd.agi';
@@ -292,12 +293,14 @@ else
}
$sthA->finish();
########## UPDATE vicidial_list ##########
$stmtA = "UPDATE vicidial_list set status='AA' where lead_id = '$VD_lead_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
if ($AMDSTATUS !~ /CPD/)
{
########## UPDATE vicidial_list ##########
$stmtA = "UPDATE vicidial_list set status='AA' where lead_id = '$VD_lead_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
}
########## DELETE vicidial_auto_calls entry ##########
$stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
@@ -310,7 +313,7 @@ else
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$epc_countCUSTDATA=0;
$epc_countCUSTDATA=0;
while ($sthArows > $epc_countCUSTDATA)
{
@aryA = $sthA->fetchrow_array;
@@ -373,7 +376,7 @@ else
}
### check for list_id override
if ($DB_amd_send_to_vmx =~ /Y/)
if ( ($DB_amd_send_to_vmx =~ /Y/) || ($AMDSTATUS =~ /CPD/) )
{
### find list_id for this lead
$stmtA = "SELECT list_id from vicidial_list where lead_id = '$VD_lead_id';";
+12 -6
View File
@@ -46,7 +46,7 @@
#exten => 8366,4,AGI(agi-VDAD_ALL_outbound.agi,SURVEY-----LB-----US_pol_survey_hello-----1238-----8-----US_pol_survey_transfer-----US_thanks_no_contact-----OPTOUT-----DNC)
#exten => 8366,5,Hangup
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# changes:
# 80218-2027 - First Build
@@ -71,6 +71,7 @@
# 90924-1605 - Added drop_inbound_group_override list_id option
# 91112-1101 - Changed ENTERQUEUE to CALLOUTBOUND in QM logging for outbound calls
# 91230-1159 - Change to callee callerID when sending the call to VMAIL
# 100205-1024 - Fixed CPD send to message
#
$script = 'agi-VDAD_ALL_outbound.agi';
@@ -2127,6 +2128,16 @@ sub cpd_end_call
if ( ($cpd_amd_action =~ /MESSAGE/) && ($cpd_result !~ /Fax/i) )
{
$DROPexten = "8320";
$AMDSTATUS_set = $AGI->set_variable('AMDSTATUS', "CPDMACHINE");
$AMDCAUSE_set = $AGI->set_variable('AMDCAUSE', $cpd_result);
}
else
{
$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;
if ($AGILOG) {$agi_string = "-- VDAD CPD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;}
}
$Euniqueid=$uniqueid;
@@ -2143,11 +2154,6 @@ sub cpd_end_call
$dbhP=$dbhA; $mysql_count='01051'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD CPD vicidial_list update: |$affected_rows|$CIDlead_id"; &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;
if ($AGILOG) {$agi_string = "-- VDAD CPD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;}
$stmtA = "UPDATE vicidial_cpd_log SET status='PROCESSED',cpd_seconds='$drop_timer' where callerid='$callerid' and result IN('Answering-Machine','Fax') and status='NEW';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01055'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
+6 -5
View File
@@ -6,7 +6,7 @@
# adjusts the auto_dial_level for vicidial adaptive-predictive campaigns.
# gather call stats for campaigns and in-groups
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 60823-1302 - First build from AST_VDhopper.pl
@@ -33,6 +33,7 @@
# 90628-2001 - Added drop rate group functions
# 91115-0929 - Added auto-kill of script at timeclock reset time of day to facilitate cleaner clearing of daily stats
# 91206-2203 - Added campaign_calldate within last 5 minute as an override to recalculate stats
# 100206-1453 - Fixed calculation of hold_sec stats (service level) for in-groups
#
# constants
@@ -1327,7 +1328,7 @@ sub calculate_drops_inbound
if ($iVCScalls_today[$p] > 0)
{
# TODAY ANSWERS
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1359,7 +1360,7 @@ sub calculate_drops_inbound
$sthA->finish();
# TODAY ANSWER PERCENT OF HOLD SECONDS one and two
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_one;";
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_one and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1369,7 +1370,7 @@ sub calculate_drops_inbound
$answer_sec_pct_rt_stat_one_PCT[$p] = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_two;";
$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and queue_seconds <= $answer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -1380,7 +1381,7 @@ sub calculate_drops_inbound
}
# TODAY TOTAL HOLD TIME FOR ANSWERED CALLS
$stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
+239 -140
View File
@@ -12,7 +12,7 @@
#
# Should only be run on one server in a multi-server Asterisk/VICIDIAL cluster
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG:
# 61115-1246 - First build, framework setup, non-functional
@@ -27,6 +27,7 @@
# 90306-1844 - Added configurable calls-per-second option
# 90729-0611 - Added vicidial_balance_rank option
# 90924-1519 - Added List callerid override option
# 100205-1245 - Added optional stagger sending of calls across all available servers in each rank
#
### begin parsing run-time options ###
@@ -41,10 +42,33 @@ if (length($ARGV[0])>1)
if ($args =~ /--help/i)
{
print "allowed run time options:\n [-t] = test\n [-debug] = verbose debug messages\n [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n\n";
print "allowed run time options:\n";
print " [-t] = test\n";
print " [-debug] = verbose debug messages\n";
print " [-staggered] = experimental staggering of placing calls on large multi-server systems\n";
print " [--delay=XXX] = delay of XXX seconds per loop, default 2.5 seconds\n";
print "\n";
exit;
}
else
{
if ($args =~ /-debug/i)
{
$DB=1; # Debug flag, set to 0 for no debug messages
print "\n-- DEBUG --\n\n";
}
if ($args =~ /-t/i)
{
$TEST=1;
$T=1;
}
if ($args =~ /-staggered/i)
{
$staggered=1;
print "\n-- STAGGERED MULTI-SERVER DIAL MODE --\n\n";
}
else
{$staggered=0;}
if ($args =~ /--delay=/i)
{
@data_in = split(/--delay=/,$args);
@@ -56,23 +80,13 @@ if (length($ARGV[0])>1)
{
$loop_delay = '2500';
}
if ($args =~ /-debug/i)
{
$DB=1; # Debug flag, set to 0 for no debug messages
print "\n-- DEBUG --\n\n";
}
if ($args =~ /-t/i)
{
$TEST=1;
$T=1;
}
}
}
else
{
print "no command line options set\n";
$loop_delay = '2500';
$DB=1;
$loop_delay = '2500';
$DB=1;
}
### end parsing run-time options ###
@@ -134,31 +148,30 @@ if (!$VDADLOGfile) {$VDADLOGfile = "$PATHlogs/vdautodial_FILL.$year-$mon-$mday";
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
### connect to MySQL database defined in the conf file
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
### connect to MySQL database defined in the conf file
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBtelnet_host = "$aryA[0]";
$DBtelnet_port = "$aryA[1]";
$DBASTmgrUSERNAME = "$aryA[2]";
$DBASTmgrSECRET = "$aryA[3]";
$DBASTmgrUSERNAMEupdate = "$aryA[4]";
$DBASTmgrUSERNAMElisten = "$aryA[5]";
$DBASTmgrUSERNAMEsend = "$aryA[6]";
$DBmax_vicidial_trunks = "$aryA[7]";
$DBanswer_transfer_agent= "$aryA[8]";
$DBSERVER_GMT = "$aryA[9]";
$DBext_context = "$aryA[10]";
$DBvd_server_logs = "$aryA[11]";
$DBtelnet_host = $aryA[0];
$DBtelnet_port = $aryA[1];
$DBASTmgrUSERNAME = $aryA[2];
$DBASTmgrSECRET = $aryA[3];
$DBASTmgrUSERNAMEupdate = $aryA[4];
$DBASTmgrUSERNAMElisten = $aryA[5];
$DBASTmgrUSERNAMEsend = $aryA[6];
$DBmax_vicidial_trunks = $aryA[7];
$DBanswer_transfer_agent= $aryA[8];
$DBSERVER_GMT = $aryA[9];
$DBext_context = $aryA[10];
$DBvd_server_logs = $aryA[11];
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
@@ -171,8 +184,7 @@ while ($sthArows > $rec_count)
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
else {$SYSLOG = '0';}
}
$sthA->finish();
@@ -182,7 +194,6 @@ $sthA->finish();
$one_day_interval = 12; # 1 month loops for one year
while($one_day_interval > 0)
{
$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
$stat_count=1;
@@ -239,12 +250,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$balance_servers = "$aryA[0]";
$rec_count++;
$balance_servers = $aryA[0];
}
$sthA->finish();
@@ -257,8 +266,8 @@ while($one_day_interval > 0)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBfill_campaign[$camp_counter] = "$aryA[0]";
$DBfill_shortage[$camp_counter] = "$aryA[1]";
$DBfill_campaign[$camp_counter] = $aryA[0];
$DBfill_shortage[$camp_counter] = $aryA[1];
$total_shortage = ($total_shortage + $aryA[1]);
if($DB) {print "$DBfill_campaign[$camp_counter]: $DBfill_shortage[$camp_counter]\n";}
@@ -275,7 +284,7 @@ while($one_day_interval > 0)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$outbound_calls_per_second = "$aryA[0]";
$outbound_calls_per_second = $aryA[0];
}
$sthA->finish();
@@ -307,7 +316,7 @@ while($one_day_interval > 0)
### grab the dial_level and multiply by active agents to get your goalcalls
$DBIPadlevel[$camp_CIPct]=0;
$stmtA = "SELECT dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,omit_phone_code,auto_alt_dial,queue_priority FROM vicidial_campaigns where campaign_id='$DBfill_campaign[$camp_CIPct]'";
$stmtA = "SELECT dial_timeout,dial_prefix,campaign_cid,active,campaign_vdad_exten,omit_phone_code,auto_alt_dial,queue_priority FROM vicidial_campaigns where campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -316,31 +325,30 @@ while($one_day_interval > 0)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DBIPdialtimeout[$camp_CIPct] = "$aryA[0]";
$DBIPdialprefix[$camp_CIPct] = "$aryA[1]";
$DBIPcampaigncid[$camp_CIPct] = "$aryA[2]";
$DBIPactive[$camp_CIPct] = "$aryA[3]";
$DBIPvdadexten[$camp_CIPct] = "$aryA[4]";
$omit_phone_code = "$aryA[5]";
if ($omit_phone_code =~ /Y/) {$DBIPomitcode[$camp_CIPct] = 1;}
else {$DBIPomitcode[$camp_CIPct] = 0;}
$DBIPautoaltdial[$camp_CIPct] = "$aryA[6]";
$DBIPqueue_priority[$camp_CIPct] = "$aryA[7]";
$DBIPdialtimeout[$camp_CIPct] = $aryA[0];
$DBIPdialprefix[$camp_CIPct] = $aryA[1];
$DBIPcampaigncid[$camp_CIPct] = $aryA[2];
$DBIPactive[$camp_CIPct] = $aryA[3];
$DBIPvdadexten[$camp_CIPct] = $aryA[4];
$omit_phone_code = $aryA[5];
$DBIPautoaltdial[$camp_CIPct] = $aryA[6];
$DBIPqueue_priority[$camp_CIPct] = $aryA[7];
if ($omit_phone_code =~ /Y/) {$DBIPomitcode[$camp_CIPct] = 1;}
else {$DBIPomitcode[$camp_CIPct] = 0;}
$rec_count++;
}
$sthA->finish();
$stmtA = "SELECT balance_trunk_fill FROM vicidial_campaign_stats where campaign_id='$DBfill_campaign[$camp_CIPct]'";
$stmtA = "SELECT balance_trunk_fill FROM vicidial_campaign_stats where campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DB_balance_fill = "$aryA[0]";
$rec_count++;
$DB_balance_fill = $aryA[0];
}
$sthA->finish();
@@ -348,12 +356,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_balance_fill = "$aryA[0]";
$rec_count++;
$VAC_balance_fill = $aryA[0];
}
$sthA->finish();
$DBfill_current_balance[$camp_CIPct] = "$VAC_balance_fill";
@@ -368,7 +374,7 @@ while($one_day_interval > 0)
##### Get a listing of the servers in the campaign that have shortages of trunks
$full_servers='|';
$full_serversSQL='';
$stmtA = "SELECT server_ip FROM vicidial_campaign_server_stats where update_time > '$XDSQLdate' and local_trunk_shortage > 0 and campaign_id='$DBfill_campaign[$camp_CIPct]'";
$stmtA = "SELECT server_ip FROM vicidial_campaign_server_stats where update_time > '$XDSQLdate' and local_trunk_shortage > 0 and campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -391,12 +397,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$AVAIL_balance_servers = "$aryA[0]";
$rec_count++;
$AVAIL_balance_servers = $aryA[0];
}
$sthA->finish();
@@ -426,9 +430,9 @@ while($one_day_interval > 0)
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$DB_camp_server_server_ip[$DB_camp_servers] = "$aryA[0]";
$DB_camp_server_max_vicidial_trunks[$DB_camp_servers] = "$aryA[1]";
$DB_camp_server_balance_trunks_offlimits[$DB_camp_servers] = "$aryA[2]";
$DB_camp_server_server_ip[$DB_camp_servers] = $aryA[0];
$DB_camp_server_max_vicidial_trunks[$DB_camp_servers] = $aryA[1];
$DB_camp_server_balance_trunks_offlimits[$DB_camp_servers] = $aryA[2];
$DB_camp_servers++;
$rec_count++;
}
@@ -444,18 +448,18 @@ while($one_day_interval > 0)
$DB_camp_server_dedicated_trunks[$server_CIPct]=0;
$DB_camp_server_trunk_restriction[$server_CIPct]=0;
$DB_NONcamp_server_dedicated_trunks[$server_CIPct]=0;
$SERVER_CAMP_temp_avail[$server_CIPct]=0;
$SERVER_CAMP_temp_tally[$server_CIPct]=0;
##### Get the campaign-specific trunk settings for the campaign on this server
$stmtA = "SELECT dedicated_trunks,trunk_restriction FROM vicidial_server_trunks where server_ip='$DB_camp_server_server_ip[$server_CIPct]' and campaign_id='$DBfill_campaign[$camp_CIPct]';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DB_camp_server_dedicated_trunks[$server_CIPct] = "$aryA[0]";
$DB_camp_server_trunk_restriction[$server_CIPct] = "$aryA[1]";
$rec_count++;
$DB_camp_server_dedicated_trunks[$server_CIPct] = $aryA[0];
$DB_camp_server_trunk_restriction[$server_CIPct] = $aryA[1];
}
$sthA->finish();
@@ -464,12 +468,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DB_NONcamp_server_dedicated_trunks[$server_CIPct] = "$aryA[0]";
$rec_count++;
$DB_NONcamp_server_dedicated_trunks[$server_CIPct] = $aryA[0];
}
$sthA->finish();
@@ -480,12 +482,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_server_BALcamp = "$aryA[0]";
$rec_count++;
$VAC_server_BALcamp = $aryA[0];
}
$sthA->finish();
@@ -493,12 +493,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_server_camp = "$aryA[0]";
$rec_count++;
$VAC_server_camp = $aryA[0];
}
$sthA->finish();
@@ -506,12 +504,10 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VAC_server_NONcamp = "$aryA[0]";
$rec_count++;
$VAC_server_NONcamp = $aryA[0];
}
$sthA->finish();
@@ -526,19 +522,19 @@ while($one_day_interval > 0)
{
$DB_camp_server_available[$server_CIPct] = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $DB_camp_server_balance_trunks_offlimits[$server_CIPct]) - $DB_NONcamp_server_dedicated_trunks[$server_CIPct]);
}
$temp_tally = ($DBfill_needed[$camp_CIPct] - $DBfill_tally[$camp_CIPct]);
$temp_avail = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $VAC_server_camp) - $VAC_server_NONcamp);
$SERVER_CAMP_temp_tally[$server_CIPct] = ($DBfill_needed[$camp_CIPct] - $DBfill_tally[$camp_CIPct]);
$SERVER_CAMP_temp_avail[$server_CIPct] = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $VAC_server_camp) - $VAC_server_NONcamp);
$DB_camp_server_available[$server_CIPct] = ($DB_camp_server_available[$server_CIPct] - $VAC_server_BALcamp);
if ($DB_camp_server_available[$server_CIPct] < 0) {$DB_camp_server_available[$server_CIPct]=0;}
if($DB) {print "TEMPVALS: |$temp_tally|$temp_avail|$DB_camp_server_available[$server_CIPct]||\n";}
if ($DB_camp_server_available[$server_CIPct] >= $temp_tally)
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $temp_tally;}
if($DB) {print "TEMPVALS: |$SERVER_CAMP_temp_tally[$server_CIPct]|$SERVER_CAMP_temp_avail[$server_CIPct]|$DB_camp_server_available[$server_CIPct]||\n";}
if ($DB_camp_server_available[$server_CIPct] >= $SERVER_CAMP_temp_tally[$server_CIPct])
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $SERVER_CAMP_temp_tally[$server_CIPct];}
else
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $DB_camp_server_available[$server_CIPct];}
if ($temp_avail < $DB_camp_server_trunks_to_dial[$server_CIPct])
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $temp_avail;}
if ($SERVER_CAMP_temp_avail[$server_CIPct] < $DB_camp_server_trunks_to_dial[$server_CIPct])
{$DB_camp_server_trunks_to_dial[$server_CIPct] = $SERVER_CAMP_temp_avail[$server_CIPct];}
$DBfill_tally[$camp_CIPct] = ($DBfill_tally[$camp_CIPct] + $DB_camp_server_trunks_to_dial[$server_CIPct]);
@@ -572,7 +568,7 @@ while($one_day_interval > 0)
my $UDaffected_rows=0;
if ($call_CMPIPct < $DB_camp_server_trunks_to_dial[$server_CIPct])
{
$stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='READY' order by priority desc,hopper_id LIMIT $DB_camp_server_trunks_to_dial[$server_CIPct]";
$stmtA = "UPDATE vicidial_hopper set status='QUEUE', user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='READY' order by priority desc,hopper_id LIMIT $DB_camp_server_trunks_to_dial[$server_CIPct];";
print "|$stmtA|\n";
$UDaffected_rows = $dbhA->do($stmtA);
print "hopper rows updated to QUEUE: |$UDaffected_rows|\n";
@@ -582,19 +578,17 @@ while($one_day_interval > 0)
$lead_id=''; $phone_code=''; $phone_number=''; $called_count='';
while ($call_CMPIPct < $UDaffected_rows)
{
$stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='QUEUE' and user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' order by priority desc,hopper_id LIMIT 1";
$stmtA = "SELECT lead_id,alt_dial FROM vicidial_hopper where campaign_id='$DBfill_campaign[$camp_CIPct]' and status='QUEUE' and user='VDAD_$DB_camp_server_server_ip[$server_CIPct]' 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)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$lead_id = "$aryA[0]";
$alt_dial = "$aryA[1]";
$rec_count++;
$lead_id = $aryA[0];
$alt_dial = $aryA[1];
}
$sthA->finish();
@@ -611,7 +605,7 @@ while($one_day_interval > 0)
}
else
{
$stmtA = "UPDATE vicidial_hopper set status='INCALL' where lead_id='$lead_id'";
$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";
@@ -620,7 +614,6 @@ while($one_day_interval > 0)
$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)
{
@@ -635,7 +628,6 @@ while($one_day_interval > 0)
$called_count = $aryA[7];
$rec_countCUSTDATA++;
$rec_count++;
}
$sthA->finish();
@@ -710,22 +702,22 @@ while($one_day_interval > 0)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$phone_code = "$aryA[0]";
$phone_number = "$aryA[1]";
$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'";
$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'";
$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'";
$stmtA = "DELETE FROM vicidial_hopper where lead_id='$lead_id';";
$affected_rows = $dbhA->do($stmtA);
$CCID_on=0; $CCID='';
@@ -768,20 +760,38 @@ while($one_day_interval > 0)
$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','$DB_camp_server_server_ip[$server_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','','','','')";
$affected_rows = $dbhA->do($stmtA);
$event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
&event_logger;
if ($staggered < 1)
{
### insert a NEW record to the vicidial_manager table to be processed
$stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$DB_camp_server_server_ip[$server_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','','','','')";
$affected_rows = $dbhA->do($stmtA);
### 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) values('$DB_camp_server_server_ip[$server_CIPct]','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
$affected_rows = $dbhA->do($stmtA);
$event_string = "| number call dialed|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$stmtA|$gmt_offset_now|$alt_dial|";
&event_logger;
### sleep for 2.5 hundredths of a second to not flood the server with new calls
# usleep(1*25*1000);
usleep(1*$per_call_delay*1000);
### 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) values('$DB_camp_server_server_ip[$server_CIPct]','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
$affected_rows = $dbhA->do($stmtA);
}
else
{
##### create dummy records to have their server_ip filled in at the stagger section
$vm_inserts[$staggered_ct] = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','XXXXXXXXXXXXXXX','','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','','','','')";
$vac_inserts[$staggered_ct] = "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) values('XXXXXXXXXXXXXXX','$DBfill_campaign[$camp_CIPct]','SENT','$lead_id','$VqueryCID','$phone_code','$phone_number','$SQLdate','OUTBALANCE','$alt_dial','$DBIPqueue_priority[$camp_CIPct]')";
$st_logged[$staggered_ct] = "$phone_number|$DBfill_campaign[$camp_CIPct]|$VqueryCID|$gmt_offset_now|$alt_dial|";
$staggered_ct++;
}
if ($staggered < 1)
{
### sleep for 2.5 hundredths of a second to not flood the server with new calls
# usleep(1*25*1000);
usleep(1*$per_call_delay*1000);
}
}
}
$call_CMPIPct++;
@@ -809,6 +819,102 @@ while($one_day_interval > 0)
&event_logger;
}
###############################################################################
###### BEGIN - experimental balanced FILL dialing ($staggered)
###############################################################################
if ( ($staggered > 0) && ($staggered_ct > 0) )
{
$staggered_fill=0;
$stmtA = "SELECT count(*),vicidial_balance_rank FROM servers group by vicidial_balance_rank order by vicidial_balance_rank desc;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$st_ct=0;
while ($sthArows > $st_ct)
{
@aryA = $sthA->fetchrow_array;
$ST_count[$st_ct] = $aryA[0];
$ST_rank[$st_ct] = $aryA[1];
$st_ct++;
}
$sthA->finish();
##### gather available trunks on all servers and place calls
$staggered_rank_ct=0;
while ( ($st_ct > $staggered_rank_ct) && ($staggered_ct > $staggered_fill) )
{
$TOTAL_available=0;
$stmtA = "SELECT server_ip FROM servers where vicidial_balance_rank='$ST_rank[$staggered_rank_ct]' order by server_ip LIMIT $ST_count[$staggered_rank_ct];";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsSIPS=$sthA->rows;
$st_si_ct=0;
while ($sthArowsSIPS > $st_si_ct)
{
@aryA = $sthA->fetchrow_array;
$ST_server_ip[$st_si_ct] = $aryA[0];
$io=0;
foreach(@DB_camp_server_server_ip)
{
if ( ($DB_camp_server_server_ip[$io] =~ /$ST_server_ip[$st_si_ct]/) && (length($DB_camp_server_server_ip[$io]) == length($ST_server_ip[$st_si_ct])) )
{
$ST_available[$st_si_ct] = $SERVER_CAMP_temp_avail[$io];
$ST_tally[$st_si_ct] = $SERVER_CAMP_temp_tally[$io];
$TOTAL_available = ($TOTAL_available + $ST_available[$st_si_ct]);
}
$io++;
}
$st_si_ct++;
}
$sthA->finish();
##### place calls
$failsafe_ct=0;
$RANK_calls_placed=0;
$st_si_loop=0;
while ( ($TOTAL_available > $RANK_calls_placed) && ($failsafe_ct < 99999) )
{
$TEMP_server_ip = $ST_server_ip[$st_si_loop];
$TEMP_vm_insert = $vm_inserts[$staggered_fill];
$TEMP_vac_insert = $vac_inserts[$staggered_fill];
$TEMP_st_logged = $st_logged[$staggered_fill];
$TEMP_vm_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi;
$TEMP_vac_insert =~ s/XXXXXXXXXXXXXXX/$TEMP_server_ip/gi;
$affected_rows_vm = $dbhA->do($TEMP_vm_insert);
$affected_rows_vac = $dbhA->do($TEMP_vac_insert);
$event_string = "| number call stagger dialed|$TEMP_server_ip| $TEMP_st_logged";
&event_logger;
### sleep for 2.5 hundredths of a second to not flood the server with new calls
# usleep(1*25*1000);
usleep(1*$per_call_delay*1000);
$RANK_calls_placed++;
$staggered_fill++;
$failsafe_ct++;
$st_si_loop++;
if ($st_si_loop >= $st_si_ct)
{$st_si_loop=0;}
}
$staggered_rank_ct++;
}
}
$staggered_ct=0;
@vm_inserts=@MT;
@vac_inserts=@MT;
@st_logged=@MT;
###############################################################################
###### END - experimental balanced FILL dialing ($staggered)
###############################################################################
$temp_balance_total = ($DBfill_current_balance[$camp_CIPct] + $DBfill_tally[$camp_CIPct]);
if ($DB) {print "CURRENT FILL: $temp_balance_total = ($DBfill_current_balance[$camp_CIPct] + $DBfill_tally[$camp_CIPct])\n";}
$stmtA = "UPDATE vicidial_campaign_stats SET balance_trunk_fill='$temp_balance_total' where campaign_id='$DBfill_campaign[$camp_CIPct]';";
@@ -832,11 +938,6 @@ while($one_day_interval > 0)
}
# so far we have a check of balance servers, a check of shortage servers and we begin traversing the campaigns array
#exit;
@@ -852,6 +953,8 @@ while($one_day_interval > 0)
&event_logger;
}
###############################################################################
###### last, wait for a little bit and repeat the loop
###############################################################################
@@ -877,14 +980,12 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBvd_server_logs = "$aryA[0]";
$DBvd_server_logs = $aryA[0];
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
$rec_count++;
else {$SYSLOG = '0';}
}
$sthA->finish();
@@ -893,19 +994,17 @@ while($one_day_interval > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBmax_vicidial_trunks = "$aryA[0]";
$DBanswer_transfer_agent= "$aryA[1]";
$DBSERVER_GMT = "$aryA[2]";
$DBext_context = "$aryA[3]";
$DBmax_vicidial_trunks = $aryA[0];
$DBanswer_transfer_agent= $aryA[1];
$DBSERVER_GMT = $aryA[2];
$DBext_context = $aryA[3];
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
$rec_count++;
}
$sthA->finish();
@@ -41,6 +41,7 @@
# 91112-0645 - Added title/alt_phone duplicate checks
# 91129-2202 - removed SELECT STAR and formatting fixes
# 100118-0527 - Added new Australian and New Zealand DST schemes (FSO-FSA and LSS-FSA)
# 100204-2333 - Added dccsv10 file format
#
$secX = time();
@@ -171,6 +172,9 @@ if (length($ARGV[0])>1)
print "sccsv11:\n";
print "STATE,ID,NAME,ADDRESS,ADDRESS2,CITY,COUNTY,PHONE,FAX,ZIP,COMMENTS\n";
print "AL,16700,Fairfax Retirement Center (Crowder House),1324 25th St,,FAIRFAX,JEFFERSON,(205) 555-0508,,35733,Comments\n\n";
print "dccsv10:\n";
print "VENDOR_ID,FIRST_NAME,LAST_NAME,PHONE_1,PHONE_2,PHONE_3,PHONE_4,PHONE_5,PHONE_6,PHONE_7\n";
print "\"100998\",\"ANGELA \",\"SMITH \",\"3145551212\",\"3145551213\",\"3145551214\",\"0\",\"3145551215\",\"3145551216\",\"0\",\n\n";
exit;
}
@@ -834,6 +838,87 @@ foreach(@FILES)
$format_set++;
}
# This is the format for the dccsv10 lead files
#"100998","ANGELA ","SMITH ","3145551212","3145551213","3145551214","0","3145551215","3145551216","0",
if ( ($format =~ /dccsv10/) && ($format_set < 1) )
{
$raw_number = $number;
chomp($number);
$number =~ s/,"0"//gi;
$number =~ s/\t/\|/gi;
$number =~ s/\'|\t|\r|\n|\l//gi;
$number =~ s/\'|\t|\r|\n|\l//gi;
$number =~ s/\",,,,,,,\"/\|\|\|\|\|\|\|/gi;
$number =~ s/\",,,,,,\"/\|\|\|\|\|\|/gi;
$number =~ s/\",,,,,\"/\|\|\|\|\|/gi;
$number =~ s/\",,,,\"/\|\|\|\|/gi;
$number =~ s/\",,,\"/\|\|\|/gi;
$number =~ s/\",,\"/\|\|/gi;
$number =~ s/\",\"/\|/gi;
$number =~ s/\"//gi;
@m = split(/\|/, $number);
$vendor_lead_code = $m[0]; chomp($vendor_lead_code);
$source_code = '';
$list_id = '929';
$phone_code = '1';
$first_name = $m[1]; chomp($first_name); $first_name =~ s/\s+$//gi;
$middle_initial = '';
$last_name = $m[2]; chomp($last_name); $last_name =~ s/\s+$//gi;
$phone_number = $m[3];
$USarea = substr($phone_number, 0, 3);
$title = '';
$address1 = '';
$address2 = '';
$address3 = $m[5]; chomp($alt_phone); $alt_phone =~ s/\D//gi;
$city = '';
$state = '';
$province = '';
$postal_code = '';
$country = '';
$gender = '';
$date_of_birth = '';
$alt_phone = $m[4]; chomp($alt_phone); $alt_phone =~ s/\D//gi;
$email = '';
$security_phrase = '';
$comments = '';
$called_count = '0';
$status = 'NEW';
$insert_date = $pulldate0;
$rank = '';
$owner = '';
$multi_alt_phones = '';
$r=0;
$map_count=0;
if (length($m[6]) > 9)
{
$ALTm_phone_number[$r] = $m[6];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
if (length($m[7]) > 9)
{
$ALTm_phone_number[$r] = $m[7];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
if (length($m[8]) > 9)
{
$ALTm_phone_number[$r] = $m[8];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
if (length($m[9]) > 9)
{
$ALTm_phone_number[$r] = $m[9];
$ALTm_phone_code[$r] = '1';
$r++; $map_count++;
}
$format_set++;
}
# This is the format for the standard lead files
#3857822|31022|105|01144|1625551212|MRS|B||BURTON|249 MUNDON ROAD|MALDON|ESSEX||||CM9 6PW|UK||||||COMMENTS
if ($format_set < 1)
@@ -1,7 +1,7 @@
<?php
# AST_CLOSERstats.php
#
# Copyright (C) 2009 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2010 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
#
@@ -24,6 +24,7 @@
# 90524-2231 - Changed to use functions.php for seconds to HH:MM:SS conversion
# 90801-0921 - Added in-group name to pulldown
# 91214-0955 - Added INITIAL QUEUE POSITION BREAKDOWN
# 100206-1454 - Fixed TMR(service level) calculation
#
require("dbconnect.php");
@@ -336,7 +337,7 @@ $rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE');";
$stmt="select count(*),sum(queue_seconds) from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$rowy=mysql_fetch_row($rslt);
@@ -432,13 +433,13 @@ if (strlen($group_SQL)>3)
$Sanswer_sec_pct_rt_stat_one = $row[0];
$Sanswer_sec_pct_rt_stat_two = $row[1];
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_one;";
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_one and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
$answer_sec_pct_rt_stat_one = $row[0];
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_two;";
$stmt = "SELECT count(*) from vicidial_closer_log where campaign_id IN($group_SQL) and call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and queue_seconds <= $Sanswer_sec_pct_rt_stat_two and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND');";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$row=mysql_fetch_row($rslt);
@@ -680,7 +681,7 @@ echo " +---------------------------------------------------------------
echo " | 0 5 10 15 20 25 30 35 40 45 50 55 60 90 +90 | TOTAL |\n";
echo "----------+-------------------------------------------------------------------------------------------+------------+\n";
$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE') group by queue_seconds;";
$stmt="select count(*),queue_seconds from vicidial_closer_log where call_date >= '$query_date_BEGIN' and call_date <= '$query_date_END' and campaign_id IN($group_SQL) and status NOT IN('DROP','XDROP','HXFER','QVMAIL','HOLDTO','LIVE','QUEUE','TIMEOT','AFTHRS','NANQUE','INBND') group by queue_seconds;";
$rslt=mysql_query($stmt, $link);
if ($DB) {echo "$stmt\n";}
$reasons_to_print = mysql_num_rows($rslt);
@@ -1222,7 +1223,7 @@ while ($j < $calls_to_print)
{
$Ftotal[$i]++;
if (ereg("DROP",$Cstatus[$j])) {$Fdrop[$i]++;}
if (!ereg("DROP|XDROP|HXFER|QVMAIL|HOLDTO|LIVE|QUEUE",$Cstatus[$j]))
if (!ereg("DROP|XDROP|HXFER|QVMAIL|HOLDTO|LIVE|QUEUE|TIMEOT|AFTHRS|NANQUE|INBND",$Cstatus[$j]))
{
$BDansweredCALLS++;
$Fanswer[$i]++;
+17 -15
View File
@@ -481,6 +481,8 @@ if (isset($_GET["state_rule"])) {$state_rule=$_GET["state_rule"];}
elseif (isset($_POST["state_rule"])) {$state_rule=$_POST["state_rule"];}
if (isset($_GET["status"])) {$status=$_GET["status"];}
elseif (isset($_POST["status"])) {$status=$_POST["status"];}
if (isset($_GET["status_id"])) {$status_id=$_GET["status_id"];}
elseif (isset($_POST["status_id"])) {$status_id=$_POST["status_id"];}
if (isset($_GET["status_name"])) {$status_name=$_GET["status_name"];}
elseif (isset($_POST["status_name"])) {$status_name=$_POST["status_name"];}
if (isset($_GET["submit"])) {$submit=$_GET["submit"];}
@@ -1498,6 +1500,7 @@ if ($non_latin < 1)
$use_internal_dnc = ereg_replace("[^0-9a-zA-Z]","",$use_internal_dnc);
$use_campaign_dnc = ereg_replace("[^0-9a-zA-Z]","",$use_campaign_dnc);
$voicemail_id = ereg_replace("[^0-9a-zA-Z]","",$voicemail_id);
$status_id = ereg_replace("[^0-9a-zA-Z]","",$status_id);
### DIGITS and Dots
$server_ip = ereg_replace("[^\.0-9]","",$server_ip);
@@ -1572,7 +1575,6 @@ if ($non_latin < 1)
$server_id = ereg_replace("[^-_0-9a-zA-Z]","",$server_id);
$stage = ereg_replace("[^-_0-9a-zA-Z]","",$stage);
$state_rule = ereg_replace("[^-_0-9a-zA-Z]","",$state_rule);
$status = ereg_replace("[^-_0-9a-zA-Z]","",$status);
$trunk_restriction = ereg_replace("[^-_0-9a-zA-Z]","",$trunk_restriction);
$user = ereg_replace("[^-_0-9a-zA-Z]","",$user);
$user_group = ereg_replace("[^-_0-9a-zA-Z]","",$user_group);
@@ -8794,21 +8796,21 @@ if ($ADD==20)
if ($ADD==22)
{
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status';";
$stmt="SELECT count(*) from vicidial_campaign_statuses where campaign_id='$campaign_id' and status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>CAMPAIGN STATUS NOT ADDED - there is already a campaign-status in the system with this name\n";}
else
{
$stmt="SELECT count(*) from vicidial_statuses where status='$status';";
$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>CAMPAIGN STATUS NOT ADDED - there is already a global-status in the system with this name\n";}
else
{
if ( (strlen($campaign_id) < 2) or (strlen($status) < 1) or (strlen($status_name) < 2) )
if ( (strlen($campaign_id) < 2) or (strlen($status_id) < 1) or (strlen($status_name) < 2) )
{
echo "<br>CAMPAIGN STATUS NOT ADDED - Please go back and look at the data you entered\n";
echo "<br>status must be between 1 and 8 characters in length\n";
@@ -8816,16 +8818,16 @@ if ($ADD==22)
}
else
{
echo "<br><B>CAMPAIGN STATUS ADDED: $campaign_id - $status</B>\n";
echo "<br><B>CAMPAIGN STATUS ADDED: $campaign_id - $status_id</B>\n";
$stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status','$status_name','$selectable','$campaign_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$stmt="INSERT INTO vicidial_campaign_statuses (status,status_name,selectable,campaign_id,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status_id','$status_name','$selectable','$campaign_id','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$rslt=mysql_query($stmt, $link);
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = ereg_replace(';','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGN_STATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status';";
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='CAMPAIGN_STATUS', event_type='ADD', record_id='$campaign_id', event_code='ADMIN ADD CAMPAIGN STATUS', event_sql=\"$SQL_log\", event_notes='Status: $status_id';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
@@ -10388,21 +10390,21 @@ if ($ADD==21111111111111)
if ($ADD==221111111111111)
{
echo "<FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2>";
$stmt="SELECT count(*) from vicidial_campaign_statuses where status='$status';";
$stmt="SELECT count(*) from vicidial_campaign_statuses where status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>SYSTEM STATUS NOT ADDED - there is already a campaign-status in the system with this name: $row[0]\n";}
else
{
$stmt="SELECT count(*) from vicidial_statuses where status='$status';";
$stmt="SELECT count(*) from vicidial_statuses where status='$status_id';";
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0] > 0)
{echo "<br>SYSTEM STATUS NOT ADDED - there is already a global-status in the system with this name\n";}
else
{
if ( (strlen($status) < 1) or (strlen($status_name) < 2) )
if ( (strlen($status_id) < 1) or (strlen($status_name) < 2) )
{
echo "<br>SYSTEM STATUS NOT ADDED - Please go back and look at the data you entered\n";
echo "<br>status must be between 1 and 8 characters in length\n";
@@ -10410,16 +10412,16 @@ if ($ADD==221111111111111)
}
else
{
echo "<br><B>SYSTEM STATUS ADDED: $status_name - $status</B>\n";
echo "<br><B>SYSTEM STATUS ADDED: $status_name - $status_id</B>\n";
$stmt="INSERT INTO vicidial_statuses (status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status','$status_name','$selectable','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$stmt="INSERT INTO vicidial_statuses (status,status_name,selectable,human_answered,category,sale,dnc,customer_contact,not_interested,unworkable) values('$status_id','$status_name','$selectable','$human_answered','$category','$sale','$dnc','$customer_contact','$not_interested','$unworkable');";
$rslt=mysql_query($stmt, $link);
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = ereg_replace(';','',$SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUSES', event_type='ADD', record_id='$status', event_code='ADMIN ADD SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
$stmt="INSERT INTO vicidial_admin_log set event_date='$SQLdate', user='$PHP_AUTH_USER', ip_address='$ip', event_section='SYSTEMSTATUSES', event_type='ADD', record_id='$status_id', event_code='ADMIN ADD SYSTEM STATUS', event_sql=\"$SQL_log\", event_notes='';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_query($stmt, $link);
}
@@ -17213,7 +17215,7 @@ if ($ADD==31)
echo "<br>ADD NEW CUSTOM CAMPAIGN STATUS<BR><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=ADD value=22>\n";
echo "<input type=hidden name=campaign_id value=\"$campaign_id\">\n";
echo "Status: <input type=text name=status size=10 maxlength=8> &nbsp; \n";
echo "Status: <input type=text name=status_id size=8 maxlength=6> &nbsp; \n";
echo "Description: <input type=text name=status_name size=20 maxlength=30> &nbsp; \n";
echo "Selectable: <select size=1 name=selectable><option>Y</option><option>N</option></select> &nbsp; <BR>\n";
echo "Human Answer: <select size=1 name=human_answered><option>Y</option><option SELECTED>N</option></select> &nbsp; \n";
@@ -22743,7 +22745,7 @@ if ($ADD==321111111111111)
echo "<br>ADD NEW SYSTEM STATUS<BR><form action=$PHP_SELF method=POST>\n";
echo "<input type=hidden name=ADD value=221111111111111>\n";
echo "Status: <input type=text name=status size=7 maxlength=6> &nbsp; \n";
echo "Status: <input type=text name=status_id size=7 maxlength=6> &nbsp; \n";
echo "Description: <input type=text name=status_name size=30 maxlength=30><BR>\n";
echo "Selectable: <select size=1 name=selectable><option>Y</option><option>N</option></select> &nbsp; \n";
echo "Human Answer: <select size=1 name=human_answered><option>Y</option><option>N</option></select> &nbsp; \n";