";
display_outcomes(false,$call_attempt_id,$case_id);
diff --git a/config.default.php b/config.default.php
index d40255f5..23b2ca67 100644
--- a/config.default.php
+++ b/config.default.php
@@ -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
*/
diff --git a/functions/functions.import.php b/functions/functions.import.php
index 84aa3faa..ee53e55e 100644
--- a/functions/functions.import.php
+++ b/functions/functions.import.php
@@ -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
");
// if ($db->HasFailedTrans()) { print "FAILED"; exit(); }
diff --git a/functions/functions.voip.php b/functions/functions.voip.php
index afebb301..738d504b 100644
--- a/functions/functions.voip.php
+++ b/functions/functions.voip.php
@@ -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") . ":
$case_id\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") . ":
$case_id\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") . ":
$case_id\n";
+ $this->setState($call_id,7,true);
+ } else {
+ print T_("Hangup") . T_(" Extension ") . $regs[1] . " " . T_("Case id") . ":
$case_id\n";
+ $this->setState($call_id,4,true);
+ }
}
}
diff --git a/index.php b/index.php
index 4e4a8425..d4793b4b 100644
--- a/index.php
+++ b/index.php
@@ -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 "
FAILED AT ENDCASE
"; exit();}
diff --git a/status.php b/status.php
index e53fa710..8898da24 100644
--- a/status.php
+++ b/status.php
@@ -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&endcase=endcase¬e=AutoCloseNoAnswer'\"";
+
+if ($state == 7 && AUTO_CLOSE_NO_ANSWER)
+ $btext = "onload=\"parent.location.href = 'index.php?outcome=14&endcase=endcase¬e=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 "
" . get_operator_time($operator_id,DATE_TIME_FORMAT) ."
";
@@ -111,6 +117,10 @@ if (!$state || $state == 5)
{
print("
" . T_("No call") . "
");
}
+else if ($state == 6)
+{
+ print("
" . T_("No answer") . "
");
+}
else if ($state == 4)
{
print("
" . T_("To be coded") . "
");