" . T_("Samples selected for this questionnaire") . "
";
+
+ 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('" . TQ_("Edit") ."') as edit,
- CONCAT('" . TQ_("Click to unassign") ."') as unassign
+ 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'";
@@ -200,9 +225,9 @@ if ($questionnaire_id != false)
$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") ));
+ 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") . "
";
+ print "
". T_("No samples selected for this questionnaire") ."
";
$sql = "SELECT si.sample_import_id,si.description
FROM sample_import as si
@@ -211,36 +236,47 @@ if ($questionnaire_id != false)
AND si.enabled = 1";
$qs = $db->GetAll($sql);
+ print"
";
if (!empty($qs))
{
-
-
- print "
" . T_("Add a sample to this questionnaire:") . "
";
+ print "";
+ print "
" . T_("Add a sample to this questionnaire:") . "
";
?>
-
-
-
-
-
-
-
-
- "/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
" data-off="" data-width="85"/>
+
+
+
+
" data-off="" data-width="85"/>
+
+
+
+
+
+
+
diff --git a/admin/assigntimeslots.php b/admin/assigntimeslots.php
new file mode 100644
index 00000000..1e92ec99
--- /dev/null
+++ b/admin/assigntimeslots.php
@@ -0,0 +1,313 @@
+
+ * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011
+ * @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("../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/css/bootstrap.min.css",
+"../include/bootstrap/css/bootstrap-theme.min.css",
+//"../include/font-awesome/css/font-awesome.css",
+"../css/custom.css"
+ );
+$js_head = array(
+ );
+$js_foot = array(
+"../js/window.js",
+//"../js/custom.js"
+ );
+
+global $db;
+
+//block availability
+if (isset($_GET['questionnaire_id']) && isset($_GET['av_availability_group']))
+{
+ //need to add availability_group to questionnaire
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $availability_group = bigintval($_GET['av_availability_group']);
+
+ $sql = "INSERT INTO questionnaire_availability(questionnaire_id,availability_group_id)
+ VALUES('$questionnaire_id','$availability_group')";
+ $db->Execute($sql);
+}
+
+if (isset($_GET['questionnaire_id']) && isset($_GET['av_ravailability_group']))
+{
+ //need to remove rsid from questionnaire
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $availability_group = bigintval($_GET['av_ravailability_group']);
+
+ $sql = "DELETE FROM questionnaire_availability
+ WHERE questionnaire_id = '$questionnaire_id'
+ AND availability_group_id = '$availability_group'";
+ $db->Execute($sql);
+}
+
+//block call_attempts
+if (isset($_GET['questionnaire_id']) && isset($_GET['ca_availability_group']))
+{
+ //need to add availability_group to questionnaire
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $availability_group = bigintval($_GET['ca_availability_group']);
+
+ $sql = "INSERT INTO questionnaire_timeslot(questionnaire_id,availability_group_id)
+ VALUES('$questionnaire_id','$availability_group')";
+ $db->Execute($sql);
+}
+
+if (isset($_GET['questionnaire_id']) && isset($_GET['ca_ravailability_group']))
+{
+ //need to remove rsid from questionnaire
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $availability_group = bigintval($_GET['ca_ravailability_group']);
+
+ $sql = "DELETE FROM questionnaire_timeslot
+ WHERE questionnaire_id = '$questionnaire_id'
+ AND availability_group_id = '$availability_group'";
+ $db->Execute($sql);
+}
+
+
+//block call_attempts by sample
+if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['qs_availability_group']))
+{
+ //need to add availability_group to questionnaire
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $sample_import_id = bigintval($_GET['sample_import_id']);
+ $availability_group = bigintval($_GET['qs_availability_group']);
+
+ $sql = "INSERT INTO questionnaire_sample_timeslot (questionnaire_id,sample_import_id,availability_group_id)
+ VALUES('$questionnaire_id','$sample_import_id','$availability_group')";
+ $db->Execute($sql);
+}
+
+if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['qs_ravailability_group']))
+{
+ //need to remove rsid from questionnaire
+ $questionnaire_id = bigintval($_GET['questionnaire_id']);
+ $sample_import_id = bigintval($_GET['sample_import_id']);
+ $availability_group = bigintval($_GET['qs_ravailability_group']);
+
+ $sql = "DELETE FROM questionnaire_sample_timeslot
+ WHERE questionnaire_id = '$questionnaire_id'
+ AND sample_import_id = '$sample_import_id'
+ AND availability_group_id = '$availability_group'";
+ $db->Execute($sql);
+}
+
+$questionnaire_id = false;
+if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
+$sample_import_id = false;
+if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
+
+xhtml_head(T_("Assign Time slots"),true,$css,$js_head);//false,array("../js/window.js")
+
+print "
" . T_("Assigning an availability group to a questionnaire will allow interviewers to select from those groups to restrict calls to a particular case to the times within the group") ."
";
+
+ $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link
+ FROM questionnaire_availability as q, availability_group as a
+ WHERE q.availability_group_id = a.availability_group_id
+ AND q.questionnaire_id = '$questionnaire_id'";
+
+ $qs = $db->GetAll($sql);
+ print "
";
+
+ if (empty($qs))
+ {
+ print "
" . T_("There are no time slots groups selected for this questionnaire") . "
";
+ }
+ else
+ {
+ print "
" . T_("Time slots groups selected for this questionnaire") . "
";
+ $sql = "SELECT si.availability_group_id,si.description
+ FROM availability_group as si
+ LEFT JOIN questionnaire_availability as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
+ WHERE q.questionnaire_id is NULL";
+
+ $qs = $db->GetAll($sql);
+
+ if (!empty($qs))
+ {
+ print "
";
+ //print "
" . T_("Add time slot to this questionnaire:") . "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
";
+
+ $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link
+
+ FROM questionnaire_timeslot as q, availability_group as a
+ WHERE q.availability_group_id = a.availability_group_id
+ AND q.questionnaire_id = '$questionnaire_id'";
+
+ $qs = $db->GetAll($sql);
+ print "
";
+ if (empty($qs))
+ {
+ print "
" . T_("There are no call attempt time slots selected for this questionnaire") . "
";
+ }
+ else
+ {
+ print "
" . T_("Call attempt time slots selected for this questionnaire") . "
";
+
+ $sql = "SELECT si.availability_group_id,si.description
+ FROM availability_group as si
+ LEFT JOIN questionnaire_timeslot as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
+ WHERE q.questionnaire_id is NULL";
+
+ $qs = $db->GetAll($sql);
+
+ if (!empty($qs))
+ {
+ print "
";
+ //print "
" . T_("Add a call attempt time slot to this questionnaire:") . "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
";
+
+ print "
" . T_("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,false, "form-inline", "form-control");
+
+ if ($sample_import_id !== false)
+ {
+ $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link
+ FROM questionnaire_sample_timeslot as q, availability_group as a
+ WHERE q.availability_group_id = a.availability_group_id
+ AND q.questionnaire_id = '$questionnaire_id'
+ AND q.sample_import_id = '$sample_import_id'";
+
+ $qs = $db->GetAll($sql);
+
+ if (empty($qs))
+ {
+ print "
" . T_("There are no call attempt time slots selected for this questionnaire sample") . "
";
+ }
+ else
+ {
+ print "
" . T_("Call attempt time slots selected for this sample") . ":
";
+ xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover");
+ }
+
+ $sql = "SELECT si.availability_group_id,si.description
+ FROM availability_group as si
+ LEFT JOIN questionnaire_sample_timeslot as q ON (q.sample_import_id = '$sample_import_id' AND q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
+ WHERE q.questionnaire_id is NULL";
+
+ $qs = $db->GetAll($sql);
+
+ if (!empty($qs))
+ {
+ print "
";
+ //print "
" . T_("Add a call attempt time slot to this questionnaire sample:") . "
";
+ print "
+
+
+
+
";
+ }
+ }
+print "
";
+}
+
+xhtml_foot($js_foot);
+?>
diff --git a/admin/availability.php b/admin/availability.php
index 03b120ac..09f23a24 100644
--- a/admin/availability.php
+++ b/admin/availability.php
@@ -44,6 +44,22 @@ include ("../db.inc.php");
*/
include ("../functions/functions.xhtml.php");
+$css = array(
+"../include/bootstrap/css/bootstrap.min.css",
+//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
+"../include/clockpicker/dist/bootstrap-clockpicker.min.css",
+"../css/custom.css"
+ );
+$js_head = array(
+"../include/jquery/jquery.min.js",
+"../include/bootstrap/js/bootstrap.min.js",
+"../js/addrow-v2.js",
+ );
+$js_foot = array(
+"../include/clockpicker/dist/bootstrap-clockpicker.js",
+"../js/custom.js"
+ );
+
global $db;
$year="2008";
@@ -63,7 +79,6 @@ if (isset($_POST['day']))
$sql = "DELETE FROM availability
WHERE availability_group_id = $availability_group";
-
$db->Execute($sql);
foreach($_POST['day'] as $key => $val)
@@ -78,7 +93,6 @@ if (isset($_POST['day']))
$sql = "INSERT INTO availability (day_of_week,start,end,availability_group_id)
VALUES ('$val',$start,$end,$availability_group)";
-
$db->Execute($sql);
}
}
@@ -86,27 +100,25 @@ if (isset($_POST['day']))
$sql = "UPDATE availability_group
SET description = " . $db->qstr($_POST['description']) . "
WHERE availability_group_id= $availability_group";
-
$db->Execute($sql);
-
$db->CompleteTrans();
}
-xhtml_head(T_("Modify time slots"),true,array("../css/shifts.css"),array("../js/addrow-v2.js"));
+xhtml_head(T_("Modify time slots"),true,$css,$js_head);//,true,array("../css/shifts.css"),array("../js/addrow-v2.js")
/**
* Display warning if timezone data not installed
*
*/
-$sql = "SELECT CONVERT_TZ(NOW(),'Australia/Victoria','UTC') as t";
+$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria'
$rs = $db->GetRow($sql);
if (empty($rs) || !$rs || empty($rs['t']))
- print "
+
diff --git a/admin/availabilitygroup.php b/admin/availabilitygroup.php
index 2599cbc9..4b7db070 100644
--- a/admin/availabilitygroup.php
+++ b/admin/availabilitygroup.php
@@ -65,9 +65,19 @@ include("../functions/functions.operator.php");
*/
include("../functions/functions.input.php");
+$css = array(
+"../include/bootstrap/css/bootstrap.min.css",
+"../css/custom.css"
+ );
+$js_head = array(
+ );
+$js_foot = array(
+"../js/window.js",
+"../js/custom.js"
+ );
global $db;
-xhtml_head(T_("Time slots"),true,array("../css/table.css"),array("../js/window.js"));
+xhtml_head(T_("Time slots"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js")
if (isset($_POST['subdel']))
{
@@ -103,33 +113,29 @@ else if (isset($_POST['availability_group']))
}
//view groups
-$sql = "SELECT description,
+$sql = "SELECT availability_group_id,description,
CONCAT('". TQ_("Modify") . "') as link
FROM availability_group";
$rs = $db->GetAll($sql);
-print "
" . T_("Time slots")."
";
-
-print "
" . T_("Time slots define periods of time during particular days of the week. These are used for the availability function and also the call attempt time slot function.") . "
";
+print "
" . T_("Time slots define periods of time during particular days of the week. These are used for the availability function and also the call attempt time slot function.") . "
";
+//add a time slot (ex- availablity group)
?>
-
-
-
"/>
-
-
+
+
+
"/>
+
"/>
+
diff --git a/admin/bulkappointment.php b/admin/bulkappointment.php
index 3e525049..567bc8f6 100644
--- a/admin/bulkappointment.php
+++ b/admin/bulkappointment.php
@@ -125,7 +125,8 @@ function validate_bulk_appointment($tmpfname)
if (isset($_POST['tmpfname']))
{
- xhtml_head("queXS",true,array("../css/table.css"));
+ $subtitle = T_("Result");
+ xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),false,false,false,false,$subtitle);
$todo = validate_bulk_appointment($_POST['tmpfname']);
if (is_array($todo))
@@ -213,60 +214,76 @@ if (isset($_POST['tmpfname']))
else if (isset($_POST['import_file']))
{
//file has been submitted
-
- xhtml_head("queXS",true,array("../css/table.css"));
+ $subtitle = T_("Check data to submit");
+ xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),false,false,false,false,$subtitle);
?>
-
+
" . T_("Please check the case id's, appointment start and end times and notes are correct before accepting below") . "";
+
+ if (is_array($todo) && !empty($todo)) {
+
+ print "
" . T_("Please check the case id's, appointment start and end times and notes are correct before accepting below") . "
Optionally you can include a note column to attach a note to the case in addition to setting an appointment. Only cases that have temporary (non final) outcomes will have appointments generated, and the outcome of the case will be updated to an appointment outcome."); ?>
+
+
+
+
+
caseid
starttime
endtime
note
+
1
2012-08-15 11:00:00
2012-08-15 13:00:00
Appointment automatically generated
+
2
2012-08-15 12:00:00
2012-08-15 14:00:00
Appointment automatically generated
+
3
2012-08-15 13:00:00
2012-08-15 15:00:00
Appointment automatically generated
+
+
+
-
-
-
"/>
+
+
+
:
+
+
+ " type="file" accept=""/>
+
+
+
diff --git a/admin/callhistory.php b/admin/callhistory.php
index 108a00ca..2e27bea8 100644
--- a/admin/callhistory.php
+++ b/admin/callhistory.php
@@ -49,42 +49,70 @@ include ("../functions/functions.xhtml.php");
*/
include("../functions/functions.operator.php");
+$css = array(
+"../include/bootstrap/css/bootstrap.min.css",
+"../include/bootstrap/css/bootstrap-theme.min.css",
+"../include/font-awesome/css/font-awesome.css",
+"../include/bs-data-table/css/jquery.bdt.css",
+"../css/custom.css"
+ );
+$js_head = array(
+"../include/jquery/jquery.min.js",
+"../include/bootstrap/js/bootstrap.min.js"
+ );
+$js_foot = array(
+"../include/bs-data-table/js/vendor/jquery.sortelements.js",
+"../include/bs-data-table/js/jquery.bdt.js",
+"../js/custom.js"
+ );
//List the case call history
$operator_id = get_operator_id();
+/*
+ Modified Call history list to have more information more suitable way with filtering, soring, paging and submenu for Cse history with asterisk records....
+ Need to be linked with cdr records from asterisk!! for monitoring (requires addtional field for call_attempt table to request and store asterisk UniqueID as a reference to CDR .wav file list at /var/spool/asterisk/monitor/ )
+*/
if ($operator_id)
{
- $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as start,DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as des, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname, ";
+ if (isset($_GET['questionnaire_id'])) $qid = $_GET['questionnaire_id'];
+ if (isset($_GET['sample_import_id'])) $sid = $_GET['sample_import_id'];
+ $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_FORMAT."') as start_date, DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as start_time, DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as descr, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname,
+ (SELECT GROUP_CONCAT(cn1.note SEPARATOR '¶ ' ) FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes,";
- if (isset($_GET['csv']))
- $sql .= " c.case_id ";
- else
- $sql .= " CONCAT('', c.case_id, '') ";
+ if (isset($_GET['csv'])) $sql .= " c.case_id ";
+ else $sql .= " CONCAT('', c.case_id, '') ";
- $sql .= " as case_id, q.description as qd
+ $sql .= " as case_id, q.description as qd , contact_phone.phone as cpi, sample_import.description as spl
FROM `call` as c
- JOIN (operator as op, respondent as r) on (op.operator_id = '$operator_id' and r.respondent_id = c.respondent_id)
- JOIN (`case` as ca, questionnaire as q) ON (ca.case_id = c.case_id AND q.questionnaire_id = ca.questionnaire_id)
+ JOIN (operator as op, respondent as r) on (op.operator_id = '$operator_id' and r.respondent_id = c.respondent_id)";
+ if ($qid) $quest = "$qid and q.questionnaire_id= $qid"; else $quest = "q.questionnaire_id";
+ if ($sid) $samimpid = "$sid and sample_import.sample_import_id=$sid"; else $samimpid = "sample_import.sample_import_id";
+
+ $sql .= "
+ JOIN (`case` as ca, questionnaire as q) ON (ca.case_id = c.case_id AND ca.questionnaire_id = $quest)
LEFT JOIN (outcome as o) on (c.outcome_id = o.outcome_id)
- LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id)
+ LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id),
+ contact_phone, sample_import, sample
+ WHERE c.contact_phone_id = contact_phone.contact_phone_id AND sample.import_id = $samimpid
+ AND sample.sample_id = ca.sample_id
ORDER BY c.start DESC";
if (!isset($_GET['csv']))
$sql .= " LIMIT 500";
-
- $rs = $db->Execute($sql);
+ else $sql .= " LIMIT 5000";
+ $rs = $db->Execute($sql);
if (empty($rs))
{
- xhtml_head(T_("Call History List"),true,array("../css/table.css"));
- print "
";//class='row_to_clone' /* these are not the rows to clone...*/
display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$shift['dt']));
- print "
";
//List the cases by outcome
$operator_id = get_operator_id();
@@ -59,27 +61,48 @@ 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
+ $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 "
";
$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 "
";
xhtml_foot();
-
-
?>
diff --git a/admin/casestatus.php b/admin/casestatus.php
index 83a199f3..25fbfb70 100644
--- a/admin/casestatus.php
+++ b/admin/casestatus.php
@@ -1,30 +1,5 @@
- * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013
- * @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
- *
*/
/**
@@ -52,6 +27,26 @@ include("../functions/functions.display.php");
*/
include("../functions/functions.input.php");
+$css = array(
+"../include/bootstrap/css/bootstrap.min.css",
+"../include/bootstrap/css/bootstrap-theme.min.css",
+"../include/font-awesome/css/font-awesome.css",
+"../include/bs-data-table/css/jquery.bdt.css",
+//"../include/iCheck/skins/square/blue.css",
+"../css/custom.css"
+ );
+$js_head = array(
+"../include/jquery/jquery.min.js",
+"../include/bootstrap/js/bootstrap.min.js"
+ );
+$js_foot = array(
+"../include/bs-data-table/js/vendor/jquery.sortelements.js",
+"../include/bs-data-table/js/jquery.bdt.js",
+"../include/iCheck/icheck.min.js",
+"../js/window.js",
+"../js/custom.js"
+ );
+
/**
* Generate the case status report
*
@@ -63,6 +58,8 @@ include("../functions/functions.input.php");
* @author Adam Zammit
* @since 2012-10-02
*/
+
+
function case_status_report($questionnaire_id = false, $sample_id = false, $outcome_id = false)
{
global $db;
@@ -78,38 +75,49 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc
$o = "";
if ($outcome_id !== false)
$o = "AND c.current_outcome_id = $outcome_id";
-
-
-
$sql = "SELECT CONCAT('', c.case_id, '') as case_id,
o.description as outcomes,
- si.description as samples,
- CASE WHEN ca.end IS NULL THEN '" . TQ_("Now") . "'
- WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Now") . "'
- ELSE ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60)
+ si.description as samples, s.Time_zone_name as timezone, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time, (SELECT COUNT(*) FROM `call` WHERE `call`.case_id = c.case_id) as nrcalls, (SELECT COUNT(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) as nrattempts,
+ CASE WHEN ca.end IS NULL THEN '" . TQ_("Available") . "'
+ WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Available") . "'
+ ELSE CONCAT(ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60),' " . TQ_("minutes") . "')
END AS availableinmin,
- CASE WHEN oq.operator_id IS NULL THEN CONCAT('". TQ_("Not assigned, select to assign") ." ','')
- ELSE CONCAT('". TQ_("Assigned to") . ": ', oq.firstName, ' " . TQ_("Order") . ":', cq.sortorder , ' (". TQ_("Click to unassign") .")')
- END AS assignedoperator
+ CASE WHEN oq.operator_id IS NULL THEN
+ CONCAT('')
+ ELSE CONCAT('', oq.firstName,' ',oq.lastName,'')
+ END AS assignedoperator,
+ CASE WHEN oq.operator_id IS NULL THEN
+ CONCAT('')
+ ELSE CONCAT(' ', cq.sortorder ,' ')
+ END AS ordr,
+ CASE WHEN oq.operator_id IS NULL THEN
+ CONCAT('')
+ ELSE CONCAT('')
+ END AS flag
FROM `case` as c
JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1)
JOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1)
JOIN sample as s ON (s.sample_id = c.sample_id $s)
- JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1)
- JOIN questionnaire_sample as qs ON (qs.questionnaire_id = q.questionnaire_id AND qs.sample_import_id = s.import_id)
+ JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1)
+ JOIN questionnaire_sample as qs ON (qs.questionnaire_id = $questionnaire_id AND qs.sample_import_id = s.import_id)
LEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id)
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)
WHERE c.current_operator_id IS NULL $q $o
- ORDER BY availableinmin ASC";
+ ORDER BY c.case_id ASC";
// print $sql;
print ("
");
- xhtml_table($db->GetAll($sql),array('case_id','outcomes','samples','availableinmin','assignedoperator'),array(T_("Case id"),T_("Outcome"),T_("Sample"),T_("Case available in x minutes"),T_("Assigned to operator")));
+ $datacol = array('case_id','samples','timezone','time','nrattempts','nrcalls','outcomes','availableinmin','assignedoperator','ordr','flag');
+ $headers = array(T_("Case id"),T_("Sample"),T_("Timezone"),T_("Time NOW"),T_("Call attempts"),T_("Calls"),T_("Outcome"),T_("Available in"),T_("Assigned to"),T_("Order"),"");
+
+ if (isset($_GET['sample_import_id'])){ unset($datacol[1]); unset($headers[1]); }
+
+ xhtml_table($db->GetAll($sql),$datacol,$headers,"tclass",false,false,"bs-table");
$sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected
FROM operator
@@ -117,11 +125,11 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc
$rs3 = $db->GetAll($sql);
- print "";
- display_chooser($rs3, "operator_id", "operator_id",true,false,false);
+ print "
");
+ print " ";
+ print "";
return true;
}
@@ -190,14 +198,29 @@ if (isset($_GET['unassign']))
$sortorder++;
}
-
$db->CompleteTrans();
-
}
-xhtml_head(T_("Case status and assignment"),true,array("../css/table.css"),array("../js/window.js"));
-
-print "
" . T_("List cases by questionnaire and sample with the ability to assign them to be called next in a queue by a particular operator. If you assign cases to an operator, it will override the normal scheduling process and call them as soon as the operator is available.") . "
";
+xhtml_head(T_("Case status and assignment"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js")
+echo " " . T_("Go back") . "
+ ";
+ ?>
+
+
+
+
+
+
+
+
If you assign cases to an operator, it will override the normal scheduling process and call them as soon as the operator is available.");?>
";
//get sample vars
- $sql = "SELECT sv.var as value, sv.var as description
- FROM `sample_var` as sv
- WHERE sv.sample_id = (SELECT sample_id FROM sample WHERE import_id = '$sample_import_id' LIMIT 1)";
+ $sql = "SELECT sivr.var_id as value, sivr.var as description
+ FROM `sample_import_var_restrict` as sivr
+ WHERE sivr.sample_import_id = $sample_import_id";
+ $rs = $db->GetAll($sql);
//download a key file linking the caseid to the sample
- print "
";
}
else
{
//Display an edit form
- $css = array("../css/timepicker.css","../include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css");
- $js = array("../include/jquery-ui/js/jquery-1.4.2.min.js","../include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js","../include/timepicker/jquery-ui-timepicker-addon.js");
- xhtml_head(T_("Edit appointment"),false,$css,$js);
- print "";
- $sql = "SELECT a.contact_phone_id,a.call_attempt_id,CONVERT_TZ(a.start,'UTC',r.Time_zone_name) as start,CONVERT_TZ(a.end,'UTC',r.Time_zone_name) as end,a.respondent_id,a.require_operator_id
- FROM appointment as a, respondent as r
+ if ($_GET['new'] == 'new'){$title = T_("Create NEW appointment");} else{$title = T_("Edit appointment"); $subtitle = "ID " . $appointment_id;}
+
+ xhtml_head($title,true,$css,$js_head,false,false,false,$subtitle);
+ $lang = DEFAULT_LOCALE;
+ $sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM',r.Time_zone_name) as startdate, CONVERT_TZ(s.end,'UTC',r.Time_zone_name) as enddate FROM `shift` as s, `case` as c, `respondent` as r WHERE s.questionnaire_id = c.questionnaire_id AND c.case_id = $case_id AND r.case_id = c.case_id ORDER BY s.end DESC LIMIT 1";
+ $rs = $db->GetRow($sql); $startdate = $rs['startdate'];$enddate = $rs['enddate'];
+
+ print "";
+
+ if ($_GET['new'] =='new'){
+ $start = $startdate;
+ $end = $enddate;
+ $rtz = $_GET['rtz'];
+ }
+ if (isset($_GET['appointment_id'])) {
+
+ $sql = "SELECT a.contact_phone_id,a.call_attempt_id, CONVERT_TZ(a.start,'UTC',r.Time_zone_name) as `start`, CONVERT_TZ(a.end,'UTC',r.Time_zone_name) as `end`, a.respondent_id, a.require_operator_id, r.Time_zone_name as rtz
+ FROM `appointment` as a, respondent as r
WHERE a.appointment_id = '$appointment_id'
AND a.case_id = '$case_id'
AND r.respondent_id = a.respondent_id";
- $rs = $db->GetRow($sql);
+ $rs = $db->GetRow($sql);
- if (!empty($rs))
- {
- $respondent_id = $rs['respondent_id'];
- $contact_phone_id = $rs['contact_phone_id'];
- $require_operator_id = $rs['require_operator_id'];
- $start = $rs['start'];
- $end = $rs['end'];
-
- print "
";
- print "
";
- display_chooser($db->GetAll("SELECT respondent_id as value, firstname as description, CASE when respondent_id = '$respondent_id' THEN 'selected=\'selected\'' ELSE '' END as selected
- FROM respondent
- WHERE case_id = '$case_id'"),"respondent_id","respondent_id",false,false,false,false);
+ if (!empty($rs)){
+ $respondent_id = $rs['respondent_id'];
+ $contact_phone_id = $rs['contact_phone_id'];
+ $require_operator_id = $rs['require_operator_id'];
+ $start = $rs['start'];
+ $end = $rs['end'];
+ $rtz = $rs['rtz'];
+ }
+ }
+ print "
";
+ print "";
+ display_chooser($db->GetAll("SELECT respondent_id as value, CONCAT(firstName,' ',lastName) as description,
+ CASE when respondent_id = '$respondent_id' THEN 'selected=\'selected\'' ELSE '' END as selected
+ FROM respondent
+ WHERE case_id = '$case_id'"),"respondent_id","respondent_id",false,false,false,true,false,true,"pull-left");
- print "
";
- display_chooser($db->GetAll("SELECT contact_phone_id as value,
- phone as description,
- CASE when contact_phone_id = '$contact_phone_id' THEN 'selected=\'selected\'' ELSE '' END as selected
+ print "
";
+ display_chooser($db->GetAll("SELECT contact_phone_id as value, phone as description,
+ CASE when contact_phone_id = '$contact_phone_id' THEN 'selected=\'selected\'' ELSE '' END as selected
FROM contact_phone
WHERE case_id = '$case_id'"),
- "contact_phone_id","contact_phone_id",false,false,false,false);
-
- print "
" . T_("All appointments (with times displayed in your time zone)") . "
";
-
- $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',o.Time_zone_name) as start, CONVERT_TZ(a.end,'UTC',o.Time_zone_name) as end, r.firstName, r.lastName, 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('". TQ_("Delete") . "') as link, CONCAT('". TQ_("Edit") . "') 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 o, 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 o.operator_id = '$operator_id' and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_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')
- ORDER BY a.start ASC";
+ $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,
+ 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)
+ 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
+ ORDER BY a.start ASC";
$rs = $db->GetAll($sql);
-
- if (!empty($rs))
- {
+ if (!empty($rs)) {
translate_array($rs,array("outcome"));
- xhtml_table($rs,array("description","case_id","start","end","makerName","witho","firstName","lastName","outcome","callerName","link","edit"),array(T_("Questionnaire"),T_("Case ID"),T_("Start"),T_("End"),T_("Operator Name"),T_("Appointment with"),T_("Respondent Name"),T_("Surname"),T_("Current outcome"),T_("Operator who called"),T_("Delete"),T_("Edit")));
- }
- else
- 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,
+ 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
+ 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");
+
+ } else print "
";
+
+ if (!empty($msg)) echo $msg;
$sql = "SELECT extension_id as value, extension as description,
CASE WHEN current_operator_id = $operator_id THEN 'selected=\'selected\'' ELSE '' END AS selected
@@ -152,38 +193,79 @@ if (isset($_GET['edit']))
OR current_operator_id = $operator_id";
$ers = $db->GetAll($sql);
-
- ?>
-
-
-
-
-
-
-
-
-
-
-
value="1" />
-
-
value="1" />
-
value="1" />
+
+?>
+
+
+
+
+
+
+
+
+
"/>
+
+ " class="btn btn-default"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
" data-off="" value="1" />
+
+
+
+
+
+
+
+
+
+
+
+
" data-off="" value="1"/>
+
+
+
+
" data-off="" value="1" />
+
-
"/>
-
-
"/>
+
+
+
+ Execute($sql);
}
-
if (isset($_GET['disable']))
{
$operator_id = intval($_GET['disable']);
@@ -264,52 +345,62 @@ if (isset($_GET['operator_id']))
if ($display)
{
- $sql = "SELECT
- CONCAT(firstName, ' ', lastName) as name,
- e.extension,
- CONCAT('" . TQ_("Windows bat file") . "') as winbat,
- CONCAT('" . TQ_("*nix script file") . "') as sh,
- CASE WHEN enabled = 0 THEN
- CONCAT('" . TQ_("Enable") . "')
- ELSE
- CONCAT('" . TQ_("Disable") . "')
- END
- as enabledisable,
- CASE WHEN voip = 0 THEN
- CONCAT('" . TQ_("Enable VoIP") . "')
- ELSE
- CONCAT('" . TQ_("Disable VoIP") . "')
- END as voipenabledisable,
- CONCAT('" . TQ_("Edit") . "') as edit,
- username
- FROM operator
- LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)";
-
+ $sql = "SELECT operator_id,
+ CONCAT(firstName, ' ', lastName) as name,
+ CONCAT ('', e.extension ,'') as `extension`,
+ CONCAT('" . TQ_("Win .bat file") . "') as winbat,
+ CONCAT('" . TQ_("*nix script file") . "') as sh,
+ CASE WHEN enabled = 0 THEN
+ CONCAT(' ')
+ ELSE
+ CONCAT(' ')
+ END as enabledisable,
+ CASE WHEN voip = 0 THEN
+ CONCAT('" . TQ_("Enable VoIP") . "')
+ ELSE
+ CONCAT('" . TQ_("Disable VoIP") . "')
+ END as voipenabledisable,
+ CONCAT(' ') as edit, username
+ FROM operator
+ LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)";
+
$rs = $db->GetAll($sql);
- xhtml_head(T_("Operator list"),true,array("../css/table.css"));
+ xhtml_head(T_("Operator list"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/font-awesome/css/font-awesome.css","../css/custom.css"));
+
+ $columns = array("operator_id","name","username","extension","enabledisable","edit");
+ $titles = array("ID",T_("Operator"),T_("Username"),T_("Extension")," "," ");
- $columns = array("name","username","extension","enabledisable","edit");
- $titles = array(T_("Operator"),T_("Username"),T_("Extension"),T_("Enable/Disable"),T_("Edit"));
-
if (VOIP_ENABLED)
{
- print "
" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server") . "
" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server"). "";
+
+ print " " . T_("Download Win file") . "";
+ print " " . T_("Download Linux file") . "
" . T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here.") . "
";
+ echo "
" . T_("The username and extension must be unique for each operator.") . "
";
+ echo "
";
}
$sql = "SELECT Time_zone_name as value, Time_zone_name as description
@@ -198,35 +198,119 @@ $sql = "SELECT extension_id as value, extension as description
WHERE current_operator_id IS NULL";
$ers = $db->GetAll($sql);
-
?>
-
-
diff --git a/admin/operatorskill.php b/admin/operatorskill.php
index 2ce676a2..40ed7bbd 100644
--- a/admin/operatorskill.php
+++ b/admin/operatorskill.php
@@ -105,8 +105,6 @@ function vqd($operator_id,$outcome_type_id)
}
-
-
if (isset($_POST['submit']))
{
$db->StartTrans();
@@ -138,7 +136,7 @@ $sql = "SELECT outcome_type_id,description
$outcome_types = $db->GetAll($sql);
-$sql = "SELECT operator_id,firstname as description
+$sql = "SELECT operator_id, CONCAT(firstName,' ', lastName) as description, username
FROM operator
WHERE enabled = 1
ORDER by operator_id ASC";
@@ -146,9 +144,10 @@ $sql = "SELECT operator_id,firstname as description
$operators = $db->GetAll($sql);
-xhtml_head(T_("Assign operators to Skills"),false,array("../css/table.css"));
+xhtml_head(T_("Assign operators to Skills"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../include/jquery/jquery.min.js","../include/iCheck/icheck.min.js"));
+
+print "
" . T_("Set which types of cases will be made available to each operator. Please note that all operators will be allowed to assign all possible outcomes to a case. This restricts which ones will be assigned to an operator.") . "
";
-print "
" . T_("Set which types of cases will be made available to each operator. Please note that all operators will be allowed to assign all possible outcomes to a case. This restricts which ones will be assigned to an operator.") . "
";
?>
@@ -207,7 +206,6 @@ function checkQid(q)
}
-
function checkVid(v)
{
@@ -230,51 +228,52 @@ function checkVid(v)
VidOn = 0;
}
-
-
+
";
$sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn,
count(*) as count
@@ -93,34 +79,35 @@ if ($questionnaire_id != false)
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id)
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
GROUP BY (c.sample_id is not null)";
-
- xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")));
-
- print "
" . T_("Case availability (cases with temporary or appointment outcomes)") ."
" . T_("Case availability (cases with temporary or appointment outcomes)") ."
";
$sql = "SELECT count(c.case_id) as available, si.description
- FROM `case` as c
- LEFT JOIN `call` as a on (a.call_id = c.last_call_id)
- JOIN (sample as s, sample_import as si) on (s.sample_id = c.sample_id and si.sample_import_id = s.import_id)
- JOIN (questionnaire_sample as qs, questionnaire as q, outcome as ou) on (q.questionnaire_id = $questionnaire_id and c.questionnaire_id = q.questionnaire_id and qs.sample_import_id = s.import_id and qs.questionnaire_id = q.questionnaire_id and ou.outcome_id = c.current_outcome_id)
- LEFT JOIN shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end))
- LEFT JOIN appointment as ap on (ap.case_id = c.case_id AND ap.completed_call_id is NULL AND (ap.start > CONVERT_TZ(NOW(),'System','UTC')))
- LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end))
- LEFT JOIN call_restrict as cr on (cr.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= cr.start and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= cr.end)
- LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id)
- LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id)
- LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id)
- WHERE c.current_operator_id IS NULL
- AND ou.outcome_type_id IN (1,5)
- AND (casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end ))
- AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC')))
- AND ap.case_id is NULL
- AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0)
- AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL AND ou.outcome_type_id != 2)
- AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL AND ou.outcome_type_id != 2)
- AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE case_id = c.case_id) < qs.call_attempt_max))
- AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE case_id = c.case_id) < qs.call_max))
- AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
+ FROM `case` as c
+ LEFT JOIN `call` as a on (a.call_id = c.last_call_id)
+ JOIN (sample as s, sample_import as si) on (s.sample_id = c.sample_id and si.sample_import_id = s.import_id)
+ JOIN (questionnaire_sample as qs, questionnaire as q, outcome as ou) on (q.questionnaire_id = $questionnaire_id and c.questionnaire_id = q.questionnaire_id and qs.sample_import_id = s.import_id and qs.questionnaire_id = q.questionnaire_id and ou.outcome_id = c.current_outcome_id)
+ LEFT JOIN shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end))
+ LEFT JOIN appointment as ap on (ap.case_id = c.case_id AND ap.completed_call_id is NULL AND (ap.start > CONVERT_TZ(NOW(),'System','UTC')))
+ LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end))
+ LEFT JOIN call_restrict as cr on (cr.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= cr.start and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= cr.end)
+ LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id)
+ LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id)
+ LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id)
+ WHERE c.current_operator_id IS NULL
+ AND ou.outcome_type_id IN (1,5)
+ AND (casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end ))
+ AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC')))
+ AND ap.case_id is NULL
+ AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0)
+ AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL AND ou.outcome_type_id != 2)
+ AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL AND ou.outcome_type_id != 2)
+ AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) < qs.call_attempt_max))
+ AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE `call`.case_id = c.case_id) < qs.call_max))
+ AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE `questionnaire_sample_quota`.questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND `questionnaire_sample_quota`.quota_reached = 1) = 0
group by s.import_id";
@@ -128,19 +115,19 @@ group by s.import_id";
if (empty($rs))
{
- print "
" . T_("No cases currently available to call") . "
";
+ print "
" . T_("No cases currently available to call") . "
";
}
else
{
xhtml_table($rs,array("description","available"),array(T_("Sample"),T_("Cases currently available to call")),"tclass",false,array("available"));
}
-
+ print "
" . T_("Average time on a completed questionnaire") . ": $mins " . T_("Min") . " $secs " . T_("Secs") . "
";
-
+ print "
" . T_("Average time on a completed questionnaire") . ": $mins " . T_("Min") . " $secs " . T_("Secs") . "
";
$sql = "SELECT o.calc, count( c.case_id )
FROM `case` AS c, `outcome` AS o
@@ -151,16 +138,17 @@ group by s.import_id";
$a = $db->GetAssoc($sql);
$a = aapor_clean($a);
-
- print "
" . T_("Outcome") . "
" . T_("Rate") . "
";
+ print "
" . T_("Outcome") . "
" . T_("Rate") . "
"; // table-hover table table-condensed
print "
" . T_("Response Rate 1") . "
" . round(aapor_rr1($a),2) . "
";
print "
" . T_("Refusal Rate 1") . "
" . round(aapor_ref1($a),2) . "
";
print "
" . T_("Cooperation Rate 1") . "
" . round(aapor_coop1($a),2) . "
";
print "
" . T_("Contact Rate 1") . "
" . round(aapor_con1($a),2) . "
";
- print "
";
+ print "
";
+ $sql = "SELECT count(case_id) FROM `case` WHERE `case`.questionnaire_id = '$questionnaire_id'";
+ $cases = $db->GetOne($sql);
- $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count, ROUND((count(c.case_id) / (SELECT count(case_id) FROM `case` WHERE questionnaire_id = '$questionnaire_id')) * 100,2) as perc
+ $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count, ROUND((count( c.case_id ) / $cases) * 100,2) as perc
FROM `case` AS c, `outcome` AS o
WHERE c.questionnaire_id = '$questionnaire_id'
AND c.current_outcome_id = o.outcome_id
@@ -169,46 +157,12 @@ group by s.import_id";
$rs = $db->GetAll($sql);
if (!empty($rs))
- {
+ { print "
";
+ //print "
" . T_("Total cases for questionnaire") . " = $cases
";
translate_array($rs,array("des"));
- xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc"));
-
- $operator_id = false;
- if (isset($_GET['operator_id'])) $operator_id = bigintval($_GET['operator_id']);
-
- //display a list of operators
- $sql = "SELECT s.operator_id as value,s.firstname as description, CASE WHEN s.operator_id = '$operator_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
- FROM operator as s, operator_questionnaire as q
- WHERE s.operator_id = q.operator_id
- AND q.questionnaire_id = '$questionnaire_id'";
-
- $r = $db->GetAll($sql);
-
- print "
";
- $sql = "SELECT o.description as des, o.outcome_id, count( c.call_id ) as count, ROUND((count(c.call_id) / (SELECT count(call.call_id) FROM `call` JOIN `case` ON (call.case_id = `case`.case_id AND `case`.questionnaire_id = $questionnaire_id ) WHERE call.operator_id = '$operator_id')) * 100,2) as perc
- FROM `call` AS c, `case` as ca, `outcome` AS o
- WHERE ca.questionnaire_id = '$questionnaire_id'
- AND ca.case_id = c.case_id
- AND c.operator_id = '$operator_id'
- AND c.outcome_id = o.outcome_id
- GROUP BY o.outcome_id";
-
- $rs = $db->GetAll($sql);
-
- if (!empty($rs))
- {
- translate_array($rs,array("des"));
- xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc"));
- }
- }
-
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
@@ -221,14 +175,13 @@ group by s.import_id";
$r = $db->GetAll($sql);
- print "
";
$sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn,
count(*) as count
@@ -238,13 +191,13 @@ group by s.import_id";
WHERE s.import_id = '$sample_import_id'
GROUP BY (c.sample_id is not null)";
- xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")));
+ xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")), "tclass", false, array("count"));
+ print "
";
+
+ print "
"; //
" . T_("Outcomes") . "
";
- print "
" . T_("Outcomes") . "
";
-
-
- $sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count,ROUND(count(c.case_id) / (SELECT count(case_id) FROM `case` JOIN sample ON (`case`.sample_id = sample.sample_id AND sample.import_id = '$sample_import_id') WHERE questionnaire_id = '$questionnaire_id' ) * 100,2) as perc
+ $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count,ROUND(count(c.case_id) / (SELECT count(case_id) FROM `case` JOIN sample ON (`case`.sample_id = sample.sample_id AND sample.import_id = '$sample_import_id') WHERE questionnaire_id = '$questionnaire_id' ) * 100,2) as perc
FROM `case` AS c, `outcome` AS o, sample as s
WHERE c.questionnaire_id = '$questionnaire_id'
@@ -262,18 +215,65 @@ group by s.import_id";
}
else
print "
" . T_("No outcomes recorded for this sample") . "
";
+
+ print "
";
}
-
+ $operator_id = false;
+ if (isset($_GET['operator_id'])) $operator_id = bigintval($_GET['operator_id']);
+
+ //display a list of operators !!!worked for this questionnaire_id !!!!
+ $sql = "SELECT s.operator_id as value, s.firstname as description, CASE WHEN s.operator_id = '$operator_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
+ FROM `call` as c , `operator`as s, `case` as ca
+ WHERE ca.questionnaire_id = '$questionnaire_id'
+ AND ca.case_id = c.case_id
+ AND c.operator_id = s.operator_id
+ GROUP by c.operator_id";
+
+ $r = $db->GetAll($sql);
+
+ print "
";
+
+ $sql = "SELECT o.description as des, o.outcome_id, count( c.call_id ) as count, ROUND((count(c.call_id) / (SELECT count(call.call_id) FROM `call` JOIN `case` ON (call.case_id = `case`.case_id AND `case`.questionnaire_id = $questionnaire_id ) WHERE call.operator_id = '$operator_id')) * 100,2) as perc
+ FROM `call` AS c, `case` as ca, `outcome` AS o
+ WHERE ca.questionnaire_id = '$questionnaire_id'
+ AND ca.case_id = c.case_id
+ AND c.operator_id = '$operator_id'
+ AND c.outcome_id = o.outcome_id
+ GROUP BY o.outcome_id";
+
+ $rs = $db->GetAll($sql);
+
+ if (!empty($rs))
+ {
+ translate_array($rs,array("des"));
+ xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc"));
+ }
+ print "
";
+ }
+
}
else
print "
" . T_("No outcomes recorded for this questionnaire") . "
";
//display a list of shifts with completions and a link to either add a report or view reports
- print "
" . T_("Shifts") . "
";
+ print "";
+ print "
" . T_("Shifts") . ":
";
- $sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."')) as description,
- CASE WHEN sr.shift_id IS NULL THEN CONCAT('" . TQ_("No shift reports: Add report") . "') ELSE CONCAT('" . TQ_("View shift reports") . "') END AS link, c.completions as completions, CONCAT('" . TQ_("View operator performance") . "') as operform
+ $sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_FORMAT . "')) as sdate,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "'),'-', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as stime,
+ CASE WHEN sr.shift_id IS NULL THEN
+ CONCAT('')
+ ELSE CONCAT('')
+ END AS link,
+ c.completions as completions,
+ CONCAT('') as operform
FROM `shift` as s
JOIN operator as o on (o.operator_id = '$admin_operator_id')
LEFT JOIN shift_report as sr on (sr.shift_id = s.shift_id)
@@ -292,15 +292,15 @@ group by s.import_id";
$r = $db->GetAll($sql);
if (empty($r))
- print "
" . T_("No shifts defined for this questionnaire") . "
";
+ }
}
-xhtml_foot();
+xhtml_foot($js_foot);
?>
-
diff --git a/admin/questionnaireavailability.php b/admin/questionnaireavailability.php
deleted file mode 100644
index 47c8e530..00000000
--- a/admin/questionnaireavailability.php
+++ /dev/null
@@ -1,157 +0,0 @@
-
- * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011
- * @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("../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['availability_group']))
-{
- //need to add availability_group to questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $availability_group = bigintval($_GET['availability_group']);
-
- $sql = "INSERT INTO questionnaire_availability(questionnaire_id,availability_group_id)
- VALUES('$questionnaire_id','$availability_group')";
-
- $db->Execute($sql);
-
-}
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['ravailability_group']))
-{
- //need to remove rsid from questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $availability_group = bigintval($_GET['ravailability_group']);
-
- $sql = "DELETE FROM questionnaire_availability
- WHERE questionnaire_id = '$questionnaire_id'
- AND availability_group_id = '$availability_group'";
-
- $db->Execute($sql);
-}
-
-
-$questionnaire_id = false;
-if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
-
-xhtml_head(T_("Assign availability group to questionnaire"),true,false,array("../js/window.js"));
-
-print "
" . T_("Assigning an availability group to a questionnaire will allow interviewers to select from those groups to restrict calls to a particular case to the times within the group") ."
";
-
-print "
" . T_("Select a questionnaire from the list below") . "
";
-display_questionnaire_chooser($questionnaire_id);
-
-
-if ($questionnaire_id != false)
-{
-
- $sql = "SELECT q.availability_group_id,a.description as description
- FROM questionnaire_availability as q, availability_group as a
- WHERE q.availability_group_id = a.availability_group_id
- AND q.questionnaire_id = '$questionnaire_id'";
-
- $qs = $db->GetAll($sql);
-
- if (empty($qs))
- {
- print "
" . T_("There are no availability groups selected for this questionnaire") . "
";
- }
- else
- {
- print "
" . T_("Availability groups selected for this questionnaire") . "
";
- }
- }
-
- $sql = "SELECT si.availability_group_id,si.description
- FROM availability_group as si
- LEFT JOIN questionnaire_availability as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
- WHERE q.questionnaire_id is NULL";
-
- $qs = $db->GetAll($sql);
-
- if (!empty($qs))
- {
-
-
- print "
" . T_("Add an availability group to this questionnaire:") . "
";
- ?>
-
-
-
- "/>
-
-
diff --git a/admin/questionnairecatimeslots.php b/admin/questionnairecatimeslots.php
deleted file mode 100644
index 5a563af3..00000000
--- a/admin/questionnairecatimeslots.php
+++ /dev/null
@@ -1,157 +0,0 @@
-
- * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011
- * @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("../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['availability_group']))
-{
- //need to add availability_group to questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $availability_group = bigintval($_GET['availability_group']);
-
- $sql = "INSERT INTO questionnaire_timeslot(questionnaire_id,availability_group_id)
- VALUES('$questionnaire_id','$availability_group')";
-
- $db->Execute($sql);
-
-}
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['ravailability_group']))
-{
- //need to remove rsid from questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $availability_group = bigintval($_GET['ravailability_group']);
-
- $sql = "DELETE FROM questionnaire_timeslot
- WHERE questionnaire_id = '$questionnaire_id'
- AND availability_group_id = '$availability_group'";
-
- $db->Execute($sql);
-}
-
-
-$questionnaire_id = false;
-if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
-
-xhtml_head(T_("Assign call attempt time slots to questionnaire"),true,false,array("../js/window.js"));
-
-print "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
";
-
-print "
" . T_("Select a questionnaire from the list below") . "
";
-display_questionnaire_chooser($questionnaire_id);
-
-
-if ($questionnaire_id != false)
-{
-
- $sql = "SELECT q.availability_group_id,a.description as description
- FROM questionnaire_timeslot as q, availability_group as a
- WHERE q.availability_group_id = a.availability_group_id
- AND q.questionnaire_id = '$questionnaire_id'";
-
- $qs = $db->GetAll($sql);
-
- if (empty($qs))
- {
- print "
" . T_("There are no call attempt time slots selected for this questionnaire") . "
";
- }
- else
- {
- print "
" . T_("Call attempt time slots selected for this questionnaire") . "
";
- }
- }
-
- $sql = "SELECT si.availability_group_id,si.description
- FROM availability_group as si
- LEFT JOIN questionnaire_timeslot as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
- WHERE q.questionnaire_id is NULL";
-
- $qs = $db->GetAll($sql);
-
- if (!empty($qs))
- {
-
-
- print "
" . T_("Add a call attempt time slot to this questionnaire:") . "
";
- ?>
-
-
-
- "/>
-
-
diff --git a/admin/questionnairecatimeslotssample.php b/admin/questionnairecatimeslotssample.php
deleted file mode 100644
index 49c151ba..00000000
--- a/admin/questionnairecatimeslotssample.php
+++ /dev/null
@@ -1,172 +0,0 @@
-
- * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011
- * @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("../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['sample_import_id']) && isset($_GET['availability_group']))
-{
- //need to add availability_group to questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $sample_import_id = bigintval($_GET['sample_import_id']);
- $availability_group = bigintval($_GET['availability_group']);
-
- $sql = "INSERT INTO questionnaire_sample_timeslot (questionnaire_id,sample_import_id,availability_group_id)
- VALUES('$questionnaire_id','$sample_import_id','$availability_group')";
-
- $db->Execute($sql);
-
-}
-
-if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['ravailability_group']))
-{
- //need to remove rsid from questionnaire
-
- $questionnaire_id = bigintval($_GET['questionnaire_id']);
- $sample_import_id = bigintval($_GET['sample_import_id']);
- $availability_group = bigintval($_GET['ravailability_group']);
-
- $sql = "DELETE FROM questionnaire_sample_timeslot
- WHERE questionnaire_id = '$questionnaire_id'
- AND sample_import_id = '$sample_import_id'
- AND availability_group_id = '$availability_group'";
-
-
- $db->Execute($sql);
-}
-
-
-$questionnaire_id = false;
-if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
-
-xhtml_head(T_("Assign call attempt time slots to questionnaire sample"),true,false,array("../js/window.js"));
-
-print "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
";
-
-print "
" . T_("Select a questionnaire from the list below") . "
";
- }
- }
-
- $sql = "SELECT si.availability_group_id,si.description
- FROM availability_group as si
- LEFT JOIN questionnaire_sample_timeslot as q ON (q.sample_import_id = '$sample_import_id' AND q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id)
- WHERE q.questionnaire_id is NULL";
-
- $qs = $db->GetAll($sql);
-
- if (!empty($qs))
- {
-
-
- print "
" . T_("Add a call attempt time slot to this questionnaire sample:") . "
" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "
";
+ print "
" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "
";
print "
" . T_("The questionnaire will be deleted from queXS including call history, cases, case notes, respondent details, appointments and the links between operators, clients and the questionnaire") . "
";
- print "
" . T_("Please confirm you wish to delete the questionnaire") . "
";
+ print "
" . T_("Please confirm you wish to delete the questionnaire") . "
') as description,
+ CASE WHEN enabled = 0 THEN
+ CONCAT(' " . TQ_("Disabled") . " ')
+ ELSE
+ CONCAT(' " . TQ_("Enabled") . " ')
+ END as status,
+ CASE WHEN enabled = 0 THEN
+ CONCAT(' ')
+ ELSE
+ CONCAT(' ')
+ END as enabledisable,
+ CONCAT('') as modify,
+ CONCAT('') as inlime,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as shifts,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as prefill,
+ CASE WHEN enabled = 1 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as deletee,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as outcomes,
+ CONCAT('') as calls,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as dataout,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as assample,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as casestatus
FROM questionnaire";
-
$rs = $db->GetAll($sql);
-
+
+ $columns = array("qid","description","status","enabledisable","outcomes","calls","casestatus","shifts","assample","dataout","modify","inlime","prefill","deletee");
+ xhtml_table($rs,$columns,false,"table-hover table-condensed ");
- xhtml_table($rs,$columns,$titles);
+print "
";
}
-
-
-xhtml_foot();
-
-
+xhtml_foot($js_foot);
?>
+
diff --git a/admin/questionnaireprefill.php b/admin/questionnaireprefill.php
index 48f68870..94dbff31 100644
--- a/admin/questionnaireprefill.php
+++ b/admin/questionnaireprefill.php
@@ -96,18 +96,19 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id'])
$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") . "
";
+xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
+print "
" . T_("Select a questionnaire") . ":
";
-$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
+$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");
+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 (click to delete)") . "
";
+ print "
" . T_("Current pre fills") . "
";
$sql = "SELECT questionnaire_prefill_id,lime_sgqa,value
FROM questionnaire_prefill
@@ -117,19 +118,18 @@ if ($questionnaire_id != false)
if (empty($r))
{
- print "
";
$sql = "SELECT lime_sid
FROM questionnaire
@@ -143,7 +143,7 @@ if ($questionnaire_id != 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,
+ CONCAT( q.sid, 'X', q.gid, 'X', q.qid, ' -> ' , 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)
@@ -154,45 +154,43 @@ if ($questionnaire_id != false)
for ($i=0; $i
";
+
if ($sgqa != false)
{
- print "
" . T_("Enter a value to pre fill this question with:") . "
";
- print "
";
+ 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
+ $sql = "SELECT sivr.var as description, CONCAT('{Sample:', sivr.var, '}') as value
+ FROM `sample_import_var_restrict` as sivr, 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 "";
+ AND sivr.sample_import_id = qs.sample_import_id";
?>
-
";
$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");
-
+display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline pull-left ");
if ($questionnaire_id != false)
{
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
- print "
" . T_("Select a sample from the list below") . "
";
+
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM sample_import as s, questionnaire_sample as q
WHERE q.questionnaire_id = $questionnaire_id
AND q.sample_import_id = s.sample_import_id";
+ $s = $db->GetAll($sql);
+ if (!empty($s)){
+
+ print "
";//(click to delete)
$sql = "SELECT questionnaire_sample_quota_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison
FROM questionnaire_sample_quota as qsq, questionnaire as q
@@ -143,7 +152,7 @@ if ($questionnaire_id != false)
if (empty($r))
{
- print "
";
$sql = "SELECT lime_sid
FROM questionnaire
@@ -177,52 +186,76 @@ if ($questionnaire_id != false)
$sgqa = false;
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
- $sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END, ' -> ' , CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ' : ', lq.question) END) as description, CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
+ $sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value,
+ CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END, ' -> ' , CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ' : ', lq.question) END) as description,
+ CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `" . LIME_PREFIX . "questions` AS lq
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
WHERE lq.sid = '$lime_sid'
ORDER BY CASE WHEN lq2.question_order IS NULL THEN lq.question_order ELSE lq2.question_order + (lq.question_order / 1000) END ASC";
-
-
- display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id");
+
+ display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id",true,true,false,true,"form-group");
+
+ print "";
if ($sgqa != false)
{
- print "
" . T_("Enter the details for creating the quota:") . "
";
- print "
" . T_("Pre defined values for this question:") . "
";
+
+ print "
" . T_("Enter the details for creating the quota:") . "
";
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
" class="btn btn-primary fa"/>
+
+ ";
+
+ print "
" . T_("Code values for this question") . ":
";
$qid = explode("X", $sgqa);
$qid = $qid[2];
- $sql = "SELECT l.code,l.answer as title
+ $sql = "SELECT CONCAT(' ', l.code , '')as code,l.answer as title
FROM `" . LIME_PREFIX . "answers` as l
WHERE l.qid = '$qid'";
$rs = $db->GetAll($sql);
if (!isset($rs) || empty($rs))
- 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");
-
+display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline pull-left ");
if ($questionnaire_id != false)
{
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
-
- print "
" . T_("Select a sample from the list below") . "
";
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM sample_import as s, questionnaire_sample as q
WHERE q.questionnaire_id = $questionnaire_id
AND q.sample_import_id = s.sample_import_id";
+ $s = $db->GetAll($sql);
+ if (!empty($s)){
+ print "
" . TQ_("Delete") . "') as qdelete
+ CONCAT(' ') as qdelete
FROM qsqr_question
WHERE questionnaire_sample_quota_row_id = $qsqri";
-
-
+
$rs = $db->GetAll($sql);
-
+
+ print "
";
+ print "
" . T_("Restrictions based on answered questions") . "
";
+ print "
";
+
if (empty($rs))
{
- print "
" . T_("All completed responses that match the sample criteria below will be counted towards the quota") . "
";
+ print "
" . T_("Currently NO Restrictions based on answered questions") . " " . T_("All completed responses that match the sample criteria below will be counted towards the quota") . "
";
}
else
{
- print "
" . T_("Only completed responses that have answered the following will be counted") . "
";
}
//add questionnaire references if any (refer to sample only or count completions based on responses to questions)
@@ -417,101 +432,136 @@ if ($questionnaire_id != false)
$ssgqa = $db->qstr($_GET['sgqa']);
//select question
- $sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END, ' -> ' , CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ' : ', lq.question) END) as description, CASE WHEN $ssgqa LIKE CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) THEN 'selected=\'selected\'' ELSE '' END AS selected
+ $sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END, ' -> ' , CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ' : ', lq.question) END) as description, CASE WHEN $ssgqa LIKE CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `" . LIME_PREFIX . "questions` AS lq
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
WHERE lq.sid = '$lime_sid'
- ORDER BY CASE WHEN lq2.question_order IS NULL THEN lq.question_order ELSE lq2.question_order + (lq.question_order / 1000) END ASC ";
+ ORDER BY CASE WHEN lq2.question_order IS NULL THEN lq.question_order ELSE lq2.question_order + (lq.question_order / 1000) END ASC";
- $rs = $db->GetAll($sql);
+ $rsgqa = $db->GetAll($sql);
- if (!empty($rs))
+ if (!empty($rsgqa))
{
- print "
";
- print "
" . T_("Add restriction based on answered questions") . "
";
+
//list sample records to exclude
- $sql = "SELECT qsqr_sample_id,exclude_var,exclude_val,comparison,description,
- CONCAT('" . TQ_("Delete") . "') as sdelete
+ $sql = "SELECT qsqr_sample_id,exclude_var_id,exclude_var,exclude_val,comparison,description,
+ CONCAT(' ') as sdelete
FROM qsqr_sample
WHERE questionnaire_sample_quota_row_id = $qsqri";
$rs = $db->GetAll($sql);
-
+
+ print "
";
+ print "
" . T_("Restrictions based on sample records") . "
";
+ print "
";
if (empty($rs))
{
- print "
" . T_("All sample records will be excluded") . "
";
+ print "
" . T_("Currently NO Restrictions based on sample records") . " " . T_("This sample will be limited to number of competions set in quota") . " " . T_("Caling cases for this sample will be stopped when the quota is reached") . "
";
}
else
{
- print "
" . T_("Completed responses that have the following sample details will be counted towards the quota and excluded when the quota is reached") . "
" . T_("Completed responses that have the following sample details will be counted towards the quota and excluded when the quota is reached") . "
";
+ xhtml_table($rs,array('description','exclude_var_id','exclude_var','comparison','exclude_val','sdelete'),array(T_("Description"),T_("Sample var ID"),T_("Sample variable"),T_("Comparison"),T_("Value")," "));
+ print "
";
}
-
- $ssample_var = "''";
- if (isset($_GET['sample_var']))
- $ssample_var = $db->qstr($_GET['sample_var']);
+ $ssample_var_id = "''";
+ if (isset($_GET['sample_var_id'])) $ssample_var_id = $db->qstr($_GET['sample_var_id']);
//add sample references (records from sample to exclude when quota reached)
- $sql = "SELECT sv.var as value, sv.var as description, CASE WHEN sv.var LIKE $ssample_var THEN 'selected=\'selected\'' ELSE '' END AS selected
- FROM sample_var AS sv, sample AS s
- WHERE s.import_id = $sample_import_id
+ $sql = "SELECT sivr.var_id as value, sivr.var as description,
+ CASE WHEN sivr.var_id = $ssample_var_id THEN 'selected=\'selected\'' ELSE '' END AS selected
+ FROM `sample_import_var_restrict` as sivr, `sample_var` AS sv, `sample` AS s
+ WHERE sivr.sample_import_id = $sample_import_id
AND s.sample_id = sv.sample_id
- GROUP BY sv.var";
+ AND sivr.var_id = sv.var_id
+ GROUP BY sivr.var_id";
- $rs = $db->GetAll($sql);
+ $rsvi = $db->GetAll($sql);
- if (!empty($rs))
+ if (!empty($rsvi))
{
- if ($ssample_var == "''")
- $ssample_var = "'" . $rs[0]['value']. "'";
+ if ($ssample_var_id == "''")
+ $ssample_var_id = $rsvi[0]['value'];
- print "
" . T_("Add restriction based on sample records") . "
", T_("Please check selected types for Postcode and/or State"), "
";}
+// ! need to add DB tables check for existing timezone data in tables and additional check if prefix_timezone selected
+ if (( ($fn + $ln) <= 2 )&&($fn == 1 || $ln == 1)) {$ch3 = true;}
+ else { echo "
", T_("Please check selected types for Firstname and/or Lastname"), "
", T_("Too many e-mail fields. Please check selected types for E-mail."), "
"; }
+
+ if ($ch1 && $ch2 && $ch3 && $ch4) */$typecheck = true; //echo $ch1,$ch2,$ch3,$ch4, "typecheck=",$typecheck, "" ;
+
+ if ($typecheck){
+
+ foreach($_POST['type'] as $p => $val)
+ {
+ $sql = "UPDATE sample_import_var_restrict
+ SET `type` = $val
+ WHERE `var_id` = $p";
+ $db->Execute($sql);
+ }
+
+ if (isset($_POST['del'])) {
+ $db->StartTrans();
- unset($_POST['submitvp']);
- unset($_POST['sample_import_id']);
+ foreach($_POST["del"] as $p) {
+ $sql = "DELETE FROM `sample_import_var_restrict`
+ WHERE var_id = $p";
+ $db->Execute($sql);
+ echo "
", T_(" String $p DELETED"), "
";
+
+ $sql = "DELETE FROM `sample_var`
+ WHERE var_id = $p
+ AND sample_id IN (SELECT sample_id FROM `sample` WHERE import_id = $sample_import_id)";
+ $db->Execute($sql);
+ echo "
", T_(" Sample_Var data for variable $p DELETED from this sample"), "
- GetOne($sql);
-
- $sql = "SELECT si.description, sv.val, sv.var,
- CONCAT('') as box,
- sir.restrict IS NULL as existss
- FROM sample_import as si
- JOIN `sample` as s ON (s.import_id = si.sample_import_id AND s.sample_id = $sample_id)
- JOIN sample_var as sv ON (sv.sample_id = s.sample_id)
- LEFT JOIN sample_import_var_restrict as sir ON (sir.sample_import_id = si.sample_import_id AND sir.var = sv.var)
- WHERE si.sample_import_id = $sample_import_id";
-
- $rs = $db->GetAll($sql);
-
- //if not in restrict table, then insert
- foreach($rs as $r)
- {
- if ($r['existss'] == 1)
- {
- $sql = "INSERT INTO sample_import_var_restrict (sample_import_id,var,`restrict`)
- VALUES ($sample_import_id,'{$r['var']}',0)";
-
- $db->Execute($sql);
+ }
+ }
+ else {
+ echo "
", T_("Smth wrong with selected field types. Please check again var types selection and/or fields that you supposed to delete."), "
";
+
+ $sample_import_id = intval($_GET['edit']);
+
+ $sql = "SELECT * FROM sample_import WHERE sample_import_id = $sample_import_id";
+ $sd = $db->GetRow($sql);
+
+ if($sd['enabled'] == 1) $dis = disabled; // -> disable edit and delete if sample is enabled
- $sample_import_id = intval($_GET['edit']);
-
- $sql = "SELECT si.description, sv.val, sv.var,
- CONCAT('') as box
- FROM sample_import as si, sample_var as sv, sample as s
+ $sql = "SELECT type, description
+ FROM sample_var_type";
+ $rd = $db->GetAll($sql);
+
+ $sql = "SELECT sir.var_id,
+ CONCAT('') as var,
+ CONCAT ('') as type, sv.val,
+ CONCAT('') as see,
+ CONCAT('') as del,
+ sir.restrict IS NULL as existss
+ FROM sample_import as si, sample_var as sv, sample as s, sample_import_var_restrict as sir, sample_var_type as svt
WHERE si.sample_import_id = $sample_import_id
+ AND sir.sample_import_id = si.sample_import_id
+ AND sir.var_id = sv.var_id
AND sv.sample_id = s.sample_id
AND s.import_id = si.sample_import_id
- GROUP BY sv.var";
-
+ AND svt.type = sir.type
+ GROUP BY sir.var_id";
$rs = $db->GetAll($sql);
- print "
" . T_("Select which fields from this sample to deidentify.
Deidentified fields will be permanently deleted from the sample.") . "";
+ }
+else
+{
+ print "
" . T_("There's no data in this sample. Probably was deidentified earlier.") . "
";
+
+ /*check `Time_zone_name` and `phone` values for deidentified records*/
+ $sql = "SELECT `sample`.sample_id FROM `sample`
+ LEFT JOIN `sample_var` ON (`sample`.sample_id = `sample_var`.sample_id)
+ WHERE `sample_var`.sample_id IS NULL
+ AND `sample`.import_id = $sample_import_id
+ AND (`sample`.Time_zone_name !='' || `sample`.phone !='')";
+ $rs = $db->GetAll($sql);
+
+ if (!empty($rs)) {
+ $num = count($rs);
+ print "
" . T_("There're still $num records for `Time_zone_name` and `phone` values for deidentified records") . "
";
+
+ print "
";
+ }
+
}
+ unset ($rs);
+ /*check if there's sample_var data not matching sample_import_var_restrict.var_id */
+ $sql = "SELECT `sv`.var_id, `sv`.var, `sv`.type FROM `sample_var` as sv
+ LEFT JOIN `sample_import_var_restrict` as sivr ON (`sivr`.var_id = `sv`.var_id)
+ WHERE `sivr`.var_id IS NULL
+ AND `sv`.sample_id IN (SELECT sample_id FROM `sample` WHERE import_id = $sample_import_id)
+ GROUP BY `sv`.var_id";
+ $rs = $db->GetAll($sql);
+ if (!empty($rs)) {
+ $count = count($rs);
+ //print_r($rs);
+ print "
" . T_("Fix this sample ") . "
";
+ print "
" . $count . " var id's not match
";
+
+/* print "
+
+
+
+
"; */
+ print "
";
+
+ /* if (isset($_POST['restore___'])){
+ $sql = "INSERT INTO sample_import_var_restrict
+ (`sample_import_id`,`var_id`,`var`,`type`,`restrict`)
+ VALUES ($sample_import_id,' ',' ',' ',1)";
+
+ $db->Execute($sql);
+ unset($_POST['restore___']);
+ }
+ if (isset($_POST['delvarf___'])){
+ $sql = "";
+
+ $db->Execute($sql);
+ unset($_POST['delvarf___']);
+ } */
+
+ unset($rs);
+ }
+
+ if (isset($_POST['dtzph'])){
+
+ /*delete `Time_zone_name` and `phone` values for deidentified records*/
+ $db->StartTrans();
+
+ $sql = "UPDATE `sample`
+ LEFT JOIN `sample_var` ON (`sample`.sample_id = `sample_var`.sample_id)
+ SET `Time_zone_name`='',`phone`=''
+ WHERE `sample_var`.sample_id IS NULL
+ AND `sample`.import_id = $sample_import_id";
+ $db->Execute($sql);
+
+ unset($_POST['dtzph']);
+
+ $db->CompleteTrans();
+ }
+
+ xhtml_foot($js_foot);
+ exit();
+}
+
if (isset($_GET['sampledisable']))
{
$id = intval($_GET['sampledisable']);
@@ -242,7 +445,6 @@ if (isset($_GET['sampledisable']))
$sql = "UPDATE sample_import
SET enabled = 0
WHERE sample_import_id = '$id'";
-
$db->Execute($sql);
}
@@ -253,32 +455,52 @@ if (isset($_GET['sampleenable']))
$sql = "UPDATE sample_import
SET enabled = 1
WHERE sample_import_id = '$id'";
-
$db->Execute($sql);
}
-
$sql = "SELECT
- CASE WHEN enabled = 0 THEN
- CONCAT('" . TQ_("Enable") . "')
- ELSE
- CONCAT('" . TQ_("Disable") . "')
- END
- as enabledisable,
- CONCAT('" . TQ_("Deidentify") . "') as did,
- CONCAT('" . TQ_("Operator viewing permissions") . "') as vp,
- CONCAT('" . TQ_("Rename") . "') as rname,
- description
- FROM sample_import";
+ CONCAT(' ',sample_import_id,' ') as id,
+ CASE WHEN enabled = 0 THEN
+ CONCAT(' " . TQ_("Disabled") . " ')
+ ELSE
+ CONCAT(' " . TQ_("Enabled") . " ')
+ END as status,
+ CASE WHEN enabled = 0 THEN
+ CONCAT('" . TQ_("Enable") . " ')
+ ELSE
+ CONCAT(' " . TQ_("Disable") . " ')
+ END
+ as enabledisable,
+ CASE WHEN enabled = 1 THEN
+ CONCAT('')
+ ELSE
+ CONCAT(' + + ')
+ END as did,
+ CASE WHEN enabled = 1 THEN
+ CONCAT('')
+ ELSE
+ CONCAT('')
+ END as delsample,
+ CONCAT('') as ssearch,
+ CONCAT('') as calls,
+ CONCAT('
',description,'
') as description,
+ CONCAT('
',(SELECT COUNT( DISTINCT`sample_var`.sample_id) FROM `sample_var`, `sample` WHERE `sample`.sample_id = `sample_var`.sample_id AND `sample`.import_id = sample_import_id ),'
') as cnt
+ FROM sample_import ORDER BY sample_import_id DESC";
+
+ $rs = $db->GetAll($sql);
-$rs = $db->GetAll($sql);
+$subtitle=T_("Sample list");
+xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
+echo "
";
-
-$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
- FROM sample_import";
-
-$r = $db->GetAll($sql);
-
-if(!empty($r))
- display_chooser($r,"sample_import_id","sample_import_id");
+print "";
if ($sample_import_id != false)
{
- if (isset($_GET['search']))
- {
- $search = $db->qstr($_GET['search']);
-
- $sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN CONCAT('" . TQ_("No cases yet assigned: Delete this sample record") . "') ELSE CONCAT('" . TQ_("Assigned to questionnaire: ") . "', q.description, '') END as link
+ $sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN
+ CONCAT(' ')
+ ELSE CONCAT('', c.case_id ,'')
+ END as link
FROM sample_var AS sv
JOIN (sample as s) ON (s.import_id = '$sample_import_id' and sv.sample_id = s.sample_id)
LEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id )
- WHERE sv.val LIKE $search
- GROUP BY s.sample_id,c.case_id";
-
+ GROUP BY s.sample_id, c.case_id";
$r = $db->GetAll($sql);
+
+ if ($r) {
- if (empty($r))
- print "
" . T_("No records in this sample match this search criteria") . "
";
- else
- {
- //add sample information to results
- $sql = "SELECT var
- FROM sample_var
- WHERE sample_id = {$r[0]['sample_id']}";
-
- $rs = $db->GetAll($sql);
$fnames = array("sample_id");
$fdesc = array(T_("Sample id"));
-
+
+ $fnames[] = "link";
+ $fdesc[] = T_("Case ID");
+
+ $sql = "SELECT var,var_id
+ FROM sample_import_var_restrict
+ WHERE sample_import_id = $sample_import_id
+ ORDER by var ASC";
+ $rs = $db->GetAll($sql);
+
foreach($rs as $rsw)
{
- $fnames[] = $rsw['var'];
+ $fnames[] = $rsw['var_id'];
$fdesc[] = $rsw['var'];
}
-
- $fnames[] = "link";
- $fdesc[] = T_("Link");
-
foreach($r as &$rw)
{
- $sql = "SELECT var,val
+ $sql = "SELECT var_id,val
FROM sample_var
WHERE sample_id = {$rw['sample_id']}";
-
$rs = $db->GetAll($sql);
+ foreach($rs as $rsw){
+ $rw[$rsw['var_id']] = $rsw['val'];
+ }
+ }
- foreach($rs as $rsw)
- $rw[$rsw['var']] = $rsw['val'];
- }
-
- xhtml_table($r,$fnames,$fdesc);
+ print "
";// class='row_to_clone' /* these are not the rows to clone...*/
display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$shift['dt']));
- print "
- $(function() { $('#call_outcome_change').modal('show'); }); ";
}
+
+ //unset($_GET['call_id']);
}
if ($case_id != false)
{
@@ -258,7 +281,7 @@ if ($case_id != false)
$db->CompleteTrans();
}
- $sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd
+ $sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd, s.import_id as sid
FROM `case` as c, `outcome` as o, questionnaire as q, sample as s, sample_import as si
WHERE c.case_id = '$case_id'
AND q.questionnaire_id = c.questionnaire_id
@@ -270,138 +293,201 @@ if ($case_id != false)
if (!empty($rs))
{
- print "
";
+
+ $sql = "SELECT sv.sample_id, c.case_id , s.Time_zone_name,
+ TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time
+ FROM sample_var AS sv
+ LEFT JOIN (`case` AS c , sample as s) ON ( c.sample_id = sv.sample_id AND s.sample_id = c.sample_id ) WHERE c.case_id = '$case_id'
+ GROUP BY sv.sample_id";
+ $r = $db->GetAll($sql);
+ if ($r){
+ $fnames = array("sample_id", "Time_zone_name", "time");
+ $fdesc = array(T_("Sample id"),T_("Timezone"),T_("Time NOW"));
+ $varr= array();
+ $sql = "SELECT var,var_id
+ FROM sample_import_var_restrict
+ WHERE sample_import_id = $sid AND type IN (2,3,6,7)
+ ORDER by var DESC";
+ $rs = $db->GetAll($sql);
- print "
" . T_("Appointments")."
";
+ foreach($rs as $rsw)
+ {
+ $fnames[] = $rsw['var_id'];
+ $fdesc[] = $rsw['var'];
+ $varr[] = $rsw['var_id']; //array for valid var_id's
+ }
+ $varr= implode(",",$varr);
+ foreach($r as &$rw)
+ {
+ $sql = "SELECT var_id,val
+ FROM sample_var
+ WHERE sample_id = {$rw['sample_id']} AND var_id IN ($varr)";
+ $rs = $db->GetAll($sql);
+ foreach($rs as $rsw){
+ $rw[$rsw['var_id']] = $rsw['val'];
+ }
+ }
+
+ xhtml_table($r,$fnames,$fdesc,"tclass");
+ }else{
+ print "
" . T_("No sample data for this case") . "
";
+ }
+ print "
";
+
+ //View appointments
+ print "
" . T_("Appointments")."
";
- //View appointments
- $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',o.Time_zone_name) as start, CONVERT_TZ(a.end,'UTC',o.Time_zone_name) as end, r.firstName, r.lastName, IFNULL(ou.description,'" . T_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName, CONCAT('', c.case_id, '') as case_id, CONCAT('". TQ_("Delete") . "') as link, CONCAT('". TQ_("Edit") . "') as edit
+ $sql = "SELECT
+ 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,'" . T_("Not yet called") . "') as outcome,
+ CONCAT (oo.firstName,' ', oo.lastName) as makerName,
+ CONCAT (ooo.firstName,' ', ooo.lastName) as callerName,
+ 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, operator as o, 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) 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)
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)
WHERE c.case_id = '$case_id'
GROUP BY a.appointment_id
ORDER BY a.start ASC";
$rs = $db->GetAll($sql);
-
+
if (!empty($rs))
{
translate_array($rs,array("outcome"));
- xhtml_table($rs,array("description","start","end","makerName","firstName","lastName","outcome","callerName","link","edit"),array(T_("Questionnaire"),T_("Start"),T_("End"),T_("Operator Name"),T_("Respondent Name"),T_("Surname"),T_("Current outcome"),T_("Operator who called"),T_("Delete"),T_("Edit")));
+ xhtml_table($rs,array("start","end","edit","makerName","resp","outcome","callerName","link"),array(T_("Start"),T_("End")," ",T_("Operator"),T_("Respondent"),T_("Current outcome"),T_("Operator who called")," "),"table-hover table-bordered table-condensed col-sm-10");
}
else
- print "
" . T_("No appointments for this case") . "
";
+ print "
" . T_("No appointments for this case") . "
";
+
+// * disable appointment creation if no sample_id
+ if ($r[0]['sample_id']){
+ $rtz= $r[0]['Time_zone_name'];
+ print " " . T_("Create appointment") . ""; }
- print "
";
//view calls and outcomes
- $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'".DATE_TIME_FORMAT."') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, op.firstName, op.lastName, o.description as des, CONCAT('". TQ_("Edit") . "') as link, cp.phone as phone
+ $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'".DATE_TIME_FORMAT."') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, CONCAT(op.firstName,' ',op.lastName) as firstName, o.description as des, CONCAT(' ') as link, cp.phone as phone
FROM `call` as c
JOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and cp.contact_phone_id = c.contact_phone_id)
WHERE c.case_id = '$case_id'
ORDER BY c.start DESC";
-
$rs = $db->GetAll($sql);
- print "
";
- //view timeslots
- $sql = "SELECT count(*)
+ //view notes
+ $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as time, CONCAT(op.firstName,' ',op.lastName) as firstName, c.note as note, CONCAT('') as link
+ FROM `case_note` as c
+ JOIN (operator as op) on (c.operator_id = op.operator_id)
+ WHERE c.case_id = '$case_id'
+ ORDER BY c.datetime DESC";
+ $rs = $db->GetAll($sql);
+
+ print "
+ ";
+
+ //view timeslots
+ $sql = "SELECT count(*)
FROM questionnaire_timeslot as q, `case` as c
WHERE c.case_id = $case_id
AND c.questionnaire_id = q.questionnaire_id";
- if ($db->GetOne($sql) >= 1)
- {
- print "
" . T_("Call attempts by timeslot") . "
";
-
- $sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca WHERE ca.case_id = c.case_id AND a.availability_group_id = ag.availability_group_id
- AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name))
- AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start
- AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou
+ if ($db->GetOne($sql) >= 1)
+ {
+ $sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca
+ WHERE ca.case_id = c.case_id
+ AND a.availability_group_id = ag.availability_group_id
+ AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name))
+ AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start
+ AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou
FROM availability_group as ag, `case` as c, `questionnaire_timeslot` as qt, sample as s
WHERE c.case_id = '$case_id'
AND s.sample_id = c.sample_id
AND qt.questionnaire_id = c.questionnaire_id AND ag.availability_group_id = qt.availability_group_id";
+ if ( array("cou") >=1){
+ print "
- " . T_("Case not yet started in Limesurvey") . "
";
+ print "
";
+
+ if ($r[0]['sample_id']){ // if sample data exists view availability
+
+ print "
" . T_("Availability groups") . "
";
if (is_using_availability($case_id))
{
-
//List all availability group items and whether selected or not (all selected by default unless >= 1 availability group is in use for this case
$sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id
FROM `case` as c
@@ -413,9 +499,8 @@ if ($case_id != false)
$rs = $db->GetAll($sql);
//Display all availability groups as checkboxes
-
- print "
" . T_("Select groups to limit availability (Selecting none means always available)") . "
";
- print "
";
+ print "
";
+ print "
" . T_("Select groups to limit availability (Selecting none means always available)") . "
" . T_("Allow interviewers to chat with the supervisor over XMPP (Jabber). Required is a BOSH enabled XMPP/Jabber server. The operators and the supervisor will need XMPP/Jabber accounts.") . "
";
+print "
" . T_("Allow interviewers to chat with the supervisor over XMPP (Jabber). Required is a BOSH enabled XMPP/Jabber server. The operators and the supervisor will need XMPP/Jabber accounts.") . "
" . T_("System wide case sorting is periodically (via SYSTEM_SORT_MINUTES configuration directive) sorting cases on a system wide basis instead of finding the most appropriate case each time an operator requests a new case. This may increase performance where there are a large number of cases or complex quotas in place. If you are not experiencing any performance problems, it is not recommended to use this feature.") . "
";
+ print "
" . T_("System wide case sorting is periodically (via SYSTEM_SORT_MINUTES configuration directive) sorting cases on a system wide basis instead of finding the most appropriate case each time an operator requests a new case. This may increase performance where there are a large number of cases or complex quotas in place. If you are not experiencing any performance problems, it is not recommended to use this feature.") . "
";
print "
" . T_("Outcome of last process run (if any)") . "
";
$d = process_get_last_data(2);
if ($d !== false)
diff --git a/admin/systemsortprocess.php b/admin/systemsortprocess.php
index b13e7f43..1a9c3bbc 100644
--- a/admin/systemsortprocess.php
+++ b/admin/systemsortprocess.php
@@ -243,23 +243,26 @@ while (!is_process_killed($process_id)) //check if process killed every $sleepin
LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id)
LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id)
LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id)
- LEFT JOIN questionnaire_timeslot AS qast ON (qast.questionnaire_id = c.questionnaire_id)
- LEFT JOIN questionnaire_sample_timeslot AS qasts ON (qasts.questionnaire_id = c.questionnaire_id AND qasts.sample_import_id = si.sample_import_id)
- WHERE c.current_operator_id IS NULL
- AND c.questionnaire_id = '$questionnaire_id'
+ LEFT JOIN questionnaire_timeslot AS qast ON (qast.questionnaire_id = c.questionnaire_id)
+ LEFT JOIN questionnaire_sample_timeslot AS qasts ON (qasts.questionnaire_id = c.questionnaire_id AND qasts.sample_import_id = si.sample_import_id)
+ WHERE c.current_operator_id IS NULL
+ AND c.questionnaire_id = '$questionnaire_id'
AND ((apn.appointment_id IS NOT NULL) OR casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end ))
- AND ((apn.appointment_id IS NOT NULL) OR qast.questionnaire_id IS NULL OR ((SELECT COUNT(*) FROM availability WHERE availability.availability_group_id = qast.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= availability.end)) >= 1 AND (SELECT COUNT(call_attempt_id) FROM `call_attempt`, availability WHERE call_attempt.case_id = c.case_id AND (availability.availability_group_id = qast.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end))) = ( SELECT (SELECT COUNT(*) FROM availability, call_attempt WHERE call_attempt.case_id = c.case_id AND availability.availability_group_id = availability_group.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end)) as cou FROM availability_group, questionnaire_timeslot WHERE questionnaire_timeslot.questionnaire_id = c.questionnaire_id AND availability_group.availability_group_id = questionnaire_timeslot.availability_group_id ORDER BY cou ASC LIMIT 1)))
- AND ((apn.appointment_id IS NOT NULL) OR qasts.questionnaire_id IS NULL OR ((SELECT COUNT(*) FROM availability WHERE availability.availability_group_id = qasts.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= availability.end)) >= 1 AND (SELECT COUNT(call_attempt_id) FROM `call_attempt`, availability WHERE call_attempt.case_id = c.case_id AND (availability.availability_group_id = qasts.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end))) = ( SELECT (SELECT COUNT(*) FROM availability, call_attempt WHERE call_attempt.case_id = c.case_id AND availability.availability_group_id = availability_group.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end)) as cou FROM availability_group, questionnaire_sample_timeslot WHERE questionnaire_sample_timeslot.questionnaire_id = c.questionnaire_id AND questionnaire_sample_timeslot.sample_import_id = si.sample_import_id AND availability_group.availability_group_id = questionnaire_sample_timeslot.availability_group_id ORDER BY cou ASC LIMIT 1)))
+
+ AND ((apn.appointment_id IS NOT NULL) OR qast.questionnaire_id IS NULL OR ((SELECT COUNT(*) FROM availability WHERE availability.availability_group_id = qast.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= availability.end)) >= 1 AND (SELECT COUNT(call_attempt_id) FROM `call_attempt`, availability WHERE call_attempt.case_id = c.case_id AND (availability.availability_group_id = qast.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end))) = ( SELECT (SELECT COUNT(*) FROM availability, call_attempt WHERE call_attempt.case_id = c.case_id AND availability.availability_group_id = availability_group.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end)) as cou FROM availability_group, questionnaire_timeslot WHERE questionnaire_timeslot.questionnaire_id = c.questionnaire_id AND availability_group.availability_group_id = questionnaire_timeslot.availability_group_id ORDER BY cou ASC LIMIT 1)))
+
+ AND ((apn.appointment_id IS NOT NULL) OR qasts.questionnaire_id IS NULL OR ((SELECT COUNT(*) FROM availability WHERE availability.availability_group_id = qasts.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= availability.end)) >= 1 AND (SELECT COUNT(call_attempt_id) FROM `call_attempt`, availability WHERE call_attempt.case_id = c.case_id AND (availability.availability_group_id = qasts.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end))) = ( SELECT (SELECT COUNT(*) FROM availability, call_attempt WHERE call_attempt.case_id = c.case_id AND availability.availability_group_id = availability_group.availability_group_id AND (availability.day_of_week = DAYOFWEEK(CONVERT_TZ(call_attempt.start,'UTC',s.Time_zone_name)) AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) >= availability.start AND TIME(CONVERT_TZ(call_attempt.start, 'UTC' , s.Time_zone_name)) <= availability.end)) as cou FROM availability_group, questionnaire_sample_timeslot WHERE questionnaire_sample_timeslot.questionnaire_id = c.questionnaire_id AND questionnaire_sample_timeslot.sample_import_id = si.sample_import_id AND availability_group.availability_group_id = questionnaire_sample_timeslot.availability_group_id ORDER BY cou ASC LIMIT 1)))
+
AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC')))
AND ap.case_id is NULL
AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0)
AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL)
AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL)
- AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE case_id = c.case_id) < qs.call_attempt_max))
- AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE case_id = c.case_id) < qs.call_max))
+ AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) < qs.call_attempt_max))
+ AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE `call`.case_id = c.case_id) < qs.call_max))
AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND quota_reached = 1) = 0
GROUP BY c.case_id
- ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, qsep.priority DESC, a.start ASC";
+ ORDER BY IF(ISNULL(apn.end),1,0),apn.end ASC, qsep.priority DESC, CONVERT_TZ(NOW(), 'System' , s.Time_zone_name) DESC , a.start ASC";
$rs = $db->GetAll($sql);
diff --git a/admin/timezonetemplate.php b/admin/timezonetemplate.php
index 963de5bd..ae0fe2e5 100644
--- a/admin/timezonetemplate.php
+++ b/admin/timezonetemplate.php
@@ -57,10 +57,10 @@ include("../functions/functions.input.php");
global $db;
-
if (isset($_POST['dtime_zone']))
{
set_setting('DEFAULT_TIME_ZONE', $_POST['dtime_zone']);
+
}
if (isset($_GET['time_zone']))
@@ -89,49 +89,48 @@ if (isset($_GET['tz']))
}
-xhtml_head(T_("Add/Remove Timezones"),true,array("../css/shifts.css"),array("../js/window.js"));
+xhtml_head(T_("Set Timezones"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); //,"../include/bootstrap/css/bootstrap-theme.min.css"
$dtz = get_setting("DEFAULT_TIME_ZONE");
$sql = "SELECT name as value, name as description,
CASE WHEN name LIKE '$dtz' THEN 'selected=\'selected\'' ELSE '' END AS selected
- FROM mysql.time_zone_name";
+ FROM mysql.time_zone_name";
$tzl = $db->GetAll($sql);
if (empty($tzl) || !$tzl)
{
- print "
') AS timediff,
+CONCAT('" . T_("Remove") . "') as link
+ FROM timezone_template ORDER BY time ASC";
$qs = $db->GetAll($sql);
+ xhtml_table($qs, array("Time_zone_name","timediff","time","link"), array(T_("Timezone name"),T_("Time diff to Default Time zone"),T_("Current time"),T_("Remove")));
+print "
";
}
/**
@@ -485,21 +459,19 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon
// Build the days in the month
$Month->build();
- ?>
-
-
- getTimeStamp())); ?>
-
-
-
M
-
T
-
W
-
T
-
F
-
S
-
S
-
-";
+ print "
" . T_( date('F Y',$Month->getTimeStamp())) . "
+
+
+
" . T_("Mon") . "
+
" . T_("Tue") . "
+
" . T_("Wed") . "
+
" . T_("Thu") . "
+
" . T_("Fri") . "
+
" . T_("Sat") . "
+
" . T_("Sun") . "
+
";
while ( $Day = $Month->fetch() ) {
@@ -512,7 +484,6 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon
$today = "";
if ($year == $Day->thisYear() && $month == $Day->thisMonth() && $day == $Day->thisDay()) $today = "today";
-
// isFirst() to find start of week
if ( $Day->isFirst() )
echo ( "
\n" );
@@ -525,7 +496,7 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon
//if it is in the past -> unavailable
if ($Day->getTimeStamp() < $ttoday->getTimeStamp())
{
- echo ( "
".$Day->thisDay()."
\n" );
+ echo ( "
".$Day->thisDay()."
\n" );
}
//if there are shift restrictions, restrict
else if ($restricted)
@@ -540,16 +511,16 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon
if (!empty($rs) && $rs->RecordCount() == 0)
{
- echo ( "
" . date('l j F Y',mktime(0,0,0,$month,$day,$year)) . "
";
}
-
-
-?>
+?>
\ No newline at end of file
diff --git a/functions/functions.client.php b/functions/functions.client.php
index d1ec7479..0815f873 100644
--- a/functions/functions.client.php
+++ b/functions/functions.client.php
@@ -87,3 +87,4 @@ function get_client_questionnaire($client_id)
}
+?>
\ No newline at end of file
diff --git a/functions/functions.display.php b/functions/functions.display.php
index 7046caa5..51ae666e 100644
--- a/functions/functions.display.php
+++ b/functions/functions.display.php
@@ -3,8 +3,6 @@
* Functions relating to displaying for XHTML
*
*
- *
- *
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
@@ -31,7 +29,6 @@
*
*/
-
/**
* Configuration file
*/
@@ -43,30 +40,23 @@ include_once(dirname(__FILE__).'/../config.inc.php');
include_once(dirname(__FILE__).'/../db.inc.php');
-
-
-
-
-
-
/**
* Display a list of questionnaires to choose from in a drop down list
*
* @param int|bool $questionnaire_id The questionnaire id or false if none selecetd
*
*/
-function display_questionnaire_chooser($questionnaire_id = false, $overall = false)
+function display_questionnaire_chooser($questionnaire_id = false, $overall = false, $divclass=false, $selectclass=false)
{
global $db;
-
$sql = "SELECT questionnaire_id,description,CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire
WHERE enabled = 1";
$rs = $db->GetAll($sql);
- print "