diff --git a/CHANGELOG b/CHANGELOG
index 9e138199..93dc3425 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,5 @@
queXS 1.14.0 - Changes since 1.13.1
-
Changes for session authentication:
queXS now uses the Limesurvey session based authentication system to authenticate all users.
@@ -29,29 +28,47 @@ These queries will:
2. Make all other users regular users, and assign them the password "password"
3. Make all clients regular clients, and assign them the password "password"
-Once you have run these - please go to the operator management page and update passwords for all users.
+Once you have run these - please go to the operator management page and update passwords for all users AND reassign any extensions.
/* Make the first user the admin user - with default password of: password */
INSERT INTO `lime_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang`, `superadmin`)
-SELECT username, '0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438', firstName, 0, 'auto', 1
+SELECT username, 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, firstName, 0, 'auto', 1
FROM operator
WHERE operator_id = 1;
/* Make all other users operators - with default password of: password */
INSERT INTO `lime_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang`, `superadmin`)
-SELECT username, '0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438', firstName, 1, 'auto', 0
+SELECT username, 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, firstName, 1, 'auto', 0
FROM operator
WHERE operator_id != 1;
/* Make all clients - with default password of: password */
INSERT INTO `lime_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang`, `superadmin`)
-SELECT username, '0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438', firstName, 1, 'auto', 0
+SELECT username, 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, firstName, 1, 'auto', 0
FROM client
WHERE 1;
/* Remove redundant table */
DROP TABLE `sessions2`;
+/* Add sort order feature to questionnaire sample table */
+ALTER TABLE `questionnaire_sample` ADD `sort_order` INT( 11 ) NOT NULL DEFAULT '0';
+UPDATE `questionnaire_sample` SET sort_order = sample_import_id;
+
+/* Add default outcomes feature */
+
+/* -- add `default` and `permanent` parameters for outcomes -- */
+ALTER TABLE `outcome` ADD `default` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Used as default for questionnaire outcomes' AFTER `calc`, ADD `permanent` TINYINT(1) UNSIGNED NOT NULL COMMENT 'Permanent outcome, used for all questionnaires, not possible to de-select' AFTER `default`;
+
+/* -- define and set mandatory(constant) outcome_id's --*/
+UPDATE `outcome` SET `permanent` = '1' WHERE `outcome`.`outcome_id` IN (1,2,3,7,9,10,14,17,18,19) ;
+
+/* -- add `outcomes` parameter , define default list of outcome_ID's to be enabled for new questionnaries --*/
+ALTER TABLE `questionnaire` ADD `outcomes` VARCHAR(256) NULL DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'Comma-separated string of outcomes defined for the questionnaire' AFTER `enabled`;
+
+/* -- enable all outcomes for existing questionnaires -- */
+UPDATE `questionnaire` SET `outcomes` = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,40,41,42,43,44,45' ;
+
queXS 1.13.1 - Changes since 1.13.0
diff --git a/DB update CHANGELOG b/DB update CHANGELOG
deleted file mode 100644
index ff054ec6..00000000
--- a/DB update CHANGELOG
+++ /dev/null
@@ -1,19 +0,0 @@
-required DB updates:
-
-/* -- add `default` and `const` parameters for outcomes -- */
-ALTER TABLE `outcome` ADD `deflt` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Used as default for questionnaire outcomes' AFTER `calc`, ADD `const` TINYINT(1) UNSIGNED NOT NULL COMMENT 'Permanent outcome, used for all questionnaires, not possible to de-select' AFTER `deflt`;
-
-/* -- define and set mandatory(constant) outcome_id's --*/
-UPDATE `outcome` SET `const` = '1' WHERE `outcome`.`outcome_id` IN (1,2,3,7,9,10,14,17,18,19) ;
-
-/* -- add `outcomes` parameter , define default list of outcome_ID's to be enabled for new questionnaries --*/
-ALTER TABLE `questionnaire` ADD `outcomes` VARCHAR(256) NULL DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'coma-separated string of outcomes defined for the questionnaire' AFTER `enabled`;
-
-/* -- enable all outcomes for existing questionnaires -- */
-UPDATE `questionnaire` SET `outcomes` = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,40,41,42,43,44,45' ;
-
-
-
-
-
-
diff --git a/admin/addshift.php b/admin/addshift.php
index 271e90fc..52089d59 100644
--- a/admin/addshift.php
+++ b/admin/addshift.php
@@ -42,7 +42,7 @@ include ("../db.inc.php");
/**
* Authentication
*/
-include ("auth-admin.php");
+require ("auth-admin.php");
/**
* XHTML functions
diff --git a/admin/assignsample.php b/admin/assignsample.php
index d4522b5a..36f35929 100644
--- a/admin/assignsample.php
+++ b/admin/assignsample.php
@@ -43,7 +43,7 @@ include ("../db.inc.php");
/**
* Authentication
*/
-include ("auth-admin.php");
+require ("auth-admin.php");
/**
* XHTML functions
@@ -93,8 +93,14 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
$an = 0;
if (isset($_GET['allownew'])) $an = 1;
- $sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new)
- VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an')";
+ $sql = "SELECT MAX(sort_order) + 1
+ FROM questionnaire_sample
+ WHERE questionnaire_id = '$questionnaire_id'";
+
+ $so = $db->GetOne($sql);
+
+ $sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new,sort_order)
+ VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an', '$so')";
$db->Execute($sql);
@@ -176,7 +182,6 @@ if (isset($_POST['edit']))
}
-
if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
{
$questionnaire_id = bigintval($_GET['questionnaire_id']);
@@ -239,7 +244,69 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
GetRow($sql);
+
+ $ssid = $rs['sample_import_id'];
+ $sso = $rs['sort_order'];
+
+ $sql = "UPDATE questionnaire_sample
+ SET sort_order = $sso
+ WHERE sample_import_id = $sid
+ AND questionnaire_id = $questionnaire_id";
+
+ $db->Execute($sql);
+
+ $sql = "UPDATE questionnaire_sample
+ SET sort_order = ($sso + 1)
+ WHERE sample_import_id = $ssid
+ AND questionnaire_id = $questionnaire_id";
+
+ $db->Execute($sql);
+ }
+ else
+ {
+ //find next in sort order and do a swap
+ $sql = "SELECT sample_import_id,sort_order
+ FROM questionnaire_sample
+ WHERE questionnaire_id = $questionnaire_id
+ AND sort_order > (SELECT sort_order FROM questionnaire_sample WHERE questionnaire_id = $questionnaire_id AND sample_import_id = $sid)
+ ORDER BY sort_order ASC LIMIT 1";
+
+ $rs = $db->GetRow($sql);
+
+ $ssid = $rs['sample_import_id'];
+ $sso = $rs['sort_order'];
+
+ $sql = "UPDATE questionnaire_sample
+ SET sort_order = $sso
+ WHERE sample_import_id = $sid
+ AND questionnaire_id = $questionnaire_id";
+
+ $db->Execute($sql);
+
+ $sql = "UPDATE questionnaire_sample
+ SET sort_order = ($sso - 1)
+ WHERE sample_import_id = $ssid
+ AND questionnaire_id = $questionnaire_id";
+
+ $db->Execute($sql);
+
+ unset($_GET['sort']);
+
+ }
+ }
else
{
//need to remove rsid from questionnaire
@@ -266,7 +333,7 @@ if ($questionnaire_id != false)
print "
". T_("Samples selected for this questionnaire") .":
";
- $sql = "SELECT si.description as description,
+ $sql = "SELECT q.sort_order as sort_order, si.description as description,si.sample_import_id,
CASE WHEN q.call_max = 0 THEN '". TQ_("Unlimited") ."' ELSE q.call_max END as call_max,
CASE WHEN q.call_attempt_max = 0 THEN '". TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max,
CASE WHEN q.random_select = 0 THEN '". TQ_("Sequential") ."' ELSE '". TQ_("Random") . "' END as random_select,
@@ -276,12 +343,39 @@ if ($questionnaire_id != false)
CONCAT('') as unassign
FROM questionnaire_sample as q, sample_import as si
WHERE q.sample_import_id = si.sample_import_id
- AND q.questionnaire_id = '$questionnaire_id'";
+ AND q.questionnaire_id = '$questionnaire_id'
+ ORDER BY q.sort_order ASC";
$qs = $db->GetAll($sql);
- if (!empty($qs))
- xhtml_table($qs,array("description","call_max","call_attempt_max","answering_machine_messages","random_select","allow_new","edit","unassign"),array(T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Allow new numbers to be drawn?"), T_("Edit"), T_("Unassign sample")));
+ if (!empty($qs))
+ {
+ $co = count($qs);
+ if ($co > 1)
+ {
+ for($i = 0; $i < $co; $i++)
+ {
+ $down = "";
+ $up = "";
+ if ($i == 0) //down only
+ {
+ $qs[$i]['sort_order'] = "
";
- if($sample_import_id=intval($_GET['sample_import_id'])){
+ if( isset($_GET['sample_import_id'])){
+ $sample_import_id=intval($_GET['sample_import_id']);
$sql = "SELECT si.description as sd
FROM `sample_import` as si
WHERE si.sample_import_id = '$sample_import_id' ;";
@@ -85,7 +86,8 @@ if ($operator_id)
}
else{$sid = " ";};
- if($oper_id= intval($_GET['oper_id'])){
+ if( isset($_GET['oper_id'])){
+ $oper_id= intval($_GET['oper_id']);
$sql = "SELECT CONCAT(op.firstname, op.lastname) as opname
FROM `operator` as op
WHERE op.operator_id = '$oper_id' ;";
diff --git a/admin/casestatus.php b/admin/casestatus.php
index f44e201a..72bbee47 100644
--- a/admin/casestatus.php
+++ b/admin/casestatus.php
@@ -15,7 +15,7 @@ include ("../db.inc.php");
/**
* Authentication file
*/
-include ("auth-admin.php");
+require ("auth-admin.php");
/**
* XHTML functions
@@ -110,19 +110,24 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc
LEFT JOIN outcome as co ON (co.outcome_id = ca.outcome_id)
LEFT JOIN case_queue as cq ON (cq.case_id = c.case_id)
LEFT JOIN operator as oq ON (cq.operator_id = oq.operator_id)
+ LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)
+ LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)
WHERE c.current_operator_id IS NULL $q $o
+ AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 )
+ AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)
ORDER BY c.case_id ASC";
-// print $sql;
-
print ("";
+print "";
?>
";
- if ($_GET['new'] =='new'){
- $start = $startdate;
- $end = $enddate;
- $rtz = $_GET['rtz'];
- }
- if (isset($_GET['appointment_id'])) {
+ print "";
}
@@ -243,45 +290,53 @@ if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(isset($_GET[
else {
$operator_id = get_operator_id();
$subtitle = T_("Appointments");
- xhtml_head(T_("Display Appointments"),true,$css,$js_head,false,30); //array("../css/table.css")
+ xhtml_head(T_("Display Appointments"),true,$css,$js_head,false,30);
print "
" . T_("All appointments (with times displayed in your time zone)") . "
";
- $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end,CONCAT(r.firstName, ' ', r.lastName) as resp, IFNULL(ou.description,'" . TQ_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName,
+ $sql = "SELECT q.description, si.description as smpl, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end,CONCAT(r.firstName, ' ', r.lastName) as resp, IFNULL(ou.description,'" . TQ_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName,
CONCAT('', c.case_id, '') as case_id,
CONCAT(' ') as link,
CONCAT(' ') as edit,IFNULL(ao.firstName,'" . TQ_("Any operator") . "') as witho
FROM appointment as a
- JOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc) on (a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_id)
+ JOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc, `sample` as s, sample_import as si) on (c.sample_id = s.sample_id and a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_id and si.sample_import_id = s.import_id)
LEFT JOIN (`call` as ca, outcome as ou, operator as ooo) ON (ca.call_id = a.completed_call_id and ou.outcome_id = ca.outcome_id and ca.operator_id = ooo.operator_id)
LEFT JOIN operator AS ao ON ao.operator_id = a.require_operator_id
- WHERE a.end >= CONVERT_TZ(NOW(),'System','UTC') AND c.current_outcome_id !=10
+ LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)
+ LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)
+ WHERE q.enabled=1 AND si.enabled=1 AND a.end >= CONVERT_TZ(NOW(),'System','UTC') AND c.current_outcome_id !=10
+ AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1)
+ AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)
ORDER BY a.start ASC";
$rs = $db->GetAll($sql);
if (!empty($rs)) {
translate_array($rs,array("outcome"));
- xhtml_table($rs,array("description","case_id","start","end","edit","makerName","witho","resp","outcome","callerName","link"),array(T_("Questionnaire"),T_("Case ID"),T_("Start"),T_("End")," ",T_("Created by"),T_("Appointment with"),T_("Respondent"),T_("Current outcome"),T_("Operator who called")," "),"tclass",false,false,"bs-table");
+ xhtml_table($rs,array("description","smpl","case_id","start","end","edit","makerName","witho","resp","outcome","callerName","link"),array(T_("Questionnaire"),T_("Sample"),T_("Case ID"),T_("Start"),T_("End")," ",T_("Created by"),T_("Appointment with"),T_("Respondent"),T_("Current outcome"),T_("Operator who called")," "),"tclass",false,false,"bs-table");
} else print "
" . T_("No future appointments") . "
";
print "
" . T_("Missed appointments (with times displayed in your time zone)") . "
";
- $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end, CONCAT(r.firstName, ' ', r.lastName) as resp,
+ $sql = "SELECT q.description, si.description as smpl, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end, CONCAT(r.firstName, ' ', r.lastName) as resp,
CONCAT('', c.case_id, '') as case_id,
CONCAT(' ') as link,
CONCAT(' ') as edit
FROM appointment as a
JOIN (`case` as c, respondent as r, questionnaire as q, `sample` as s, sample_import as si) on (a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and s.sample_id = c.sample_id and s.import_id= si.sample_import_id)
LEFT JOIN (`call` as ca) ON (ca.call_id = a.completed_call_id)
- WHERE q.enabled=1 AND si.enabled = 1 AND a.end < CONVERT_TZ(NOW(),'System','UTC') AND a.completed_call_id IS NULL AND c.current_outcome_id !=10
+ LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id)
+ LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id)
+ WHERE q.enabled=1 AND si.enabled=1 AND a.end < CONVERT_TZ(NOW(),'System','UTC') AND a.completed_call_id IS NULL AND c.current_outcome_id !=10
+ AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 )
+ AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1)
GROUP BY c.case_id
ORDER BY a.start ASC";
$rs = $db->GetAll($sql);
if (!empty($rs)) {
- xhtml_table($rs,array("description","case_id","start","end","edit","resp","link"),array(T_("Questionnaire"),T_("Case ID"),T_("Start"),T_("End")," ",T_("Respondent")," "),"tclass",false,false,"bs-table");
+ xhtml_table($rs,array("description","smpl","case_id","start","end","edit","resp","link"),array(T_("Questionnaire"),T_("Sample"),T_("Case ID"),T_("Start"),T_("End")," ",T_("Respondent")," "),"tclass",false,false,"bs-table");
- } else print "