Added transfer_conf-ID of epoch to help prevent double-execution of transfer commands for agent api

Added vicidial_api_log to archive_log_tables --daily process

git-svn-id: svn://192.168.202.10@2243 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-01-09 00:33:46 +00:00
parent 032b6645a0
commit eb7ed8c0f3
6 changed files with 132 additions and 63 deletions
+61 -8
View File
@@ -20,7 +20,7 @@
# Based on perl scripts in ViciDial from Matt Florell and post:
# http://www.vicidial.org/VICIDIALforum/viewtopic.php?p=22506&sid=ca5347cffa6f6382f56ce3db9fb3d068#22506
#
# Copyright (C) 2014 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 90615-1701 - First version
@@ -38,6 +38,7 @@
# 120831-1536 - Added rolling of vicidial_dial_log entries
# 140107-1508 - Added rolling of vicidial_api_log entries
# 140305-0955 - Changed to use --days (--months is approximation[bug fix]), changed default from 2 months to 2 years
# 150107-2308 - Added vicidial_api_log to daily process
#
$CALC_TEST=0;
@@ -230,10 +231,10 @@ if (!$T)
{
if ($daily > 0)
{
# The --daily option was added because these tables(call_log, vicidial_dial_log and
# vicidial_log_extended) are not used for any processes or reports past
# 24 hours, and on systems dialing 500,000 calls per day or more, this
# can lead to system delay issues even if the 1-month archive process is
# The --daily option was added because these tables(call_log, vicidial_dial_log,
# vicidial_log_extended and vicidial_api_log) are not used for any processes or
# reports past 24 hours, and on systems dialing 500,000 calls per day or more,
# this can lead to system delay issues even if the 1-month archive process is
# run every weekend. This --daily option will keep only the last
# 24-hours and can improve DB performance greatly
@@ -316,7 +317,7 @@ if (!$T)
$rv = $sthA->err();
if (!$rv)
{
{
$stmtA = "DELETE FROM vicidial_log_extended WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -363,7 +364,7 @@ if (!$T)
$rv = $sthA->err();
if (!$rv)
{
{
$stmtA = "DELETE FROM vicidial_dial_log WHERE call_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -377,6 +378,57 @@ if (!$T)
##### END vicidial_dial_log DAILY processing #####
##### BEGIN vicidial_api_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_api_log;";
$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;
$vicidial_api_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_api_log_archive;";
$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;
$vicidial_api_log_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_api_log table... ($vicidial_api_log_count|$vicidial_api_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_api_log_archive SELECT * from vicidial_api_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows inserted into vicidial_api_log_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_api_log WHERE api_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_api_log table \n";}
$stmtA = "optimize table vicidial_api_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_api_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_api_log DAILY processing #####
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secX);
@@ -385,6 +437,7 @@ if (!$T)
exit;
}
########## END of --daily flag processing ##########
@@ -754,7 +807,7 @@ if (!$T)
$rv = $sthA->err();
if (!$rv)
{
{
$stmtA = "DELETE FROM vicidial_api_log WHERE api_date < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+1 -1
View File
@@ -649,7 +649,7 @@ VALUES:
consultative -
OPTIONAL, when you want to do a consultative transfer with your customer and another ViciDial agent, 'YES' and 'NO' are valid options, you can only use this with DIAL_WITH_CUSTOMER or PARK_CUSTOMER_DIAL
dial_override -
OPTIONAL, dials exactly the phone number specified with no campaign-defined phone code or prefix
OPTIONAL, dials exactly the phone number specified with no campaign-defined phone code or prefix, 'YES' and 'NO' are valid options
group_alias -
OPTIONAL, defines what caller ID number to use when doing DIAL_WITH_CUSTOMER or PARK_CUSTOMER_DIAL
+2 -2
View File
@@ -401,7 +401,7 @@ manager_ingroup_set ENUM('Y','N','SET') default 'N',
ra_user VARCHAR(20) default '',
ra_extension VARCHAR(100) default '',
external_dtmf VARCHAR(100) default '',
external_transferconf VARCHAR(100) default '',
external_transferconf VARCHAR(120) default '',
external_park VARCHAR(40) default '',
external_timer_action_destination VARCHAR(100) default '',
on_hook_agent ENUM('Y','N') default 'N',
@@ -3363,4 +3363,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1398',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1399',db_schema_update_date=NOW(),reload_timestamp=NOW();
+4
View File
@@ -160,3 +160,7 @@ CREATE INDEX vlali on vicidial_live_agents (lead_id);
CREATE INDEX vlaus on vicidial_live_agents (user);
UPDATE system_settings SET db_schema_version='1398',db_schema_update_date=NOW() where db_schema_version < 1398;
ALTER TABLE vicidial_live_agents MODIFY external_transferconf VARCHAR(120) default '';
UPDATE system_settings SET db_schema_version='1399',db_schema_update_date=NOW() where db_schema_version < 1399;
+8 -7
View File
@@ -1,7 +1,7 @@
<?php
# api.php
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# This script is designed as an API(Application Programming Interface) to allow
# other programs to interact with the VICIDIAL Agent screen
@@ -78,10 +78,11 @@
# 140811-1243 - Changed to use QXZ function for echoing text
# 141128-0847 - Code cleanup for QXZ functions
# 141216-2118 - Added language settings lookups and user/pass variable standardization
# 150108-1039 - Added transfer_conf-ID of epoch to help prevent double-execution of transfer commands
#
$version = '2.10-44';
$build = '141216-2118';
$version = '2.10-45';
$build = '150108-1039';
$startMS = microtime();
@@ -3383,7 +3384,7 @@ if ($function == 'transfer_conference')
}
}
$external_transferconf = "$value---$ingroup_choices---$phone_number---$consultative------$group_alias---$caller_id_number";
$external_transferconf = "$value---$ingroup_choices---$phone_number---$consultative------$group_alias---$caller_id_number---$epoch";
}
}
}
@@ -3425,7 +3426,7 @@ if ($function == 'transfer_conference')
}
$processed++;
$external_transferconf = "$value------$phone_number---NO---$dial_override---$group_alias---$caller_id_number";
$external_transferconf = "$value------$phone_number---NO---$dial_override---$group_alias---$caller_id_number---$epoch";
$SUCCESS++;
}
@@ -3433,7 +3434,7 @@ if ($function == 'transfer_conference')
if ( ($processed < 1) and ( ($value=='HANGUP_XFER') or ($value=='HANGUP_BOTH') ) )
{
$processed++;
$external_transferconf = "$value---------NO---";
$external_transferconf = "$value---------NO------------$epoch";
$SUCCESS++;
}
@@ -3441,7 +3442,7 @@ if ($function == 'transfer_conference')
if ( ($processed < 1) and ($value=='LEAVE_3WAY_CALL') )
{
$processed++;
$external_transferconf = "$value---------NO---";
$external_transferconf = "$value---------NO------------$epoch";
$SUCCESS++;
}
+56 -45
View File
@@ -465,10 +465,11 @@
# 141227-1759 - Found missing phrase for QXZ
# 141229-1429 - Changed single-quote QXZ arguments to double-quotes
# 150101-1516 - Updated for 2015
# 150108-1725 - Added more validation for API transfer commands
#
$version = '2.10-436c';
$build = '150101-1516';
$version = '2.10-437c';
$build = '150108-1725';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=85;
$one_mysql_log=0;
@@ -4051,6 +4052,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
var show_previous_callback='<?php echo $show_previous_callback ?>';
var clear_script='<?php echo $clear_script ?>';
var parked_hangup='0';
var api_transferconf_ID = '';
var DiaLControl_auto_HTML = "<img src=\"./images/<?php echo _QXZ("vdc_LB_pause_OFF.gif") ?>\" border=\"0\" alt=\" Pause \" /><a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADready');\"><img src=\"./images/<?php echo _QXZ("vdc_LB_resume.gif") ?>\" border=\"0\" alt=\"Resume\" /></a>";
var DiaLControl_auto_HTML_ready = "<a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADpause');\"><img src=\"./images/<?php echo _QXZ("vdc_LB_pause.gif") ?>\" border=\"0\" alt=\" Pause \" /></a><img src=\"./images/<?php echo _QXZ("vdc_LB_resume_OFF.gif") ?>\" border=\"0\" alt=\"Resume\" />";
var DiaLControl_auto_HTML_OFF = "<img src=\"./images/<?php echo _QXZ("vdc_LB_pause_OFF.gif") ?>\" border=\"0\" alt=\" Pause \" /><img src=\"./images/<?php echo _QXZ("vdc_LB_resume_OFF.gif") ?>\" border=\"0\" alt=\"Resume\" />";
@@ -4968,58 +4970,67 @@ function set_length(SLnumber,SLlength_goal,SLdirection)
}
if (api_transferconf_function.length > 0)
{
if (api_transferconf_function == 'HANGUP_XFER')
{xfercall_send_hangup();}
if (api_transferconf_function == 'HANGUP_BOTH')
{bothcall_send_hangup();}
if (api_transferconf_function == 'LEAVE_VM')
{mainxfer_send_redirect('XfeRVMAIL',lastcustchannel,lastcustserverip);}
if (api_transferconf_function == 'LEAVE_3WAY_CALL')
{leave_3way_call('FIRST');}
if (api_transferconf_function == 'BLIND_TRANSFER')
if (api_transferconf_ID == api_transferconf_values_array[7])
{
document.vicidial_form.xfernumber.value = api_transferconf_number;
mainxfer_send_redirect('XfeRBLIND',lastcustchannel,lastcustserverip);
// alert("TRANSFERCONF COMMAND ALREADY RECEIVED: " + api_transferconf_function + "|" + api_transferconf_ID + "|" + api_transferconf_values_array[7] + "|" + external_transferconf_count);
Clear_API_Field('external_transferconf');
}
if (external_transferconf_count < 1)
else
{
if (api_transferconf_function == 'LOCAL_CLOSER')
api_transferconf_ID = api_transferconf_values_array[7];
if (api_transferconf_function == 'HANGUP_XFER')
{xfercall_send_hangup();}
if (api_transferconf_function == 'HANGUP_BOTH')
{bothcall_send_hangup();}
if (api_transferconf_function == 'LEAVE_VM')
{mainxfer_send_redirect('XfeRVMAIL',lastcustchannel,lastcustserverip);}
if (api_transferconf_function == 'LEAVE_3WAY_CALL')
{leave_3way_call('FIRST');}
if (api_transferconf_function == 'BLIND_TRANSFER')
{
API_selected_xfergroup = api_transferconf_group;
document.vicidial_form.xfernumber.value = api_transferconf_number;
mainxfer_send_redirect('XfeRLOCAL',lastcustchannel,lastcustserverip);
mainxfer_send_redirect('XfeRBLIND',lastcustchannel,lastcustserverip);
}
if (api_transferconf_function == 'DIAL_WITH_CUSTOMER')
if (external_transferconf_count < 1)
{
if (api_transferconf_consultative=='YES')
{document.vicidial_form.consultativexfer.checked=true;}
if (api_transferconf_consultative=='NO')
{document.vicidial_form.consultativexfer.checked=false;}
if (api_transferconf_override=='YES')
{document.vicidial_form.xferoverride.checked=true;}
API_selected_xfergroup = api_transferconf_group;
document.vicidial_form.xfernumber.value = api_transferconf_number;
active_group_alias = api_transferconf_group_alias;
cid_choice = api_transferconf_cid_number;
SendManualDial('YES');
if (api_transferconf_function == 'LOCAL_CLOSER')
{
API_selected_xfergroup = api_transferconf_group;
document.vicidial_form.xfernumber.value = api_transferconf_number;
mainxfer_send_redirect('XfeRLOCAL',lastcustchannel,lastcustserverip);
}
if (api_transferconf_function == 'DIAL_WITH_CUSTOMER')
{
if (api_transferconf_consultative=='YES')
{document.vicidial_form.consultativexfer.checked=true;}
if (api_transferconf_consultative=='NO')
{document.vicidial_form.consultativexfer.checked=false;}
if (api_transferconf_override=='YES')
{document.vicidial_form.xferoverride.checked=true;}
API_selected_xfergroup = api_transferconf_group;
document.vicidial_form.xfernumber.value = api_transferconf_number;
active_group_alias = api_transferconf_group_alias;
cid_choice = api_transferconf_cid_number;
SendManualDial('YES');
}
if (api_transferconf_function == 'PARK_CUSTOMER_DIAL')
{
if (api_transferconf_consultative=='YES')
{document.vicidial_form.consultativexfer.checked=true;}
if (api_transferconf_consultative=='NO')
{document.vicidial_form.consultativexfer.checked=false;}
if (api_transferconf_override=='YES')
{document.vicidial_form.xferoverride.checked=true;}
API_selected_xfergroup = api_transferconf_group;
document.vicidial_form.xfernumber.value = api_transferconf_number;
active_group_alias = api_transferconf_group_alias;
cid_choice = api_transferconf_cid_number;
xfer_park_dial();
}
external_transferconf_count=3;
}
if (api_transferconf_function == 'PARK_CUSTOMER_DIAL')
{
if (api_transferconf_consultative=='YES')
{document.vicidial_form.consultativexfer.checked=true;}
if (api_transferconf_consultative=='NO')
{document.vicidial_form.consultativexfer.checked=false;}
if (api_transferconf_override=='YES')
{document.vicidial_form.xferoverride.checked=true;}
API_selected_xfergroup = api_transferconf_group;
document.vicidial_form.xfernumber.value = api_transferconf_number;
active_group_alias = api_transferconf_group_alias;
cid_choice = api_transferconf_cid_number;
xfer_park_dial();
}
external_transferconf_count=3;
Clear_API_Field('external_transferconf');
}
Clear_API_Field('external_transferconf');
}
if (api_parkcustomer == 'PARK_CUSTOMER')
{mainxfer_send_redirect('ParK',lastcustchannel,lastcustserverip);}