diff --git a/admin/assignsample.php b/admin/assignsample.php
index 63cf4b56..bd5b6b5f 100644
--- a/admin/assignsample.php
+++ b/admin/assignsample.php
@@ -1,267 +1,282 @@
-
- * @copyright Deakin University 2007,2008
- * @package queXS
- * @subpackage admin
- * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
- * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
- *
- *
- */
-
-/**
- * Configuration file
- */
-include("../config.inc.php");
-
-/**
- * Database file
- */
-include ("../db.inc.php");
-
-/**
- * XHTML functions
- */
-include("../functions/functions.xhtml.php");
-
-/**
- * Display functions
- */
-include("../functions/functions.display.php");
-
-/**
- * Input functions
- */
-include("../functions/functions.input.php");
-
-$css = array(
-"../include/bootstrap-3.3.2/css/bootstrap.min.css",
-"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
-"../include/font-awesome-4.3.0/css/font-awesome.css",
-"../css/bootstrap-switch.min.css",
-"../css/custom.css"
- );
-$js_head = array(
-"../js/jquery-2.1.3.min.js",
-"../include/bootstrap-3.3.2/js/bootstrap.min.js",
-"../js/bootstrap-switch.min.js",
-"../js/window.js"
- );
-$js_foot = array(
-"../js/bootstrap-confirmation.js",
-"../js/custom.js"
- );
-global $db;
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max']))
-{
- //need to add sample to questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $sid = bigintval($_GET['sample']);
- $cm = bigintval($_GET['call_max']);
- $cam = bigintval($_GET['call_attempt_max']);
- $am = bigintval($_GET['answering_machine_messages']);
- $selecttype = 0;
- if (isset($_GET['selecttype'])) $selecttype = 1;
- $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')";
-
- $db->Execute($sql);
-}
-
-if (isset($_POST['edit']))
-{
- //need to add sample to questionnaire
- $questionnaire_id = bigintval($_POST['questionnaire_id']);
- $sid = bigintval($_POST['sample_import_id']);
- $cm = bigintval($_POST['call_max']);
- $cam = bigintval($_POST['call_attempt_max']);
- $am = bigintval($_POST['answering_machine_messages']);
- $selecttype = 0;
- if (isset($_POST['selecttype'])) $selecttype = 1;
- $an = 0;
- if (isset($_POST['allownew'])) $an = 1;
-
- $sql = "UPDATE questionnaire_sample
- SET call_max = '$cm',
- call_attempt_max = '$cam',
- random_select = '$selecttype',
- answering_machine_messages = '$am',
- allow_new = '$an'
- WHERE questionnaire_id = '$questionnaire_id'
- AND sample_import_id = '$sid'";
-
- $db->Execute($sql);
-}
-
-
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
-{
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $sid = bigintval($_GET['rsid']);
-
- if (isset($_GET['edit']))
- {
- $subtitle = T_("Edit assignment parameters");
- xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js")
-
- $sql = "SELECT si.description as description,
- qr.description as qdescription,
- q.call_max,
- q.call_attempt_max,
- q.random_select,
- q.answering_machine_messages,
- q.allow_new
- FROM questionnaire_sample as q, sample_import as si, questionnaire as qr
- WHERE q.sample_import_id = si.sample_import_id
- AND q.questionnaire_id = '$questionnaire_id'
- AND si.sample_import_id = '$sid'
- AND qr.questionnaire_id = q.questionnaire_id";
-
- $qs = $db->GetRow($sql);
-
- //print "
" . T_("Edit sample details") . "";
- print "
" . T_("Go back") . "
- " . T_("Questionnaire") . ": " . $qs['qdescription'] . "
- " . T_("Sample") . ": " . $qs['description'] . "
- ";
-
- $allownew = $selected ="";
- if ($qs['random_select'] == 1)
- $selected = "checked=\"checked\"";
- if ($qs['allow_new'] == 1)
- $allownew = "checked=\"checked\"";
- ?>
-
-
-
-
- Execute($sql);
- }
-}
-
-$questionnaire_id = false;
-if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
-$subtitle = T_("List & Add Sample");
-xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js")
-
-print " " . T_("Go back") . "";
-print "" . T_("Select a questionnaire") . ":
";
-display_questionnaire_chooser($questionnaire_id,false, "pull-left", "form-control");
-
-if ($questionnaire_id != false)
-{
-
- print "
-
". T_("Samples selected for this questionnaire") .":
";
-
- $sql = "SELECT si.description as description,
- 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,
- CASE WHEN q.answering_machine_messages = 0 THEN '". TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages,
- CASE WHEN q.allow_new = 0 THEN '". TQ_("No") ."' ELSE '".TQ_("Yes")."' END as allow_new,
- CONCAT('
') as edit,
- 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'";
-
- $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")));
- else
- print "
". T_("No samples selected for this questionnaire") ."
";
-
- $sql = "SELECT si.sample_import_id,si.description
- FROM sample_import as si
- LEFT JOIN questionnaire_sample as q ON (q.questionnaire_id = '$questionnaire_id' AND q.sample_import_id = si.sample_import_id)
- WHERE q.questionnaire_id is NULL
- AND si.enabled = 1";
-
- $qs = $db->GetAll($sql);
- print"
";
-
- if (!empty($qs))
- {
- print "";
- print "" . T_("Add a sample to this questionnaire:") . "
";
- ?>
-
-
-
\ No newline at end of file
diff --git a/admin/casesbyoutcome.php b/admin/casesbyoutcome.php
index 09d65fd6..2bf0d14f 100644
--- a/admin/casesbyoutcome.php
+++ b/admin/casesbyoutcome.php
@@ -1,99 +1,121 @@
-
- * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2012
- * @package queXS
- * @subpackage user
- * @link http://www.acspri.org.au/software queXS was writen for ACSPRI
- * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
- *
- */
-
-/**
- * Configuration file
- */
-include ("../config.inc.php");
-
-/**
- * Database file
- */
-include ("../db.inc.php");
-
-/**
- * XHTML functions
- */
-include ("../functions/functions.xhtml.php");
-
-/**
- * Operator functions
- */
-include("../functions/functions.operator.php");
-
-xhtml_head(T_("Cases by outcome"),true,array("../css/table.css"));
-
-//List the cases by outcome
-$operator_id = get_operator_id();
-
-if ($operator_id)
-{
- //get the outcome and the questionnaire
- $outcome_id = intval($_GET['outcome_id']);
- $questionnaire_id = intval($_GET['questionnaire_id']);
-
- $sql = "SELECT o.description, q.description as qd
- FROM `outcome` as o, questionnaire as q
- WHERE o.outcome_id = '$outcome_id'
- AND q.questionnaire_id = '$questionnaire_id'";
-
- $rs = $db->GetRow($sql);
-
- if (!empty($rs))
- {
- print "" . T_("Project") . ": {$rs['qd']}
";
- print "". T_("Current outcome:") ." " . T_($rs['description']) . "
";
-
- $sql = "SELECT CONCAT('', c.case_id, '') as case_id
- FROM `case` as c
- WHERE c.questionnaire_id = '$questionnaire_id'
- AND c.current_outcome_id = '$outcome_id'
- LIMIT 500";
-
- $rs = $db->GetAll($sql);
-
- if (empty($rs))
- print "" . T_("No cases with this outcome") . "
";
- else
- {
- xhtml_table($rs,array("case_id"),array(T_("Case ID")));
- }
- }
- else
- print "" . T_("Error with input") . "
";
-}
-else
- print "" . T_("No operator") . "
";
-
-xhtml_foot();
-
-
-?>
+
+ * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2012
+ * @package queXS
+ * @subpackage user
+ * @link http://www.acspri.org.au/software queXS was writen for ACSPRI
+ * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
+ *
+ */
+
+/**
+ * Configuration file
+ */
+include ("../config.inc.php");
+
+/**
+ * Database file
+ */
+include ("../db.inc.php");
+
+/**
+ * XHTML functions
+ */
+include ("../functions/functions.xhtml.php");
+
+/**
+ * Operator functions
+ */
+include("../functions/functions.operator.php");
+
+xhtml_head(T_("Cases by outcome"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"));
+
+print "";
+
+//List the cases by outcome
+$operator_id = get_operator_id();
+
+if ($operator_id)
+{
+ //get the outcome and the questionnaire
+ $outcome_id = intval($_GET['outcome_id']);
+ $questionnaire_id = intval($_GET['questionnaire_id']);
+ $sql = "SELECT o.description, q.description as qd
+ FROM `outcome` as o, questionnaire as q
+ WHERE o.outcome_id = '$outcome_id'
+ AND q.questionnaire_id = '$questionnaire_id'";
+
+ $rs = $db->GetRow($sql);
+
+ if (!empty($rs)){
+ print "" . T_("Project") . ": {$rs['qd']}
";
+ if($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' ;";
+ $sd = $db->GetRow($sql);
+ print "". T_("Sample:") ." " . T_($sd['sd']) . "
";
+ $sid = "AND s.import_id= '$sample_import_id'";
+ }
+ else{$sid = " ";};
+
+ if($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' ;";
+ $on = $db->GetRow($sql);
+ print "". T_("Operator") ." : " . T_($on['opname']) . "
oper_id = $oper_id ";
+ $opn = "AND c.current_operator_id= '$oper_id'";
+ }
+ else{$opn = " ";};
+
+ print "". T_("Current outcome:") ." " . T_($rs['description']) . "
";
+
+ $sql = "SELECT CONCAT('', c.case_id, '') as case_id
+ FROM `case` as c
+ LEFT JOIN `sample` as s ON ( s.sample_id = c.sample_id )
+ WHERE c.questionnaire_id = '$questionnaire_id'
+ AND c.current_outcome_id = '$outcome_id'
+ $sid
+ $opn
+ LIMIT 500";
+
+ $rs = $db->GetAll($sql);
+ print "";
+ if (empty($rs))
+ print "
" . T_("No cases with this outcome") . "
";
+ else
+ {
+ xhtml_table($rs,array("case_id"),array(T_("Case ID")));
+ }
+ }
+ else
+ print "
" . T_("Error with input") . "
";
+}
+else
+ print "
" . T_("No operator") . "
";
+print "
";
+
+xhtml_foot();
+?>
\ No newline at end of file
diff --git a/admin/questionnaireprefill.php b/admin/questionnaireprefill.php
index 48f68870..758cb109 100644
--- a/admin/questionnaireprefill.php
+++ b/admin/questionnaireprefill.php
@@ -1,198 +1,198 @@
-
- * @copyright Deakin University 2007,2008
- * @package queXS
- * @subpackage admin
- * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
- * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
- *
- *
- */
-
-/**
- * Configuration file
- */
-include("../config.inc.php");
-
-/**
- * Database file
- */
-include ("../db.inc.php");
-
-/**
- * XHTML functions
- */
-include("../functions/functions.xhtml.php");
-
-/**
- * Display functions
- */
-include("../functions/functions.display.php");
-
-
-/**
- * Input functions
- */
-include("../functions/functions.input.php");
-
-global $db;
-
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']))
-{
- //need to add prefill to questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $value = $db->quote($_GET['value']);
- $svar = $db->quote($_GET['svar']);
- $sgqa = $db->quote($_GET['sgqa']);
-
- if (!empty($_GET['svar']) && empty($_GET['value']))
- $value = $svar;
-
- $sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value)
- VALUES('$questionnaire_id',$sgqa,$value)";
-
- $db->Execute($sql);
-
-}
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id']))
-{
- //need to remove prefill from questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']);
-
- $sql = "DELETE FROM questionnaire_prefill
- WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'";
-
- $db->Execute($sql);
-
-}
-
-
-$questionnaire_id = false;
-if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
-
-xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,false,array("../js/window.js"));
-print "" . T_("Select a questionnaire from the list below") . "
";
-
-$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
- FROM questionnaire
- WHERE enabled = 1";
-display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");
-
-
-if ($questionnaire_id != false)
-{
- print "" . T_("Current pre fills (click to delete)") . "
";
-
- $sql = "SELECT questionnaire_prefill_id,lime_sgqa,value
- FROM questionnaire_prefill
- WHERE questionnaire_id = '$questionnaire_id'";
-
- $r = $db->GetAll($sql);
-
- if (empty($r))
- {
- print "" . T_("Currently no pre fills") . "
";
- }
- else
- {
- foreach($r as $v)
- {
- print "";
-
- }
- }
-
-
- print "" . T_("Select a question to pre fill") . "
";
-
- $sql = "SELECT lime_sid
- FROM questionnaire
- WHERE questionnaire_id = '$questionnaire_id'";
-
- $r = $db->GetRow($sql);
-
- $lime_sid = $r['lime_sid'];
-
- $sgqa = false;
- if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
-
- $sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid) AS value,
- CASE WHEN qo.question IS NULL THEN q.question ELSE CONCAT(qo.question,' : ',q.question) END as description,
- CASE WHEN CONCAT(q.sid, 'X', q.gid, 'X', q.qid) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
- FROM `" . LIME_PREFIX . "questions` AS q
- LEFT JOIN `" . LIME_PREFIX . "questions` as qo ON (qo.qid = q.parent_qid)
- WHERE q.sid = '$lime_sid'
- ORDER BY CASE WHEN qo.question_order IS NULL THEN q.question_order ELSE qo.question_order + (q.question_order / 1000) END ASC";
-
- $rs = $db->GetAll($sql);
-
- for ($i=0; $i" . T_("Enter a value to pre fill this question with:") . "";
- print "";
- print T_("Possible uses:");
- print "
";
- print "- " . T_("{Respondent:firstName} First name of the respondent") . "
";
- print "- " . T_("{Respondent:lastName} Last name of the respondent") . "
";
- print "- " . T_("{Sample:var} A record from the sample where the column name is 'var'") . "
";
-
- $sql = "SELECT sv.var as description, CONCAT('{Sample:', sv.var, '}') as value
- FROM `sample` AS s, sample_var AS sv, questionnaire_sample as qs
- WHERE qs.questionnaire_id = '$questionnaire_id'
- AND s.import_id = qs.sample_import_id
- AND s.sample_id = sv.sample_id
- GROUP BY sv.var";
-
- print "
";
- ?>
-
-
+
+ * @copyright Deakin University 2007,2008
+ * @package queXS
+ * @subpackage admin
+ * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
+ * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
+ *
+ *
+ */
+
+/**
+ * Configuration file
+ */
+include("../config.inc.php");
+
+/**
+ * Database file
+ */
+include ("../db.inc.php");
+
+/**
+ * XHTML functions
+ */
+include("../functions/functions.xhtml.php");
+
+/**
+ * Display functions
+ */
+include("../functions/functions.display.php");
+
+
+/**
+ * Input functions
+ */
+include("../functions/functions.input.php");
+
+global $db;
+
+
+if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']))
+{
+ //need to add prefill to questionnaire
+
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $value = $db->quote($_GET['value']);
+ $svar = $db->quote($_GET['svar']);
+ $sgqa = $db->quote($_GET['sgqa']);
+
+ if (!empty($_GET['svar']) && empty($_GET['value']))
+ $value = $svar;
+
+ $sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value)
+ VALUES('$questionnaire_id',$sgqa,$value)";
+
+ $db->Execute($sql);
+
+}
+
+if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id']))
+{
+ //need to remove prefill from questionnaire
+
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']);
+
+ $sql = "DELETE FROM questionnaire_prefill
+ WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'";
+
+ $db->Execute($sql);
+
+}
+
+
+$questionnaire_id = false;
+if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
+
+xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
+print "";
+
+$sql = "SELECT questionnaire_id as value,description,
+ CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
+ FROM questionnaire
+ WHERE enabled = 1";
+display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline form-group");
+
+
+if ($questionnaire_id != false)
+{
+ print "" . T_("Current pre fills") . "
";
+
+ $sql = "SELECT questionnaire_prefill_id,lime_sgqa,value
+ FROM questionnaire_prefill
+ WHERE questionnaire_id = '$questionnaire_id'";
+
+ $r = $db->GetAll($sql);
+
+ if (empty($r))
+ {
+ print "" . T_("Currently no pre fills") . "
";
+ }
+ else
+ {
+ foreach($r as $v)
+ {
+ print "";
+ }
+ }
+ print "";
+
+ print "" . T_("Select a question to pre fill") . "
";
+
+ $sql = "SELECT lime_sid
+ FROM questionnaire
+ WHERE questionnaire_id = '$questionnaire_id'";
+
+ $r = $db->GetRow($sql);
+
+ $lime_sid = $r['lime_sid'];
+
+ $sgqa = false;
+ if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
+
+ $sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid) AS value,
+ CASE WHEN qo.question IS NULL THEN q.question ELSE CONCAT(qo.question,' : ',q.question) END as description,
+ CASE WHEN CONCAT(q.sid, 'X', q.gid, 'X', q.qid) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
+ FROM `" . LIME_PREFIX . "questions` AS q
+ LEFT JOIN `" . LIME_PREFIX . "questions` as qo ON (qo.qid = q.parent_qid)
+ WHERE q.sid = '$lime_sid'
+ ORDER BY CASE WHEN qo.question_order IS NULL THEN q.question_order ELSE qo.question_order + (q.question_order / 1000) END ASC";
+
+ $rs = $db->GetAll($sql);
+
+ for ($i=0; $i";
+
+ if ($sgqa != false)
+ {
+ print "" . T_("Enter a value to pre fill this question with:") . "
";
+ print "";
+ print T_("Possible uses:");
+ print "
";
+ print "- " . T_("{Respondent:firstName} First name of the respondent") . "
";
+ print "- " . T_("{Respondent:lastName} Last name of the respondent") . "
";
+ print "- " . T_("{Sample:var} A record from the sample where the column name is 'var'") . "
";
+ print "
";
+
+ $sql = "SELECT sv.var as description, CONCAT('{Sample:', sv.var, '}') as value
+ FROM `sample` AS s, sample_var AS sv, questionnaire_sample as qs
+ WHERE qs.questionnaire_id = '$questionnaire_id'
+ AND s.import_id = qs.sample_import_id
+ AND s.sample_id = sv.sample_id
+ GROUP BY sv.var";
+ ?>
+
+
\ No newline at end of file
diff --git a/admin/samplecallattempts.php b/admin/samplecallattempts.php
index 8a37abb5..a103d2c2 100644
--- a/admin/samplecallattempts.php
+++ b/admin/samplecallattempts.php
@@ -1,215 +1,216 @@
-
- * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
- * @package queXS
- * @subpackage admin
- * @link http://www.acspri.org.au/ queXS was writen for ACSPRI
- * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
- *
- */
-
-/**
- * Configuration file
- */
-include_once(dirname(__FILE__).'/../config.inc.php');
-
-/**
- * Database file
- */
-include ("../db.inc.php");
-
-/**
- * XHTML functions
- */
-include ("../functions/functions.xhtml.php");
-
-/**
- * Display functions
- */
-include("../functions/functions.display.php");
-
-/**
- * Input functions
- */
-include("../functions/functions.input.php");
-
-/**
- * Generate the sample call attempt report
- *
- * @param mixed $questionnaire_id The quesitonnaire, if specified
- * @param string $sample_id The sample, if speified
- * @param mixed $qsqri THe questionnaire sample quota row id, if specified
- *
- * @return false if empty otherwise true if table drawn
- * @author Adam Zammit
- * @since 2012-10-02
- */
-function sample_call_attempt_report($questionnaire_id = false, $sample_id = false, $qsqri = false)
-{
- global $db;
-
- $q = "";
- if ($questionnaire_id !== false && $questionnaire_id != -1)
- $q = "AND c.questionnaire_id = $questionnaire_id";
-
- $s = "";
- if ($sample_id !== false)
- $s = "JOIN sample as s ON (s.sample_id = c.sample_id AND s.import_id = '$sample_id')";
-
- $qs = "";
- if ($qsqri !== false)
- $qs = "JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$qsqri')
- JOIN sample_var ON (sample_var.sample_id = c.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)";
-
- $sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
- FROM ( SELECT count( ca.call_attempt_id ) AS ca1
- FROM call_attempt as ca
- JOIN `case` as c ON (c.case_id = ca.case_id $q)
- $s
- $qs
- GROUP BY ca.case_id) AS t1
- GROUP BY ca1";
-
- $overall = $db->GetAll($sql);
-
- if (empty($overall))
- return false;
-
-
- $sql = "SELECT outcome_id,description
- FROM outcome";
-
- $outcomes = $db->GetAssoc($sql);
-
- translate_array($outcomes,array("description"));
-
- $rep = array("sample","callattempts");
- $rept = array(T_("Number of cases"),T_("Call attempts made"));
- $totals = array("sample");
-
- $outcomesfilled = array();
-
- foreach($outcomes as $key => $val)
- {
- $rep[] = $key;
- $rept[] = $val;
- $outcomesfilled[$key] = 0;
- }
-
- //Add breakdown by call attempt
- for ($i = 0; $i < count($overall); $i++)
- {
- //break down by outcome
- $sql = "SELECT oi1, ca1 as callattempts, count(ca1) as sample
- FROM ( SELECT count( ca.call_attempt_id ) AS ca1, ca.case_id, c.current_outcome_id as oi1
- FROM call_attempt AS ca
- JOIN `case` AS c ON ( c.case_id = ca.case_id $q)
- $s
- $qs
- GROUP BY ca.case_id
- ) as t1
- GROUP BY ca1,oi1
- HAVING ca1 = {$overall[$i]['callattempts']}";
-
- $byoutcome = $db->GetAssoc($sql);
-
- foreach($outcomes as $key => $val)
- {
- $sample = 0;
- if (isset($byoutcome[$key]))
- {
- $outcomesfilled[$key] = 1;
- $sample = $byoutcome[$key]['sample'];
- }
-
- $overall[$i][$key] = $sample;
- }
- }
-
- //Remove columns that are empty
- $count = 2;
- foreach ($outcomesfilled as $key => $val)
- {
- if ($val == 0)
- {
- unset($rep[$count]);
- unset($rept[$count]);
- }
- else
- $totals[] = $key;
-
- $count++;
- }
-
- xhtml_table($overall,$rep,$rept,"tclass",false,$totals);
-
- return true;
-}
-
-
-xhtml_head(T_("Sample call attempt"),true,array("../css/table.css"),array("../js/window.js"));
-
-print "" . T_("Please select a questionnaire") . "
";
-$questionnaire_id = false;
-if (isset($_GET['questionnaire_id'])) $questionnaire_id = intval($_GET['questionnaire_id']);
-display_questionnaire_chooser($questionnaire_id,array(-1,T_("Overall")));
-
-
-if ($questionnaire_id || $questionnaire_id == -1)
-{
- if (sample_call_attempt_report($questionnaire_id,false,false))
- {
- if ($questionnaire_id != -1)
- {
- print "" . T_("Please select a sample") . "
";
- $sample_import_id = false;
- if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
- display_sample_chooser($questionnaire_id,$sample_import_id);
-
- if ($sample_import_id)
- {
- if (sample_call_attempt_report($questionnaire_id,$sample_import_id,false))
- {
- $questionnaire_sample_quota_row_id = false;
- if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
- print "" . T_("Please select a quota") . "
";
- display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id);
-
- if ($questionnaire_sample_quota_row_id)
- {
- if (!sample_call_attempt_report($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id))
- print "" . T_("No calls for this quota") . "
";
- }
- }
- else
- print "" . T_("No calls for this sample") . "
";
- }
- }
- }
- else
- print "" . T_("No calls for this questionnaire") . "
";
-}
-
-xhtml_foot();
-
-?>
+
+ * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
+ * @package queXS
+ * @subpackage admin
+ * @link http://www.acspri.org.au/ queXS was writen for ACSPRI
+ * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
+ *
+ */
+
+/**
+ * Configuration file
+ */
+include_once(dirname(__FILE__).'/../config.inc.php');
+
+/**
+ * Database file
+ */
+include ("../db.inc.php");
+
+/**
+ * XHTML functions
+ */
+include ("../functions/functions.xhtml.php");
+
+/**
+ * Display functions
+ */
+include("../functions/functions.display.php");
+
+/**
+ * Input functions
+ */
+include("../functions/functions.input.php");
+
+/**
+ * Generate the sample call attempt report
+ *
+ * @param mixed $questionnaire_id The quesitonnaire, if specified
+ * @param string $sample_id The sample, if speified
+ * @param mixed $qsqri THe questionnaire sample quota row id, if specified
+ *
+ * @return false if empty otherwise true if table drawn
+ * @author Adam Zammit
+ * @since 2012-10-02
+ */
+function sample_call_attempt_report($questionnaire_id = false, $sample_id = false, $qsqri = false)
+{
+ global $db;
+
+ $q = "";
+ if ($questionnaire_id !== false && $questionnaire_id != -1)
+ $q = "AND c.questionnaire_id = $questionnaire_id";
+
+ $s = "";
+ if ($sample_id !== false)
+ $s = "JOIN sample as s ON (s.sample_id = c.sample_id AND s.import_id = '$sample_id')";
+
+ $qs = "";
+ if ($qsqri !== false)
+ $qs = "JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$qsqri')
+ JOIN sample_var ON (sample_var.sample_id = c.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)";
+
+ $sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
+ FROM ( SELECT count( ca.call_attempt_id ) AS ca1
+ FROM call_attempt as ca
+ JOIN `case` as c ON (c.case_id = ca.case_id $q)
+ $s
+ $qs
+ GROUP BY ca.case_id) AS t1
+ GROUP BY ca1";
+
+ $overall = $db->GetAll($sql);
+
+ if (empty($overall))
+ return false;
+
+
+ $sql = "SELECT outcome_id,description
+ FROM outcome";
+
+ $outcomes = $db->GetAssoc($sql);
+
+ translate_array($outcomes,array("description"));
+
+ $rep = array("callattempts","sample");
+ $rept = array(T_("Call attempts made"),T_("Number of cases"));
+ $totals = array("sample");
+
+ $outcomesfilled = array();
+
+ foreach($outcomes as $key => $val)
+ {
+ $rep[] = $key;
+ $rept[] = $val;
+ $outcomesfilled[$key] = 0;
+ }
+
+ //Add breakdown by call attempt
+ for ($i = 0; $i < count($overall); $i++)
+ {
+ //break down by outcome
+ $sql = "SELECT oi1, ca1 as callattempts, count(ca1) as sample
+ FROM ( SELECT count( ca.call_attempt_id ) AS ca1, ca.case_id, c.current_outcome_id as oi1
+ FROM call_attempt AS ca
+ JOIN `case` AS c ON ( c.case_id = ca.case_id $q)
+ $s
+ $qs
+ GROUP BY ca.case_id
+ ) as t1
+ GROUP BY ca1,oi1
+ HAVING ca1 = {$overall[$i]['callattempts']}";
+
+ $byoutcome = $db->GetAssoc($sql);
+
+ foreach($outcomes as $key => $val)
+ {
+ $sample = 0;
+ if (isset($byoutcome[$key]))
+ {
+ $outcomesfilled[$key] = 1;
+ $sample = $byoutcome[$key]['sample'];
+ }
+
+ $overall[$i][$key] = $sample;
+ }
+ }
+
+ //Remove columns that are empty
+ $count = 2;
+ foreach ($outcomesfilled as $key => $val)
+ {
+ if ($val == 0)
+ {
+ unset($rep[$count]);
+ unset($rept[$count]);
+ }
+ else
+ $totals[] = $key;
+
+ $count++;
+ }
+
+ xhtml_table($overall,$rep,$rept,"tclass",false,$totals);
+ print "";
+ return true;
+}
+
+
+xhtml_head(T_("Sample call attempt"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
+
+print "";
+$questionnaire_id = false;
+if (isset($_GET['questionnaire_id'])) $questionnaire_id = intval($_GET['questionnaire_id']);
+display_questionnaire_chooser($questionnaire_id,array(-1,T_("Overall")),"form-inline clearfix", "form-control");
+
+
+if ($questionnaire_id || $questionnaire_id == -1)
+{
+ if (sample_call_attempt_report($questionnaire_id,false,false))
+ {
+ if ($questionnaire_id != -1)
+ {
+ print "";
+ $sample_import_id = false;
+ if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
+ display_sample_chooser($questionnaire_id,$sample_import_id,false,"form-inline clearfix", "form-control");
+
+ if ($sample_import_id)
+ {
+ if (sample_call_attempt_report($questionnaire_id,$sample_import_id,false))
+ {
+ $questionnaire_sample_quota_row_id = false;
+ if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
+ print "";
+ display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id,"form-inline clearfix", "form-control");
+
+ if ($questionnaire_sample_quota_row_id)
+ {
+ if (!sample_call_attempt_report($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id))
+ print "" . T_("No calls for this quota") . "
";
+
+ }
+ }
+ else
+ print "" . T_("No calls for this sample") . "
";
+ }
+ }
+ }
+ else
+ print "" . T_("No calls for this questionnaire") . "
";
+}
+
+xhtml_foot();
+
+?>