From bf34a4eeccf0f01128960a625c50c1d7f96ec0af Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 14 May 2009 10:53:52 +0000 Subject: [PATCH] Added audio store and audio synchronization processes Fixed bug in AST_VDadapt.pl script git-svn-id: svn://192.168.202.10@1115 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 5 + bin/ADMIN_audio_store_sync.pl | 396 ++++ bin/ADMIN_keepalive_ALL.pl | 60 +- bin/AST_VDadapt.pl | 2097 ++++++++--------- bin/Vtiger_OUT_sync2VICIDIAL_file.pl | 6 +- docs/NON-AGENT_API.txt | 27 + docs/REQUIREMENTS.txt | 3 +- docs/Ubuntu_Install.txt | 10 +- extras/MySQL_AST_CREATE_tables.sql | 17 +- extras/upgrade_2.2.0.sql | 16 + .../TO_BE_TRANSLATED_2.2.0.txt | 13 + www/vicidial/admin.php | 86 +- www/vicidial/admin_header.php | 50 + www/vicidial/audio_store.php | 290 +++ www/vicidial/dbconnect.php | 2 + www/vicidial/non_agent_api.php | 168 +- 16 files changed, 2136 insertions(+), 1110 deletions(-) create mode 100644 bin/ADMIN_audio_store_sync.pl create mode 100644 www/vicidial/audio_store.php diff --git a/UPGRADE b/UPGRADE index 7c8b91f6..e4e517ab 100644 --- a/UPGRADE +++ b/UPGRADE @@ -36,6 +36,11 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 8. Changed all PHP scripts to use long tags, short tags are depricated in PHP6 +9. Added audio upload ability from web interface, choose audio prompts from a + list in the call menu and in-group admin screens, and back-end audio + synchronization utilities have been added for multi-server setups. + + diff --git a/bin/ADMIN_audio_store_sync.pl b/bin/ADMIN_audio_store_sync.pl new file mode 100644 index 00000000..c538aaa6 --- /dev/null +++ b/bin/ADMIN_audio_store_sync.pl @@ -0,0 +1,396 @@ +#!/usr/bin/perl +# +# ADMIN_audio_store_sync.pl version 2.2.0 +# +# DESCRIPTION: +# syncronizes audio between audio store and this server +# +# +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 +# +# CHANGELOG +# 90513-0458 - First Build +# + +# constants +$DB=0; +$US='__'; +$MT[0]=''; +$uploaded=0; +$downloaded=0; + +$secT = time(); +$now_date_epoch = $secT; +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$mon++; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$Fhour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$file_date = "$year-$mon-$mday"; +$now_date = "$year-$mon-$mday $hour:$min:$sec"; +$VDL_date = "$year-$mon-$mday 00:00:01"; +$inactive_epoch = ($secT - 60); +$HHMM = "$hour$min"; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--upload] = upload audio not found on audio store\n [--force-download] = force download of everything from audio store\n [--settings-override] = ignore database settings and run sync anyway\n\n"; + exit; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; + print "\n----- DEBUG -----\n\n"; + } + if ($args =~ /--upload/i) + { + $upload=1; + if ($DB) {print "\n----- UPLOAD -----\n\n";} + } + if ($args =~ /--force-download/i) + { + $force_download=1; + if ($DB) {print "\n----- FORCE DOWNLOAD -----\n\n";} + } + if ($args =~ /--settings-override/i) + { + $settings_override=1; + if ($DB) {print "\n----- SETTINGS OVERRIDE -----\n\n";} + } + if ($args =~ /--debugX/i) + { + $DBX=1; + if ($DB) {print "\n----- SUPER DEBUG -----\n\n";} + } + if ($args =~ /-t/i) + { + $T=1; $TEST=1; + if ($DB) {print "\n-----TESTING -----\n\n";} + } + } + } +else + { +# print "no command line options set\n"; + } + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) ) + {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) ) + {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) ) + {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) ) + {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +if (!$VASLOGfile) {$VASLOGfile = "$PATHlogs/audiostore.$year-$mon-$mday";} +if (!$VARDB_port) {$VARDB_port='3306';} + +use DBI; + +$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 active_asterisk_server FROM servers where server_ip = '$VARserver_ip';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $active_asterisk_server = "$aryA[0]"; + } + $sthA->finish(); + +### Grab system_settings values from the database + $stmtA = "SELECT sounds_central_control_active,sounds_web_server,sounds_web_directory FROM system_settings;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $sounds_central_control_active = "$aryA[0]"; + $sounds_web_server = "$aryA[1]"; + $sounds_web_directory = "$aryA[2]"; + } + $sthA->finish(); + +if ( ( ($sounds_central_control_active < 1) || ($active_asterisk_server !~ /Y/) ) && ($settings_override < 1) ) + { + print "Audio Sync Settings not active, Exiting\n"; + exit; + } + +$stmtA="UPDATE servers SET sounds_update='N' where server_ip='$VARserver_ip';"; +$affected_rows = $dbhA->do($stmtA); + + + + +### find wget binary +$wgetbin = ''; +if ( -e ('/bin/wget')) {$wgetbin = '/bin/wget';} +else + { + if ( -e ('/usr/bin/wget')) {$wgetbin = '/usr/bin/wget';} + else + { + if ( -e ('/usr/local/bin/wget')) {$wgetbin = '/usr/local/bin/wget';} + else + { + print "Can't find wget binary! Exiting...\n"; + exit + } + } + } + +### find curl binary +$curlbin = ''; +if ( -e ('/bin/curl')) {$curlbin = '/bin/curl';} +else + { + if ( -e ('/usr/bin/curl')) {$curlbin = '/usr/bin/curl';} + else + { + if ( -e ('/usr/local/bin/curl')) {$curlbin = '/usr/local/bin/curl';} + else + { + print "Can't find curl binary! Exiting...\n"; + exit + } + } + } + + +$URL = "http://$sounds_web_server/vicidial/audio_store.php?action=LIST"; + +$URL =~ s/&/\\&/gi; +if ($DB) + {print "\n$URL\n";} + +$audio_list_file = '/tmp/audio_store_list.txt'; +`rm -f $audio_list_file`; +`$wgetbin -q --output-document=$audio_list_file $URL `; + +open(list, "$audio_list_file") || die "can't open $audio_list_file: $!\n"; +@list = ; +close(list); + +opendir(sounds, "$PATHsounds"); +@sounds= readdir(sounds); +closedir(sounds); + + + +####### BEGIN download of audio files +if ($DB > 0) {print "REMOTE AUDIO FILES:\n";} + +$i=0; +while ($i <= $#list) + { + chomp($list[$i]); + @file_data = split(/\t/, $list[$i]); + $filename = $file_data[1]; + $filedate = $file_data[2]; + $filesize = $file_data[3]; + $fileepoch = $file_data[4]; + if ($DB > 0) {print "$i $filename $filedate $filesize $fileepoch\n";} + + $k=0; + $found_file=0; + while ($k <= $#sounds) + { + chomp($sounds[$k]); + $soundname = $sounds[$k]; + $soundsize = (-s "$PATHsounds/$sounds[$k]"); + + if ( ($filename eq "$soundname") && ($filesize eq "$soundsize") ) + { + $found_file++; + } + $k++; + } + + if ($found_file < 1) + { + `$wgetbin -q --output-document=$PATHsounds/$filename http://$sounds_web_server/$sounds_web_directory/$filename`; + $event_string = "DOWNLOADING: $filename $filesize"; + if ($DB > 0) {print " $event_string\n";} + &event_logger; + + $downloaded++; + } + else + { + if ($DB > 0) {print " FILE FOUND: $filename\n";} + } + $i++; + } +####### END download of audio files + +$total_files = $i; + + + +`rm -f $audio_list_file`; +`$wgetbin -q --output-document=$audio_list_file $URL `; + +open(list, "$audio_list_file") || die "can't open $audio_list_file: $!\n"; +@list = ; +close(list); + +opendir(sounds, "$PATHsounds"); +@sounds= readdir(sounds); +closedir(sounds); + + + + + +####### BEGIN upload of audio files +if ($upload > 0) + { + if ($DB > 0) {print "LOCAL AUDIO FILES:\n";} + + $k=0; + while ($k <= $#sounds) + { + chomp($sounds[$k]); + if ($sounds[$k] =~ /\.wav$|\.gsm$/) + { + $soundname = $sounds[$k]; + $sounddate = (-M "$PATHsounds/$sounds[$k]"); + $soundsize = (-s "$PATHsounds/$sounds[$k]"); + $soundsec = ($sounddate * 86400); + $soundepoch = ($secT - $soundsec); + + if ($DB > 0) {print "$k $soundname $sounddate $soundsize $soundepoch\n";} + + $i=0; + $found_file=0; + while ($i <= $#list) + { + chomp($list[$i]); + @file_data = split(/\t/, $list[$i]); + $filename = $file_data[1]; + $filedate = $file_data[2]; + $filesize = $file_data[3]; + $fileepoch = $file_data[4]; + + if ( ($filename eq "$soundname") && ($filesize eq "$soundsize") ) + { + $found_file++; + } + $i++; + } + + if ($found_file < 1) + { + $curloptions = "-s 'http://$sounds_web_server/vicidial/audio_store.php?action=AUTOUPLOAD' -F \"audiofile=\@$PATHsounds/$soundname\""; + `$curlbin $curloptions`; + $event_string = "UPLOADING: $soundname $soundsize"; + if ($DB > 0) {print " $event_string\n|$curlbin $curloptions|\n";} + &event_logger; + + $uploaded++; + } + else + { + if ($DB > 0) {print " FILE FOUND: $soundname\n";} + } + } + $k++; + } + } +####### END upload of audio files + + + + +###### If audio was uploaded from this server, set all other servers to update sounds next minute +if ($uploaded > 0) + { + $stmtA="UPDATE servers SET sounds_update='Y' where server_ip NOT IN('$VARserver_ip');"; + $affected_rows = $dbhA->do($stmtA); + } + + +if($DB) + { + print "AUDIO FILES ON SERVER: $total_files\n"; + print "NEW DOWNLOADED: $downloaded\n"; + print "NEW UPLOADED: $uploaded\n\n"; + + ### calculate time to run script ### + $secY = time(); + $secZ = ($secY - $secT); + + if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";} + } + +$dbhA->disconnect(); + +exit; + + + +sub event_logger + { + if ($SYSLOG) + { + ### open the log file for writing ### + open(Lout, ">>$VASLOGfile") + || die "Can't open $VASLOGfile: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; + } + diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index b977b77e..d2691e24 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# ADMIN_keepalive_ALL.pl version 2.0.5 +# ADMIN_keepalive_ALL.pl version 2.2.0 # # Designed to keep the astGUIclient processes alive and check every minute # Replaces all other ADMIN_keepalive scripts @@ -9,7 +9,7 @@ # # Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # -# +# CHANGES # 61011-1348 - First build # 61120-2011 - Added option 7 for AST_VDauto_dial_FILL.pl # 80227-1526 - Added option 8 for ip_relay @@ -20,6 +20,7 @@ # 90327-1421 - Removed [globals] tag from auto-generated extensions file # 90409-1251 - Fixed voicemail conf file issue # 90506-1155 - Added Call Menu functionality +# 90513-0449 - Added audio store sync functionality # $DB=0; # Debug flag @@ -493,7 +494,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA or die "Couldn't connect to database: " . DBI->errstr; ##### Get the settings for this server's server_ip ##### -$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version FROM servers where server_ip='$server_ip';"; +$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update FROM servers where server_ip='$server_ip';"; # print "$stmtA\n"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -501,11 +502,11 @@ $sthArows=$sthA->rows; if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $active_asterisk_server = "$aryA[0]"; - $generate_vicidial_conf = "$aryA[1]"; - $rebuild_conf_files = "$aryA[2]"; - $asterisk_version = "$aryA[3]"; - $i++; + $active_asterisk_server = $aryA[0]; + $generate_vicidial_conf = $aryA[1]; + $rebuild_conf_files = $aryA[2]; + $asterisk_version = $aryA[3]; + $sounds_update = $aryA[4]; } $sthA->finish(); @@ -1100,11 +1101,6 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r } } - - - - - ################################################################################ ##### END Creation of auto-generated conf files ################################################################################ @@ -1113,6 +1109,44 @@ if ( ($active_asterisk_server =~ /Y/) && ($generate_vicidial_conf =~ /Y/) && ($r + + + +################################################################################ +##### BEGIN Audio Store sync +################################################################################ +if ( ($active_asterisk_server =~ /Y/) && ($sounds_update =~ /Y/) ) + { + ##### Get the settings from system_settings ##### + $stmtA = "SELECT sounds_central_control_active FROM system_settings;"; + # print "$stmtA\n"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $sounds_central_control_active = "$aryA[0]"; + } + $sthA->finish(); + + if ($sounds_central_control_active > 0) + { + if ($DB) {print "running audio store sync process...\n";} + `/usr/bin/screen -d -m -S AudioStore $PATHhome/ADMIN_audio_store_sync.pl 2>/dev/null 1>&2`; + } + } + + +################################################################################ +##### END Audio Store sync +################################################################################ + + + + + + if ($DB) {print "DONE\n";} exit; diff --git a/bin/AST_VDadapt.pl b/bin/AST_VDadapt.pl index 58fd2508..bd87b5ad 100644 --- a/bin/AST_VDadapt.pl +++ b/bin/AST_VDadapt.pl @@ -1,11 +1,12 @@ #!/usr/bin/perl # -# AST_VDadapt.pl version 2.0.5 +# AST_VDadapt.pl version 2.2.0 # # DESCRIPTION: # adjusts the auto_dial_level for vicidial adaptive-predictive campaigns. +# gather call stats for campaigns and in-groups # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # 60823-1302 - First build from AST_VDhopper.pl @@ -28,6 +29,7 @@ # 81022-0713 - Added gathering of vicidial_inbound_groups stats(day only) # 81108-0808 - Added more inbound stats with some debug output and added campaign agent non-pause time # 90415-0925 - Fixed rare division by zero bug +# 90512-1549 - Formatting fixes and calculation bugs in blended # # constants @@ -88,20 +90,20 @@ $secT = time(); ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--loops=XXX] = force a number of loops of XXX\n [--delay=XXX] = force a loop delay of XXX seconds\n [--campaign=XXX] = run for campaign XXX only\n [-force] = force calculation of suggested predictive dial_level\n [-test] = test only, do not alter dial_level\n\n"; - } + { + print "allowed run time options(must stay in this order):\n [--debug] = debug\n [--debugX] = super debug\n [-t] = test\n [--loops=XXX] = force a number of loops of XXX\n [--delay=XXX] = force a loop delay of XXX seconds\n [--campaign=XXX] = run for campaign XXX only\n [-force] = force calculation of suggested predictive dial_level\n [-test] = test only, do not alter dial_level\n\n"; + } else - { + { if ($args =~ /--campaign=/i) # CLI defined campaign { @CLIvarARY = split(/--campaign=/,$args); @@ -192,15 +194,15 @@ if (length($ARGV[0])>1) $T=1; $TEST=1; print "\n-----TESTING -----\n\n"; } + } } -} else -{ -$CLIcampaign = ''; -$CLIlevel = ''; -$CLIloops = '1000000'; -$CLIdelay = '1'; -} + { + $CLIcampaign = ''; + $CLIlevel = ''; + $CLIloops = '1000000'; + $CLIdelay = '1'; + } # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -252,7 +254,7 @@ if ($DBX) {print "CONNECTED TO DATABASE: $VARDB_server|$VARDB_database\n";} ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### -# Disabled per Lorenzo at QueueMetrics because this event is apparently useless +# Disabled per Lorenzo at QueueMetrics because this Asterisk event is apparently useless #$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; #$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; #$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -291,7 +293,7 @@ $master_loop=0; ### Start master loop ### while ($master_loop<$CLIloops) -{ + { &get_time_now; ### Grab Server values from the database @@ -302,18 +304,17 @@ while ($master_loop<$CLIloops) $rec_count=0; while ($sthArows > $rec_count) { - @aryA = $sthA->fetchrow_array; - $DBvd_server_logs = "$aryA[0]"; - $DBSERVER_GMT = "$aryA[1]"; - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - else {$SYSLOG = '0';} - if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} - $rec_count++; + @aryA = $sthA->fetchrow_array; + $DBvd_server_logs = "$aryA[0]"; + $DBSERVER_GMT = "$aryA[1]"; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + $rec_count++; } $sthA->finish(); - $secX = time(); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secX); $LOCAL_GMT_OFF = $SERVER_GMT; @@ -330,74 +331,33 @@ while ($master_loop<$CLIloops) if ($min < 10) {$min = "0$min";} if ($sec < 10) {$sec = "0$sec";} -# if ($DB) {print "TIME DEBUG: $master_loop $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} + # if ($DB) {print "TIME DEBUG: $master_loop $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} -@campaign_id=@MT; -@lead_order=@MT; -@hopper_level=@MT; -@auto_dial_level=@MT; -@local_call_time=@MT; -@lead_filter_id=@MT; -@use_internal_dnc=@MT; -@dial_method=@MT; -@available_only_ratio_tally[$i]=@MT; -@adaptive_dropped_percentage=@MT; -@adaptive_maximum_level=@MT; -@adaptive_latest_server_time=@MT; -@adaptive_intensity=@MT; -@adaptive_dl_diff_target=@MT; -@campaign_changedate=@MT; -@campaign_stats_refresh=@MT; + @campaign_id=@MT; + @lead_order=@MT; + @hopper_level=@MT; + @auto_dial_level=@MT; + @local_call_time=@MT; + @lead_filter_id=@MT; + @use_internal_dnc=@MT; + @dial_method=@MT; + @available_only_ratio_tally=@MT; + @adaptive_dropped_percentage=@MT; + @adaptive_maximum_level=@MT; + @adaptive_latest_server_time=@MT; + @adaptive_intensity=@MT; + @adaptive_dl_diff_target=@MT; + @campaign_changedate=@MT; + @campaign_stats_refresh=@MT; -if ($CLIcampaign) - { - $stmtA = "SELECT * from vicidial_campaigns where campaign_id='$CLIcampaign'"; - } -else - { - $stmtA = "SELECT campaign_id,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,UNIX_TIMESTAMP(campaign_changedate),campaign_stats_refresh,campaign_allow_inbound from vicidial_campaigns where ( (active='Y') or (campaign_stats_refresh='Y') )"; - } -$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) - { - @aryA = $sthA->fetchrow_array; - $campaign_id[$rec_count] = $aryA[0]; - $lead_order[$rec_count] = $aryA[1]; - if (!$CLIlevel) - {$hopper_level[$rec_count] = $aryA[2];} + if ($CLIcampaign) + { + $stmtA = "SELECT * from vicidial_campaigns where campaign_id='$CLIcampaign'"; + } else - {$hopper_level[$rec_count] = $CLIlevel;} - $auto_dial_level[$rec_count] = $aryA[3]; - $local_call_time[$rec_count] = $aryA[4]; - $lead_filter_id[$rec_count] = $aryA[5]; - $use_internal_dnc[$rec_count] = $aryA[6]; - $dial_method[$rec_count] = $aryA[7]; - $available_only_ratio_tally[$i][$rec_count] = $aryA[8]; - $adaptive_dropped_percentage[$rec_count] = $aryA[9]; - $adaptive_maximum_level[$rec_count] = $aryA[10]; - $adaptive_latest_server_time[$rec_count] = $aryA[11]; - $adaptive_intensity[$rec_count] = $aryA[12]; - $adaptive_dl_diff_target[$rec_count] = $aryA[13]; - $campaign_changedate[$rec_count] = $aryA[14]; - $campaign_stats_refresh[$rec_count] = $aryA[15]; - $campaign_allow_inbound[$rec_count] = $aryA[16]; - - $rec_count++; - } -$sthA->finish(); -if ($DB) {print "$now_date CAMPAIGNS TO PROCESSES ADAPT FOR: $rec_count|$#campaign_id IT: $master_loop\n";} - - -##### LOOP THROUGH EACH CAMPAIGN AND PROCESS THE HOPPER ##### -$i=0; -foreach(@campaign_id) - { - ### Find out how many leads are in the hopper from a specific campaign - $hopper_ready_count=0; - $stmtA = "SELECT count(*) from vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';"; + { + $stmtA = "SELECT campaign_id,lead_order,hopper_level,auto_dial_level,local_call_time,lead_filter_id,use_internal_dnc,dial_method,available_only_ratio_tally,adaptive_dropped_percentage,adaptive_maximum_level,adaptive_latest_server_time,adaptive_intensity,adaptive_dl_diff_target,UNIX_TIMESTAMP(campaign_changedate),campaign_stats_refresh,campaign_allow_inbound from vicidial_campaigns where ( (active='Y') or (campaign_stats_refresh='Y') )"; + } $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -405,45 +365,116 @@ foreach(@campaign_id) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $hopper_ready_count = $aryA[0]; - if ($DB) {print " $campaign_id[$i] hopper READY count: $hopper_ready_count";} -# if ($DBX) {print " |$stmtA|\n";} + $campaign_id[$rec_count] = $aryA[0]; + $lead_order[$rec_count] = $aryA[1]; + if (!$CLIlevel) + {$hopper_level[$rec_count] = $aryA[2];} + else + {$hopper_level[$rec_count] = $CLIlevel;} + $auto_dial_level[$rec_count] = $aryA[3]; + $local_call_time[$rec_count] = $aryA[4]; + $lead_filter_id[$rec_count] = $aryA[5]; + $use_internal_dnc[$rec_count] = $aryA[6]; + $dial_method[$rec_count] = $aryA[7]; + $available_only_ratio_tally[$i][$rec_count] = $aryA[8]; + $adaptive_dropped_percentage[$rec_count] = $aryA[9]; + $adaptive_maximum_level[$rec_count] = $aryA[10]; + $adaptive_latest_server_time[$rec_count] = $aryA[11]; + $adaptive_intensity[$rec_count] = $aryA[12]; + $adaptive_dl_diff_target[$rec_count] = $aryA[13]; + $campaign_changedate[$rec_count] = $aryA[14]; + $campaign_stats_refresh[$rec_count] = $aryA[15]; + $campaign_allow_inbound[$rec_count] = $aryA[16]; + $rec_count++; } $sthA->finish(); - $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]|$diff_ratio_updater|$drop_count_updater|"; - if ($DBX) {print "$i $event_string\n";} - &event_logger; + if ($DB) {print "$now_date CAMPAIGNS TO PROCESSES ADAPT FOR: $rec_count|$#campaign_id IT: $master_loop\n";} - ##### IF THERE ARE NO LEADS IN THE HOPPER FOR THE CAMPAIGN WE DO NOT WANT TO ADJUST THE DIAL_LEVEL - if ($hopper_ready_count>0) + + ##### LOOP THROUGH EACH CAMPAIGN AND PROCESS THE HOPPER ##### + $i=0; + foreach(@campaign_id) { - ### BEGIN - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### - $differential_onemin[$i]=0; - $agents_average_onemin[$i]=0; - - # ### Grab the count of agents and lines - # if ($campaign_id[$i] !~ /(CLOSER|BLEND|INBND|_C$|_B$|_I$)/) - # { - &count_agents_lines; - # } - # else - # { - # if ($DB) {print " CLOSER CAMPAIGN\n";} - # } - - if ($total_agents_avg[$i] > 0) + ### Find out how many leads are in the hopper from a specific campaign + $hopper_ready_count=0; + $stmtA = "SELECT count(*) from vicidial_hopper where campaign_id='$campaign_id[$i]' and status='READY';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) { - ### Update Drop counter every 60 seconds - if ($drop_count_updater>=60) - { - &calculate_drops; - } + @aryA = $sthA->fetchrow_array; + $hopper_ready_count = $aryA[0]; + if ($DB) {print " $campaign_id[$i] hopper READY count: $hopper_ready_count";} + # if ($DBX) {print " |$stmtA|\n";} + } + $sthA->finish(); + $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]|$diff_ratio_updater|$drop_count_updater|"; + if ($DBX) {print "$i $event_string\n";} + &event_logger; - ### Calculate and update Dial level every 15 seconds - if ($diff_ratio_updater>=15) + ##### IF THERE ARE NO LEADS IN THE HOPPER FOR THE CAMPAIGN WE DO NOT WANT TO ADJUST THE DIAL_LEVEL + if ($hopper_ready_count>0) + { + ### BEGIN - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### + $differential_onemin[$i]=0; + $agents_average_onemin[$i]=0; + + # ### Grab the count of agents and lines + # if ($campaign_id[$i] !~ /(CLOSER|BLEND|INBND|_C$|_B$|_I$)/) + # { + &count_agents_lines; + # } + # else + # { + # if ($DB) {print " CLOSER CAMPAIGN\n";} + # } + + if ($total_agents_avg[$i] > 0) { - &calculate_dial_level; + ### Update Drop counter every 60 seconds + if ($drop_count_updater>=60) + { + &calculate_drops; + } + + ### Calculate and update Dial level every 15 seconds + if ($diff_ratio_updater>=15) + { + &calculate_dial_level; + } + } + else + { + if ($campaign_stats_refresh[$i] =~ /Y/) + { + if ($drop_count_updater>=60) + { + if ($DB) {print " REFRESH OVERRIDE: $campaign_id[$i]\n";} + + &calculate_drops; + + $RESETdrop_count_updater++; + + $stmtA = "UPDATE vicidial_campaigns SET campaign_stats_refresh='N' where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + } + } + else + { + if ($campaign_changedate[$i] >= $VDL_ninty) + { + if ($drop_count_updater>=60) + { + if ($DB) {print " CHANGEDATE OVERRIDE: $campaign_id[$i]\n";} + + &calculate_drops; + + $RESETdrop_count_updater++; + } + } + } } } else @@ -477,68 +508,36 @@ foreach(@campaign_id) } } } + $i++; } - else + + if ( ($stat_count =~ /00$|50$/) || ($stat_count==1) ) { - if ($campaign_stats_refresh[$i] =~ /Y/) - { - if ($drop_count_updater>=60) - { - if ($DB) {print " REFRESH OVERRIDE: $campaign_id[$i]\n";} - - &calculate_drops; - - $RESETdrop_count_updater++; - - $stmtA = "UPDATE vicidial_campaigns SET campaign_stats_refresh='N' where campaign_id='$campaign_id[$i]';"; - $affected_rows = $dbhA->do($stmtA); - } - } - else - { - if ($campaign_changedate[$i] >= $VDL_ninty) - { - if ($drop_count_updater>=60) - { - if ($DB) {print " CHANGEDATE OVERRIDE: $campaign_id[$i]\n";} - - &calculate_drops; - - $RESETdrop_count_updater++; - } - } - } + &launch_inbound_gather; } - $i++; + + if ($RESETdiff_ratio_updater>0) {$RESETdiff_ratio_updater=0; $diff_ratio_updater=0;} + if ($RESETdrop_count_updater>0) {$RESETdrop_count_updater=0; $drop_count_updater=0;} + $diff_ratio_updater = ($diff_ratio_updater + $CLIdelay); + $drop_count_updater = ($drop_count_updater + $CLIdelay); + + + sleep($CLIdelay); + + $stat_count++; + $master_loop++; } -if ( ($stat_count =~ /00$|50$/) || ($stat_count==1) ) - { - &launch_inbound_gather; - } - -if ($RESETdiff_ratio_updater>0) {$RESETdiff_ratio_updater=0; $diff_ratio_updater=0;} -if ($RESETdrop_count_updater>0) {$RESETdrop_count_updater=0; $drop_count_updater=0;} -$diff_ratio_updater = ($diff_ratio_updater + $CLIdelay); -$drop_count_updater = ($drop_count_updater + $CLIdelay); - - -sleep($CLIdelay); - -$stat_count++; -$master_loop++; -} - $dbhA->disconnect(); if($DB) -{ -### calculate time to run script ### -$secY = time(); -$secZ = ($secY - $secT); + { + ### calculate time to run script ### + $secY = time(); + $secZ = ($secY - $secT); -if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";} -} + if (!$q) {print "DONE. Script execution time in seconds: $secZ\n";} + } exit; @@ -549,260 +548,189 @@ exit; ### SUBROUTINES ############################################################### sub event_logger -{ -if ($SYSLOG) { - if (!$VDHLOGfile) {$VDHLOGfile = "$PATHlogs/adapt.$year-$mon-$mday";} + if ($SYSLOG) + { + if (!$VDHLOGfile) {$VDHLOGfile = "$PATHlogs/adapt.$year-$mon-$mday";} - ### open the log file for writing ### - open(Lout, ">>$VDHLOGfile") - || die "Can't open $VDHLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); + ### open the log file for writing ### + open(Lout, ">>$VDHLOGfile") + || die "Can't open $VDHLOGfile: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; } -$event_string=''; -} sub adaptive_logger -{ -if ($SYSLOG) { - $VDHCLOGfile = "$PATHlogs/VDadaptive-$campaign_id[$i].$file_date"; + if ($SYSLOG) + { + $VDHCLOGfile = "$PATHlogs/VDadaptive-$campaign_id[$i].$file_date"; - ### open the log file for writing ### - open(Aout, ">>$VDHCLOGfile") - || die "Can't open $VDHCLOGfile: $!\n"; - print Aout "$now_date$adaptive_string\n"; - close(Aout); + ### open the log file for writing ### + open(Aout, ">>$VDHCLOGfile") + || die "Can't open $VDHCLOGfile: $!\n"; + print Aout "$now_date$adaptive_string\n"; + close(Aout); + } + $adaptive_string=''; } -$adaptive_string=''; -} sub get_time_now -{ -$secX = time(); -($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); -$year = ($year + 1900); -$mon++; -if ($mon < 10) {$mon = "0$mon";} -if ($mday < 10) {$mday = "0$mday";} -if ($hour < 10) {$Fhour = "0$hour";} -if ($min < 10) {$min = "0$min";} -if ($sec < 10) {$sec = "0$sec";} -$file_date = "$year-$mon-$mday"; -$now_date = "$year-$mon-$mday $hour:$min:$sec"; -$VDL_date = "$year-$mon-$mday 00:00:01"; -$current_hourmin = "$hour$min"; + { + $secX = time(); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year = ($year + 1900); + $mon++; + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + if ($hour < 10) {$Fhour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + $file_date = "$year-$mon-$mday"; + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + $VDL_date = "$year-$mon-$mday 00:00:01"; + $current_hourmin = "$hour$min"; -### get date-time of one hour ago ### - $VDL_hour = ($secX - (60 * 60)); -($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_hour); -$Vyear = ($Vyear + 1900); -$Vmon++; -if ($Vmon < 10) {$Vmon = "0$Vmon";} -if ($Vmday < 10) {$Vmday = "0$Vmday";} -$VDL_hour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; + ### get date-time of one hour ago ### + $VDL_hour = ($secX - (60 * 60)); + ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_hour); + $Vyear = ($Vyear + 1900); + $Vmon++; + if ($Vmon < 10) {$Vmon = "0$Vmon";} + if ($Vmday < 10) {$Vmday = "0$Vmday";} + $VDL_hour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; -### get date-time of half hour ago ### - $VDL_halfhour = ($secX - (30 * 60)); -($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_halfhour); -$Vyear = ($Vyear + 1900); -$Vmon++; -if ($Vmon < 10) {$Vmon = "0$Vmon";} -if ($Vmday < 10) {$Vmday = "0$Vmday";} -$VDL_halfhour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; + ### get date-time of half hour ago ### + $VDL_halfhour = ($secX - (30 * 60)); + ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_halfhour); + $Vyear = ($Vyear + 1900); + $Vmon++; + if ($Vmon < 10) {$Vmon = "0$Vmon";} + if ($Vmday < 10) {$Vmday = "0$Vmday";} + $VDL_halfhour = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; -### get date-time of five minutes ago ### - $VDL_five = ($secX - (5 * 60)); -($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_five); -$Vyear = ($Vyear + 1900); -$Vmon++; -if ($Vmon < 10) {$Vmon = "0$Vmon";} -if ($Vmday < 10) {$Vmday = "0$Vmday";} -$VDL_five = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; + ### get date-time of five minutes ago ### + $VDL_five = ($secX - (5 * 60)); + ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_five); + $Vyear = ($Vyear + 1900); + $Vmon++; + if ($Vmon < 10) {$Vmon = "0$Vmon";} + if ($Vmday < 10) {$Vmday = "0$Vmday";} + $VDL_five = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; -### get epoch of ninty seconds ago ### - $VDL_ninty = ($secX - (1 * 90)); + ### get epoch of ninty seconds ago ### + $VDL_ninty = ($secX - (1 * 90)); -### get date-time of one minute ago ### - $VDL_one = ($secX - (1 * 60)); -($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_one); -$Vyear = ($Vyear + 1900); -$Vmon++; -if ($Vmon < 10) {$Vmon = "0$Vmon";} -if ($Vmday < 10) {$Vmday = "0$Vmday";} -$VDL_one = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; -} + ### get date-time of one minute ago ### + $VDL_one = ($secX - (1 * 60)); + ($Vsec,$Vmin,$Vhour,$Vmday,$Vmon,$Vyear,$Vwday,$Vyday,$Visdst) = localtime($VDL_one); + $Vyear = ($Vyear + 1900); + $Vmon++; + if ($Vmon < 10) {$Vmon = "0$Vmon";} + if ($Vmday < 10) {$Vmday = "0$Vmday";} + $VDL_one = "$Vyear-$Vmon-$Vmday $Vhour:$Vmin:$Vsec"; + } sub count_agents_lines -{ -### Calculate campaign-wide agent waiting and calls waiting differential -$stat_it=15; -$total_agents[$i]=0; -$ready_agents[$i]=0; -$waiting_calls[$i]=0; -$ready_diff_total[$i]=0; -$waiting_diff_total[$i]=0; -$total_agents_total[$i]=0; -$ready_diff_avg[$i]=0; -$waiting_diff_avg[$i]=0; -$total_agents_avg[$i]=0; -$stat_differential[$i]=0; - -$stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; -$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) { - @aryA = $sthA->fetchrow_array; - $VCSagent_count[$i] = "$aryA[0]"; - $VCSagent_status[$i] = "$aryA[1]"; - $rec_count++; - if ($VCSagent_status[$i] =~ /READY|DONE/) {$ready_agents[$i] = ($ready_agents[$i] + $VCSagent_count[$i]);} - $total_agents[$i] = ($total_agents[$i] + $VCSagent_count[$i]); - } -$sthA->finish(); + ### Calculate campaign-wide agent waiting and calls waiting differential + $stat_it=15; + $total_agents[$i]=0; + $ready_agents[$i]=0; + $waiting_calls[$i]=0; + $ready_diff_total[$i]=0; + $waiting_diff_total[$i]=0; + $total_agents_total[$i]=0; + $ready_diff_avg[$i]=0; + $waiting_diff_avg[$i]=0; + $total_agents_avg[$i]=0; + $stat_differential[$i]=0; -$stmtA = "SELECT count(*) FROM vicidial_auto_calls where campaign_id='$campaign_id[$i]' and status IN('LIVE');"; -$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) - { - @aryA = $sthA->fetchrow_array; + $stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; + $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) + { + @aryA = $sthA->fetchrow_array; + $VCSagent_count[$i] = "$aryA[0]"; + $VCSagent_status[$i] = "$aryA[1]"; + $rec_count++; + if ($VCSagent_status[$i] =~ /READY|DONE/) {$ready_agents[$i] = ($ready_agents[$i] + $VCSagent_count[$i]);} + $total_agents[$i] = ($total_agents[$i] + $VCSagent_count[$i]); + } + $sthA->finish(); + + $stmtA = "SELECT count(*) FROM vicidial_auto_calls where campaign_id='$campaign_id[$i]' and status IN('LIVE');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; $waiting_calls[$i] = "$aryA[0]"; - $rec_count++; + } + $sthA->finish(); + + $stat_ready_agents[$i][$stat_count] = $ready_agents[$i]; + $stat_waiting_calls[$i][$stat_count] = $waiting_calls[$i]; + $stat_total_agents[$i][$stat_count] = $total_agents[$i]; + + if ($stat_count < 15) + { + $stat_it = $stat_count; + $stat_B = 1; + } + else + { + $stat_B = ($stat_count - 14); + } + + $it=0; + while($it < $stat_it) + { + $it_ary = ($it + $stat_B); + $ready_diff_total[$i] = ($ready_diff_total[$i] + $stat_ready_agents[$i][$it_ary]); + $waiting_diff_total[$i] = ($waiting_diff_total[$i] + $stat_waiting_calls[$i][$it_ary]); + $total_agents_total[$i] = ($total_agents_total[$i] + $stat_total_agents[$i][$it_ary]); + # $event_string="$stat_count $it_ary $stat_total_agents[$i][$it_ary]|$stat_ready_agents[$i][$it_ary]|$stat_waiting_calls[$i][$it_ary]"; + # if ($DB) {print " $event_string\n";} + # &event_logger; + $it++; + } + + if ($ready_diff_total[$i] > 0) + {$ready_diff_avg[$i] = ($ready_diff_total[$i] / $stat_it);} + if ($waiting_diff_total[$i] > 0) + {$waiting_diff_avg[$i] = ($waiting_diff_total[$i] / $stat_it);} + if ($total_agents_total[$i] > 0) + {$total_agents_avg[$i] = ($total_agents_total[$i] / $stat_it);} + $stat_differential[$i] = ($ready_diff_avg[$i] - $waiting_diff_avg[$i]); + + $event_string="CAMPAIGN DIFFERENTIAL: $total_agents_avg[$i] $stat_differential[$i] ($ready_diff_avg[$i] - $waiting_diff_avg[$i])"; + if ($DBX) {print "$campaign_id[$i]|$event_string\n";} + if ($DB) {print " $event_string\n";} + + &event_logger; + + # $stmtA = "UPDATE vicidial_campaign_stats SET differential_onemin[$i]='$stat_differential[$i]', agents_average_onemin[$i]='$total_agents_avg[$i]' where campaign_id='$DBIPcampaign[$i]';"; + # $affected_rows = $dbhA->do($stmtA); } -$sthA->finish(); - -$stat_ready_agents[$i][$stat_count] = $ready_agents[$i]; -$stat_waiting_calls[$i][$stat_count] = $waiting_calls[$i]; -$stat_total_agents[$i][$stat_count] = $total_agents[$i]; - -if ($stat_count < 15) - { - $stat_it = $stat_count; - $stat_B = 1; - } -else - { - $stat_B = ($stat_count - 14); - } - -$it=0; -while($it < $stat_it) - { - $it_ary = ($it + $stat_B); - $ready_diff_total[$i] = ($ready_diff_total[$i] + $stat_ready_agents[$i][$it_ary]); - $waiting_diff_total[$i] = ($waiting_diff_total[$i] + $stat_waiting_calls[$i][$it_ary]); - $total_agents_total[$i] = ($total_agents_total[$i] + $stat_total_agents[$i][$it_ary]); -# $event_string="$stat_count $it_ary $stat_total_agents[$i][$it_ary]|$stat_ready_agents[$i][$it_ary]|$stat_waiting_calls[$i][$it_ary]"; -# if ($DB) {print " $event_string\n";} -# &event_logger; - $it++; - } - -if ($ready_diff_total[$i] > 0) - {$ready_diff_avg[$i] = ($ready_diff_total[$i] / $stat_it);} -if ($waiting_diff_total[$i] > 0) - {$waiting_diff_avg[$i] = ($waiting_diff_total[$i] / $stat_it);} -if ($total_agents_total[$i] > 0) - {$total_agents_avg[$i] = ($total_agents_total[$i] / $stat_it);} -$stat_differential[$i] = ($ready_diff_avg[$i] - $waiting_diff_avg[$i]); - -$event_string="CAMPAIGN DIFFERENTIAL: $total_agents_avg[$i] $stat_differential[$i] ($ready_diff_avg[$i] - $waiting_diff_avg[$i])"; -if ($DBX) {print "$campaign_id[$i]|$event_string\n";} -if ($DB) {print " $event_string\n";} - -&event_logger; - -# $stmtA = "UPDATE vicidial_campaign_stats SET differential_onemin[$i]='$stat_differential[$i]', agents_average_onemin[$i]='$total_agents_avg[$i]' where campaign_id='$DBIPcampaign[$i]';"; -# $affected_rows = $dbhA->do($stmtA); -} sub calculate_drops -{ -$camp_ANS_STAT_SQL=''; -# GET LIST OF HUMAN-ANSWERED STATUSES -$stmtA = "SELECT status from vicidial_statuses where human_answered='Y';"; -$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) { - @aryA = $sthA->fetchrow_array; - $camp_ANS_STAT_SQL .= "'$aryA[0]',"; - $rec_count++; - } -$sthA->finish(); - -$stmtA = "SELECT status from vicidial_campaign_statuses where campaign_id='$campaign_id[$i]' and human_answered='Y';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $camp_ANS_STAT_SQL .= "'$aryA[0]',"; - $rec_count++; - } -$sthA->finish(); -chop($camp_ANS_STAT_SQL); - -if ($DBX) {print " CAMPAIGN ANSWERED STATUSES: $campaign_id[$i]|$camp_ANS_STAT_SQL|\n";} - -$RESETdrop_count_updater++; -$VCScalls_today[$i]=0; -$VCSanswers_today[$i]=0; -$VCSdrops_today[$i]=0; -$VCSdrops_today_pct[$i]=0; -$VCSdrops_answers_today_pct[$i]=0; -$VCScalls_hour[$i]=0; -$VCSanswers_hour[$i]=0; -$VCSdrops_hour[$i]=0; -$VCSdrops_hour_pct[$i]=0; -$VCScalls_halfhour[$i]=0; -$VCSanswers_halfhour[$i]=0; -$VCSdrops_halfhour[$i]=0; -$VCSdrops_halfhour_pct[$i]=0; -$VCScalls_five[$i]=0; -$VCSanswers_five[$i]=0; -$VCSdrops_five[$i]=0; -$VCSdrops_five_pct[$i]=0; -$VCScalls_one[$i]=0; -$VCSanswers_one[$i]=0; -$VCSdrops_one[$i]=0; -$VCSdrops_one_pct[$i]=0; -$VCSagent_nonpause_time[$i]=0; - -# LAST ONE MINUTE CALL AND DROP STATS -$stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VCScalls_one[$i] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); -if ($VCScalls_one[$i] > 0) - { - # LAST MINUTE ANSWERS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one' and status IN($camp_ANS_STAT_SQL);"; + $camp_ANS_STAT_SQL=''; + # GET LIST OF HUMAN-ANSWERED STATUSES + $stmtA = "SELECT status from vicidial_statuses where human_answered='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -810,12 +738,12 @@ if ($VCScalls_one[$i] > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VCSanswers_one[$i] = "$aryA[0]"; + $camp_ANS_STAT_SQL .= "'$aryA[0]',"; $rec_count++; } $sthA->finish(); - # LAST MINUTE DROPS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one' and status IN('DROP','XDROP');"; + + $stmtA = "SELECT status from vicidial_campaign_statuses where campaign_id='$campaign_id[$i]' and human_answered='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -823,264 +751,280 @@ if ($VCScalls_one[$i] > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VCSdrops_one[$i] = "$aryA[0]"; - if ($VCSdrops_one[$i] > 0) + $camp_ANS_STAT_SQL .= "'$aryA[0]',"; + $rec_count++; + } + $sthA->finish(); + chop($camp_ANS_STAT_SQL); + + if ($DBX) {print " CAMPAIGN ANSWERED STATUSES: $campaign_id[$i]|$camp_ANS_STAT_SQL|\n";} + + $RESETdrop_count_updater++; + $VCScalls_today[$i]=0; + $VCSanswers_today[$i]=0; + $VCSdrops_today[$i]=0; + $VCSdrops_today_pct[$i]=0; + $VCSdrops_answers_today_pct[$i]=0; + $VCScalls_hour[$i]=0; + $VCSanswers_hour[$i]=0; + $VCSdrops_hour[$i]=0; + $VCSdrops_hour_pct[$i]=0; + $VCScalls_halfhour[$i]=0; + $VCSanswers_halfhour[$i]=0; + $VCSdrops_halfhour[$i]=0; + $VCSdrops_halfhour_pct[$i]=0; + $VCScalls_five[$i]=0; + $VCSanswers_five[$i]=0; + $VCSdrops_five[$i]=0; + $VCSdrops_five_pct[$i]=0; + $VCScalls_one[$i]=0; + $VCSanswers_one[$i]=0; + $VCSdrops_one[$i]=0; + $VCSdrops_one_pct[$i]=0; + $VCSagent_nonpause_time[$i]=0; + + # LAST ONE MINUTE CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCScalls_one[$i] = "$aryA[0]"; + } + $sthA->finish(); + if ($VCScalls_one[$i] > 0) + { + # LAST MINUTE ANSWERS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one' and status IN($camp_ANS_STAT_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) { - $VCSdrops_one_pct[$i] = ( ($VCSdrops_one[$i] / $VCScalls_one[$i]) * 100 ); - $VCSdrops_one_pct[$i] = sprintf("%.2f", $VCSdrops_one_pct[$i]); + @aryA = $sthA->fetchrow_array; + $VCSanswers_one[$i] = "$aryA[0]"; } - $rec_count++; - } - $sthA->finish(); - } - -# TODAY CALL AND DROP STATS -$stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VCScalls_today[$i] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); -if ($VCScalls_today[$i] > 0) - { - # TODAY ANSWERS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN($camp_ANS_STAT_SQL);"; - $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) - { - @aryA = $sthA->fetchrow_array; - $VCSanswers_today[$i] = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - # TODAY DROPS - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; - $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) - { - @aryA = $sthA->fetchrow_array; - $VCSdrops_today[$i] = "$aryA[0]"; - if ($VCSdrops_today[$i] > 0) + $sthA->finish(); + # LAST MINUTE DROPS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_one' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) { - $VCSdrops_today_pct[$i] = ( ($VCSdrops_today[$i] / $VCScalls_today[$i]) * 100 ); - $VCSdrops_today_pct[$i] = sprintf("%.2f", $VCSdrops_today_pct[$i]); - if ($VCSanswers_today[$i] < 1) {$VCSanswers_today[$i] = 1;} - $VCSdrops_answers_today_pct[$i] = ( ($VCSdrops_today[$i] / $VCSanswers_today[$i]) * 100 ); - $VCSdrops_answers_today_pct[$i] = sprintf("%.2f", $VCSdrops_answers_today_pct[$i]); + @aryA = $sthA->fetchrow_array; + $VCSdrops_one[$i] = "$aryA[0]"; + if ($VCSdrops_one[$i] > 0) + { + $VCSdrops_one_pct[$i] = ( ($VCSdrops_one[$i] / $VCScalls_one[$i]) * 100 ); + $VCSdrops_one_pct[$i] = sprintf("%.2f", $VCSdrops_one_pct[$i]); + } } - $rec_count++; + $sthA->finish(); } - $sthA->finish(); - } -# LAST HOUR CALL AND DROP STATS -$stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VCScalls_hour[$i] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); -if ($VCScalls_hour[$i] > 0) - { - # ANSWERS LAST HOUR - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN($camp_ANS_STAT_SQL);"; + # TODAY CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date';"; $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; - $VCSanswers_hour[$i] = "$aryA[0]"; - $rec_count++; + $VCScalls_today[$i] = "$aryA[0]"; } $sthA->finish(); - # DROP LAST HOUR - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN('DROP','XDROP');"; - $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 ($VCScalls_today[$i] > 0) { - @aryA = $sthA->fetchrow_array; - $VCSdrops_hour[$i] = "$aryA[0]"; - if ($VCSdrops_hour[$i] > 0) + # TODAY ANSWERS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN($camp_ANS_STAT_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) { - $VCSdrops_hour_pct[$i] = ( ($VCSdrops_hour[$i] / $VCScalls_hour[$i]) * 100 ); - $VCSdrops_hour_pct[$i] = sprintf("%.2f", $VCSdrops_hour_pct[$i]); + @aryA = $sthA->fetchrow_array; + $VCSanswers_today[$i] = "$aryA[0]"; } - $rec_count++; - } - $sthA->finish(); - } - -# LAST HALFHOUR CALL AND DROP STATS -$stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VCScalls_halfhour[$i] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); -if ($VCScalls_halfhour[$i] > 0) - { - # ANSWERS HALFHOUR - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN($camp_ANS_STAT_SQL);"; - $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) - { - @aryA = $sthA->fetchrow_array; - $VCSanswers_halfhour[$i] = "$aryA[0]"; - $rec_count++; - } - $sthA->finish(); - # DROPS HALFHOUR - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN('DROP','XDROP');"; - $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) - { - @aryA = $sthA->fetchrow_array; - $VCSdrops_halfhour[$i] = "$aryA[0]"; - if ($VCSdrops_halfhour[$i] > 0) + $sthA->finish(); + # TODAY DROPS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + if ($DBX > 0) {print "$stmtA\n";} + $sthArows=$sthA->rows; + if ($sthArows > 0) { - $VCSdrops_halfhour_pct[$i] = ( ($VCSdrops_halfhour[$i] / $VCScalls_halfhour[$i]) * 100 ); - $VCSdrops_halfhour_pct[$i] = sprintf("%.2f", $VCSdrops_halfhour_pct[$i]); + @aryA = $sthA->fetchrow_array; + $VCSdrops_today[$i] = "$aryA[0]"; + if ($VCSdrops_today[$i] > 0) + { + $VCSdrops_today_pct[$i] = ( ($VCSdrops_today[$i] / $VCScalls_today[$i]) * 100 ); + $VCSdrops_today_pct[$i] = sprintf("%.2f", $VCSdrops_today_pct[$i]); + if ($VCSanswers_today[$i] < 1) {$VCSanswers_today[$i] = 1;} + $VCSdrops_answers_today_pct[$i] = ( ($VCSdrops_today[$i] / $VCSanswers_today[$i]) * 100 ); + $VCSdrops_answers_today_pct[$i] = sprintf("%.2f", $VCSdrops_answers_today_pct[$i]); + } } - $rec_count++; + $sthA->finish(); } - $sthA->finish(); - } -# LAST FIVE MINUTE CALL AND DROP STATS -$stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; -if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $VCScalls_five[$i] = "$aryA[0]"; - } -$sthA->finish(); - -if ($VCScalls_five[$i] > 0) - { - # ANSWERS FIVEMINUTE - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN($camp_ANS_STAT_SQL);"; + # LAST HOUR CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour';"; $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; - $VCSanswers_five[$i] = "$aryA[0]"; - $rec_count++; + $VCScalls_hour[$i] = "$aryA[0]"; } $sthA->finish(); - # DROPS FIVEMINUTE - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN('DROP','XDROP');"; - $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 ($VCScalls_hour[$i] > 0) { - @aryA = $sthA->fetchrow_array; - $VCSdrops_five[$i] = "$aryA[0]"; - if ($VCSdrops_five[$i] > 0) + # ANSWERS LAST HOUR + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN($camp_ANS_STAT_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) { - $VCSdrops_five_pct[$i] = ( ($VCSdrops_five[$i] / $VCScalls_five[$i]) * 100 ); - $VCSdrops_five_pct[$i] = sprintf("%.2f", $VCSdrops_five_pct[$i]); + @aryA = $sthA->fetchrow_array; + $VCSanswers_hour[$i] = "$aryA[0]"; } + $sthA->finish(); + # DROP LAST HOUR + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_hour' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCSdrops_hour[$i] = "$aryA[0]"; + if ($VCSdrops_hour[$i] > 0) + { + $VCSdrops_hour_pct[$i] = ( ($VCSdrops_hour[$i] / $VCScalls_hour[$i]) * 100 ); + $VCSdrops_hour_pct[$i] = sprintf("%.2f", $VCSdrops_hour_pct[$i]); + } + $rec_count++; + } + $sthA->finish(); + } + + # LAST HALFHOUR CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCScalls_halfhour[$i] = "$aryA[0]"; + } + $sthA->finish(); + if ($VCScalls_halfhour[$i] > 0) + { + # ANSWERS HALFHOUR + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN($camp_ANS_STAT_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCSanswers_halfhour[$i] = "$aryA[0]"; + } + $sthA->finish(); + # DROPS HALFHOUR + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_halfhour' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCSdrops_halfhour[$i] = "$aryA[0]"; + if ($VCSdrops_halfhour[$i] > 0) + { + $VCSdrops_halfhour_pct[$i] = ( ($VCSdrops_halfhour[$i] / $VCScalls_halfhour[$i]) * 100 ); + $VCSdrops_halfhour_pct[$i] = sprintf("%.2f", $VCSdrops_halfhour_pct[$i]); + } + } + $sthA->finish(); + } + + # LAST FIVE MINUTE CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCScalls_five[$i] = "$aryA[0]"; + } + $sthA->finish(); + + if ($VCScalls_five[$i] > 0) + { + # ANSWERS FIVEMINUTE + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN($camp_ANS_STAT_SQL);"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCSanswers_five[$i] = "$aryA[0]"; + } + $sthA->finish(); + # DROPS FIVEMINUTE + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_five' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VCSdrops_five[$i] = "$aryA[0]"; + if ($VCSdrops_five[$i] > 0) + { + $VCSdrops_five_pct[$i] = ( ($VCSdrops_five[$i] / $VCScalls_five[$i]) * 100 ); + $VCSdrops_five_pct[$i] = sprintf("%.2f", $VCSdrops_five_pct[$i]); + } + } + $sthA->finish(); + } + if ($DBX) {print "$campaign_id[$i]|$VCSdrops_five_pct[$i]|$VCSdrops_today_pct[$i]| |$VCSdrops_today[$i] / $VCScalls_today[$i] / $VCSanswers_today[$i]| $i\n";} + + # DETERMINE WHETHER TO GATHER STATUS CATEGORY STATISTICS + $VSC_categories=0; + $VSCupdateSQL=''; + $stmtA = "SELECT vsc_id from vicidial_status_categories where tovdad_display='Y' limit 4;"; + $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) + { + @aryA = $sthA->fetchrow_array; + $VSC_categories[$rec_count] = "$aryA[0]"; $rec_count++; } $sthA->finish(); - } -if ($DBX) {print "$campaign_id[$i]|$VCSdrops_five_pct[$i]|$VCSdrops_today_pct[$i]\n";} -# DETERMINE WHETHER TO GATHER STATUS CATEGORY STATISTICS -$VSC_categories=0; -$VSCupdateSQL=''; -$stmtA = "SELECT vsc_id from vicidial_status_categories where tovdad_display='Y' limit 4;"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VSC_categories[$rec_count] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); - -$g=0; -foreach (@VSC_categories) - { + $g=0; + foreach (@VSC_categories) + { $VSCcategory=$VSC_categories[$g]; $VSCtally=''; $CATstatusesSQL=''; - # FIND STATUSES IN STATUS CATEGORY - $stmtA = "SELECT status from vicidial_statuses where category='$VSCcategory';"; - $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) - { - @aryA = $sthA->fetchrow_array; - $CATstatusesSQL .= "'$aryA[0]',"; - $rec_count++; - } - # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY - $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory' and campaign_id='$campaign_id[$i]';"; - $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) - { - @aryA = $sthA->fetchrow_array; - $CATstatusesSQL .= "'$aryA[0]',"; - $rec_count++; - } - chop($CATstatusesSQL); - if (length($CATstatusesSQL)>2) - { # FIND STATUSES IN STATUS CATEGORY - $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN($CATstatusesSQL);"; - # if ($DBX) {print "|$stmtA|\n";} + $stmtA = "SELECT status from vicidial_statuses where category='$VSCcategory';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1088,153 +1032,122 @@ foreach (@VSC_categories) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VSCtally = "$aryA[0]"; + $CATstatusesSQL .= "'$aryA[0]',"; $rec_count++; } + # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY + $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory' and campaign_id='$campaign_id[$i]';"; + $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) + { + @aryA = $sthA->fetchrow_array; + $CATstatusesSQL .= "'$aryA[0]',"; + $rec_count++; + } + chop($CATstatusesSQL); + if (length($CATstatusesSQL)>2) + { + # FIND STATUSES IN STATUS CATEGORY + $stmtA = "SELECT count(*) from $vicidial_log where campaign_id='$campaign_id[$i]' and call_date > '$VDL_date' and status IN($CATstatusesSQL);"; + # if ($DBX) {print "|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VSCtally = "$aryA[0]"; + } + } + $g++; + if ($DBX) {print " $campaign_id[$i]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n";} + $VSCupdateSQL .= "status_category_$g='$VSCcategory',status_category_count_$g='$VSCtally',"; } - $g++; - if ($DBX) {print " $campaign_id[$i]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n";} - $VSCupdateSQL .= "status_category_$g='$VSCcategory',status_category_count_$g='$VSCtally',"; - } -while ($g < 4) - { - $g++; - $VSCupdateSQL .= "status_category_$g='',status_category_count_$g='0',"; - } -chop($VSCupdateSQL); + while ($g < 4) + { + $g++; + $VSCupdateSQL .= "status_category_$g='',status_category_count_$g='0',"; + } + chop($VSCupdateSQL); -# AGENT NON-PAUSE TIME PULL -$stmtA = "SELECT sum(wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where campaign_id='$campaign_id[$i]' and event_time > '$VDL_date';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; -if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - if ($aryA[0] > 0) + # AGENT NON-PAUSE TIME PULL + $stmtA = "SELECT sum(wait_sec + talk_sec + dispo_sec) from vicidial_agent_log where campaign_id='$campaign_id[$i]' and event_time > '$VDL_date';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + if ($aryA[0] > 0) {$VCSagent_nonpause_time[$i] = $aryA[0];} + } + $sthA->finish(); + + + $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$i]',answers_today='$VCSanswers_today[$i]',drops_today='$VCSdrops_today[$i]',drops_today_pct='$VCSdrops_today_pct[$i]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$i]',calls_hour='$VCScalls_hour[$i]',answers_hour='$VCSanswers_hour[$i]',drops_hour='$VCSdrops_hour[$i]',drops_hour_pct='$VCSdrops_hour_pct[$i]',calls_halfhour='$VCScalls_halfhour[$i]',answers_halfhour='$VCSanswers_halfhour[$i]',drops_halfhour='$VCSdrops_halfhour[$i]',drops_halfhour_pct='$VCSdrops_halfhour_pct[$i]',calls_fivemin='$VCScalls_five[$i]',answers_fivemin='$VCSanswers_five[$i]',drops_fivemin='$VCSdrops_five[$i]',drops_fivemin_pct='$VCSdrops_five_pct[$i]',calls_onemin='$VCScalls_one[$i]',answers_onemin='$VCSanswers_one[$i]',drops_onemin='$VCSdrops_one[$i]',drops_onemin_pct='$VCSdrops_one_pct[$i]',agent_non_pause_sec='$VCSagent_nonpause_time[$i]',$VSCupdateSQL where campaign_id='$campaign_id[$i]';"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "$campaign_id[$i]|$stmtA|\n";} } -$sthA->finish(); - - -$stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$i]',answers_today='$VCSanswers_today[$i]',drops_today='$VCSdrops_today[$i]',drops_today_pct='$VCSdrops_today_pct[$i]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$i]',calls_hour='$VCScalls_hour[$i]',answers_hour='$VCSanswers_hour[$i]',drops_hour='$VCSdrops_hour[$i]',drops_hour_pct='$VCSdrops_hour_pct[$i]',calls_halfhour='$VCScalls_halfhour[$i]',answers_halfhour='$VCSanswers_halfhour[$i]',drops_halfhour='$VCSdrops_halfhour[$i]',drops_halfhour_pct='$VCSdrops_halfhour_pct[$i]',calls_fivemin='$VCScalls_five[$i]',answers_fivemin='$VCSanswers_five[$i]',drops_fivemin='$VCSdrops_five[$i]',drops_fivemin_pct='$VCSdrops_five_pct[$i]',calls_onemin='$VCScalls_one[$i]',answers_onemin='$VCSanswers_one[$i]',drops_onemin='$VCSdrops_one[$i]',drops_onemin_pct='$VCSdrops_one_pct[$i]',agent_non_pause_sec='$VCSagent_nonpause_time[$i]',$VSCupdateSQL where campaign_id='$campaign_id[$i]';"; -$affected_rows = $dbhA->do($stmtA); -if ($DBX) {print "$campaign_id[$i]|$stmtA|\n";} -} sub launch_inbound_gather -{ -################################################################################ -#### BEGIN gather stats for inbound groups for the real-time display -################################################################################ -$stmtA = "SELECT group_id from vicidial_inbound_groups where active='Y';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; -$ibg_count=0; -while ($sthArows > $ibg_count) { - @aryA = $sthA->fetchrow_array; - $group_id[$ibg_count] = $aryA[0]; - $ibg_count++; + ################################################################################ + #### BEGIN gather stats for inbound groups for the real-time display + ################################################################################ + $stmtA = "SELECT group_id from vicidial_inbound_groups where active='Y';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $ibg_count=0; + while ($sthArows > $ibg_count) + { + @aryA = $sthA->fetchrow_array; + $group_id[$ibg_count] = $aryA[0]; + $ibg_count++; + } + $sthA->finish(); + if ($DB) {print "$now_date INBOUND GROUPS TO GET STATS FOR: $ibg_count|$#group_id IT: $master_loop\n";} + + + ##### LOOP THROUGH EACH INBOUND GROUP AND GATHER STATS ##### + $p=0; + foreach(@group_id) + { + &calculate_drops_inbound; + + $p++; + } + + ################################################################################ + #### END gather stats for inbound groups for the real-time display + ################################################################################ } -$sthA->finish(); -if ($DB) {print "$now_date INBOUND GROUPS TO GET STATS FOR: $ibg_count|$#group_id IT: $master_loop\n";} - - -##### LOOP THROUGH EACH INBOUND GROUP AND GATHER STATS ##### -$p=0; -foreach(@group_id) - { - &calculate_drops_inbound; - - $p++; - } - -################################################################################ -#### END gather stats for inbound groups for the real-time display -################################################################################ -} sub calculate_drops_inbound -{ -# GET inbound group hold stat seconds settings -$stmtA = "SELECT answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two from vicidial_inbound_groups where group_id='$group_id[$p]';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; -if ($sthArows > 0) { - @aryA = $sthA->fetchrow_array; - $answer_sec_pct_rt_stat_one = $aryA[0]; - $answer_sec_pct_rt_stat_two = $aryA[1]; - } -$sthA->finish(); + # GET inbound group hold stat seconds settings + $stmtA = "SELECT answer_sec_pct_rt_stat_one,answer_sec_pct_rt_stat_two from vicidial_inbound_groups where group_id='$group_id[$p]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $answer_sec_pct_rt_stat_one = $aryA[0]; + $answer_sec_pct_rt_stat_two = $aryA[1]; + } + $sthA->finish(); -$camp_ANS_STAT_SQL=''; -# GET LIST OF HUMAN-ANSWERED STATUSES -$stmtA = "SELECT status from vicidial_statuses where human_answered='Y';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $camp_ANS_STAT_SQL .= "'$aryA[0]',"; - $rec_count++; - } -$sthA->finish(); - -$stmtA = "SELECT distinct(status) from vicidial_campaign_statuses where human_answered='Y';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $camp_ANS_STAT_SQL .= "'$aryA[0]',"; - $rec_count++; - } -$sthA->finish(); -chop($camp_ANS_STAT_SQL); - -if ($DBX) {print " ANSWERED STATUSES: $group_id[$p]|$camp_ANS_STAT_SQL|\n";} - -#$RESETdrop_count_updater++; -$VCScalls_today[$p]=0; -$VCSanswers_today[$p]=0; -$VCSdrops_today[$p]=0; -$VCSdrops_today_pct[$p]=0; -$VCSdrops_answers_today_pct[$p]=0; -$answer_sec_pct_rt_stat_one_PCT[$p]=0; -$answer_sec_pct_rt_stat_two_PCT[$p]=0; -$hold_sec_answer_calls[$p]=0; -$hold_sec_drop_calls[$p]=0; -$hold_sec_queue_calls[$p]=0; - -# TODAY CALL AND DROP STATS -$stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date';"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VCScalls_today[$p] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); -if ($VCScalls_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');"; + $camp_ANS_STAT_SQL=''; + # GET LIST OF HUMAN-ANSWERED STATUSES + $stmtA = "SELECT status from vicidial_statuses where human_answered='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1242,12 +1155,12 @@ if ($VCScalls_today[$p] > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VCSanswers_today[$p] = "$aryA[0]"; + $camp_ANS_STAT_SQL .= "'$aryA[0]',"; $rec_count++; } $sthA->finish(); - # TODAY DROPS - $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; + + $stmtA = "SELECT distinct(status) from vicidial_campaign_statuses where human_answered='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1255,130 +1168,154 @@ if ($VCScalls_today[$p] > 0) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VCSdrops_today[$p] = "$aryA[0]"; - if ($VCSdrops_today[$p] > 0) + $camp_ANS_STAT_SQL .= "'$aryA[0]',"; + $rec_count++; + } + $sthA->finish(); + chop($camp_ANS_STAT_SQL); + + if ($DBX) {print " ANSWERED STATUSES: $group_id[$p]|$camp_ANS_STAT_SQL|\n";} + + #$RESETdrop_count_updater++; + $iVCScalls_today[$p]=0; + $iVCSanswers_today[$p]=0; + $iVCSdrops_today[$p]=0; + $iVCSdrops_today_pct[$p]=0; + $iVCSdrops_answers_today_pct[$p]=0; + $answer_sec_pct_rt_stat_one_PCT[$p]=0; + $answer_sec_pct_rt_stat_two_PCT[$p]=0; + $hold_sec_answer_calls[$p]=0; + $hold_sec_drop_calls[$p]=0; + $hold_sec_queue_calls[$p]=0; + + # TODAY CALL AND DROP STATS + $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $iVCScalls_today[$p] = "$aryA[0]"; + } + $sthA->finish(); + 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');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) { - $VCSdrops_today_pct[$p] = ( ($VCSdrops_today[$p] / $VCScalls_today[$p]) * 100 ); - $VCSdrops_today_pct[$p] = sprintf("%.2f", $VCSdrops_today_pct[$p]); - if ($VCSanswers_today[$p] < 1) {$VCSanswers_today[$p] = 1;} - $VCSdrops_answers_today_pct[$p] = ( ($VCSdrops_today[$p] / $VCSanswers_today[$p]) * 100 ); - $VCSdrops_answers_today_pct[$p] = sprintf("%.2f", $VCSdrops_answers_today_pct[$p]); + @aryA = $sthA->fetchrow_array; + $iVCSanswers_today[$p] = "$aryA[0]"; } + $sthA->finish(); + # TODAY DROPS + $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($DBX > 0) {print "$stmtA\n";} + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $iVCSdrops_today[$p] = "$aryA[0]"; + if ($iVCSdrops_today[$p] > 0) + { + $iVCSdrops_today_pct[$p] = ( ($iVCSdrops_today[$p] / $iVCScalls_today[$p]) * 100 ); + $iVCSdrops_today_pct[$p] = sprintf("%.2f", $iVCSdrops_today_pct[$p]); + if ($iVCSanswers_today[$p] < 1) {$iVCSanswers_today[$p] = 1;} + $iVCSdrops_answers_today_pct[$p] = ( ($iVCSdrops_today[$p] / $iVCSanswers_today[$p]) * 100 ); + $iVCSdrops_answers_today_pct[$p] = sprintf("%.2f", $iVCSdrops_answers_today_pct[$p]); + } + } + $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;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $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;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $answer_sec_pct_rt_stat_two_PCT[$p] = $aryA[0]; + } + + # 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');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + if ($aryA[0] > 0) + {$hold_sec_answer_calls[$p] = $aryA[0];} + } + # TODAY TOTAL HOLD TIME FOR DROP CALLS + $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + if ($aryA[0] > 0) + {$hold_sec_drop_calls[$p] = $aryA[0];} + } + # TODAY TOTAL QUEUE TIME FOR QUEUE CALLS + $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + if ($aryA[0] > 0) + {$hold_sec_queue_calls[$p] = $aryA[0];} + } + } + + + + + # DETERMINE WHETHER TO GATHER STATUS CATEGORY STATISTICS + $VSC_categories=0; + $VSCupdateSQL=''; + $stmtA = "SELECT vsc_id from vicidial_status_categories where tovdad_display='Y' limit 4;"; + $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) + { + @aryA = $sthA->fetchrow_array; + $VSC_categories[$rec_count] = "$aryA[0]"; $rec_count++; } $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;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) + $g=0; + foreach (@VSC_categories) { - @aryA = $sthA->fetchrow_array; - $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;"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $answer_sec_pct_rt_stat_two_PCT[$p] = $aryA[0]; - } - - # 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');"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - if ($aryA[0] > 0) - {$hold_sec_answer_calls[$p] = $aryA[0];} - } - # TODAY TOTAL HOLD TIME FOR DROP CALLS - $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN('DROP','XDROP');"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - if ($aryA[0] > 0) - {$hold_sec_drop_calls[$p] = $aryA[0];} - } - # TODAY TOTAL QUEUE TIME FOR QUEUE CALLS - $stmtA = "SELECT sum(queue_seconds) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - if ($aryA[0] > 0) - {$hold_sec_queue_calls[$p] = $aryA[0];} - } - } - - - - -# DETERMINE WHETHER TO GATHER STATUS CATEGORY STATISTICS -$VSC_categories=0; -$VSCupdateSQL=''; -$stmtA = "SELECT vsc_id from vicidial_status_categories where tovdad_display='Y' limit 4;"; -$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) - { - @aryA = $sthA->fetchrow_array; - $VSC_categories[$rec_count] = "$aryA[0]"; - $rec_count++; - } -$sthA->finish(); - -$g=0; -foreach (@VSC_categories) - { $VSCcategory=$VSC_categories[$g]; $VSCtally=''; $CATstatusesSQL=''; - # FIND STATUSES IN STATUS CATEGORY - $stmtA = "SELECT status from vicidial_statuses where category='$VSCcategory';"; - $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) - { - @aryA = $sthA->fetchrow_array; - $CATstatusesSQL .= "'$aryA[0]',"; - $rec_count++; - } - # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY - $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory';"; - $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) - { - @aryA = $sthA->fetchrow_array; - $CATstatusesSQL .= "'$aryA[0]',"; - $rec_count++; - } - chop($CATstatusesSQL); - if (length($CATstatusesSQL)>2) - { # FIND STATUSES IN STATUS CATEGORY - $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN($CATstatusesSQL);"; - # if ($DBX) {print "|$stmtA|\n";} + $stmtA = "SELECT status from vicidial_statuses where category='$VSCcategory';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1386,95 +1323,91 @@ foreach (@VSC_categories) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $VSCtally = "$aryA[0]"; + $CATstatusesSQL .= "'$aryA[0]',"; $rec_count++; } + # FIND CAMPAIGN_STATUSES IN STATUS CATEGORY + $stmtA = "SELECT status from vicidial_campaign_statuses where category='$VSCcategory';"; + $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) + { + @aryA = $sthA->fetchrow_array; + $CATstatusesSQL .= "'$aryA[0]',"; + $rec_count++; + } + chop($CATstatusesSQL); + if (length($CATstatusesSQL)>2) + { + # FIND STATUSES IN STATUS CATEGORY + $stmtA = "SELECT count(*) from $vicidial_closer_log where campaign_id='$group_id[$p]' and call_date > '$VDL_date' and status IN($CATstatusesSQL);"; + # if ($DBX) {print "|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $VSCtally = "$aryA[0]"; + } + } + $g++; + if ($DBX) {print " $group_id[$p]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n";} + $VSCupdateSQL .= "status_category_$g='$VSCcategory',status_category_count_$g='$VSCtally',"; } - $g++; - if ($DBX) {print " $group_id[$p]|$VSCcategory|$VSCtally|$CATstatusesSQL|\n";} - $VSCupdateSQL .= "status_category_$g='$VSCcategory',status_category_count_$g='$VSCtally',"; - } -while ($g < 4) - { - $g++; - $VSCupdateSQL .= "status_category_$g='',status_category_count_$g='0',"; - } -chop($VSCupdateSQL); + while ($g < 4) + { + $g++; + $VSCupdateSQL .= "status_category_$g='',status_category_count_$g='0',"; + } + chop($VSCupdateSQL); -$vcs_exists=1; -$stmtA = "SELECT count(*) from vicidial_campaign_stats where campaign_id='$group_id[$p]';"; -$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; -$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; -$sthArows=$sthA->rows; -if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - $vcs_exists = "$aryA[0]"; - } -$sthA->finish(); + $vcs_exists=1; + $stmtA = "SELECT count(*) from vicidial_campaign_stats where campaign_id='$group_id[$p]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $vcs_exists = "$aryA[0]"; + } + $sthA->finish(); -if ($vcs_exists < 1) - { - $stmtA = "INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id[$p]');"; + if ($vcs_exists < 1) + { + $stmtA = "INSERT INTO vicidial_campaign_stats (campaign_id) values('$group_id[$p]');"; + $affected_rows = $dbhA->do($stmtA); + if ($DBX) {print "$group_id[$p]|$stmtA|\n";} + } + + $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$iVCScalls_today[$p]',answers_today='$iVCSanswers_today[$p]',drops_today='$iVCSdrops_today[$p]',drops_today_pct='$iVCSdrops_today_pct[$p]',drops_answers_today_pct='$iVCSdrops_answers_today_pct[$p]',hold_sec_stat_one='$answer_sec_pct_rt_stat_one_PCT[$p]',hold_sec_stat_two='$answer_sec_pct_rt_stat_two_PCT[$p]',hold_sec_answer_calls='$hold_sec_answer_calls[$p]',hold_sec_drop_calls='$hold_sec_drop_calls[$p]',hold_sec_queue_calls='$hold_sec_queue_calls[$p]',$VSCupdateSQL where campaign_id='$group_id[$p]';"; $affected_rows = $dbhA->do($stmtA); if ($DBX) {print "$group_id[$p]|$stmtA|\n";} + + print "$p IN-GROUP: $group_id[$p] CALLS: $iVCScalls_today[$p] ANSWER: $iVCSanswers_today[$p] DROPS: $iVCSdrops_today[$p]\n"; + print " Stat1: $answer_sec_pct_rt_stat_one_PCT[$p] Stat2: $answer_sec_pct_rt_stat_two_PCT[$p] Hold: $hold_sec_queue_calls[$p]|$hold_sec_answer_calls[$p]|$hold_sec_drop_calls[$p]\n"; } - -$stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today[$p]',answers_today='$VCSanswers_today[$p]',drops_today='$VCSdrops_today[$p]',drops_today_pct='$VCSdrops_today_pct[$p]',drops_answers_today_pct='$VCSdrops_answers_today_pct[$p]',hold_sec_stat_one='$answer_sec_pct_rt_stat_one_PCT[$p]',hold_sec_stat_two='$answer_sec_pct_rt_stat_two_PCT[$p]',hold_sec_answer_calls='$hold_sec_answer_calls[$p]',hold_sec_drop_calls='$hold_sec_drop_calls[$p]',hold_sec_queue_calls='$hold_sec_queue_calls[$p]',$VSCupdateSQL where campaign_id='$group_id[$p]';"; -$affected_rows = $dbhA->do($stmtA); -if ($DBX) {print "$group_id[$p]|$stmtA|\n";} - -print " IN-GROUP: $group_id[$p] CALLS: $VCScalls_today[$p] ANSWER: $VCSanswers_today[$p] DROPS: $VCSdrops_today[$p]\n"; -print " Stat1: $answer_sec_pct_rt_stat_one_PCT[$p] Stat2: $answer_sec_pct_rt_stat_two_PCT[$p] Hold: $hold_sec_queue_calls[$p]|$hold_sec_answer_calls[$p]|$hold_sec_drop_calls[$p]\n"; -} ##### END calculate_drops_inbound sub calculate_dial_level -{ -$RESETdiff_ratio_updater++; -$VCSINCALL[$i]=0; -$VCSREADY[$i]=0; -$VCSCLOSER[$i]=0; -$VCSPAUSED[$i]=0; -$VCSagents[$i]=0; -$VCSagents_calc[$i]=0; -$VCSagents_active[$i]=0; - -# COUNTS OF STATUSES OF AGENTS IN THIS CAMPAIGN -$stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; -$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) { - @aryA = $sthA->fetchrow_array; - $VCSagent_count[$i] = "$aryA[0]"; - $VCSagent_status[$i] = "$aryA[1]"; - $rec_count++; - if ($VCSagent_status[$i] =~ /INCALL|QUEUE/) {$VCSINCALL[$i] = ($VCSINCALL[$i] + $VCSagent_count[$i]);} - if ($VCSagent_status[$i] =~ /READY/) {$VCSREADY[$i] = ($VCSREADY[$i] + $VCSagent_count[$i]);} - if ($VCSagent_status[$i] =~ /CLOSER/) {$VCSCLOSER[$i] = ($VCSCLOSER[$i] + $VCSagent_count[$i]);} - if ($VCSagent_status[$i] =~ /PAUSED/) {$VCSPAUSED[$i] = ($VCSPAUSED[$i] + $VCSagent_count[$i]);} - $VCSagents[$i] = ($VCSagents[$i] + $VCSagent_count[$i]); - } -$sthA->finish(); + $RESETdiff_ratio_updater++; + $VCSINCALL[$i]=0; + $VCSREADY[$i]=0; + $VCSCLOSER[$i]=0; + $VCSPAUSED[$i]=0; + $VCSagents[$i]=0; + $VCSagents_calc[$i]=0; + $VCSagents_active[$i]=0; -if ($available_only_ratio_tally[$i] =~ /Y/) - {$VCSagents_calc[$i] = $VCSREADY[$i];} -else - {$VCSagents_calc[$i] = ($VCSINCALL[$i] + $VCSREADY[$i]);} -$VCSagents_active[$i] = ($VCSINCALL[$i] + $VCSREADY[$i] + $VCSCLOSER[$i]); - -### END - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### - -if ($campaign_allow_inbound[$i] =~ /Y/) - { - # GET AVERAGES FROM THIS CAMPAIGN - $stmtA = "SELECT differential_onemin,agents_average_onemin from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; + # COUNTS OF STATUSES OF AGENTS IN THIS CAMPAIGN + $stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -1482,152 +1415,182 @@ if ($campaign_allow_inbound[$i] =~ /Y/) while ($sthArows > $rec_count) { @aryA = $sthA->fetchrow_array; - $differential_onemin[$i] = "$aryA[0]"; - $agents_average_onemin[$i] = "$aryA[1]"; + $VCSagent_count[$i] = "$aryA[0]"; + $VCSagent_status[$i] = "$aryA[1]"; $rec_count++; + if ($VCSagent_status[$i] =~ /INCALL|QUEUE/) {$VCSINCALL[$i] = ($VCSINCALL[$i] + $VCSagent_count[$i]);} + if ($VCSagent_status[$i] =~ /READY/) {$VCSREADY[$i] = ($VCSREADY[$i] + $VCSagent_count[$i]);} + if ($VCSagent_status[$i] =~ /CLOSER/) {$VCSCLOSER[$i] = ($VCSCLOSER[$i] + $VCSagent_count[$i]);} + if ($VCSagent_status[$i] =~ /PAUSED/) {$VCSPAUSED[$i] = ($VCSPAUSED[$i] + $VCSagent_count[$i]);} + $VCSagents[$i] = ($VCSagents[$i] + $VCSagent_count[$i]); } $sthA->finish(); - } -else - { - $agents_average_onemin[$i] = $total_agents_avg[$i]; - $differential_onemin[$i] = $stat_differential[$i]; - } -if ( ($dial_method[$i] =~ /ADAPT_HARD_LIMIT|ADAPT_AVERAGE|ADAPT_TAPERED/) || ($force_test>0) ) - { - # Calculate the optimal dial_level differential for the past minute - $differential_target[$i] = ($differential_onemin[$i] + $adaptive_dl_diff_target[$i]); - if ( ($differential_target[$i] != 0) && ($agents_average_onemin[$i] != 0) ) - { - $differential_mul[$i] = ($differential_target[$i] / $agents_average_onemin[$i]); - $differential_pct_raw[$i] = ($differential_mul[$i] * 100); - } + if ($available_only_ratio_tally[$i] =~ /Y/) + {$VCSagents_calc[$i] = $VCSREADY[$i];} else - { - $differential_mul[$i] = 0; - $differential_pct_raw[$i] = 0; - } - $differential_pct[$i] = sprintf("%.2f", $differential_pct_raw[$i]); + {$VCSagents_calc[$i] = ($VCSINCALL[$i] + $VCSREADY[$i]);} + $VCSagents_active[$i] = ($VCSINCALL[$i] + $VCSREADY[$i] + $VCSCLOSER[$i]); - # Factor in the intensity setting - $intensity_mul[$i] = ($adaptive_intensity[$i] / 100); - if ($differential_pct_raw[$i] < 0) - { - $abs_intensity_mul[$i] = abs($intensity_mul[$i] - 1); - $intensity_diff[$i] = ($differential_pct_raw[$i] * $abs_intensity_mul[$i]); - } - else - {$intensity_diff[$i] = ($differential_pct_raw[$i] * ($intensity_mul[$i] + 1) );} - $intensity_pct[$i] = sprintf("%.2f", $intensity_diff[$i]); - $intensity_diff_mul[$i] = ($intensity_diff[$i] / 100); + ### END - GATHER STATS FOR THE vicidial_campaign_stats TABLE ### - # Suggested dial_level based on differential - $suggested_dial_level[$i] = ($auto_dial_level[$i] * ($differential_mul[$i] + 1) ); - $suggested_dial_level[$i] = sprintf("%.3f", $suggested_dial_level[$i]); - - # Suggested dial_level based on differential with intensity setting - $intensity_dial_level[$i] = ($auto_dial_level[$i] * ($intensity_diff_mul[$i] + 1) ); - $intensity_dial_level[$i] = sprintf("%.3f", $intensity_dial_level[$i]); - - # Calculate last timezone target for ADAPT_TAPERED - $last_target_hour_final[$i] = $adaptive_latest_server_time[$i]; -# if ($last_target_hour_final[$i]>2400) {$last_target_hour_final[$i]=2400;} - $tapered_hours_left[$i] = ($last_target_hour_final[$i] - $current_hourmin); - if ($tapered_hours_left[$i] > 1000) - {$tapered_rate[$i] = 1;} - else - {$tapered_rate[$i] = ($tapered_hours_left[$i] / 1000);} - - $adaptive_string = "\n"; - $adaptive_string .= "CAMPAIGN: $campaign_id[$i]\n"; - $adaptive_string .= "SETTINGS-\n"; - $adaptive_string .= " DIAL LEVEL: $auto_dial_level[$i]\n"; - $adaptive_string .= " DIAL METHOD: $dial_method[$i]\n"; - $adaptive_string .= " AVAIL ONLY: $available_only_ratio_tally[$i]\n"; - $adaptive_string .= " DROP PERCENT: $adaptive_dropped_percentage[$i]\n"; - $adaptive_string .= " MAX LEVEL: $adaptive_maximum_level[$i]\n"; - $adaptive_string .= " SERVER TIME: $current_hourmin\n"; - $adaptive_string .= " LATE TARGET: $last_target_hour_final[$i] ($tapered_hours_left[$i] left|$tapered_rate[$i])\n"; - $adaptive_string .= " INTENSITY: $adaptive_intensity[$i]\n"; - $adaptive_string .= " DLDIFF TARGET: $adaptive_dl_diff_target[$i]\n"; - $adaptive_string .= "CURRENT STATS-\n"; - $adaptive_string .= " AVG AGENTS: $agents_average_onemin[$i]\n"; - $adaptive_string .= " AGENTS: $VCSagents[$i] ACTIVE: $VCSagents_active[$i] CALC: $VCSagents_calc[$i] INCALL: $VCSINCALL[$i] READY: $VCSREADY[$i]\n"; - $adaptive_string .= " DL DIFFERENTIAL: $differential_target[$i] = ($differential_onemin[$i] + $adaptive_dl_diff_target[$i])\n"; - $adaptive_string .= "DIAL LEVEL SUGGESTION-\n"; - $adaptive_string .= " PERCENT DIFF: $differential_pct[$i]\n"; - $adaptive_string .= " SUGGEST DL: $suggested_dial_level[$i] = ($auto_dial_level[$i] * ($differential_mul[$i] + 1) )\n"; - $adaptive_string .= " INTENSE DIFF: $intensity_pct[$i]\n"; - $adaptive_string .= " INTENSE DL: $intensity_dial_level[$i] = ($auto_dial_level[$i] * ($intensity_diff_mul[$i] + 1) )\n"; - if ($intensity_dial_level[$i] > $adaptive_maximum_level[$i]) + if ($campaign_allow_inbound[$i] =~ /Y/) { - $adaptive_string .= " DIAL LEVEL OVER CAP! SETTING TO CAP: $adaptive_maximum_level[$i]\n"; - $intensity_dial_level[$i] = $adaptive_maximum_level[$i]; - } - if ($intensity_dial_level[$i] < 1) - { - $adaptive_string .= " DIAL LEVEL TOO LOW! SETTING TO 1\n"; - $intensity_dial_level[$i] = "1.0"; - } - $adaptive_string .= "DROP STATS-\n"; - $adaptive_string .= " TODAY DROPS: $VCScalls_today[$i] $VCSdrops_today[$i] $VCSdrops_today_pct[$i]%\n"; - $adaptive_string .= " ANSWER DROPS: $VCSanswers_today[$i] $VCSdrops_answers_today_pct[$i]%\n"; - $adaptive_string .= " ONE HOUR DROPS: $VCScalls_hour[$i]/$VCSanswers_hour[$i] $VCSdrops_hour[$i] $VCSdrops_hour_pct[$i]%\n"; - $adaptive_string .= " HALF HOUR DROPS: $VCScalls_halfhour[$i]/$VCSanswers_halfhour[$i] $VCSdrops_halfhour[$i] $VCSdrops_halfhour_pct[$i]%\n"; - $adaptive_string .= " FIVE MIN DROPS: $VCScalls_five[$i]/$VCSanswers_five[$i] $VCSdrops_five[$i] $VCSdrops_five_pct[$i]%\n"; - $adaptive_string .= " ONE MIN DROPS: $VCScalls_one[$i]/$VCSanswers_one[$i] $VCSdrops_one[$i] $VCSdrops_one_pct[$i]%\n"; - - ### DROP PERCENTAGE RULES TO LOWER DIAL_LEVEL ### - if ( ($VCScalls_one[$i] > 20) && ($VCSdrops_one_pct[$i] > 50) ) - { - $intensity_dial_level[$i] = ($intensity_dial_level[$i] / 2); - $adaptive_string .= " DROP RATE OVER 50% FOR LAST MINUTE! CUTTING DIAL LEVEL TO: $intensity_dial_level[$i]\n"; - } - if ( ($VCScalls_today[$i] > 50) && ($VCSdrops_answers_today_pct[$i] > $adaptive_dropped_percentage[$i]) ) - { - if ($dial_method[$i] =~ /ADAPT_HARD_LIMIT/) + # GET AVERAGES FROM THIS CAMPAIGN + $stmtA = "SELECT differential_onemin,agents_average_onemin from vicidial_campaign_stats where campaign_id='$campaign_id[$i]';"; + $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) { - $intensity_dial_level[$i] = "1.0"; - $adaptive_string .= " DROP RATE OVER HARD LIMIT FOR TODAY! HARD DIAL LEVEL TO: 1.0\n"; + @aryA = $sthA->fetchrow_array; + $differential_onemin[$i] = "$aryA[0]"; + $agents_average_onemin[$i] = "$aryA[1]"; + $rec_count++; } - if ($dial_method[$i] =~ /ADAPT_AVERAGE/) + $sthA->finish(); + } + else + { + $agents_average_onemin[$i] = $total_agents_avg[$i]; + $differential_onemin[$i] = $stat_differential[$i]; + } + + if ( ($dial_method[$i] =~ /ADAPT_HARD_LIMIT|ADAPT_AVERAGE|ADAPT_TAPERED/) || ($force_test>0) ) + { + # Calculate the optimal dial_level differential for the past minute + $differential_target[$i] = ($differential_onemin[$i] + $adaptive_dl_diff_target[$i]); + if ( ($differential_target[$i] != 0) && ($agents_average_onemin[$i] != 0) ) + { + $differential_mul[$i] = ($differential_target[$i] / $agents_average_onemin[$i]); + $differential_pct_raw[$i] = ($differential_mul[$i] * 100); + } + else + { + $differential_mul[$i] = 0; + $differential_pct_raw[$i] = 0; + } + $differential_pct[$i] = sprintf("%.2f", $differential_pct_raw[$i]); + + # Factor in the intensity setting + $intensity_mul[$i] = ($adaptive_intensity[$i] / 100); + if ($differential_pct_raw[$i] < 0) + { + $abs_intensity_mul[$i] = abs($intensity_mul[$i] - 1); + $intensity_diff[$i] = ($differential_pct_raw[$i] * $abs_intensity_mul[$i]); + } + else + {$intensity_diff[$i] = ($differential_pct_raw[$i] * ($intensity_mul[$i] + 1) );} + $intensity_pct[$i] = sprintf("%.2f", $intensity_diff[$i]); + $intensity_diff_mul[$i] = ($intensity_diff[$i] / 100); + + # Suggested dial_level based on differential + $suggested_dial_level[$i] = ($auto_dial_level[$i] * ($differential_mul[$i] + 1) ); + $suggested_dial_level[$i] = sprintf("%.3f", $suggested_dial_level[$i]); + + # Suggested dial_level based on differential with intensity setting + $intensity_dial_level[$i] = ($auto_dial_level[$i] * ($intensity_diff_mul[$i] + 1) ); + $intensity_dial_level[$i] = sprintf("%.3f", $intensity_dial_level[$i]); + + # Calculate last timezone target for ADAPT_TAPERED + $last_target_hour_final[$i] = $adaptive_latest_server_time[$i]; + # if ($last_target_hour_final[$i]>2400) {$last_target_hour_final[$i]=2400;} + $tapered_hours_left[$i] = ($last_target_hour_final[$i] - $current_hourmin); + if ($tapered_hours_left[$i] > 1000) + {$tapered_rate[$i] = 1;} + else + {$tapered_rate[$i] = ($tapered_hours_left[$i] / 1000);} + + $adaptive_string = "\n"; + $adaptive_string .= "CAMPAIGN: $campaign_id[$i] $i\n"; + $adaptive_string .= "SETTINGS-\n"; + $adaptive_string .= " DIAL LEVEL: $auto_dial_level[$i]\n"; + $adaptive_string .= " DIAL METHOD: $dial_method[$i]\n"; + $adaptive_string .= " AVAIL ONLY: $available_only_ratio_tally[$i]\n"; + $adaptive_string .= " DROP PERCENT: $adaptive_dropped_percentage[$i]\n"; + $adaptive_string .= " MAX LEVEL: $adaptive_maximum_level[$i]\n"; + $adaptive_string .= " SERVER TIME: $current_hourmin\n"; + $adaptive_string .= " LATE TARGET: $last_target_hour_final[$i] ($tapered_hours_left[$i] left|$tapered_rate[$i])\n"; + $adaptive_string .= " INTENSITY: $adaptive_intensity[$i]\n"; + $adaptive_string .= " DLDIFF TARGET: $adaptive_dl_diff_target[$i]\n"; + $adaptive_string .= "CURRENT STATS-\n"; + $adaptive_string .= " AVG AGENTS: $agents_average_onemin[$i]\n"; + $adaptive_string .= " AGENTS: $VCSagents[$i] ACTIVE: $VCSagents_active[$i] CALC: $VCSagents_calc[$i] INCALL: $VCSINCALL[$i] READY: $VCSREADY[$i]\n"; + $adaptive_string .= " DL DIFFERENTIAL: $differential_target[$i] = ($differential_onemin[$i] + $adaptive_dl_diff_target[$i])\n"; + $adaptive_string .= "DIAL LEVEL SUGGESTION-\n"; + $adaptive_string .= " PERCENT DIFF: $differential_pct[$i]\n"; + $adaptive_string .= " SUGGEST DL: $suggested_dial_level[$i] = ($auto_dial_level[$i] * ($differential_mul[$i] + 1) )\n"; + $adaptive_string .= " INTENSE DIFF: $intensity_pct[$i]\n"; + $adaptive_string .= " INTENSE DL: $intensity_dial_level[$i] = ($auto_dial_level[$i] * ($intensity_diff_mul[$i] + 1) )\n"; + if ($intensity_dial_level[$i] > $adaptive_maximum_level[$i]) + { + $adaptive_string .= " DIAL LEVEL OVER CAP! SETTING TO CAP: $adaptive_maximum_level[$i]\n"; + $intensity_dial_level[$i] = $adaptive_maximum_level[$i]; + } + if ($intensity_dial_level[$i] < 1) + { + $adaptive_string .= " DIAL LEVEL TOO LOW! SETTING TO 1\n"; + $intensity_dial_level[$i] = "1.0"; + } + $adaptive_string .= "DROP STATS-\n"; + $adaptive_string .= " TODAY DROPS: $VCScalls_today[$i] $VCSdrops_today[$i] $VCSdrops_today_pct[$i]%\n"; + $adaptive_string .= " ANSWER DROPS: $VCSanswers_today[$i] $VCSdrops_answers_today_pct[$i]%\n"; + $adaptive_string .= " ONE HOUR DROPS: $VCScalls_hour[$i]/$VCSanswers_hour[$i] $VCSdrops_hour[$i] $VCSdrops_hour_pct[$i]%\n"; + $adaptive_string .= " HALF HOUR DROPS: $VCScalls_halfhour[$i]/$VCSanswers_halfhour[$i] $VCSdrops_halfhour[$i] $VCSdrops_halfhour_pct[$i]%\n"; + $adaptive_string .= " FIVE MIN DROPS: $VCScalls_five[$i]/$VCSanswers_five[$i] $VCSdrops_five[$i] $VCSdrops_five_pct[$i]%\n"; + $adaptive_string .= " ONE MIN DROPS: $VCScalls_one[$i]/$VCSanswers_one[$i] $VCSdrops_one[$i] $VCSdrops_one_pct[$i]%\n"; + + ### DROP PERCENTAGE RULES TO LOWER DIAL_LEVEL ### + if ( ($VCScalls_one[$i] > 20) && ($VCSdrops_one_pct[$i] > 50) ) { $intensity_dial_level[$i] = ($intensity_dial_level[$i] / 2); - $adaptive_string .= " DROP RATE OVER LIMIT FOR TODAY! AVERAGING DIAL LEVEL TO: $intensity_dial_level[$i]\n"; + $adaptive_string .= " DROP RATE OVER 50% FOR LAST MINUTE! CUTTING DIAL LEVEL TO: $intensity_dial_level[$i]\n"; } - if ($dial_method[$i] =~ /ADAPT_TAPERED/) + if ( ($VCScalls_today[$i] > 50) && ($VCSdrops_answers_today_pct[$i] > $adaptive_dropped_percentage[$i]) ) { - if ($tapered_hours_left[$i] < 0) + if ($dial_method[$i] =~ /ADAPT_HARD_LIMIT/) { $intensity_dial_level[$i] = "1.0"; - $adaptive_string .= " DROP RATE OVER LAST HOUR LIMIT FOR TODAY! TAPERING DIAL LEVEL TO: 1.0\n"; + $adaptive_string .= " DROP RATE OVER HARD LIMIT FOR TODAY! HARD DIAL LEVEL TO: 1.0\n"; } - else + if ($dial_method[$i] =~ /ADAPT_AVERAGE/) { - $intensity_dial_level[$i] = ($intensity_dial_level[$i] * $tapered_rate[$i]); - $adaptive_string .= " DROP RATE OVER LIMIT FOR TODAY! TAPERING DIAL LEVEL TO: $intensity_dial_level[$i]\n"; + $intensity_dial_level[$i] = ($intensity_dial_level[$i] / 2); + $adaptive_string .= " DROP RATE OVER LIMIT FOR TODAY! AVERAGING DIAL LEVEL TO: $intensity_dial_level[$i]\n"; + } + if ($dial_method[$i] =~ /ADAPT_TAPERED/) + { + if ($tapered_hours_left[$i] < 0) + { + $intensity_dial_level[$i] = "1.0"; + $adaptive_string .= " DROP RATE OVER LAST HOUR LIMIT FOR TODAY! TAPERING DIAL LEVEL TO: 1.0\n"; + } + else + { + $intensity_dial_level[$i] = ($intensity_dial_level[$i] * $tapered_rate[$i]); + $adaptive_string .= " DROP RATE OVER LIMIT FOR TODAY! TAPERING DIAL LEVEL TO: $intensity_dial_level[$i]\n"; + } } } + + ### ALWAYS RAISE DIAL_LEVEL TO 1.0 IF IT IS LOWER ### + if ($intensity_dial_level[$i] < 1) + { + $adaptive_string .= " DIAL LEVEL TOO LOW! SETTING TO 1\n"; + $intensity_dial_level[$i] = "1.0"; + } + + if (!$TEST) + { + $stmtA = "UPDATE vicidial_campaigns SET auto_dial_level='$intensity_dial_level[$i]' where campaign_id='$campaign_id[$i]';"; + $Uaffected_rows = $dbhA->do($stmtA); + } + + $adaptive_string .= "DIAL LEVEL UPDATED TO: $intensity_dial_level[$i] CONFIRM: $Uaffected_rows\n"; } - ### ALWAYS RAISE DIAL_LEVEL TO 1.0 IF IT IS LOWER ### - if ($intensity_dial_level[$i] < 1) - { - $adaptive_string .= " DIAL LEVEL TOO LOW! SETTING TO 1\n"; - $intensity_dial_level[$i] = "1.0"; - } - - if (!$TEST) - { - $stmtA = "UPDATE vicidial_campaigns SET auto_dial_level='$intensity_dial_level[$i]' where campaign_id='$campaign_id[$i]';"; - $Uaffected_rows = $dbhA->do($stmtA); - } - - $adaptive_string .= "DIAL LEVEL UPDATED TO: $intensity_dial_level[$i] CONFIRM: $Uaffected_rows\n"; - } - -if ($DB) {print "campaign stats updated: $campaign_id[$i] $adaptive_string\n";} + if ($DB) {print "campaign stats updated: $campaign_id[$i] $adaptive_string\n";} &adaptive_logger; -} + } diff --git a/bin/Vtiger_OUT_sync2VICIDIAL_file.pl b/bin/Vtiger_OUT_sync2VICIDIAL_file.pl index 1f1f4307..d5030712 100644 --- a/bin/Vtiger_OUT_sync2VICIDIAL_file.pl +++ b/bin/Vtiger_OUT_sync2VICIDIAL_file.pl @@ -705,7 +705,7 @@ while ($sthBrowsC > $i) if (length($territory)>0) { $VL_exists=0; - $stmtA = "SELECT count(*) FROM vicidial_users where user_code='$territory';"; + $stmtA = "SELECT count(*) FROM vicidial_user_territories where territory='$territory';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -719,7 +719,7 @@ while ($sthBrowsC > $i) if ($VL_exists > 0) { $user=''; - $stmtA = "SELECT user FROM vicidial_users where user_code='$territory';"; + $stmtA = "SELECT user FROM vicidial_user_territories where territory='$territory';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -747,7 +747,7 @@ while ($sthBrowsC > $i) if (length($user_id)>0) { - $stmtB = "UPDATE vtiger_crmentity SET smownerid='$user_id' where accountid='$crmid[$i]';"; + $stmtB = "UPDATE vtiger_crmentity SET smownerid='$user_id' where crmid='$crmid[$i]';"; if ($T < 1) {$affected_rowsB = $dbhB->do($stmtB) or die "Couldn't execute query: |$stmtB|\n";} if($DB){print "|$affected_rowsB|$stmtB|\n";} $n++; diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 5d9b8024..9ff73499 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -18,6 +18,7 @@ New scripts: Changes: 80724-1723 - First build 90428-0208 - Added blind_monitor function +90513-1720 - Added sounds_list function @@ -40,6 +41,32 @@ VERSION: 2.0.5-4|BUILD: 80910-0020|DATE: 2008-09-10 00:26:43|EPOCH: 1221020803 + +-------------------------------------------------------------------------------- +sounds_list - outputs a list of audio files from the audio store + +NOTE: api user for this function must have user_level set to 7 or higher + +OPTIONAL FIELDS- +format - format of the output(tab, link, selectframe) +stage - how to sort the output(date, size, name) +comments - name of the field to populate + + +Example URL strings for API calls: +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=sounds_list&format=selectframe&comments=fieldname&stage=date + +Example responses: + + +ERROR: sounds_list USER DOES NOT HAVE PERMISSION TO VIEW SOUNDS LIST + +ERROR: sounds_list CENTRAL SOUND CONTROL IS NOT ACTIVE + + + + + -------------------------------------------------------------------------------- blind_monitor - calls user-defined phone and places them in session as blind monitor diff --git a/docs/REQUIREMENTS.txt b/docs/REQUIREMENTS.txt index 5b97e3de..93032a8c 100644 --- a/docs/REQUIREMENTS.txt +++ b/docs/REQUIREMENTS.txt @@ -3,7 +3,8 @@ recommended that you read the SCRATCH_INSTALL doc for more information on installing the package properly. Requirements for installing astGUIclient/VICIDIAL on an Asterisk server: -- Asterisk 1.2.24 recommended but will work with most older Asterisk versions +- Asterisk 1.2.27 and 1.4.21.2 recommended but will work with most older Asterisk versions +- ViciDial does NOT support Asterisk 1.6.X at this time due to stability issues - Zap trunks(T1/E1 or PSTN lines), IAX2 trunks or SIP trunks required - If using VOIP trunks and VICIDIAL auto-dial, you must have trunks registered - It is strongly suggested that you have a zaptel timer like a PSTN/T1/E1 card or ztdummy diff --git a/docs/Ubuntu_Install.txt b/docs/Ubuntu_Install.txt index 407f4b27..e1c5dea2 100644 --- a/docs/Ubuntu_Install.txt +++ b/docs/Ubuntu_Install.txt @@ -1,4 +1,4 @@ -Ubuntu VICIDIAL Install: 2009-04-23 +Ubuntu VICIDIAL Install: 2009-05-12 ### NOTE ### If you just want a quick setup of ViciDial on Ubuntu, take a look at our @@ -42,6 +42,8 @@ sox (command line encoding and decoding tool) subversion (code versioning tool) subversion-tools unzip +libcurl3 +curl Go to terminal: @@ -121,9 +123,9 @@ mkdir /usr/src/asterisk cd /usr/src/asterisk ****FOR 1.2 asterisk run the following -wget http://ftp.digium.com/pub/asterisk/releases/asterisk-1.2.30.2.tar.gz -wget http://ftp.digium.com/pub/zaptel/releases/zaptel-1.2.27.tar.gz -wget http://ftp.digium.com/pub/libpri/releases/libpri-1.2.8.tar.gz +wget http://downloads.digium.com/pub/asterisk/releases/asterisk-1.2.30.2.tar.gz +wget http://downloads.digium.com/pub/zaptel/releases/zaptel-1.2.27.tar.gz +wget http://downloads.digium.com/pub/libpri/releases/libpri-1.2.8.tar.gz tar xzf asterisk-1.2.30.2.tar.gz tar xzf zaptel-1.2.27.tar.gz tar xzf libpri-1.2.8.tar.gz diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 02850ecd..52698d07 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -104,7 +104,8 @@ outbound_calls_per_second SMALLINT(3) UNSIGNED default '20', sysload INT(6) NOT NULL default '0', channels_total SMALLINT(4) UNSIGNED NOT NULL default '0', cpu_idle_percent SMALLINT(3) UNSIGNED NOT NULL default '0', -disk_usage VARCHAR(255) default '1' +disk_usage VARCHAR(255) default '1', +sounds_update ENUM('Y','N') default 'N' ); CREATE UNIQUE INDEX server_id on servers (server_id); @@ -1095,7 +1096,10 @@ qc_features_active ENUM('1','0') default '0', outbound_autodial_active ENUM('1','0') default '1', outbound_calls_per_second SMALLINT(3) UNSIGNED default '40', enable_tts_integration ENUM('0','1') default '0', -agentonly_callback_campaign_lock ENUM('0','1') default '1' +agentonly_callback_campaign_lock ENUM('0','1') default '1', +sounds_central_control_active ENUM('0','1') default '0', +sounds_web_server VARCHAR(15) default '127.0.0.1', +sounds_web_directory VARCHAR(255) default '' ); CREATE TABLE vicidial_campaigns_list_mix ( @@ -1497,6 +1501,13 @@ index (menu_id), unique index menuoption (menu_id, option_value) ); +CREATE TABLE vicidial_user_territories ( +user VARCHAR(20) NOT NULL, +territory VARCHAR(100) default '', +index (user), +unique index userterritory (user, territory) +); + ALTER TABLE vicidial_campaign_server_stats ENGINE=HEAP; @@ -1593,7 +1604,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1141'; +UPDATE system_settings SET db_schema_version='1142'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/extras/upgrade_2.2.0.sql b/extras/upgrade_2.2.0.sql index 7aaba75a..a33d11fa 100644 --- a/extras/upgrade_2.2.0.sql +++ b/extras/upgrade_2.2.0.sql @@ -83,3 +83,19 @@ UPDATE system_settings SET db_schema_version='1140'; ALTER TABLE system_settings ADD agentonly_callback_campaign_lock ENUM('0','1') default '1'; UPDATE system_settings SET db_schema_version='1141'; + +ALTER TABLE system_settings ADD sounds_central_control_active ENUM('0','1') default '0'; +ALTER TABLE system_settings ADD sounds_web_server VARCHAR(15) default '127.0.0.1'; +ALTER TABLE system_settings ADD sounds_web_directory VARCHAR(255) default ''; + +ALTER TABLE servers ADD sounds_update ENUM('Y','N') default 'N'; + +CREATE TABLE vicidial_user_territories ( +user VARCHAR(20) NOT NULL, +territory VARCHAR(100) default '', +index (user), +unique index userterritory (user, territory) +); + +UPDATE system_settings SET db_schema_version='1142'; + diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt index deae45fb..ea2ed846 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt @@ -104,8 +104,21 @@ Copy Call Menu|| To delete an Option, just set the Route to REMOVE and the option will be deleted when you click the SUBMIT button|| Agent Only Callback Campaign Lock|| This option defines whether AGENTONLY callbacks are locked to the campaign that the agent originally created them under. Setting this to 1 means that the agent can only dial them from the campaign they were set under, 0 means that the agent can access them no matter what campaign they are logged into. Default is 1|| +Central Sound Control Active|| +This option defines whether the sound synchronization system is active across all servers. Default is 0 for inactive|| +Sounds Web Server IP|| +This is the IP address of the web server that will be handling the sound files on this system, this must match the server IP of the machine you are trying to access the audio_store.php webpage on or it will not work. Default is 127.0.0.1|| +Sounds Web Directory|| +This auto-generated directory name is created at random by the system as the place that the audio store will be kept. All audio files will reside in this directory|| +Audio Store|| +Audio File to Upload|| +This utility allows you to upload audio files to the web server so that they can be distributed to all of the ViciDial servers in a multi-server cluster. An important note, only two audio file types will work, .wav files that are PCM 16bit 8k and .gsm files that are 8bit 8k. Please verify that your files are properly formatted before uploading them here|| +Sounds Update|| +If you want to force a check of the sound files on this server, and the central audio store is enabled as a system setting, then this field will allow the sounds updater to run at the next top of the minute. Any time an audio file is uploaded from the web interface this is automatically set to Y for all servers that have Asterisk active. Default is N|| +add-file: audio_store.php + ############################################################ CLIENT You are not allowed to dial into other agent sessions|| diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 91e3dd81..98cf8a74 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -1012,6 +1012,14 @@ if (isset($_GET["source_menu"])) {$source_menu=$_GET["source_menu"];} elseif (isset($_POST["source_menu"])) {$source_menu=$_POST["source_menu"];} if (isset($_GET["agentonly_callback_campaign_lock"])) {$agentonly_callback_campaign_lock=$_GET["agentonly_callback_campaign_lock"];} elseif (isset($_POST["agentonly_callback_campaign_lock"])) {$agentonly_callback_campaign_lock=$_POST["agentonly_callback_campaign_lock"];} +if (isset($_GET["sounds_central_control_active"])) {$sounds_central_control_active=$_GET["sounds_central_control_active"];} + elseif (isset($_POST["sounds_central_control_active"])) {$sounds_central_control_active=$_POST["sounds_central_control_active"];} +if (isset($_GET["sounds_web_server"])) {$sounds_web_server=$_GET["sounds_web_server"];} + elseif (isset($_POST["sounds_web_server"])) {$sounds_web_server=$_POST["sounds_web_server"];} +if (isset($_GET["sounds_web_directory"])) {$sounds_web_directory=$_GET["sounds_web_directory"];} + elseif (isset($_POST["sounds_web_directory"])) {$sounds_web_directory=$_POST["sounds_web_directory"];} +if (isset($_GET["sounds_update"])) {$sounds_update=$_GET["sounds_update"];} + elseif (isset($_POST["sounds_update"])) {$sounds_update=$_POST["sounds_update"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -1024,7 +1032,7 @@ if (strlen($dial_status) > 0) ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active FROM system_settings;"; +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active FROM system_settings;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysql_num_rows($rslt); @@ -1037,6 +1045,7 @@ while ($i < $qm_conf_ct) $SSenable_vtiger_integration = $row[2]; $SSqc_features_active = $row[3]; $SSoutbound_autodial_active = $row[4]; + $SSsounds_central_control_active = $row[5]; $i++; } ##### END SETTINGS LOOKUP ##### @@ -1201,6 +1210,7 @@ $menu_time_check = ereg_replace("[^0-9]","",$menu_time_check); $track_in_vdac = ereg_replace("[^0-9]","",$track_in_vdac); $menu_repeat = ereg_replace("[^0-9]","",$menu_repeat); $agentonly_callback_campaign_lock = ereg_replace("[^0-9]","",$agentonly_callback_campaign_lock); +$sounds_central_control_active = ereg_replace("[^0-9]","",$sounds_central_control_active); ### DIGITS and COLONS $shift_length = ereg_replace("[^\:0-9]","",$shift_length); @@ -1259,6 +1269,7 @@ $dnc = ereg_replace("[^NY]","",$dnc); $customer_contact = ereg_replace("[^NY]","",$customer_contact); $not_interested = ereg_replace("[^NY]","",$not_interested); $unworkable = ereg_replace("[^NY]","",$unworkable); +$sounds_update = ereg_replace("[^NY]","",$sounds_update); $qc_enabled = ereg_replace("[^0-9NY]","",$qc_enabled); @@ -1294,6 +1305,7 @@ $shift_enforcement = ereg_replace("[^0-9a-zA-Z]","",$shift_enforcement); $agent_shift_enforcement_override = ereg_replace("[^0-9a-zA-Z]","",$agent_shift_enforcement_override); $survey_third_status = ereg_replace("[^0-9a-zA-Z]","",$survey_third_status); $survey_fourth_status = ereg_replace("[^0-9a-zA-Z]","",$survey_fourth_status); +$sounds_web_directory = ereg_replace("[^0-9a-zA-Z]","",$sounds_web_directory); ### DIGITS and Dots $server_ip = ereg_replace("[^\.0-9]","",$server_ip); @@ -1304,6 +1316,7 @@ $old_server_ip = ereg_replace("[^\.0-9]","",$old_server_ip); $computer_ip = ereg_replace("[^\.0-9]","",$computer_ip); $queuemetrics_server_ip = ereg_replace("[^\.0-9]","",$queuemetrics_server_ip); $vtiger_server_ip = ereg_replace("[^\.0-9]","",$vtiger_server_ip); +$sounds_web_server = ereg_replace("[^\.0-9]","",$sounds_web_server); ### ALPHA-NUMERIC and spaces and hash and star and comma $xferconf_a_dtmf = ereg_replace("[^ \,\*\#0-9a-zA-Z]","",$xferconf_a_dtmf); @@ -1743,11 +1756,13 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90430-0154 - Added RANDOM and LAST CALL TIME options to lead order for campaigns # 90504-0901 - Added Call Menu feature, changed script to use long PHP tags # 90511-0910 - Added agentonly_callback_campaign_lock to system_settings +# 90512-0440 - Added sounds settings to system_settings table +# 90514-0607 - Added select prompts from list in call menu and in-group screens # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.2.0-183'; -$build = '90511-0910'; +$admin_version = '2.2.0-185'; +$build = '90514-0607'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -4368,6 +4383,14 @@ if ($SSoutbound_autodial_active > 0) + + +
+ +Audio Store - This utility allows you to upload audio files to the web server so that they can be distributed to all of the ViciDial servers in a multi-server cluster. An important note, only two audio file types will work, .wav files that are PCM 16bit 8k and .gsm files that are 8bit 8k. Please verify that your files are properly formatted before uploading them here. + + + 0) { @@ -4964,6 +4987,11 @@ if ($SSoutbound_autodial_active > 0)
Rebuild conf files - If you want to force a rebuilding of the Asterisk conf files or if any of the phones or carrier entries have changed then this should be set to Y. After the conf files have been generated and Asterisk has been reloaded then this will be changed to N. Default is Y. +
+
+
+Sounds Update - If you want to force a check of the sound files on this server, and the central audio store is enabled as a system setting, then this field will allow the sounds updater to run at the next top of the minute. Any time an audio file is uploaded from the web interface this is automatically set to Y for all servers that have Asterisk active. Default is N. + @@ -5172,6 +5200,21 @@ FR_SPAC 00 00 00 00 00 - France space separated phone number

Agent Only Callback Campaign Lock - This option defines whether AGENTONLY callbacks are locked to the campaign that the agent originally created them under. Setting this to 1 means that the agent can only dial them from the campaign they were set under, 0 means that the agent can access them no matter what campaign they are logged into. Default is 1. +
+
+
+Central Sound Control Active - This option defines whether the sound synchronization system is active across all servers. Default is 0 for inactive. + +
+
+
+Sounds Web Server IP - This is the IP address of the web server that will be handling the sound files on this system, this must match the server IP of the machine you are trying to access the audio_store.php webpage on or it will not work. Default is 127.0.0.1. + +
+
+
+Sounds Web Directory - This auto-generated directory name is created at random by the system as the place that the audio store will be kept. All audio files will reside in this directory. +

@@ -11267,7 +11310,7 @@ if ($ADD==411111111111) { echo "
SERVER MODIFIED: $server_ip\n"; - $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second' where server_id='$old_server_id';"; + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second',sounds_update='$sounds_update' where server_id='$old_server_id';"; $rslt=mysql_query($stmt, $link); $stmtA="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; @@ -11519,7 +11562,7 @@ if ($ADD==411111111111111) echo "
VICIDIAL SYSTEM SETTINGS MODIFIED\n"; - $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock';"; + $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory';"; $rslt=mysql_query($stmt, $link); ### LOG INSERTION Admin Log Table ### @@ -16614,7 +16657,7 @@ if ($ADD==3111) {$Hgroups_menu .= "\n";} - echo "
MODIFY A GROUPS RECORD: $row[0]
\n"; + echo "
MODIFY A GROUPS RECORD: $row[0]\n"; echo "\n"; echo "\n"; echo "
\n"; @@ -16675,7 +16718,7 @@ if ($ADD==3111) echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; @@ -16685,13 +16728,13 @@ if ($ADD==3111) echo "$Agroups_menu"; echo "$NWB#vicidial_inbound_groups-afterhours_xfer_group$NWE\n"; - echo "\n"; + echo "\n"; echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; @@ -16711,7 +16754,7 @@ if ($ADD==3111) echo "$Tgroups_menu"; echo "$NWB#vicidial_inbound_groups-hold_time_option_xfer_group$NWE\n"; - echo "\n"; + echo "\n"; echo "\n"; @@ -17103,16 +17146,16 @@ if ($ADD==3511) $track_in_vdac = $row[8]; - echo "
MODIFY A CALL MENU RECORD: $menu_id\n"; + echo "
MODIFY A CALL MENU RECORD: $menu_id\n"; echo "\n"; echo "\n"; echo "
After Hours Action: $NWB#vicidial_inbound_groups-after_hours_action$NWE
After Hours Message Filename: $NWB#vicidial_inbound_groups-after_hours_message_filename$NWE
After Hours Message Filename: audio chooser $NWB#vicidial_inbound_groups-after_hours_message_filename$NWE
After Hours Extension: $NWB#vicidial_inbound_groups-after_hours_exten$NWE
Welcome Message Filename: $NWB#vicidial_inbound_groups-welcome_message_filename$NWE
Welcome Message Filename: audio chooser $NWB#vicidial_inbound_groups-welcome_message_filename$NWE
Play Welcome Message: $NWB#vicidial_inbound_groups-play_welcome_message$NWE
Music On Hold Context: $NWB#vicidial_inbound_groups-moh_context$NWE
On Hold Prompt Filename: $NWB#vicidial_inbound_groups-onhold_prompt_filename$NWE
On Hold Prompt Filename: audio chooser $NWB#vicidial_inbound_groups-onhold_prompt_filename$NWE
On Hold Prompt Interval: $NWB#vicidial_inbound_groups-prompt_interval$NWE
Hold Time Option Callback Filename: $NWB#vicidial_inbound_groups-hold_time_option_callback_filename$NWE
Hold Time Option Callback Filename: audio chooser $NWB#vicidial_inbound_groups-hold_time_option_callback_filename$NWE
Hold Time Option Callback List ID: $NWB#vicidial_inbound_groups-hold_time_option_callback_list_id$NWE
\n"; echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "
Menu ID: $menu_id $NWB#vicidial_call_menu-menu_id$NWE
Menu Name: $NWB#vicidial_call_menu-menu_name$NWE
Menu Prompt: $NWB#vicidial_call_menu-menu_prompt$NWE
Menu Prompt: audio chooser $NWB#vicidial_call_menu-menu_prompt$NWE
Menu Timeout: $NWB#vicidial_call_menu-menu_timeout$NWE
Menu Timeout Prompt: $NWB#vicidial_call_menu-menu_timeout_prompt$NWE
Menu Invalid Prompt: $NWB#vicidial_call_menu-menu_invalid_prompt$NWE
Menu Timeout Prompt: audio chooser $NWB#vicidial_call_menu-menu_timeout_prompt$NWE
Menu Invalid Prompt: audio chooser $NWB#vicidial_call_menu-menu_invalid_prompt$NWE
Menu Repeat: $NWB#vicidial_call_menu-menu_repeat$NWE
Menu Time Check: \n"; echo "\n"; echo "\n"; + echo "\n"; echo "\n"; @@ -18827,7 +18872,7 @@ if ($ADD==311111111111111) echo "
\n"; echo ""; - $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage from servers where server_id='$server_id' or server_ip='$server_ip';"; + $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage,sounds_update from servers where server_id='$server_id' or server_ip='$server_ip';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $server_id = $row[0]; @@ -18274,6 +18317,7 @@ if ($ADD==311111111111) $channels_total = $row[29]; $cpu_idle_percent = $row[30]; $disk_usage = $row[31]; + $sounds_update = $row[32]; $cpu = (100 - $cpu_idle_percent); $disk_usage = preg_replace("/ /"," - ",$disk_usage); @@ -18317,6 +18361,7 @@ if ($ADD==311111111111) echo "
Active Asterisk Server: $NWB#servers-active_asterisk_server$NWE
Generate conf files: $NWB#servers-generate_vicidial_conf$NWE
Rebuild conf files: $NWB#servers-rebuild_conf_files$NWE
Sounds Update: $NWB#servers-sounds_update$NWE
\n"; echo ""; - $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,agentonly_callback_campaign_lock from system_settings;"; + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $version = $row[0]; @@ -18865,9 +18910,13 @@ if ($ADD==311111111111111) $outbound_autodial_active = $row[32]; $outbound_calls_per_second = $row[33]; $agentonly_callback_campaign_lock = $row[34]; + $sounds_central_control_active = $row[35]; + $sounds_web_server = $row[36]; + $sounds_web_directory = $row[37]; echo "
MODIFY VICIDIAL SYSTEM SETTINGS\n"; echo "\n"; + echo "\n"; echo "
\n"; echo "\n"; echo "\n"; @@ -18922,6 +18971,11 @@ if ($ADD==311111111111111) echo "$NWB#settings-vdc_header_phone_format$NWE\n"; echo "\n"; echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; diff --git a/www/vicidial/admin_header.php b/www/vicidial/admin_header.php index df3ffce8..0afc73bf 100644 --- a/www/vicidial/admin_header.php +++ b/www/vicidial/admin_header.php @@ -7,6 +7,7 @@ # CHANGES # 90310-0709 - First Build # 90508-0542 - Added Call Menu option, changed script to use long PHP tags +# 90514-0605 - Added audio prompt selection functions # @@ -75,6 +76,10 @@ if ($hh=='reports') echo "\n"; echo "\n"; + echo "\n\n"; + + echo "\n"; + echo "close frame\n"; + echo "
\n"; + echo "
Version: $version
DB Schema Version: $db_schema_version
Agent API Active: $NWB#settings-vdc_agent_api_active$NWE
Agent Only Callback Campaign Lock: $NWB#settings-agentonly_callback_campaign_lock$NWE
Central Sound Control Active: $NWB#settings-sounds_central_control_active$NWE
Sounds Web Server IP: $NWB#settings-sounds_web_server$NWE
Sounds Web Directory: $sounds_web_directory $NWB#settings-sounds_web_directory$NWE
QC Features Active: $NWB#settings-qc_features_active$NWE
Outbound Auto-Dial Active: $NWB#settings-outbound_autodial_active$NWE
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + $sf++; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + $k++; + } + if ($sf > 0) + { + echo "
#FILENAMEDATESIZEPLAY
$sf$file_names[$m]$file_dates[$m]$file_sizes[$m]PLAY
\n"; + } + + exit; + + } + } + } + + + + ################################################################################ ### blind_monitor - sends call to phone from session from listening ################################################################################