mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Made get_call_attempt be able to not create a call attempt (just return one if necessary)
This commit is contained in:
@@ -698,19 +698,22 @@ function is_on_call($operator_id)
|
|||||||
|
|
||||||
if ($case_id)
|
if ($case_id)
|
||||||
{
|
{
|
||||||
$ca = get_call_attempt($operator_id);
|
$ca = get_call_attempt($operator_id,false);
|
||||||
|
|
||||||
$sql = "SELECT call_id,state
|
if ($ca)
|
||||||
FROM `call`
|
{
|
||||||
WHERE case_id = '$case_id'
|
$sql = "SELECT call_id,state
|
||||||
AND operator_id = '$operator_id'
|
FROM `call`
|
||||||
AND call_attempt_id = '$ca'
|
WHERE case_id = '$case_id'
|
||||||
AND outcome_id = '0'";
|
AND operator_id = '$operator_id'
|
||||||
|
AND call_attempt_id = '$ca'
|
||||||
|
AND outcome_id = '0'";
|
||||||
|
|
||||||
$row = $db->GetRow($sql);
|
$row = $db->GetRow($sql);
|
||||||
|
|
||||||
if (!empty($row))
|
if (!empty($row))
|
||||||
$call_state_id = $row['state'];
|
$call_state_id = $row['state'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if ($db->HasFailedTrans()) { print "FAILED in is_on_call"; exit; }
|
//if ($db->HasFailedTrans()) { print "FAILED in is_on_call"; exit; }
|
||||||
@@ -1132,7 +1135,7 @@ function end_call_attempt($operator_id)
|
|||||||
|
|
||||||
$return = false;
|
$return = false;
|
||||||
|
|
||||||
$ca = get_call_attempt($operator_id);
|
$ca = get_call_attempt($operator_id,false);
|
||||||
|
|
||||||
if ($ca)
|
if ($ca)
|
||||||
{
|
{
|
||||||
@@ -1180,10 +1183,11 @@ function get_respondent_id($call_attempt_id)
|
|||||||
* Return the call attempt of the given operator
|
* Return the call attempt of the given operator
|
||||||
*
|
*
|
||||||
* @param int $operator_id The oeprator
|
* @param int $operator_id The oeprator
|
||||||
|
* @param bool $create If true, will create a call attempt if none exists
|
||||||
* @return bool|int False if no case otherwise the call_attempt_id
|
* @return bool|int False if no case otherwise the call_attempt_id
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function get_call_attempt($operator_id)
|
function get_call_attempt($operator_id,$create = true)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
@@ -1203,27 +1207,28 @@ function get_call_attempt($operator_id)
|
|||||||
|
|
||||||
$row = $db->GetRow($sql);
|
$row = $db->GetRow($sql);
|
||||||
|
|
||||||
$id = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no call_attempt, create one
|
* If no call_attempt, create one
|
||||||
*/
|
*/
|
||||||
if (empty($row))
|
if (empty($row))
|
||||||
{
|
{
|
||||||
$sql = "SELECT respondent_id
|
if ($create)
|
||||||
FROM respondent
|
{
|
||||||
WHERE case_id = '$case_id'";
|
$sql = "SELECT respondent_id
|
||||||
|
FROM respondent
|
||||||
|
WHERE case_id = '$case_id'";
|
||||||
|
|
||||||
$row2 = $db->GetRow($sql);
|
$row2 = $db->GetRow($sql);
|
||||||
|
|
||||||
$respondent_id = 0;
|
$respondent_id = 0;
|
||||||
if (!empty($row2)) $respondent_id = $row2['respondent_id'];
|
if (!empty($row2)) $respondent_id = $row2['respondent_id'];
|
||||||
|
|
||||||
$sql = "INSERT INTO `call_attempt` (call_attempt_id,operator_id,case_id,respondent_id,start,end)
|
$sql = "INSERT INTO `call_attempt` (call_attempt_id,operator_id,case_id,respondent_id,start,end)
|
||||||
VALUES (NULL,'$operator_id','$case_id','$respondent_id',CONVERT_TZ(NOW(),'System','UTC'),NULL)";
|
VALUES (NULL,'$operator_id','$case_id','$respondent_id',CONVERT_TZ(NOW(),'System','UTC'),NULL)";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
$id = $db->Insert_Id();
|
$id = $db->Insert_Id();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1262,7 +1267,7 @@ function end_call($operator_id,$outcome_id,$state = 5)
|
|||||||
|
|
||||||
if ($ca)
|
if ($ca)
|
||||||
{
|
{
|
||||||
$c = get_call_attempt($operator_id);
|
$c = get_call_attempt($operator_id,false);
|
||||||
if ($c)
|
if ($c)
|
||||||
{
|
{
|
||||||
$a = is_on_appointment($c); //if we were on an appointment, complete it with this call
|
$a = is_on_appointment($c); //if we were on an appointment, complete it with this call
|
||||||
|
|||||||
Reference in New Issue
Block a user