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

Merged to queXS 1.15.1

This commit is contained in:
Adam Zammit
2017-04-03 11:38:54 +10:00
parent a6b3e814c8
commit f5a120638b
2 changed files with 91 additions and 8 deletions

View File

@@ -137,11 +137,44 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
foreach($rs as $r)
{
set_time_limit(30);
$count++;
set_time_limit(30);
//only if a valid email
if (validate_email($r['email'])) {
if (add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, $addsample) === false) {
$error = "Could not add case - please ensure there enough additional attributes available in your Limesurvey participant table";
break;
$case_id = add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, $addsample);
if ($case_id === false) {
$error .= "Could not add case - please ensure there enough additional attributes available in your Limesurvey participant table";
$error .= "<br/>Failed to add case for record #$count";
} else {
//add call and call attempt records
$resp_id = 0;
$sql = "SELECT respondent_id
FROM respondent
WHERE case_id = $case_id";
$rsp = $db->GetOne($sql);
if (!empty($rsp)) {
$resp_id = $rsp;
}
$sql = "INSERT INTO call_attempt (case_id,operator_id,respondent_id,start,end)
VALUES ($case_id, 1, $resp_id, NOW(), NOW())";
$db->Execute($sql);
$call_attempt_id = $db->Insert_ID();
$sql = "INSERT INTO `call` (operator_id,respondent_id,case_id,contact_phone_id,call_attempt_id,start,end,outcome_id,state)
VALUES (1,$resp_id,$case_id,0,$call_attempt_id,NOW(),NOW(),41,5)";
$db->Execute($sql);
$call_id = $db->Insert_ID();
$sql = "UPDATE `case`
SET last_call_id = $call_id
WHERE case_id = $case_id";
$db->Execute($sql);
}
}
}