2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Added new feature of automatic dialling using AUTO_DIAL_SECONDS parameter in config file

Will also automatically end the case after the same number of seconds
This commit is contained in:
Adam Zammit
2013-11-20 11:40:46 +11:00
parent d52e76f09b
commit ae36595e72
5 changed files with 203 additions and 17 deletions

View File

@@ -183,10 +183,8 @@ if (isset($_POST['submit']))
$v->connect(VOIP_SERVER);
$v->dial(get_extension($operator_id),get_call_number($call_id));
}
if (is_respondent_selection($operator_id))
$btext = "onload='openParentObject(\"main-content\",\"" . get_respondentselection_url($operator_id) . "\"); parent.closePopup();'";
else
$btext = "onload='parent.closePopup();'";
$btext = "onload='openParentObject(\"main-content\",\"" . get_respondentselection_url($operator_id) . "\"); parent.closePopup();'";
$js = "js/window.js";
if (browser_ie()) $js = "js/window_ie6.js";

View File

@@ -199,6 +199,13 @@ if (!defined('AUTO_COMPLETE_OUTCOME')) define('AUTO_COMPLETE_OUTCOME',false);
*/
if (!defined('AUTO_LOGOUT_MINUTES')) define('AUTO_LOGOUT_MINUTES',false);
/**
* The number of seconds to wait before automatically dialling the first available number or ending the case
* where an operator has an open screen
* False to disable
*/
if (!defined('AUTO_DIAL_SECONDS')) define('AUTO_DIAL_SECONDS',false);
/**
* The default tab to start on on the main screen
*/

View File

@@ -1185,7 +1185,7 @@ function get_call($operator_id,$respondent_id = "",$contact_phone_id = "",$creat
/**
* Get the complete URL for the Limesurvey questionnaire of respondent selection
* If no case available, return an error screen
* If no call available, return an error screen
*
* @param int $operator_id The operator id
* @param bool $escape Whether to escape the ampersands default true
@@ -1210,13 +1210,22 @@ function get_respondentselection_url($operator_id,$escape = true,$interface2 = f
{
$sid = get_limesurvey_id($operator_id,true); //true for RS
if ($sid != false && !empty($sid) && $sid != 'NULL')
$url = LIME_URL . "index.php?interviewer=interviewer&loadall=reload" . $amp . "sid=$sid" . $amp . "token=$call_id" . $amp . "lang=" . DEFAULT_LOCALE;
$url = LIME_URL . "index.php?interviewer=interviewer" . $amp . "loadall=reload" . $amp . "sid=$sid" . $amp . "token=$call_id" . $amp . "lang=" . DEFAULT_LOCALE;
else
{
if ($interface2)
$url = 'rs_intro_interface2.php';
else
$url = 'rs_intro.php';
{
if (is_respondent_selection($operator_id) === false)
{
$url = get_limesurvey_url($operator_id);
if (!$escape)
$url = str_replace("&","&",$url);
}
else
{
if ($interface2)
$url = 'rs_intro_interface2.php';
else
$url = 'rs_intro.php';
}
}
}

View File

@@ -173,11 +173,7 @@ if ($ca)
}
}
if (!is_respondent_selection($operator_id))
$data = get_limesurvey_url($operator_id);
else
$data = get_respondentselection_url($operator_id);
$data = "nocallavailable.php";
$db->CompleteTrans();

View File

@@ -44,16 +44,192 @@ include ("functions/functions.xhtml.php");
*/
include ("lang.inc.php");
$js = false;
if (isset($_GET['contact_phone']))
{
include_once ("functions/functions.operator.php");
include_once ("functions/functions.input.php");
$operator_id = get_operator_id();
$contact_phone_id = bigintval($_GET['contact_phone']);
$call_attempt_id = get_call_attempt($operator_id,false);
$respondent_id = get_respondent_id($call_attempt_id);
$call_id = get_call($operator_id,$respondent_id,$contact_phone_id,true);
if ($call_id)
{
if (is_voip_enabled($operator_id))
{
include("functions/functions.voip.php");
$v = new voip();
$v->connect(VOIP_SERVER);
$v->dial(get_extension($operator_id),get_call_number($call_id));
}
header('Location: '.get_respondentselection_url($operator_id,false));
die();
}
}
$js = array();
if (AUTO_LOGOUT_MINUTES !== false)
$js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js");
$jsw = "js/window.js";
if (browser_ie()) $jsw = "js/window_ie6.js";
$js[] = $jsw;
xhtml_head(T_("No call available"),true,array("css/table.css"),$js);
?>
<h1><?php echo T_("Please click on:") . " " . T_("Call/Hangup") . " " .T_("to display call script"); ?></h1>
<?php
//auto dial, if set should check for numbers to call. If one or more, set a timer for calling the first available number
//if none - timer should end the case
//
//if the user clicks on call / hangup the timer should stop
if (AUTO_DIAL_SECONDS !== false)
{
include_once ("functions/functions.operator.php");
$operator_id = get_operator_id();
$call_attempt_id = get_call_attempt($operator_id,false);
$case_id = get_case_id($operator_id);
$contact_phone_id = false;
//first check we aren't already on a call
if (is_on_call($operator_id) == false)
{
//check if voip is enabled and available
if (is_voip_enabled($operator_id))
{
if (get_extension_status($operator_id))
{
//if we are on an appointment, we will just call the specified number for the appointment
$appointment_id = is_on_appointment($call_attempt_id);
if ($appointment_id)
{
$sql = "SELECT c.contact_phone_id
FROM contact_phone as c, appointment as a
WHERE a.appointment_id = '$appointment_id'
AND a.contact_phone_id = c.contact_phone_id";
$contact_phone_id = $db->GetOne($sql);
}
else
{
//determine whether we should make any more calls based on the last call outcome
$sql = "SELECT o.tryanother, o.require_note
FROM `call` as c, `outcome` as o
WHERE c.call_attempt_id = '$call_attempt_id'
AND c.outcome_id = o.outcome_id
ORDER BY call_id DESC
LIMIT 1";
$rs = $db->GetRow($sql);
if ((empty($rs) || $rs['tryanother'] == 1)) //dial another number only when available and not ending
{
$rn = 0;
if (!empty($rs) && $rs['require_note'] == 1) $rn = 1;
//an exclusion left join
$sql = "SELECT c. *
FROM contact_phone AS c
LEFT JOIN (
SELECT contact_phone.contact_phone_id
FROM contact_phone
LEFT JOIN `call` ON ( call.contact_phone_id = contact_phone.contact_phone_id )
LEFT JOIN outcome ON ( call.outcome_id = outcome.outcome_id )
WHERE contact_phone.case_id = '$case_id'
AND outcome.tryagain =0
) AS l ON l.contact_phone_id = c.contact_phone_id
LEFT JOIN
(
SELECT contact_phone_id
FROM `call`
WHERE call_attempt_id = '$call_attempt_id'
AND outcome_id != 18
) as ca on ca.contact_phone_id = c.contact_phone_id
WHERE c.case_id = '$case_id'
AND l.contact_phone_id IS NULL
AND ca.contact_phone_id IS NULL"; //only select numbers that should be tried again and have not been tried in this attempt which are not the accidental hang up outcome
//could be updated to take in to account the time delay and outcome
$rs = $db->GetAll($sql);
if (!empty($rs))
{
$contact_phone_id = $rs[0]['contact_phone_id'];
}
}
}
$jsfunctocall = "";
$texttodisplay = "";
$endtexttodisplay = "";
if ($contact_phone_id !== false)
{
//got a number to dial so initiate the countdown to begin dialing
$texttodisplay = T_("Will dial in");
$endtexttodisplay = T_("Dialling now");
$jsfunctocall = "document.location.href = 'nocallavailable.php?contact_phone=" . $contact_phone_id . "';";
}
else
{
//no more numbers to dial so initiate the countdown to end the case
$texttodisplay = T_("Will end case in");
$endtexttodisplay = T_("Ending case now");
$jsfunctocall = "openParent('endcase=endcase');";
}
print "<div id='timer'></div>";
print " <script type='text/javascript'>
var count=" . AUTO_DIAL_SECONDS . ";
var counter=setInterval(timer, 1000);
function timer()
{
count=count-1;
if (count <= 0)
{
clearInterval(counter);
document.getElementById('timer').innerHTML='". $endtexttodisplay ."';
" . $jsfunctocall . "
return;
}
document.getElementById('timer').innerHTML='". $texttodisplay ." ' + count + ' " . T_("seconds") . "';
}
window.onload = function()
{
timer();
}
</script>";
}
else
{
//voip extension not active
print "<div>" . T_("Your VoIP extension is not active. Please activate VoIP by clicking once on the red button that says 'VoIP Off'") . "</div>";
}
}
else
{
//voip isn't enabled so can't auto dial
print "<div>" . T_("Auto dialling unavailable as VoIP is not enabled") . "</div>";
}
}
else
{
//on a call so can't proceed
print "<div>" . T_("Auto dialling unavailable as you are already on a call") . "</div>";
}
}
xhtml_foot();