2
0
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:
azammitdcarf
2009-02-19 03:21:23 +00:00
parent ebced25727
commit d346b8f04c

View File

@@ -698,8 +698,10 @@ 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);
if ($ca)
{
$sql = "SELECT call_id,state $sql = "SELECT call_id,state
FROM `call` FROM `call`
WHERE case_id = '$case_id' WHERE case_id = '$case_id'
@@ -712,6 +714,7 @@ function is_on_call($operator_id)
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; }
if ($db->CompleteTrans()) if ($db->CompleteTrans())
@@ -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,12 +1207,12 @@ 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))
{
if ($create)
{ {
$sql = "SELECT respondent_id $sql = "SELECT respondent_id
FROM respondent FROM respondent
@@ -1225,6 +1229,7 @@ function get_call_attempt($operator_id)
$db->Execute($sql); $db->Execute($sql);
$id = $db->Insert_Id(); $id = $db->Insert_Id();
} }
}
else else
{ {
$id = $row['call_attempt_id']; $id = $row['call_attempt_id'];
@@ -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