mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Appointment list: error in SQL
No case available, now list quota row's Do not allow the assigning of a case_id or creation of a token in the Limesurvey tables where a transaction has failed
This commit is contained in:
@@ -75,7 +75,7 @@ else
|
||||
$sql = "SELECT q.description, DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'".DATE_TIME_FORMAT."') as start,DATE_FORMAT(CONVERT_TZ(c.end,'UTC',r.Time_zone_name),'".TIME_FORMAT."') as end, c.completed_call_id, IFNULL(ou.firstName,'" . T_("Not yet called") . "') as firstName, r.firstName as rname, r.lastName as rsname, IFNULL(o.description,'" . T_("Not yet called") . "') as des
|
||||
FROM `appointment` as c
|
||||
JOIN respondent as r on (r.respondent_id = c.respondent_id)
|
||||
JOIN `case` as ca on (ca.case_id = c.case_id)
|
||||
JOIN `case` as cas on (cas.case_id = c.case_id)
|
||||
LEFT JOIN (`call` as ca, outcome as o, operator as ou) on (ca.call_id = c.completed_call_id and ca.outcome_id = o.outcome_id and ou.operator_id = ca.operator_id)
|
||||
WHERE oq.operator_id = '$operator_id'
|
||||
AND ca.questionnaire_id = oq.questionnaire_id
|
||||
|
||||
@@ -428,21 +428,23 @@ function get_case_id($operator_id, $create = false)
|
||||
//add resopndent to Lime Survey token table for this questionnaire
|
||||
|
||||
//first we need to get the limesurvey survey id
|
||||
|
||||
$lime_sid = get_limesurvey_id($operator_id);
|
||||
|
||||
if ($lime_sid)
|
||||
|
||||
if (!$db->HasFailedTrans()) //if the transaction hasn't failed
|
||||
{
|
||||
$sql = "INSERT INTO ".LIME_PREFIX."tokens_$lime_sid (tid,firstname,lastname,email,token,language,sent,completed,attribute_1,attribute_2,mpid)
|
||||
VALUES (NULL,'','','',$case_id,'en','N','N','','',NULL)";
|
||||
|
||||
if (!$ldb->Execute($sql)) //if we cannot insert
|
||||
$lime_sid = get_limesurvey_id($operator_id);
|
||||
|
||||
if ($lime_sid)
|
||||
{
|
||||
$db->FailTrans();
|
||||
$case_id = false;
|
||||
$sql = "INSERT INTO ".LIME_PREFIX."tokens_$lime_sid (tid,firstname,lastname,email,token,language,sent,completed,attribute_1,attribute_2,mpid)
|
||||
VALUES (NULL,'','','',$case_id,'en','N','N','','',NULL)";
|
||||
|
||||
if (!$ldb->Execute($sql)) //if we cannot insert
|
||||
{
|
||||
$db->FailTrans();
|
||||
$case_id = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -470,13 +472,13 @@ function get_case_id($operator_id, $create = false)
|
||||
|
||||
}
|
||||
|
||||
//if ($db->HasFailedTrans()) { print "FAILED in get_case_id"; exit; }
|
||||
if ($db->HasFailedTrans())
|
||||
{
|
||||
error_log("FAILED in get_case_id for case $case_id",0);
|
||||
$case_id = false; //make sure we aren't returning an invalid case id
|
||||
}
|
||||
$db->CompleteTrans();
|
||||
|
||||
/**
|
||||
* @todo should re return some sort of status? Like "on appointment" "refusal" "supervisor"?
|
||||
*/
|
||||
|
||||
return $case_id;
|
||||
|
||||
}
|
||||
|
||||
@@ -196,6 +196,27 @@ if (isset($rs) && !empty($rs))
|
||||
}
|
||||
}
|
||||
|
||||
//quota row's full
|
||||
$sql = "SELECT questionnaire_sample_quota_row_id,q.questionnaire_id,sample_import_id,lime_sgqa,value,comparison,completions,quota_reached,q.lime_sid
|
||||
FROM questionnaire_sample_quota_row as qsq, questionnaire as q, operator_questionnaire as oq
|
||||
WHERE oq.operator_id = '$operator_id'
|
||||
AND qsq.questionnaire_id = oq.questionnaire_id
|
||||
AND q.questionnaire_id = oq.questionnaire_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
if (isset($rs) && !empty($rs))
|
||||
{
|
||||
foreach($rs as $r)
|
||||
{
|
||||
if ($r['quota_reached'] == 1)
|
||||
{
|
||||
print "<p class='error'>" . T_("POSSIBLE ERROR: Row quota reached for this question") . " - " . $r['lime_sgqa'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//no tokens table associated with questionnaire in limesurvey
|
||||
|
||||
|
||||
Reference in New Issue
Block a user