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

New feature: Allow selection of outcome code when generating cases

This commit is contained in:
Adam Zammit
2017-05-26 10:50:58 +10:00
parent 24974850ab
commit c306d2f551

View File

@@ -143,7 +143,7 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
$lime_sid = $db->GetOne("SELECT lime_sid FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
$testing = $db->GetOne("SELECT testing FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
//generate one case for each sample record and set outcome to 41 (where an email address provided)
//generate one case for each sample record and set outcome to goutcome
$sql = "SELECT s.sample_id, sv.val as email
FROM sample as s
LEFT JOIN (sample_var as sv, sample_import_var_restrict as sivr) ON (sv.sample_id = s.sample_id and sv.var_id = sivr.var_id and sivr.type = 8)
@@ -156,6 +156,7 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
$onlyvalidemail = true;
}
$goutcome = bigintval($_GET['goutcome']);
foreach($rs as $r)
{
@@ -163,7 +164,7 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
set_time_limit(30);
//only if a valid email
if (!$onlyvalidemail || validate_email($r['email'])) {
$case_id = add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, $addsample);
$case_id = add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,$goutcome, $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";
@@ -181,13 +182,13 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
}
$sql = "INSERT INTO call_attempt (case_id,operator_id,respondent_id,start,end)
VALUES ($case_id, 1, $resp_id, NOW(), NOW())";
VALUES ($case_id, 1, $resp_id, CONVERT_TZ(NOW(),'System','UTC'), CONVERT_TZ(NOW(),'System','UTC'))";
$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)";
VALUES (1,$resp_id,$case_id,0,$call_attempt_id,CONVERT_TZ(NOW(),'System','UTC'),CONVERT_TZ(NOW(),'System','UTC'),$goutcome,5)";
$db->Execute($sql);
$call_id = $db->Insert_ID();
@@ -515,6 +516,12 @@ if ($questionnaire_id != false)
print "<div>" . T_("Unable to access token/participants table in Limesurvey. Please confirm that this survey has a participant table created.") . "</div>";
} else {
$sql = "SELECT outcome_id,description
FROM outcome
WHERE 1";
$ou = $db->GetAll($sql);
?>
<form action="" method="get" class="form-horizontal">
<label for="sample" class="control-label col-lg-4"><?php echo T_("Select sample:");?></label>
@@ -541,14 +548,23 @@ if ($questionnaire_id != false)
<div class="col-sm-1"><input type="checkbox" id = "allownew" name="allownew" checked="checked" class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<label class="control-label text-info"><?php ;?></label><br/><br/><br/>
<label for="generatecases" class="control-label col-lg-4"><?php echo T_("Generate cases for all sample records with a valid email address and set outcome to 'Self completion email invitation sent'?");?></label>
<label for="generatecases" class="control-label col-lg-4"><?php echo T_("Generate cases for all sample records?");?></label>
<div class="col-sm-1"><input type="checkbox" onchange="if(this.checked==true) {$('#ve').show();} else {$('#ve').hide();}" id = "generatecases" name="generatecases" class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<em class="control-label"> * <?php echo T_("Ideal if you intend to send an email invitation to sample members before attempting to call using queXS"); ?></em>
<div class='clearfix '></div></br>
<div id='ve' style='display:none'><label for="validemail" class="control-label col-lg-4"><?php echo T_("Only generate cases where there is a valid email attached?");?></label>
<div id='ve' style='display:none'>
<label for="goutcome" class="control-label col-lg-4"><?php echo T_("Select an outcome to assign generated cases to");?></label>
<div class="col-lg-4"><select name="goutcome" id="goutcome" class="form-control " >
<?php foreach($ou as $q) { $sel =""; if ($q['outcome_id'] == 41) { $sel="selected='selected'";} print "<option $sel value=\"{$q['outcome_id']}\">{$q['description']}</option>"; } ?> </select></div>
<div class='clearfix '></div></br>
<label for="validemail" class="control-label col-lg-4"><?php echo T_("Only generate cases where there is a valid email attached?");?></label>
<div class="col-sm-1"><input type="checkbox" checked="checked" id = "validemail" name="validemail" class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<div class='clearfix '></div></br></div>
<div class='clearfix '></div></br>
</div>
<?php