Added SCRIPT_multirecording.php script that allows triggering of starting and stopping of recordings on demand within a script in a IFRAME
git-svn-id: svn://192.168.202.10@1791 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -822,6 +822,9 @@ OTHER CHANGES:
|
||||
|
||||
187. Added HTML bar chart display options to most of the reports.
|
||||
|
||||
188. Added SCRIPT_multirecording.php script that allows triggering of starting
|
||||
and stopping of recordings on demand within a script in a IFRAME
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<?
|
||||
# SCRIPT_multirecording.php - script page that stops/starts recordings being made over a forced-recording (ALLFORCE) call
|
||||
#
|
||||
# Copyright (C) 2012 Joe Johnson <joej@vicidial.com> LICENSE: AGPLv2
|
||||
# - works in conjunction with SCRIPT_multirecording_AJAX.php to allow reps the ability to make their own recordings over the course of a call while the entire call is being recorded into its own file, as in ALLFORCE recording.
|
||||
#
|
||||
# Implementation is done by creating a script in the Scripts section that calls this page within an <iframe> tag which passes several essential dialer variables to the page
|
||||
#
|
||||
# SAMPLE SCRIPT TEXT:
|
||||
# <iframe src="http://<your-domain.com>/agc/SCRIPT_multirecording.php?campaign=--A--campaign--B--&lead_id=--A--lead_id--B--&phone_number=--A--phone_number--B--&session_id=--A--session_id--B--&server_ip=--A--server_ip--B--&user=--A--user--B--&vendor_lead_code=--A--vendor_lead_code--B--&uniqueid=--A--uniqueid--B--" style="width:570;height:275;background-color:transparent;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="570" height="270"></iframe>
|
||||
#
|
||||
# All style parameters may be adjusted to suit your needs, but all variables listed in the above example MUST be passed to the VICI_multirecording.php page if this is implemented.
|
||||
# Variables are: campaign, lead_id, phone_number, session_id, server_ip, user, vendor_lead_code, uniqueid
|
||||
#
|
||||
# CHANGELOG
|
||||
# 120227-1512 - First Build
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
|
||||
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
|
||||
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
|
||||
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
|
||||
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
|
||||
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
|
||||
if (isset($_GET["user"])) {$user=$_GET["user"];}
|
||||
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
|
||||
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
|
||||
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
|
||||
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
|
||||
if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];}
|
||||
elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];}
|
||||
?>
|
||||
<html>
|
||||
<style type="text/css">
|
||||
input.red_btn{
|
||||
color:#FFFFFF;
|
||||
font-size:84%;
|
||||
font-weight:bold;
|
||||
background-color:#990000;
|
||||
border:2px solid;
|
||||
border-top-color:#FFCCCC;
|
||||
border-left-color:#FFCCCC;
|
||||
border-right-color:#660000;
|
||||
border-bottom-color:#660000;
|
||||
}
|
||||
|
||||
input.green_btn{
|
||||
color:#FFFFFF;
|
||||
font-size:84%;
|
||||
font-weight:bold;
|
||||
background-color:#009900;
|
||||
border:2px solid;
|
||||
border-top-color:#CCFFCC;
|
||||
border-left-color:#CCFFCC;
|
||||
border-right-color:#006600;
|
||||
border-bottom-color:#006600;
|
||||
}
|
||||
</style>
|
||||
<script language="Javascript">
|
||||
function RecordingAction(campaign, lead_id, phone_number, user, session_id, server_ip, vendor_lead_code, uniqueid, rec_action, recording_channel) {
|
||||
document.getElementById("recording_button_span").innerHTML = "<b><font color='red'><blink>Please wait...</blink></font></b>";
|
||||
var xmlhttp=false;
|
||||
/*@cc_on @*/
|
||||
/*@if (@_jscript_version >= 5)
|
||||
// JScript gives us Conditional compilation, we can cope with old IE versions.
|
||||
// and security blocked creation of the objects.
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (E) {
|
||||
xmlhttp = false;
|
||||
}
|
||||
}
|
||||
@end @*/
|
||||
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
|
||||
{
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}
|
||||
if (xmlhttp)
|
||||
{
|
||||
if (rec_action=="START")
|
||||
{
|
||||
recording_query = "&campaign=" + campaign + "&lead_id=" + lead_id + "&phone_number=" + phone_number + "&user=" + user + "&session_id=" + session_id + "&server_ip=" + server_ip + "&vendor_lead_code=" + vendor_lead_code + "&uniqueid=" + uniqueid + "&rec_action=" + rec_action;
|
||||
}
|
||||
else
|
||||
{
|
||||
recording_query = "&campaign=" + campaign + "&lead_id=" + lead_id + "&phone_number=" + phone_number + "&user=" + user + "&session_id=" + session_id + "&server_ip=" + server_ip + "&vendor_lead_code=" + vendor_lead_code + "&uniqueid=" + uniqueid + "&rec_action=" + rec_action + "&recording_channel=" + recording_channel;
|
||||
}
|
||||
xmlhttp.open('POST', 'SCRIPT_multirecording_AJAX.php');
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
|
||||
xmlhttp.send(recording_query);
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
|
||||
{
|
||||
recording_response = null;
|
||||
recording_response = xmlhttp.responseText;
|
||||
// alert(recording_query);
|
||||
// alert(xmlhttp.responseText);
|
||||
if (recording_response.length>0 && rec_action=="START")
|
||||
{
|
||||
var recording_response_array=recording_response.split("|");
|
||||
var recording_id=recording_response_array[0];
|
||||
var recording_channel=recording_response_array[1];
|
||||
document.getElementById("recording_button_span").innerHTML = "<input type=\"button\" class=\"red_btn\" value=\"STOP RECORDING\" onclick=\"RecordingAction(<?php echo "'$campaign', '$lead_id', '$phone_number', '$user', '$session_id', '$server_ip', '$vendor_lead_code', '$uniqueid'"; ?>, '"+recording_id+"', '"+recording_channel+"')\" />";
|
||||
}
|
||||
else if (recording_response=="HANGUP SUCCESSFUL")
|
||||
{
|
||||
document.getElementById("recording_button_span").innerHTML = "<input type=\"button\" class=\"green_btn\" onClick=\"RecordingAction(<?php echo "'$campaign', '$lead_id', '$phone_number', '$user', '$session_id', '$server_ip', '$vendor_lead_code', '$uniqueid'"; ?>, 'START')\" value=\"START RECORDING\">";
|
||||
}
|
||||
}
|
||||
}
|
||||
delete xmlhttp;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<form action="<?php echo $PHP_SELF; ?>" method="post" target="_self">
|
||||
<center>
|
||||
<!-- You may put script text here //-->
|
||||
<span id="recording_button_span">
|
||||
<input type="button" class="green_btn" onClick="RecordingAction(<?php echo "'$campaign', '$lead_id', '$phone_number', '$user', '$session_id', '$server_ip', '$vendor_lead_code', '$uniqueid'"; ?>, 'START')" value="START RECORDING">
|
||||
</span>
|
||||
<!-- You may also put script text here //-->
|
||||
</center>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
</iframe>
|
||||
@@ -0,0 +1,178 @@
|
||||
<?
|
||||
# SCRIPT_multirecording_AJAX.php - script that stops/starts recordings being made over a forced-recording (ALLFORCE) call
|
||||
#
|
||||
# Copyright (C) 2012 Joe Johnson <joej@vicidial.com> LICENSE: AGPLv2
|
||||
#
|
||||
# Other scripts that this application depends on:
|
||||
# - SCRIPT_multirecording.php: Gives agents ability to stop and start recordings over a forced-recording (ALLFORCE) call
|
||||
#
|
||||
# CHANGELOG
|
||||
# 120224-2240 - First Build
|
||||
#
|
||||
|
||||
require("dbconnect.php");
|
||||
if (isset($_GET["campaign"])) {$campaign=$_GET["campaign"];}
|
||||
elseif (isset($_POST["campaign"])) {$campaign=$_POST["campaign"];}
|
||||
if (isset($_GET["lead_id"])) {$lead_id=$_GET["lead_id"];}
|
||||
elseif (isset($_POST["lead_id"])) {$lead_id=$_POST["lead_id"];}
|
||||
if (isset($_GET["phone_number"])) {$phone_number=$_GET["phone_number"];}
|
||||
elseif (isset($_POST["phone_number"])) {$phone_number=$_POST["phone_number"];}
|
||||
if (isset($_GET["user"])) {$user=$_GET["user"];}
|
||||
elseif (isset($_POST["user"])) {$user=$_POST["user"];}
|
||||
if (isset($_GET["session_id"])) {$session_id=$_GET["session_id"];}
|
||||
elseif (isset($_POST["session_id"])) {$session_id=$_POST["session_id"];}
|
||||
if (isset($_GET["server_ip"])) {$server_ip=$_GET["server_ip"];}
|
||||
elseif (isset($_POST["server_ip"])) {$server_ip=$_POST["server_ip"];}
|
||||
if (isset($_GET["uniqueid"])) {$uniqueid=$_GET["uniqueid"];}
|
||||
elseif (isset($_POST["uniqueid"])) {$uniqueid=$_POST["uniqueid"];}
|
||||
if (isset($_GET["vendor_lead_code"])) {$vendor_lead_code=$_GET["vendor_lead_code"];}
|
||||
elseif (isset($_POST["vendor_lead_code"])) {$vendor_lead_code=$_POST["vendor_lead_code"];}
|
||||
if (isset($_GET["rec_action"])) {$rec_action=$_GET["rec_action"];}
|
||||
elseif (isset($_POST["rec_action"])) {$rec_action=$_POST["rec_action"];}
|
||||
if (isset($_GET["recording_channel"])) {$recording_channel=$_GET["recording_channel"];}
|
||||
elseif (isset($_POST["recording_channel"])) {$recording_channel=$_POST["recording_channel"];}
|
||||
|
||||
$StarTtime = date("U");
|
||||
$NOW_DATE = date("Y-m-d");
|
||||
$NOW_TIME = date("Y-m-d H:i:s");
|
||||
$NOWnum = date("YmdHis");
|
||||
$exten="8309";
|
||||
$ext_context="default";
|
||||
#if (eregi("^10.10.", $server_ip)) {$ext_context="demo";} else {$ext_content="default";}
|
||||
|
||||
$stmt="select campaign_rec_filename from vicidial_campaigns where campaign_id='$campaign'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$row=mysql_fetch_array($rslt);
|
||||
$filename=$row["campaign_rec_filename"];
|
||||
$filename=eregi_replace("CAMPAIGN", $campaign, $filename);
|
||||
$filename=eregi_replace("CUSTPHONE", $phone_number, $filename);
|
||||
$filename=eregi_replace("FULLDATE", date("Ymd-His"), $filename);
|
||||
$filename=eregi_replace("TINYDATE", (date("Y")-2000).date("mdHis"), $filename);
|
||||
$filename=eregi_replace("AGENT", $user, $filename);
|
||||
$filename=eregi_replace("EPOCH", $StarTtime, $filename);
|
||||
$filename=eregi_replace("VENDORLEADCODE", $vendor_lead_code, $filename);
|
||||
$filename=eregi_replace("LEADID", $lead_id, $filename);
|
||||
|
||||
$channel="Local/5".$session_id."@".$ext_context;
|
||||
$ext_priority=1;
|
||||
$one_mysql_log=0;
|
||||
$row=''; $rowx='';
|
||||
$channel_live=1;
|
||||
|
||||
if ($rec_action=="START")
|
||||
{
|
||||
|
||||
if ( (strlen($exten)<3) or (strlen($channel)<4) or (strlen($filename)<15)) {
|
||||
$channel_live=0;
|
||||
echo "ERROR 1";
|
||||
} else {
|
||||
######################## START RECORDING ##########################
|
||||
|
||||
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\";";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$channel_SQL=" and channel not in (";
|
||||
while($row=mysql_fetch_array($rslt))
|
||||
{
|
||||
$channel_SQL.="'$row[channel]',";
|
||||
}
|
||||
$channel_SQL=substr($channel_SQL,0,-1);
|
||||
$channel_SQL.=")";
|
||||
|
||||
|
||||
|
||||
$VDvicidial_id='';
|
||||
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$filename','Channel: $channel','Context: $ext_context','Exten: $exten','Priority: $ext_priority','Callerid: $filename','','','','','');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
|
||||
$stmt = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,filename,lead_id,user) values('$channel','$server_ip','$exten','$NOW_TIME','$StarTtime','$filename','$lead_id','$user')";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$RLaffected_rows = mysql_affected_rows($link);
|
||||
if ($RLaffected_rows > 0) {
|
||||
usleep(2000000);
|
||||
$recording_id = mysql_insert_id($link);
|
||||
$current_rec_filename=$filename;
|
||||
$channel_stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$channel%\" and channel LIKE \"%,1\" $channel_SQL;";
|
||||
$channel_rslt=mysql_query($channel_stmt, $link);
|
||||
if (mysql_num_rows($channel_rslt)==1)
|
||||
{
|
||||
$channel_row=mysql_fetch_row($channel_rslt);
|
||||
echo "$recording_id|$channel_row[0]";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Error 2\n$channel_stmt\n".mysql_num_rows($channel_rslt);
|
||||
}
|
||||
} else {
|
||||
echo "Error 3";
|
||||
}
|
||||
|
||||
##### get call type from vicidial_live_agents table
|
||||
$VLA_inOUT='NONE';
|
||||
$stmt="SELECT comments FROM vicidial_live_agents where user='$user' order by last_update_time desc limit 1;";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$VLA_inOUT_ct = mysql_num_rows($rslt);
|
||||
if ($VLA_inOUT_ct > 0) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$VLA_inOUT = $row[0];
|
||||
}
|
||||
if ($VLA_inOUT == 'INBOUND') {
|
||||
$four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y")));
|
||||
|
||||
##### look for the vicidial ID in the vicidial_closer_log table
|
||||
$stmt="SELECT closecallid FROM vicidial_closer_log where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;";
|
||||
} else {
|
||||
##### look for the vicidial ID in the vicidial_log table
|
||||
$stmt="SELECT uniqueid FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id';";
|
||||
}
|
||||
/*
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$VM_mancall_ct = mysql_num_rows($rslt);
|
||||
if ($VM_mancall_ct > 0) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$VDvicidial_id = $row[0];
|
||||
$stmt = "UPDATE recording_log SET vicidial_id='$VDvicidial_id' where recording_id='$recording_id';";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
############### STOP RECORDING ########
|
||||
$stmt="SELECT recording_id,start_epoch FROM recording_log where recording_id='$rec_action' and end_epoch is null";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$rec_count = mysql_num_rows($rslt);
|
||||
if ($rec_count>0) {
|
||||
$row=mysql_fetch_row($rslt);
|
||||
$recording_id = $row[0];
|
||||
$start_time = $row[1];
|
||||
$length_in_sec = ($StarTtime - $start_time);
|
||||
$length_in_min = ($length_in_sec / 60);
|
||||
$length_in_min = sprintf("%8.2f", $length_in_min);
|
||||
|
||||
$stmt = "UPDATE recording_log set end_time='$NOW_TIME',end_epoch='$StarTtime',length_in_sec=$length_in_sec,length_in_min='$length_in_min' where recording_id='$rec_action'";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
}
|
||||
|
||||
# find and hang up the recording
|
||||
$stmt="SELECT channel FROM live_sip_channels where server_ip = '$server_ip' and channel LIKE \"$recording_channel%\" and channel LIKE \"%,1\";";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$rec_count = mysql_num_rows($rslt);
|
||||
$h=0;
|
||||
while ($rec_count>$h) {
|
||||
$rowx=mysql_fetch_row($rslt);
|
||||
$HUchannel[$h] = $rowx[0];
|
||||
$h++;
|
||||
}
|
||||
$i=0;
|
||||
while ($h>$i) {
|
||||
$stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Hangup','RH12345$StarTtime$i','Channel: $HUchannel[$i]','','','','','','','','','');";
|
||||
$rslt=mysql_query($stmt, $link);
|
||||
$i++;
|
||||
echo "HANGUP SUCCESSFUL";
|
||||
}
|
||||
|
||||
}
|
||||
######################################
|
||||
?>
|
||||
Reference in New Issue
Block a user