mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Allow for tokens to be imported
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
INSERT INTO `sample_var_type` (`type`, `description`, `table`) VALUES(9, 'Token', '');
|
||||
|
||||
|
||||
queXS 1.14.4 - Changes since 1.14.3
|
||||
|
||||
Fourth bug fix release.
|
||||
|
||||
@@ -79,6 +79,8 @@ $js_foot = array(
|
||||
);
|
||||
global $db;
|
||||
|
||||
$error = "";
|
||||
|
||||
if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max']))
|
||||
{
|
||||
//need to add sample to questionnaire
|
||||
@@ -144,10 +146,14 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$count = 0;
|
||||
foreach($rs as $r)
|
||||
{
|
||||
{
|
||||
$count++;
|
||||
set_time_limit(30);
|
||||
add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, true);
|
||||
if (add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, true) === false) {
|
||||
$error .= "<br/>Failed to add case for record #$count";
|
||||
}
|
||||
}
|
||||
|
||||
$db->CompleteTrans();
|
||||
@@ -306,6 +312,9 @@ xhtml_head(T_("Assign samples to questionnaires"),true,$css,$js_head,false,false
|
||||
|
||||
print "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>";
|
||||
|
||||
if (!empty($error)) {
|
||||
print "<div class='alert text-danger'>$error</div>";
|
||||
}
|
||||
|
||||
$questionnaire_id = false;
|
||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
|
||||
@@ -1523,6 +1523,7 @@ INSERT INTO `sample_var_type` (`type`, `description`, `table`) VALUES(5, 'Postco
|
||||
INSERT INTO `sample_var_type` (`type`, `description`, `table`) VALUES(6, 'Respondent first name', '');
|
||||
INSERT INTO `sample_var_type` (`type`, `description`, `table`) VALUES(7, 'Respondent last name', '');
|
||||
INSERT INTO `sample_var_type` (`type`, `description`, `table`) VALUES(8, 'Email address', '');
|
||||
INSERT INTO `sample_var_type` (`type`, `description`, `table`) VALUES(9, 'Token', '');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
||||
@@ -95,6 +95,18 @@ function verify_fields($fields)
|
||||
}
|
||||
}
|
||||
|
||||
//check that only 0 or 1 token fields selected
|
||||
$count = 0;
|
||||
foreach($names as $val)
|
||||
{
|
||||
if ($val == 9) $count++;
|
||||
}
|
||||
|
||||
if ($count > 1)
|
||||
{
|
||||
return T_("No more than one field may be a token field");
|
||||
}
|
||||
|
||||
//check that there is one and one only primary phone selected
|
||||
$count = 0;
|
||||
foreach($names as $val)
|
||||
|
||||
@@ -354,10 +354,23 @@ function add_case($sample_id,$questionnaire_id,$operator_id = "NULL",$testing =
|
||||
{
|
||||
global $db;
|
||||
|
||||
//if token is specified, get from sample
|
||||
$sql = "SELECT sv.val
|
||||
FROM sample_var as sv, sample_import_var_restrict as sivr
|
||||
WHERE sv.sample_id = '$sample_id'
|
||||
AND sv.var_id = sivr.var_id
|
||||
AND sivr.type = 9"; //9 is the token value
|
||||
|
||||
$dtoken = $db->GetOne($sql);
|
||||
|
||||
$ttries = 0;
|
||||
|
||||
do {
|
||||
$token = sRandomChars();
|
||||
if (empty($dtoken)) {
|
||||
$token = sRandomChars();
|
||||
} else {
|
||||
$token = $dtoken;
|
||||
}
|
||||
|
||||
$sql = "SELECT count(*) as c
|
||||
FROM `case`
|
||||
@@ -365,7 +378,9 @@ function add_case($sample_id,$questionnaire_id,$operator_id = "NULL",$testing =
|
||||
|
||||
$ttries++;
|
||||
} while ($db->GetOne($sql) > 0 && $ttries < 10);
|
||||
|
||||
|
||||
if ($ttries >= 10) //failed to get a token
|
||||
return false;
|
||||
|
||||
$sql = "INSERT INTO `case` (case_id, sample_id, questionnaire_id, last_call_id, current_operator_id, current_call_id, current_outcome_id,token)
|
||||
VALUES (NULL, $sample_id, $questionnaire_id, NULL, $operator_id, NULL, '$current_outcome_id','$token')";
|
||||
|
||||
Reference in New Issue
Block a user