fixed multi-campaign trunks short miscalculation in AST_VDauto_dial.pl

added option to vicidial.php to resend a "leave 3way call"
added logging functions to manager_send.php for leave 3way calls
added force Redirect on leave 3way calls when resend is used from dispo screen

git-svn-id: svn://192.168.202.10@560 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2007-03-20 18:51:35 +00:00
parent 499e620ced
commit 5afbd927b2
3 changed files with 143 additions and 30 deletions
+45 -22
View File
@@ -288,6 +288,7 @@ while($one_day_interval > 0)
$active_line_counter=0;
$user_counter=0;
$user_campaigns = '|';
$user_campaignsSQL = "''";
$user_campaigns_counter = 0;
$user_campaignIP = '|';
$user_CIPct = 0;
@@ -317,6 +318,7 @@ while($one_day_interval > 0)
{
if ($campaigns_update !~ /'$DBlive_campaign[$user_counter]'/) {$campaigns_update .= "'$DBlive_campaign[$user_counter]',"; $CPcount++;}
$user_campaigns .= "$DBlive_campaign[$user_counter]|";
$user_campaignsSQL .= ",'$DBlive_campaign[$user_counter]'";
$DBcampaigns[$user_campaigns_counter] = $DBlive_campaign[$user_counter];
$user_campaigns_counter++;
}
@@ -332,9 +334,30 @@ while($one_day_interval > 0)
}
$sthA->finish();
$event_string="LIVE AGENTS LOGGED IN: $user_counter";
### see how many total VDAD calls are going on right now for max limiter
$stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$server_ip' and status IN('SENT','RINGING','LIVE','XFER');";
$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;
$active_line_counter = "$aryA[0]";
$rec_count++;
}
$sthA->finish();
$event_string="LIVE AGENTS LOGGED IN: $user_counter ACTIVE CALLS: $active_line_counter";
&event_logger;
$stmtA = "UPDATE vicidial_campaign_server_stats set local_trunk_shortage='0' where server_ip='$server_ip' and campaign_id NOT IN($user_campaignsSQL);";
$UVCSSaffected_rows = $dbhA->do($stmtA);
if ($UVCSSaffected_rows > 0)
{
$event_string="OLD TRUNK SHORTS CLEARED: $UVCSSaffected_rows |$user_campaignsSQL|";
&event_logger;
}
$user_CIPct = 0;
foreach(@DBIPcampaign)
{
@@ -470,21 +493,6 @@ while($one_day_interval > 0)
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: agents: $DBIPcount[$user_CIPct] dial_level: $DBIPadlevel[$user_CIPct]";
&event_logger;
$active_line_counter=0;
$active_line_goal=0;
### see how many total VDAD calls are going on right now for max limiter
$stmtA = "SELECT count(*) FROM vicidial_auto_calls where server_ip='$DBIPaddress[$user_CIPct]' and status IN('SENT','RINGING','LIVE','XFER');";
$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;
$active_line_counter = "$aryA[0]";
$rec_count++;
}
$sthA->finish();
### see how many calls are alrady active per campaign per server and
### subtract that number from goalcalls to determine how many new
@@ -515,15 +523,21 @@ while($one_day_interval > 0)
}
$sthA->finish();
$active_line_goal=0;
$DBIPmakecalls[$user_CIPct] = ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]);
$DBIPmakecallsGOAL = $DBIPmakecalls[$user_CIPct];
$MVT_msg = '';
$DBIPtrunk_shortage[$user_CIPct] = 0;
$active_line_goal = ($active_line_counter + $DBIPmakecalls[$user_CIPct]);
if ($active_line_goal > $max_vicidial_trunks)
{
$MVT_msg = "MVT override: $max_vicidial_trunks";
$DBIPmakecalls[$user_CIPct] = ($max_vicidial_trunks - $active_line_counter);
$NEWmakecallsgoal = ($max_vicidial_trunks - $active_line_counter);
if ($DBIPmakecalls[$user_CIPct] > $NEWmakecallsgoal)
{$DBIPmakecalls[$user_CIPct] = $NEWmakecallsgoal;}
$DBIPtrunk_shortage[$user_CIPct] = ($active_line_goal - $max_vicidial_trunks);
if ($DBIPtrunk_shortage[$user_CIPct] > $DBIPmakecallsGOAL)
{$DBIPtrunk_shortage[$user_CIPct] = $DBIPmakecallsGOAL}
$MVT_msg = "MVT override: $max_vicidial_trunks |$DBIPmakecalls[$user_CIPct] $DBIPtrunk_shortage[$user_CIPct]|";
}
if (length($DBIPserver_trunks_limit[$user_CIPct])>0)
{
@@ -531,8 +545,12 @@ while($one_day_interval > 0)
{
$MVT_msg .= " TRUNK LIMIT override: $DBIPserver_trunks_limit[$user_CIPct]";
$DBIPtrunk_shortage[$user_CIPct] = ($active_line_goal - $DBIPserver_trunks_limit[$user_CIPct]);
if ($DBIPtrunk_shortage[$user_CIPct] > $DBIPmakecallsGOAL)
{$DBIPtrunk_shortage[$user_CIPct] = $DBIPmakecallsGOAL}
$active_line_goal = $DBIPserver_trunks_limit[$user_CIPct];
$DBIPmakecalls[$user_CIPct] = ($active_line_goal - $active_line_counter);
$NEWmakecallsgoal = ($active_line_goal - $active_line_counter);
if ($DBIPmakecalls[$user_CIPct] > $NEWmakecallsgoal)
{$DBIPmakecalls[$user_CIPct] = $NEWmakecallsgoal;}
}
}
else
@@ -541,15 +559,20 @@ while($one_day_interval > 0)
{
$MVT_msg .= " OTHER LIMIT override: $DBIPserver_trunks_allowed[$user_CIPct]";
$DBIPtrunk_shortage[$user_CIPct] = ($active_line_goal - $DBIPserver_trunks_allowed[$user_CIPct]);
if ($DBIPtrunk_shortage[$user_CIPct] > $DBIPmakecallsGOAL)
{$DBIPtrunk_shortage[$user_CIPct] = $DBIPmakecallsGOAL}
$active_line_goal = $DBIPserver_trunks_allowed[$user_CIPct];
$DBIPmakecalls[$user_CIPct] = ($active_line_goal - $active_line_counter);
$NEWmakecallsgoal = ($active_line_goal - $active_line_counter);
if ($DBIPmakecalls[$user_CIPct] > $NEWmakecallsgoal)
{$DBIPmakecalls[$user_CIPct] = $NEWmakecallsgoal;}
}
}
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]) $MVT_msg";
if ($DBIPmakecalls[$user_CIPct] > 0)
{$active_line_counter = ($DBIPmakecalls[$user_CIPct] + $active_line_counter);}
$event_string="$DBIPcampaign[$user_CIPct] $DBIPaddress[$user_CIPct]: Calls to place: $DBIPmakecalls[$user_CIPct] ($DBIPgoalcalls[$user_CIPct] - $DBIPexistcalls[$user_CIPct]) $active_line_counter $MVT_msg";
&event_logger;
### Calculate campaign-wide agent waiting and calls waiting differential
### This is used by the AST_VDadapt script to see if the current dial_level
### should be changed at all
+53 -3
View File
@@ -562,6 +562,7 @@ if ($ACTION=="RedirectNameVmail")
if ($ACTION=="RedirectXtraCX")
{
$DBout='';
$row=''; $rowx='';
$channel_liveX=1;
$channel_liveY=1;
@@ -577,6 +578,15 @@ if ($ACTION=="RedirectXtraCX")
echo "ext_context $ext_context must be set\n";
echo "ext_priority $ext_priority must be set\n";
echo "\nRedirect Action not sent\n";
if (ereg("SECOND|FIRST|DEBUG",$filename))
{
if ($WeBRooTWritablE > 0)
{
$fp = fopen ("./vicidial_debug.txt", "a");
fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n");
fclose($fp);
}
}
}
else
{
@@ -596,6 +606,7 @@ if ($ACTION=="RedirectXtraCX")
{
$channel_liveX=0;
echo "Channel $channel is not live on $call_server_ip, Redirect command not inserted\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel is not live on $call_server_ip";}
}
}
$stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';";
@@ -612,6 +623,7 @@ if ($ACTION=="RedirectXtraCX")
{
$channel_liveY=0;
echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel is not live on $server_ip";}
}
}
if ( ($channel_liveX==1) && ($channel_liveY==1) )
@@ -624,6 +636,7 @@ if ($ACTION=="RedirectXtraCX")
{
$channel_liveY=0;
echo "No Local agent to send call to, Redirect command not inserted\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "No Local agent to send call to";}
}
else
{
@@ -656,6 +669,7 @@ if ($ACTION=="RedirectXtraCX")
$rslt=mysql_query($stmt, $link);
echo "RedirectXtraCX command sent for Channel $channel on $call_server_ip and \nHungup $extrachannel on $server_ip\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel on $call_server_ip, Hungup $extrachannel on $server_ip";}
}
}
else
@@ -664,8 +678,19 @@ if ($ACTION=="RedirectXtraCX")
{$ACTION="Redirect"; $server_ip = $call_server_ip;}
if ($channel_liveY==1)
{$ACTION="Redirect"; $channel=$extrachannel;}
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Changed to Redirect: $channel on $server_ip";}
}
if (ereg("SECOND|FIRST|DEBUG",$filename))
{
if ($WeBRooTWritablE > 0)
{
$fp = fopen ("./vicidial_debug.txt", "a");
fwrite ($fp, "$NOW_TIME|RDCXC|$filename|$user|$campaign|$DBout|\n");
fclose($fp);
}
}
}
}
@@ -690,6 +715,15 @@ if ($ACTION=="RedirectXtra")
echo "ext_context $ext_context must be set\n";
echo "ext_priority $ext_priority must be set\n";
echo "\nRedirect Action not sent\n";
if (ereg("SECOND|FIRST|DEBUG",$filename))
{
if ($WeBRooTWritablE > 0)
{
$fp = fopen ("./vicidial_debug.txt", "a");
fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$$channel|$extrachannel|$queryCID|$exten|$ext_context|ext_priority|\n");
fclose($fp);
}
}
}
else
{
@@ -710,6 +744,7 @@ if ($ACTION=="RedirectXtra")
{
$channel_liveX=0;
echo "Cannot find empty conference on $server_ip, Redirect command not inserted\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";}
}
}
@@ -719,7 +754,7 @@ if ($ACTION=="RedirectXtra")
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
if ( ($row[0]==0) && (!ereg("SECOND",$filename)) )
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$call_server_ip' and channel='$channel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
@@ -729,13 +764,14 @@ if ($ACTION=="RedirectXtra")
{
$channel_liveX=0;
echo "Channel $channel is not live on $call_server_ip, Redirect command not inserted\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel is not live on $call_server_ip";}
}
}
$stmt="SELECT count(*) FROM live_channels where server_ip = '$server_ip' and channel='$extrachannel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
if ($row[0]==0)
if ( ($row[0]==0) && (!ereg("SECOND",$filename)) )
{
$stmt="SELECT count(*) FROM live_sip_channels where server_ip = '$server_ip' and channel='$extrachannel';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
@@ -745,6 +781,7 @@ if ($ACTION=="RedirectXtra")
{
$channel_liveY=0;
echo "Channel $channel is not live on $server_ip, Redirect command not inserted\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel is not live on $server_ip";}
}
}
if ( ($channel_liveX==1) && ($channel_liveY==1) )
@@ -756,6 +793,7 @@ if ($ACTION=="RedirectXtra")
$rslt=mysql_query($stmt, $link);
echo "RedirectXtra command sent for Channel $channel and \nExtraChannel $extrachannel\n to $exten on $server_ip\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel and $extrachannel to $exten on $server_ip";}
}
else
{
@@ -780,6 +818,7 @@ if ($ACTION=="RedirectXtra")
$rslt=mysql_query($stmt, $link);
echo "RedirectXtra command sent for Channel $channel on $call_server_ip and \nExtraChannel $extrachannel\n to $exten on $server_ip\n";
if (ereg("SECOND|FIRST|DEBUG",$filename)) {$DBout .= "$channel/$call_server_ip and $extrachannel/$server_ip to $exten";}
}
}
else
@@ -790,6 +829,17 @@ if ($ACTION=="RedirectXtra")
{$ACTION="Redirect"; $channel=$extrachannel;}
}
if (ereg("SECOND|FIRST|DEBUG",$filename))
{
if ($WeBRooTWritablE > 0)
{
$fp = fopen ("./vicidial_debug.txt", "a");
fwrite ($fp, "$NOW_TIME|RDX|$filename|$user|$campaign|$DBout|\n");
fclose($fp);
}
}
}
}
}
+45 -5
View File
@@ -1590,6 +1590,11 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
var manual_auto_hotkey = 0;
var dialed_number = '';
var dialed_label = '';
var DispO3waychannel = '';
var DispO3wayXtrAchannel = '';
var DispO3wayCalLserverip = '';
var DispO3wayCalLxfernumber = '';
var DispO3wayCalLcamptail = '';
var DiaLControl_auto_HTML = "<IMG SRC=\"./images/vdc_LB_pause_OFF.gif\" border=0 alt=\"Pause\"><a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADready');\"><IMG SRC=\"./images/vdc_LB_resume.gif\" border=0 alt=\"Resume\"></a>";
var DiaLControl_auto_HTML_ready = "<a href=\"#\" onclick=\"AutoDial_ReSume_PauSe('VDADpause');\"><IMG SRC=\"./images/vdc_LB_pause.gif\" border=0 alt=\"Pause\"></a><IMG SRC=\"./images/vdc_LB_resume_OFF.gif\" border=0 alt=\"Resume\">";
var DiaLControl_auto_HTML_OFF = "<IMG SRC=\"./images/vdc_LB_pause_OFF.gif\" border=0 alt=\"Pause\"><IMG SRC=\"./images/vdc_LB_resume_OFF.gif\" border=0 alt=\"Resume\">";
@@ -1763,9 +1768,9 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
// ################################################################################
// place 3way and customer into other conference and fake-hangup the lines
function leave_3way_call()
function leave_3way_call(tempvarattempt)
{
mainxfer_send_redirect('3WAY');
mainxfer_send_redirect('3WAY','','',tempvarattempt);
document.vicidial_form.callchannel.value = '';
document.vicidial_form.callserverip.value = '';
@@ -2301,7 +2306,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
// ################################################################################
// Send Redirect command for live call to Manager sends phone name where call is going to
// Covers the following types: XFER, VMAIL, ENTRY, CONF, PARK, FROMPARK, XfeRLOCAL, XfeRINTERNAL, XfeRBLIND, VfeRVMAIL
function mainxfer_send_redirect(taskvar,taskxferconf,taskserverip)
function mainxfer_send_redirect(taskvar,taskxferconf,taskserverip,taskdebugnote)
{
var xmlhttp=false;
/*@cc_on @*/
@@ -2416,6 +2421,8 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
}
if (taskvar == '3WAY')
{
xferredirect_query='';
var queryCID = "VXvdcW" + epoch_sec + user_abb;
var redirectdestination = "NEXTAVAILABLE";
var redirectXTRAvalue = XDchannel;
@@ -2426,7 +2433,18 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
{var redirecttype = 'RedirectXtraCX';}
else
{var redirecttype = 'RedirectXtra';}
xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=" + redirecttype + "&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&extrachannel=" + redirectXTRAvalue + "&lead_id=" + document.vicidial_form.lead_id.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + document.vicidial_form.phone_number.value + "&campaign=CL_" + campaign + '' + closerxfercamptail;
DispO3waychannel = redirectvalue;
DispO3wayXtrAchannel = redirectXTRAvalue;
DispO3wayCalLserverip = redirectserverip;
DispO3wayCalLxfernumber = document.vicidial_form.xfernumber.value;
DispO3wayCalLcamptail = document.vicidial_form.xfercode.value;
xferredirect_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&ACTION=" + redirecttype + "&format=text&channel=" + redirectvalue + "&call_server_ip=" + redirectserverip + "&queryCID=" + queryCID + "&exten=" + redirectdestination + "&ext_context=" + ext_context + "&ext_priority=1&extrachannel=" + redirectXTRAvalue + "&lead_id=" + document.vicidial_form.lead_id.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&phone_number=" + document.vicidial_form.phone_number.value+ "&filename=" + taskdebugnote + "&campaign=CL_" + campaign + '' + closerxfercamptail;
if (taskdebugnote == 'FIRST')
{
document.getElementById("DispoSelectHAspan").innerHTML = "<a href=\"#\" onclick=\"DispoLeavE3wayAgaiN()\">Leave 3Way Call Again</a>";
}
}
if (taskvar == 'ParK')
{
@@ -2911,7 +2929,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
document.getElementById("MainStatuSSpan").innerHTML = " Called 3rd party: " + document.vicidial_form.xfernumber.value + " UID: " + CIDcheck;
document.getElementById("Leave3WayCall").innerHTML ="<a href=\"#\" onclick=\"leave_3way_call();return false;\"><IMG SRC=\"./images/vdc_XB_leave3waycall.gif\" border=0 alt=\"LEAVE 3-WAY CALL\"></a>";
document.getElementById("Leave3WayCall").innerHTML ="<a href=\"#\" onclick=\"leave_3way_call('FIRST');return false;\"><IMG SRC=\"./images/vdc_XB_leave3waycall.gif\" border=0 alt=\"LEAVE 3-WAY CALL\"></a>";
document.getElementById("DialWithCustomer").innerHTML ="<IMG SRC=\"./images/vdc_XB_dialwithcustomer_OFF.gif\" border=0 alt=\"Dial With Customer\">";
@@ -3931,6 +3949,28 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";}
}
// ################################################################################
// Send leave 3way call a second time from the dispo screen
function DispoLeavE3wayAgaiN()
{
XDchannel = DispO3wayXtrAchannel;
document.vicidial_form.xfernumber.value = DispO3wayCalLxfernumber;
document.vicidial_form.xfercode.value = DispO3wayCalLcamptail;
MDchannel = DispO3waychannel;
lastcustserverip = DispO3wayCalLserverip;
document.getElementById("DispoSelectHAspan").innerHTML = "";
leave_3way_call('SECOND');
DispO3waychannel = '';
DispO3wayXtrAchannel = '';
DispO3wayCalLserverip = '';
DispO3wayCalLxfernumber = '';
DispO3wayCalLcamptail = '';
}
// ################################################################################
// Start Hangup Functions for both
function bothcall_send_hangup()