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

New feature: Auto close and code a case on no answer / disconnected

This commit is contained in:
Adam Zammit
2019-05-21 16:14:48 +10:00
parent 19344e0d01
commit 24947696de
8 changed files with 93 additions and 15 deletions

View File

@@ -612,7 +612,7 @@ else
ELSE
CONCAT('<a href=\'casestatus.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Case status and assignment"). "\' data-toggle=\'tooltip\'><i class=\'fa fa-question-circle fa-2x\'></i></a>')
END as casestatus
FROM questionnaire";
FROM questionnaire ORDER BY questionnaire_id DESC";
$rs = $db->GetAll($sql);
$columns = array("qid","description","status","enabledisable","outcomes","calls","casestatus","shifts","assample","quotareport","dataout","modify","setoutcomes","inlime","prefill","deletee");

View File

@@ -451,6 +451,7 @@ switch($state)
print "<div><input type='submit' value=\"" . T_("Hangup") . "\" name='submit' id='submit'/></div></form>";
break;
case 4: //requires coding
case 6:
print "<div class='status'>" . T_("Requires coding") . "</div>";
print "<form action='?' method='post'>";
display_outcomes(false,$call_attempt_id,$case_id);

View File

@@ -466,6 +466,7 @@ switch($state)
case 2: //ringing
case 3: //answered
case 4: //requires coding
case 6: //no answer
// print "<div class='status'>" . T_("Requires coding") . "</div>";
print "<form action='?' method='post'><div class=\" \">";
display_outcomes(false,$call_attempt_id,$case_id);

View File

@@ -114,6 +114,11 @@ if (!defined('MEET_ME_ROOM')) define('MEET_ME_ROOM','5000');
*/
if (!defined('AUTO_POPUP')) define('AUTO_POPUP',false);
/**
* Whether to automatically code a no answer
*/
if (!defined('AUTO_CLOSE_NO_ANSWER')) define('AUTO_CLOSE_NO_ANSWER',false);
/**
* The extension of the supervisor for dialing the supervisor
*/

View File

@@ -281,8 +281,9 @@ function import_file($file, $description, $fields, $firstrow = 2)
$db->StartTrans();
$sql = "INSERT INTO sample_import
(sample_import_id, description)
VALUES (NULL, '$description')";
(sample_import_id, description,call_restrict)
VALUES (NULL, '$description',0)";
// print("$sql<br/>");
// if ($db->HasFailedTrans()) { print "FAILED"; exit(); }

View File

@@ -545,7 +545,7 @@ class voipWatch extends voip {
/**
* The call is ringing
*/
if (preg_match("{Event: Dial.*SubEvent: Begin.*Channel: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs))
if (preg_match("{Event: DialBegin.*Channel: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs))
{
list($call_id,$case_id) = $this->getCallId($regs[1]);
if ($call_id != 0)
@@ -569,13 +569,22 @@ class voipWatch extends voip {
/**
* The call has been hung up
*/
else if (preg_match("{Event: Hangup.*Channel: ((SIP/|IAX2/)[0-9]+)}is",$line,$regs))
else if (preg_match("{Event: Hangup.*Channel: ((SIP/|IAX2/)[0-9]+).*Cause: ([0-9]+)}is",$line,$regs))
{
list($call_id,$case_id) = $this->getCallId($regs[1]);
// print_r($regs);
if ($call_id != 0)
{
print T_("Hangup") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ": <a href=\"supervisor.php?case_id=$case_id\">$case_id</a>\n";
$this->setState($call_id,4,true);
if ($regs[3] == 16) { //Cause 16 - was ringing so this is an auto no-answer hangup
print T_("No Answer - Auto Hangup") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ": <a href=\"supervisor.php?case_id=$case_id\">$case_id</a>\n";
$this->setState($call_id,6,true);
} else if ($regs[3] == 19) { //Cause 19 - Disconnected
print T_("Disconnected - Auto Hangup") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ": <a href=\"supervisor.php?case_id=$case_id\">$case_id</a>\n";
$this->setState($call_id,7,true);
} else {
print T_("Hangup") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ": <a href=\"supervisor.php?case_id=$case_id\">$case_id</a>\n";
$this->setState($call_id,4,true);
}
}
}

View File

@@ -108,14 +108,65 @@ if (isset($_GET['endcase']))
VALUES (NULL,'$case_id','$operator_id',$note,CONVERT_TZ(NOW(),'System','UTC'))";
$db->Execute($sql);
}
end_call_attempt($operator_id);
end_case($operator_id);
$endthecase = true;
$db->CompleteTrans(); //need to complete here otherwise getting the case later will fail
if (isset($_GET['outcome']))
{
$outcome_id = intval($_GET['outcome']);
end_call($operator_id,$outcome_id);
//redirect back here
header('Location: index.php');
exit();
$sql = "SELECT tryanother
FROM outcome
WHERE outcome_id = '$outcome_id'";
$rs = $db->GetRow($sql);
if (!empty($rs) && $rs['tryanother'] == 1)
{
//we can try another number...
$case_id = get_case_id($operator_id,false);
$call_attempt_id = get_call_attempt($operator_id,false);
//check if there is another number to try...
$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
$rs = $db->GetAll($sql);
if (!empty($rs))
$endthecase = false;
}
}
if ($endthecase) {
end_call_attempt($operator_id);
end_case($operator_id);
$db->CompleteTrans(); //need to complete here otherwise getting the case later will fail
//redirect back here
header('Location: index.php');
exit();
}
//$db->StartTrans();
//if ($db->HasFailedTrans()) {print "<p>FAILED AT ENDCASE</p>"; exit();}

View File

@@ -71,7 +71,13 @@ $state = is_on_call($operator_id);
$btext = false;
if ($state == 4 && AUTO_POPUP)
$btext = "onload=\"poptastic('call.php')\"";
$btext = "onload=\"parent.poptastic('call.php')\"";
if ($state == 6 && AUTO_CLOSE_NO_ANSWER)
$btext = "onload=\"parent.location.href = 'index.php?outcome=2&amp;endcase=endcase&amp;note=AutoCloseNoAnswer'\"";
if ($state == 7 && AUTO_CLOSE_NO_ANSWER)
$btext = "onload=\"parent.location.href = 'index.php?outcome=14&amp;endcase=endcase&amp;note=AutoCloseDisconnect'\"";
$js = array("js/popupkeep.js");
if (AUTO_LOGOUT_MINUTES !== false)
@@ -80,7 +86,7 @@ if (AUTO_LOGOUT_MINUTES !== false)
$js[] = "js/childnap.js";
}
xhtml_head(T_("Status"),true,array("css/status.css"),$js,$btext,60,false,false,false,false);
xhtml_head(T_("Status"),true,array("css/status.css"),$js,$btext,5,false,false,false,false);
print "<div class='text'>" . get_operator_time($operator_id,DATE_TIME_FORMAT) ."</div>";
@@ -111,6 +117,10 @@ if (!$state || $state == 5)
{
print("<div class='offline statusbutton'>" . T_("No call") . "</div>");
}
else if ($state == 6)
{
print("<div class='online statusbutton'>" . T_("No answer") . "</div>");
}
else if ($state == 4)
{
print("<div class='tobecoded statusbutton'>" . T_("To be coded") . "</div>");