mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
NEW Admin panel pages: questionnairelist.php, samplelist.php, samplesearch.php,
updated callhistory.php, custom.css aded library bootstrap-toggle, bootstrap-confirmation.js
This commit is contained in:
@@ -54,16 +54,11 @@ $css = array(
|
||||
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
|
||||
"../include/font-awesome-4.3.0/css/font-awesome.css",
|
||||
"../include/bs-data-table/css/jquery.bdt.css",
|
||||
//"../css/bootstrap-switch.min.css",
|
||||
//"../css/table.css",
|
||||
"../css/custom.css"
|
||||
);
|
||||
$js_head = array(
|
||||
//"../js/modernizr.js",
|
||||
"../js/jquery-2.1.3.min.js",
|
||||
//"//code.jquery.com/jquery-migrate-1.2.1.min.js",
|
||||
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
|
||||
//"../js/bootstrap-switch.min.js"
|
||||
"../include/bootstrap-3.3.2/js/bootstrap.min.js"
|
||||
);
|
||||
$js_foot = array(
|
||||
"../include/bs-data-table/js/vendor/jquery.sortelements.js",
|
||||
@@ -77,41 +72,48 @@ $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)
|
||||
{
|
||||
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 '¶   \r' ) FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes,";
|
||||
(SELECT GROUP_CONCAT(cn1.note SEPARATOR '</br>¶ ' ) 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('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') ";
|
||||
if (isset($_GET['csv'])) $sql .= " c.case_id ";
|
||||
else $sql .= " CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') ";
|
||||
|
||||
$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),
|
||||
contact_phone, sample_import, sample
|
||||
WHERE c.contact_phone_id = contact_phone.contact_phone_id AND sample_import.sample_import_id = sample.import_id
|
||||
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";
|
||||
|
||||
else $sql .= " LIMIT 5000";
|
||||
|
||||
$rs = $db->Execute($sql);
|
||||
|
||||
if (empty($rs))
|
||||
{
|
||||
print "<div class='alert alert-warning col-sm-4'>" . T_("No calls ever made") . "</div>";
|
||||
print "<div class='alert alert-warning col-sm-6'>" . T_("No calls ever made") . "</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_GET['csv']))
|
||||
{
|
||||
$fn = "callhistory" . date("_d-M-Y__H-i") . ".csv";
|
||||
{
|
||||
$qds = str_replace(' ','_',$_GET['dq']); $smpds = str_replace(' ','_',$_GET['ds']);
|
||||
$fn = "callhistory-" . $qds . $smpds . date("_d-M-Y_H-i") . ".csv";
|
||||
|
||||
header("Content-Type: text/csv");
|
||||
header("Content-Disposition: attachment; filename=$fn");
|
||||
@@ -119,7 +121,7 @@ if ($operator_id)
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
header("Pragma: no-cache"); // HTTP/1.0
|
||||
|
||||
|
||||
echo(T_("Date") . ",".T_("Start time") . "," . T_("End time") . "," . T_("Case ID") . "," . T_("Questionnaire") . "," . T_("Sample") . "," . T_("Phone number") . "," . T_("Operator") . "," . T_("Outcome") . ",".T_("Case notes")."," . T_("Respondent") . "\n");
|
||||
|
||||
while ($r = $rs->FetchRow())
|
||||
@@ -127,22 +129,40 @@ if ($operator_id)
|
||||
translate_array($r,array("des"));
|
||||
echo $r['start_date'] . "," .$r['start_time'] . "," . $r['end'] . "," . $r['case_id'] . "," . $r['qd'] . "," . $r['spl'] . "," . $r['cpi'] . "," . $r['opname'] . "," . $r['descr'] . "," . $r['casenotes'] . "," . $r['firstName'] . "\n";
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rs = $rs->GetArray();
|
||||
translate_array($rs,array("des"));
|
||||
xhtml_head(T_("Call History List"),true,$css,$js_head); //array("../css/table.css")
|
||||
print "<a href='?csv=csv' class='btn btn-default pull-right'><i class='fa fa-download fa-lg text-primary'></i> " . T_("Download Call History List") . "</a>";
|
||||
xhtml_table($rs,array("start_date", "start_time", "end","case_id","qd","spl","cpi","opname","descr","casenotes","firstName"),array(T_("Date"), T_("Start time"), T_("End time"),T_("Case ID"),T_("Questionnaire"),T_("Sample"),T_("Phone number"),T_("Operator"),T_("Outcome"),T_("Case notes"),T_("Respondent")), "tclass",false,false,"bs-table");
|
||||
xhtml_head(T_("Call History List"),true,$css,$js_head);
|
||||
echo "<div class='form-group col-sm-2'><a href='' onclick='history.back();return false;' class='btn btn-default'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a></div>";
|
||||
|
||||
$datacol = array("start_date", "start_time","end","case_id","qd","spl","cpi","opname","descr","casenotes","firstName");
|
||||
$headers = array(T_("Date"), T_("Start time"), T_("End time"),T_("Case ID"),T_("Questionnaire"),T_("Sample"),T_("Phone number"),T_("Operator"),T_("Outcome"),T_("Case notes"),T_("Respondent"));
|
||||
|
||||
if (isset($_GET['questionnaire_id'])){
|
||||
$sql = "SELECT description FROM `questionnaire` WHERE `questionnaire_id` = $qid ";
|
||||
$dq = $db->GetOne($sql);
|
||||
print "<h3><small>" . T_("Questionnaire") . " ID: $qid</small> " . $dq . "</h3>";
|
||||
unset($datacol[4]); unset($headers[4]); }
|
||||
|
||||
if (isset($_GET['sample_import_id'])){
|
||||
$sql = "SELECT description FROM `sample_import` WHERE `sample_import_id` = $sid ";
|
||||
$ds = $db->GetOne($sql);
|
||||
print "<h3><small>" . T_("Sample") . " ID: $sid</small> " . $ds . "</h3>";
|
||||
unset($datacol[5]); unset($headers[5]); }
|
||||
|
||||
print "<a href='?csv=csv&questionnaire_id=$qid&dq=" . $dq . "&sample_import_id=$sid&ds=" . $ds . "' class='btn btn-default pull-right'><i class='fa fa-download fa-lg text-primary'></i> " . T_("Download Call History List") . "</a>";
|
||||
|
||||
xhtml_table($rs,$datacol,$headers,"tclass",false,false,"bs-table");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
print "<div class='alert alert-warning col-sm-4'>" . T_("No operator") . "</div>";
|
||||
print "<div class='alert alert-warning col-sm-6'>" . T_("No operator") . "</div>";
|
||||
}
|
||||
|
||||
xhtml_foot($js_foot);
|
||||
|
||||
@@ -1,421 +1,511 @@
|
||||
<?php
|
||||
/**
|
||||
* Manage questionnaires by editing them or disabling/enabling them
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||
* @copyright Australian Consortium for Social and Political Research Incorporated (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");
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
/**
|
||||
* CKEditor
|
||||
*/
|
||||
include("../include/ckeditor/ckeditor.php");
|
||||
|
||||
global $db;
|
||||
|
||||
|
||||
if (isset($_POST['questionnaire_id']) && isset($_POST['submit']))
|
||||
{
|
||||
//Delete the questionnaire
|
||||
|
||||
$questionnaire_id = intval($_POST['questionnaire_id']);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "DELETE FROM `appointment`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `call`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
$sql = "DELETE FROM `call_attempt`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
$sql = "DELETE FROM `case_availability`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `case_note`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `contact_phone`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `respondent`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `client_questionnaire`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `operator_questionnaire`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_availability`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_prefill`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_exclude_priority`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_quota`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_quota_row`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_quota_row_exclude`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `shift_report`
|
||||
WHERE shift_id IN
|
||||
(SELECT shift_id
|
||||
FROM `shift`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `shift`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$db->CompleteTrans();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['disable']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['disable']);
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET enabled = 0
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if (isset($_GET['enable']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['enable']);
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET enabled = 1
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if (isset($_POST['update']) && isset($_GET['modify']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['modify']);
|
||||
|
||||
$ras =0;
|
||||
$rws = 0;
|
||||
$rs = 0;
|
||||
$respsc = 0;
|
||||
$referral = 0;
|
||||
if (isset($_POST['ras'])) $ras = 1;
|
||||
if (isset($_POST['rws'])) $rws = 1;
|
||||
if (isset($_POST['respsc'])) $respsc = 1;
|
||||
if (isset($_POST['referral'])) $referral = 1;
|
||||
|
||||
$name = $db->qstr(html_entity_decode($_POST['description'],ENT_QUOTES,'UTF-8'));
|
||||
if (isset($_POST['rs_intro']))
|
||||
{
|
||||
$rs = 1;
|
||||
$rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8'));
|
||||
}
|
||||
$info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8'));
|
||||
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws', self_complete = $respsc, referral = $referral
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
if ($rs)
|
||||
{
|
||||
$sql = "UPDATE questionnaire
|
||||
SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if ($respsc == 1)
|
||||
{
|
||||
$lime_mode = $db->qstr($_POST['lime_mode'],get_magic_quotes_gpc());
|
||||
$lime_template = $db->qstr($_POST['lime_template'],get_magic_quotes_gpc());
|
||||
$lime_endurl = $db->qstr($_POST['lime_endurl'],get_magic_quotes_gpc());
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
xhtml_head(T_("Questionnaire list"),true,array("../css/table.css"),array("../js/new.js"));
|
||||
|
||||
|
||||
if (isset($_GET['modify']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['modify']);
|
||||
|
||||
$CKEditor = new CKEditor();
|
||||
$CKEditor->basePath = "../include/ckeditor/";
|
||||
|
||||
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
|
||||
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
|
||||
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
|
||||
"/",
|
||||
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
|
||||
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
|
||||
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
|
||||
array('BidiLtr', 'BidiRtl'),
|
||||
array('Link','Unlink','Anchor'),
|
||||
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
|
||||
"/",
|
||||
array('Styles','Format','Font','FontSize'),
|
||||
array('TextColor','BGColor'),
|
||||
array('About')),
|
||||
"extraPlugins" => "tokens");
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM questionnaire
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$rs = $db->GetRow($sql);
|
||||
|
||||
$referral = $testing = $rws = $ras = $rsc = "checked=\"checked\"";
|
||||
$rscd = "";
|
||||
|
||||
$aio = $qbq = $gat = "";
|
||||
if ($rs['lime_mode'] == "survey") $aio = "selected=\"selected\"";
|
||||
if ($rs['lime_mode'] == "question") $qbq = "selected=\"selected\"";
|
||||
if ($rs['lime_mode'] == "group") $gat = "selected=\"selected\"";
|
||||
|
||||
|
||||
if ($rs['restrict_appointments_shifts'] != 1) $ras = "";
|
||||
if ($rs['restrict_work_shifts'] != 1) $rws = "";
|
||||
if ($rs['testing'] != 1) $testing = "";
|
||||
if ($rs['referral'] != 1) $referral = "";
|
||||
if ($rs['self_complete'] == 0)
|
||||
{
|
||||
$rsc = "";
|
||||
$rscd = "style='display:none;'";
|
||||
}
|
||||
|
||||
echo "<h1>" . $rs['description'] . "</h1>";
|
||||
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
|
||||
echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'>" . T_("Edit instrument in Limesurvey") . "</a></p>";
|
||||
?>
|
||||
<form action="?modify=<?php echo $questionnaire_id; ?>" method="post">
|
||||
<p><?php echo T_("Name for questionnaire:"); ?> <input type="text" name="description" value="<?php echo $rs['description']; ?>"/></p>
|
||||
<p><?php echo T_("Restrict appointments to shifts?"); ?> <input name="ras" type="checkbox" <?php echo $ras; ?>/></p>
|
||||
<p><?php echo T_("Restrict work to shifts?"); ?> <input name="rws" type="checkbox" <?php echo $rws; ?>/></p>
|
||||
<p><?php echo T_("Questionnaire for testing only?"); ?> <input name="testing" type="checkbox" disabled="true" <?php echo $testing; ?>/></p>
|
||||
<p><?php echo T_("Allow operators to generate referrals?"); ?> <input name="referral" type="checkbox" <?php echo $referral; ?>/></p>
|
||||
<p><?php echo T_("Allow for respondent self completion via email invitation?"); ?> <input name="respsc" type="checkbox" <?php echo $rsc ?> onchange="if(this.checked==true) show(this,'limesc'); else hide(this,'limesc');" /></p>
|
||||
<div id='limesc' <?php echo $rscd; ?>>
|
||||
<p><?php echo T_("Questionnaire display mode for respondent");?>: <select name="lime_mode"><option <?php echo $aio;?> value="survey"><?php echo T_("All in one"); ?></option><option <?php echo $qbq; ?> value="question"><?php echo T_("Question by question"); ?></option><option <?php echo $gat; ?> value="group"><?php echo T_("Group at a time"); ?></option></select></p>
|
||||
<p><?php echo T_("Limesurvey template for respondent");?>: <select name="lime_template">
|
||||
<?php
|
||||
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != ".." && is_dir(dirname(__FILE__)."/../include/limesurvey/templates/" . $entry)){
|
||||
echo "<option value=\"$entry\" ";
|
||||
if ($rs['lime_template'] == $entry) echo " selected=\"selected\" ";
|
||||
echo ">$entry</option>";
|
||||
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
?>
|
||||
</select></p>
|
||||
<p><?php echo T_("URL to forward respondents on self completion (required)");?>: <input name="lime_endurl" type="text" value="<?php echo $rs['lime_endurl']; ?>"/></p>
|
||||
</div>
|
||||
<?php if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) { ?>
|
||||
<p><?php echo T_("Respondent selection introduction:"); echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);?></p>
|
||||
<p><?php echo T_("Respondent selection project introduction:"); echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);?></p>
|
||||
<p><?php echo T_("Respondent selection callback (already started questionnaire):"); echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);?> </p>
|
||||
<p><?php echo T_("Message to leave on an answering machine:"); echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);?> </p>
|
||||
<?php } else if (!empty($rs['lime_rs_sid'])) { echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_rs_sid']}'>" . T_("Edit respondent selection instrument in Limesurvey") . "</a></p>"; } ?>
|
||||
<p><?php echo T_("Project end text (thank you screen):");echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig); ?></p>
|
||||
<p><?php echo T_("Project information for interviewers/operators:");echo $CKEditor->editor("info",$rs['info'],$ckeditorConfig); ?></p>
|
||||
<p><input type="submit" name="update" value="<?php echo T_("Update Questionnaire"); ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
}
|
||||
else if (isset($_GET['delete']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['delete']);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM questionnaire
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$rs = $db->GetRow($sql);
|
||||
|
||||
echo "<h1>" . $rs['description'] . "</h1>";
|
||||
|
||||
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
|
||||
|
||||
print "<p>" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "</p>";
|
||||
print "<p>" . 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") . "</p>";
|
||||
print "<p>" . T_("Please confirm you wish to delete the questionnaire") . "</p>";
|
||||
|
||||
print "<form method='post' action='?'>";
|
||||
print "<p><input type='submit' name='submit' value=\"" . T_("Delete this questionnaire") . "\"/>";
|
||||
print "<input type='hidden' name='questionnaire_id' value='$questionnaire_id'/></p>";
|
||||
print "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$columns = array("description","enabledisable","modify","deletee");
|
||||
$titles = array(T_("Questionnaire"),T_("Enable/Disable"),T_("Modify"),T_("Delete"));
|
||||
|
||||
$sql = "SELECT
|
||||
description,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<a href=\'?enable=',questionnaire_id,'\'>" . TQ_("Enable") . "</a>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'?disable=',questionnaire_id,'\'>" . TQ_("Disable") . "</a>')
|
||||
END
|
||||
as enabledisable,
|
||||
CONCAT('<a href=\'?modify=',questionnaire_id,'\'>" . TQ_("Modify"). "</a>') as modify,
|
||||
CONCAT('<a href=\'?delete=',questionnaire_id,'\'>" . TQ_("Delete"). "</a>') as deletee
|
||||
FROM questionnaire";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
|
||||
xhtml_table($rs,$columns,$titles);
|
||||
}
|
||||
|
||||
|
||||
xhtml_foot();
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Manage questionnaires by editing them or disabling/enabling them
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||
* @copyright Australian Consortium for Social and Political Research Incorporated (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");
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
/**
|
||||
* CKEditor
|
||||
*/
|
||||
include("../include/ckeditor/ckeditor.php");
|
||||
|
||||
global $db;
|
||||
|
||||
$css = array(
|
||||
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
|
||||
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
|
||||
"../include/font-awesome-4.3.0/css/font-awesome.css",
|
||||
"../include/bootstrap-toggle/css/bootstrap-toggle.min.css",
|
||||
"../css/custom.css"
|
||||
);
|
||||
$js_head = array(
|
||||
"../js/jquery-2.1.3.min.js",
|
||||
"../include/bootstrap-3.3.2/js/bootstrap.min.js"
|
||||
);
|
||||
$js_foot = array(
|
||||
"../js/new.js",
|
||||
"../include/bootstrap-toggle/js/bootstrap-toggle.min.js",
|
||||
"../js/bootstrap-confirmation.js",
|
||||
"../js/custom.js"
|
||||
);
|
||||
|
||||
if (isset($_POST['questionnaire_id']) && isset($_POST['submit']))
|
||||
{
|
||||
//Delete the questionnaire
|
||||
|
||||
$questionnaire_id = intval($_POST['questionnaire_id']);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "DELETE FROM `appointment`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `call`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
$sql = "DELETE FROM `call_attempt`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
|
||||
$sql = "DELETE FROM `case_availability`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `case_note`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `contact_phone`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `respondent`
|
||||
WHERE case_id IN
|
||||
(SELECT case_id
|
||||
FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `client_questionnaire`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `operator_questionnaire`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_availability`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_prefill`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_exclude_priority`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_quota`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_quota_row`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire_sample_quota_row_exclude`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `shift_report`
|
||||
WHERE shift_id IN
|
||||
(SELECT shift_id
|
||||
FROM `shift`
|
||||
WHERE questionnaire_id = $questionnaire_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `shift`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `case`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM `questionnaire`
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$db->CompleteTrans();
|
||||
}
|
||||
|
||||
if (isset($_GET['disable']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['disable']);
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET enabled = 0
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if (isset($_GET['enable']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['enable']);
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET enabled = 1
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if (isset($_POST['update']) && isset($_GET['modify']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['modify']);
|
||||
|
||||
$ras =0;
|
||||
$rws = 0;
|
||||
$rs = 0;
|
||||
$respsc = 0;
|
||||
$referral = 0;
|
||||
if (isset($_POST['ras'])) $ras = 1;
|
||||
if (isset($_POST['rws'])) $rws = 1;
|
||||
if (isset($_POST['respsc'])) $respsc = 1;
|
||||
if (isset($_POST['referral'])) $referral = 1;
|
||||
|
||||
$name = $db->qstr(html_entity_decode($_POST['description'],ENT_QUOTES,'UTF-8'));
|
||||
if (isset($_POST['rs_intro']))
|
||||
{
|
||||
$rs = 1;
|
||||
$rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8'));
|
||||
}
|
||||
$info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8'));
|
||||
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8'));
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws', self_complete = $respsc, referral = $referral
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
if ($rs)
|
||||
{
|
||||
$sql = "UPDATE questionnaire
|
||||
SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine
|
||||
WHERE questionnaire_id = '$questionnaire_id'";
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if ($respsc == 1)
|
||||
{
|
||||
$lime_mode = $db->qstr($_POST['lime_mode'],get_magic_quotes_gpc());
|
||||
$lime_template = $db->qstr($_POST['lime_template'],get_magic_quotes_gpc());
|
||||
$lime_endurl = $db->qstr($_POST['lime_endurl'],get_magic_quotes_gpc());
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
$db->Execute($sql);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['modify']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['modify']);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM questionnaire
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
$rs = $db->GetRow($sql);
|
||||
|
||||
$referral = $testing = $rws = $ras = $rsc = "checked=\"checked\"";
|
||||
$rscd = "";
|
||||
|
||||
$aio = $qbq = $gat = "";
|
||||
if ($rs['lime_mode'] == "survey") $aio = "selected=\"selected\"";
|
||||
if ($rs['lime_mode'] == "question") $qbq = "selected=\"selected\"";
|
||||
if ($rs['lime_mode'] == "group") $gat = "selected=\"selected\"";
|
||||
|
||||
if ($rs['restrict_appointments_shifts'] != 1) $ras = "";
|
||||
if ($rs['restrict_work_shifts'] != 1) $rws = "";
|
||||
if ($rs['testing'] != 1) $testing = "";
|
||||
if ($rs['referral'] != 1) $referral = "";
|
||||
if ($rs['self_complete'] == 0)
|
||||
{
|
||||
$rsc = "";
|
||||
$rscd = "style='display:none;'";
|
||||
}
|
||||
|
||||
xhtml_head(T_("Modify Questionnaire "),true,$css,$js_head, false, false, false, "  <span class=' text-uppercase'>" . "$rs[description]" . "</span>");
|
||||
|
||||
$CKEditor = new CKEditor();
|
||||
$CKEditor->basePath = "../include/ckeditor/";
|
||||
|
||||
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
|
||||
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
|
||||
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
|
||||
array('Link','Unlink','Anchor'),
|
||||
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
|
||||
array('About'),
|
||||
"/",
|
||||
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
|
||||
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
|
||||
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
|
||||
array('BidiLtr', 'BidiRtl'),
|
||||
array('Styles','Format','Font','FontSize'),
|
||||
array('TextColor','BGColor')),
|
||||
"extraPlugins" => "tokens");
|
||||
?>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2"><a href='questionnairelist.php' class='btn btn-default pull-left' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i> <?php echo T_("Go back"); ?></a></div>
|
||||
<div class="col-sm-8"><?php // ?> </div>
|
||||
<div class="col-sm-2"><?php echo "<a class='btn btn-default btn-lime pull-right' href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'><i class='fa fa-edit' style='color:blue;'></i> " . T_("Edit instrument in Limesurvey") . " </a>"; ?> </div>
|
||||
</div>
|
||||
|
||||
<form action="?modify=<?php echo $questionnaire_id; ?>" method="post" class="form-horizontal col-sm-12">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Edit")," ", T_("Name for questionnaire:"); ?> </label>
|
||||
<div class="col-sm-4"><input type="text" name="description" class="form-control" value="<?php echo $rs['description']; ?>" label="<?php echo T_("Name for questionnaire:") ; ?> "/></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Restrict appointments to shifts?"); ?> </label>
|
||||
<div class="col-sm-4" style="height: 30px;"><input name="ras" type="checkbox" <?php echo $ras; ?> data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/> </div>
|
||||
</div>
|
||||
<div class="form-group"><label class="col-sm-4 control-label" ><?php echo T_("Restrict work to shifts?"); ?> </label>
|
||||
<div class="col-sm-4" style="height: 30px;" ><input name="rws" type="checkbox" <?php echo $rws; ?> data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Questionnaire for testing only?"); ?> </label>
|
||||
<div class="col-sm-4" style="height: 30px;" ><input name="testing" type="checkbox" disabled="true" data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>" <?php echo $testing; ?> data-onstyle="danger" /></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Allow operators to generate referrals?"); ?></label>
|
||||
<div class="col-sm-4" style="height: 30px;"> <input name="referral" type="checkbox" <?php echo $referral; ?> data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Allow for respondent self completion via email invitation?"); ?> </label>
|
||||
<div class="col-sm-4" style="height: 30px;"><input name="respsc" id="respsc" type="checkbox" <?php echo $rsc ?> onchange="if(this.checked==true) show(this,'limesc'); else hide(this,'limesc');" data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/></div>
|
||||
</div>
|
||||
<div id="limesc" <?php echo $rscd; ?> >
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Questionnaire display mode for respondent");?>: </label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" name="lime_mode">
|
||||
<option <?php echo $aio;?> value="survey"><?php echo T_("All in one"); ?></option>
|
||||
<option <?php echo $qbq;?> value="question"><?php echo T_("Question by question"); ?></option>
|
||||
<option <?php echo $gat;?> value="group"><?php echo T_("Group at a time"); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label" ><?php echo T_("Limesurvey template for respondent");?>: </label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" name="lime_template">
|
||||
<?php
|
||||
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != ".." && is_dir(dirname(__FILE__)."/../include/limesurvey/templates/" . $entry)){
|
||||
echo "<option value=\"$entry\" ";
|
||||
if ($rs['lime_template'] == $entry) echo " selected=\"selected\" ";
|
||||
echo ">$entry</option>";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label text-danger" ><?php echo T_("URL to forward respondents on self completion (required)");?>: </label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" name="lime_endurl" type="text" value="<?php echo $rs['lime_endurl']; ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) {
|
||||
echo "<p><h4 style='text-align:center;' >" . T_("Respondent selection introduction:") . "</h4>"; echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);
|
||||
echo "</p><p><h4 style='text-align:center;' >" . T_("Respondent selection project introduction:") . "</h4>"; echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);
|
||||
echo "</p><p><h4 style='text-align:center;' >" . T_("Respondent selection callback (already started questionnaire):") . "</h4>"; echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);
|
||||
echo "</p><p><h4 style='text-align:center;' >" . T_("Message to leave on an answering machine:") . "</h4>"; echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);
|
||||
echo "</p>"; }
|
||||
else if (!empty($rs['lime_rs_sid'])) { echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_rs_sid']}'>" . T_("Edit respondent selection instrument in Limesurvey") . "</a></p>"; }
|
||||
echo "<p><h4 style='text-align:center;' >" . T_("Project end text (thank you screen):") . "</h4>"; echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig);
|
||||
echo "</p><p><h4 style='text-align:center;' >" . T_("Project information for interviewers/operators:") . "</h4>"; echo $CKEditor->editor("info",$rs['info'],$ckeditorConfig);
|
||||
echo "</p>";
|
||||
?>
|
||||
<p><a href="questionnairelist.php" class="btn btn-default"><i class="fa fa-chevron-left fa-lg" style="color:blue;"></i> <?php echo T_("Go back") ; ?></a><input type="submit" class="btn btn-primary col-sm-offset-4" name="update" value="<?php echo T_("Update Questionnaire"); ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
else if (isset($_GET['delete']))
|
||||
{
|
||||
$questionnaire_id = intval($_GET['delete']);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM questionnaire
|
||||
WHERE questionnaire_id = $questionnaire_id";
|
||||
$rs = $db->GetRow($sql);
|
||||
|
||||
xhtml_head(T_("Delete Questionnaire"),true,$css,$js_head, false, false, false, " <span class='text-uppercase'>" . "$rs[description]" . "</span>");
|
||||
|
||||
print "<div class='alert alert-danger'><p>" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "</p>";
|
||||
print "<p>" . 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") . "</p>";
|
||||
print "<p>" . T_("Please confirm you wish to delete the questionnaire") . "</p></div>";
|
||||
|
||||
print "<form method='post' action='?'>";
|
||||
print "<p>  <a href='questionnairelist.php' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i> " . T_("Go back") . "</a><input type='submit' name='submit' class='btn btn-danger col-sm-offset-4' value=\"" . T_("Delete this questionnaire") . "\"/>";
|
||||
print "<input type='hidden' name='questionnaire_id' value='$questionnaire_id'/></p>";
|
||||
print "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
xhtml_head(T_("Questionnaire management"),true,$css,$js_head, false, false, false, "Questionnaire list");
|
||||
echo "<div class='form-group'>
|
||||
<a href='' onclick='history.back();return false;' class='btn btn-default'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>
|
||||
<a href='new.php' class='btn btn-default col-sm-offset-6' ><i class='fa fa-file-text-o fa-lg'></i> " . T_("Create a new questionnaire") . "</a>
|
||||
</div>";
|
||||
print "<div>"; // add timeslots, callattempts, quotas?
|
||||
|
||||
$sql = "SELECT
|
||||
CONCAT(' <b class=\'badge\'>',questionnaire_id,'</b> ') as qid,
|
||||
CONCAT('<h4>',description,'</h4>') as description,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT(' <span class=\'btn label label-default\'>" . TQ_("Disabled") . "</span> ')
|
||||
ELSE
|
||||
CONCAT(' <span class=\'btn label label-primary\'>" . TQ_("Enabled") . "</span> ')
|
||||
END as status,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT(' <a href=\'?enable=',questionnaire_id,'\'><i data-toggle=\'tooltip\' title=\'" . TQ_("Enable") . "\' class=\'fa fa-toggle-off fa-3x\' style=\'color:grey;\'></i></a> ')
|
||||
ELSE
|
||||
CONCAT(' <a href=\'\' data-toggle=\'confirmation\' data-href=\'?disable=',questionnaire_id,'\'><i data-toggle=\'tooltip\' title=\'" . TQ_("Disable") . "\' class=\'fa fa-toggle-on fa-3x\'></i></a> ')
|
||||
END as enabledisable,
|
||||
CONCAT('<a href=\'?modify=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Edit Questionnaire") . " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-edit fa-2x \'></i></a>') as modify,
|
||||
CONCAT('<a href=\'" . LIME_URL . "admin/admin.php?sid=',lime_sid,'\' class=\'btn\' title=\'" . T_("Edit Lime survey") . " ',lime_sid,'\' data-toggle=\'tooltip\'><i class=\'btn-lime fa fa-lemon-o fa-2x\'></i></a>') as inlime,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-calendar fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'addshift.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Shifts") . " \n" . TQ_("questionnaire") . " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-calendar fa-2x\'></i></a>')
|
||||
END as shifts,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-square-o fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'questionnaireprefill.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Pre-fill questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-check-square-o fa-2x\'></i></a>')
|
||||
END as prefill,
|
||||
CASE WHEN enabled = 1 THEN
|
||||
CONCAT('<i class=\'btn fa fa-trash-o fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'?delete=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Delete questionnaire") . " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-trash-o fa-2x\' style=\'color:red;\'></i></a>')
|
||||
END as deletee,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-bar-chart fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'outcomes.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Outcomes for questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-bar-chart fa-2x\'></i></a>')
|
||||
END as outcomes,
|
||||
CONCAT('<a href=\'callhistory.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Call history"). " \n" . TQ_("questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-phone fa-2x\'></i></a>') as calls,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-download fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'dataoutput.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Data output"). " \n" . TQ_("questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-download fa-2x\'></i></a>')
|
||||
END as dataout,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-book fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'assignsample.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Assigned samples"). "\' data-toggle=\'tooltip\'><i class=\'fa fa-book fa-2x\'></i></a>')
|
||||
END as assample,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-question-circle fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'casestatus.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Case status and assignment"). "\' data-toggle=\'tooltip\'><i class=\'fa fa-question-circle fa-2x\'></i></a>')
|
||||
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 ");
|
||||
|
||||
print "</div>";
|
||||
}
|
||||
xhtml_foot($js_foot);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('[data-toggle="confirmation"]').confirmation()
|
||||
</script>
|
||||
@@ -1,284 +1,315 @@
|
||||
<?php
|
||||
/**
|
||||
* List operators and allow for customised VoIP downloads, changing passwords, disabling, etc
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013
|
||||
* @package queXS
|
||||
* @subpackage admin
|
||||
* @link http://www.acspri.org.au/software queXS was writen for ACSPRI
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../config.inc.php');
|
||||
|
||||
/**
|
||||
* Database
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../db.inc.php');
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../functions/functions.xhtml.php');
|
||||
|
||||
|
||||
|
||||
if (isset($_POST['submitr']))
|
||||
{
|
||||
$sample_import_id = intval($_POST['sample_import_id']);
|
||||
|
||||
$sql = "UPDATE sample_import
|
||||
SET description = " . $db->qstr($_POST['description']) . "
|
||||
WHERE sample_import_id = $sample_import_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$_GET['rename'] = $sample_import_id;
|
||||
}
|
||||
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
$sample_import_id = intval($_POST['sample_import_id']);
|
||||
|
||||
unset($_POST['submit']);
|
||||
unset($_POST['sample_import_id']);
|
||||
|
||||
foreach($_POST as $p)
|
||||
{
|
||||
$sql = "DELETE FROM sample_var
|
||||
WHERE var LIKE " . $db->qstr($p) . "
|
||||
AND sample_id IN
|
||||
(SELECT sample_id
|
||||
FROM sample
|
||||
WHERE import_id = $sample_import_id)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
}
|
||||
|
||||
$_GET['edit'] = $sample_import_id;
|
||||
}
|
||||
|
||||
if (isset($_POST['submitvp']))
|
||||
{
|
||||
$sample_import_id = intval($_POST['sample_import_id']);
|
||||
|
||||
unset($_POST['submitvp']);
|
||||
unset($_POST['sample_import_id']);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "UPDATE sample_import_var_restrict
|
||||
SET `restrict` = 1
|
||||
WHERE sample_import_id = $sample_import_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
foreach($_POST as $p => $val)
|
||||
{
|
||||
$sql = "UPDATE sample_import_var_restrict
|
||||
SET `restrict` = 0
|
||||
WHERE sample_import_id = $sample_import_id
|
||||
AND `var` LIKE " . $db->qstr($p);
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
$db->CompleteTrans();
|
||||
|
||||
$_GET['view'] = $sample_import_id;
|
||||
}
|
||||
|
||||
if (isset($_GET['rename']))
|
||||
{
|
||||
xhtml_head(T_("Rename"),true,array("../css/table.css"));
|
||||
|
||||
$sample_import_id = intval($_GET['rename']);
|
||||
|
||||
$sql = "SELECT description
|
||||
FROM sample_import
|
||||
WHERE sample_import_id = $sample_import_id";
|
||||
|
||||
$rs = $db->GetOne($sql);
|
||||
|
||||
print "<h2>" . T_("Rename") . ": " . $rs. "</h2>";
|
||||
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
|
||||
|
||||
?>
|
||||
<form action="?" method="post">
|
||||
<div><label for='description'><?php echo T_("Description") . ": "; ?></label><input type='text' name='description' value="<?php echo $rs;?>"/></div>
|
||||
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div>
|
||||
<div><input type="submit" name="submitr" value="<?php echo T_("Rename");?>"/></div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
|
||||
xhtml_foot();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['view']))
|
||||
{
|
||||
xhtml_head(T_("Operator viewing permissions"),true,array("../css/table.css"));
|
||||
|
||||
$sample_import_id = intval($_GET['view']);
|
||||
|
||||
$sql = "SELECT sample_id
|
||||
FROM `sample`
|
||||
WHERE import_id = $sample_import_id";
|
||||
|
||||
$sample_id = $db->GetOne($sql);
|
||||
|
||||
$sql = "SELECT si.description, sv.val, sv.var,
|
||||
CONCAT('<input type=\'checkbox\' ', CASE WHEN (sir.restrict IS NULL || sir.restrict = 0) THEN 'checked=\"checked\"' ELSE '' END ,' name=\'',sv.var,'\' value=\'11\'/>') 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);
|
||||
}
|
||||
}
|
||||
|
||||
print "<h2>" . T_("Operator viewing permissions") . ": " . $rs[0]['description'] . "</h2>";
|
||||
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
|
||||
|
||||
print "<p>" . T_("Select which fields from this sample should be able to be viewed by operators") . "</p>";
|
||||
|
||||
?>
|
||||
<form action="?" method="post">
|
||||
<?php
|
||||
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Allow operator to see?")));
|
||||
?>
|
||||
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div>
|
||||
<div><input type="submit" name="submitvp" value="<?php echo T_("Save changes");?>"/></div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
|
||||
xhtml_foot();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
if (isset($_GET['edit']))
|
||||
{
|
||||
xhtml_head(T_("Deidentify"),true,array("../css/table.css"));
|
||||
|
||||
$sample_import_id = intval($_GET['edit']);
|
||||
|
||||
$sql = "SELECT si.description, sv.val, sv.var,
|
||||
CONCAT('<input type=\'checkbox\' name=\'',sv.var,'\' value=\'',sv.var,'\'/>') as box
|
||||
FROM sample_import as si, sample_var as sv, sample as s
|
||||
WHERE si.sample_import_id = $sample_import_id
|
||||
AND sv.sample_id = s.sample_id
|
||||
AND s.import_id = si.sample_import_id
|
||||
GROUP BY sv.var";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
print "<h2>" . T_("Deidentify") . ": " . $rs[0]['description'] . "</h2>";
|
||||
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
|
||||
|
||||
print "<p>" . T_("Select which fields from this sample to deidentify. Deidentified fields will be permanently deleted from the sample.") . "</p>";
|
||||
|
||||
?>
|
||||
<form action="?" method="post">
|
||||
<?php
|
||||
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Deidentify")));
|
||||
?>
|
||||
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div>
|
||||
<div><input type="submit" name="submit" value="<?php echo T_("Delete selected fields");?>"/></div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
|
||||
xhtml_foot();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isset($_GET['sampledisable']))
|
||||
{
|
||||
$id = intval($_GET['sampledisable']);
|
||||
|
||||
$sql = "UPDATE sample_import
|
||||
SET enabled = 0
|
||||
WHERE sample_import_id = '$id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if (isset($_GET['sampleenable']))
|
||||
{
|
||||
$id = intval($_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('<a href=\'?sampleenable=',sample_import_id,'\'>" . TQ_("Enable") . "</a>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'?sampledisable=',sample_import_id,'\'>" . TQ_("Disable") . "</a>')
|
||||
END
|
||||
as enabledisable,
|
||||
CONCAT('<a href=\'?edit=',sample_import_id,'\'>" . TQ_("Deidentify") . "</a>') as did,
|
||||
CONCAT('<a href=\'?view=',sample_import_id,'\'>" . TQ_("Operator viewing permissions") . "</a>') as vp,
|
||||
CONCAT('<a href=\'?rename=',sample_import_id,'\'>" . TQ_("Rename") . "</a>') as rname,
|
||||
description
|
||||
FROM sample_import";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
xhtml_head(T_("Sample list"),true,array("../css/table.css"));
|
||||
|
||||
$columns = array("description","enabledisable","did","vp","rname");
|
||||
$titles = array(T_("Sample"),T_("Enable/Disable"),T_("Deidentify"),T_("Operator viewing permissions"),T_("Rename"));
|
||||
|
||||
xhtml_table($rs,$columns,$titles);
|
||||
|
||||
xhtml_foot();
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* List operators and allow for customised VoIP downloads, changing passwords, disabling, etc
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013
|
||||
* @package queXS
|
||||
* @subpackage admin
|
||||
* @link http://www.acspri.org.au/software queXS was writen for ACSPRI
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../config.inc.php');
|
||||
|
||||
/**
|
||||
* Database
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../db.inc.php');
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../functions/functions.xhtml.php');
|
||||
|
||||
$css = array(
|
||||
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
|
||||
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
|
||||
"../include/font-awesome-4.3.0/css/font-awesome.css",
|
||||
"../css/bootstrap-switch.min.css",
|
||||
"../css/custom.css"
|
||||
);
|
||||
$js_head = array(
|
||||
"../js/jquery-2.1.3.min.js",
|
||||
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
|
||||
"../js/bootstrap-switch.min.js"
|
||||
);
|
||||
$js_foot = array(
|
||||
"../js/bootstrap-confirmation.js",
|
||||
"../js/custom.js"
|
||||
);
|
||||
|
||||
if (isset($_POST['submitr']))
|
||||
{
|
||||
$sample_import_id = intval($_POST['sample_import_id']);
|
||||
|
||||
$sql = "UPDATE sample_import
|
||||
SET description = " . $db->qstr($_POST['description']) . "
|
||||
WHERE sample_import_id = $sample_import_id";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$_GET['rename'] = $sample_import_id;
|
||||
}
|
||||
|
||||
if (isset($_POST['submit']))
|
||||
{
|
||||
$sample_import_id = intval($_POST['sample_import_id']);
|
||||
|
||||
unset($_POST['submit']);
|
||||
unset($_POST['sample_import_id']);
|
||||
|
||||
foreach($_POST as $p)
|
||||
{
|
||||
$sql = "DELETE FROM sample_var
|
||||
WHERE var LIKE " . $db->qstr($p) . "
|
||||
AND sample_id IN
|
||||
(SELECT sample_id
|
||||
FROM sample
|
||||
WHERE import_id = $sample_import_id)";
|
||||
$db->Execute($sql);
|
||||
|
||||
}
|
||||
|
||||
$_GET['edit'] = $sample_import_id;
|
||||
}
|
||||
|
||||
if (isset($_POST['submitvp']))
|
||||
{
|
||||
$sample_import_id = intval($_POST['sample_import_id']);
|
||||
|
||||
unset($_POST['submitvp']);
|
||||
unset($_POST['sample_import_id']);
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "UPDATE sample_import_var_restrict
|
||||
SET `restrict` = 1
|
||||
WHERE sample_import_id = $sample_import_id";
|
||||
$db->Execute($sql);
|
||||
|
||||
foreach($_POST as $p => $val)
|
||||
{
|
||||
$sql = "UPDATE sample_import_var_restrict
|
||||
SET `restrict` = 0
|
||||
WHERE sample_import_id = $sample_import_id
|
||||
AND `var` LIKE " . $db->qstr($p);
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
$db->CompleteTrans();
|
||||
|
||||
$_GET['view'] = $sample_import_id;
|
||||
}
|
||||
|
||||
if (isset($_GET['rename']))
|
||||
{
|
||||
$subtitle=T_("Rename sample");
|
||||
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
|
||||
|
||||
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i> " . T_("Go back") . "</a>";
|
||||
$sample_import_id = intval($_GET['rename']);
|
||||
|
||||
$sql = "SELECT description
|
||||
FROM sample_import
|
||||
WHERE sample_import_id = $sample_import_id";
|
||||
$rs = $db->GetOne($sql);
|
||||
|
||||
print "<h3>" . T_("Sample current description") . ": <span class='text-primary'>" . $rs . "</span></h3>";
|
||||
?>
|
||||
<form action="?" method="post" class="form-group " >
|
||||
<div class="form-group">
|
||||
<h4 class="col-sm-3 control-label text-right" for="description"><?php echo T_("Enter")," ", T_("new")," ", T_("Description"), ":" ; ?></h4>
|
||||
<div class="col-sm-4"><input type='text' name='description' class="form-control" value="<?php echo $rs;?>"/></div>
|
||||
</div>
|
||||
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div>
|
||||
<div><button type="submit" name="submitr" class="btn btn-default"><i class="fa fa-edit fa-lg fa-fw text-primary"></i> <?php echo T_("Rename");?></button></div>
|
||||
</form>
|
||||
<?php
|
||||
xhtml_foot();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['view']))
|
||||
{
|
||||
$subtitle=T_("Operator viewing permissions");
|
||||
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
|
||||
|
||||
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i> " . T_("Go back") . "</a>";
|
||||
|
||||
$sample_import_id = intval($_GET['view']);
|
||||
|
||||
$sql = "SELECT sample_id
|
||||
FROM `sample`
|
||||
WHERE import_id = $sample_import_id";
|
||||
|
||||
$sample_id = $db->GetOne($sql);
|
||||
|
||||
$sql = "SELECT si.description, sv.val, sv.var,
|
||||
CONCAT('<input type=\'checkbox\' ', CASE WHEN (sir.restrict IS NULL || sir.restrict = 0) THEN 'checked=\"checked\"' ELSE '' END ,' name=\'',sv.var,'\' value=\'11\' switch=\'yes\' data-size=\'small\' data-on-text=" . TQ_("Yes") . " data-off-text=" . TQ_("No") . " />') 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);
|
||||
}
|
||||
}
|
||||
|
||||
print "<h3>" . T_("Operator viewing permissions") . " ". T_("for") . " " . T_("sample") . ": " . $rs[0]['description'] . "</h3>";
|
||||
if (!$rs) print "<div class='alert alert-info col-sm-6' role='alert'><h4>" . T_("There's no data in this sample. ") . "</h4></div>";
|
||||
else {
|
||||
print "<div class='alert alert-info' role='alert'><p>" . T_("Select which fields from this sample should be able to be viewed by operators") . "</p></div>
|
||||
<form action='?' method='post' class='form-group form-horisontal'>";
|
||||
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Allow operator to see?")));
|
||||
?>
|
||||
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div></br>
|
||||
<div class="col-md-offset-4"><button type="submit" name="submitvp" class="btn btn-default"> <i class="fa fa-eye fa-lg fa-fw text-primary"></i> <?php echo T_("Save changes");?></button></div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$('[switch="yes"]').bootstrapSwitch();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
xhtml_foot();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['edit']))
|
||||
{
|
||||
$subtitle=T_("Delete sample variables") ;
|
||||
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
|
||||
|
||||
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i> " . T_("Go back") . "</a>";
|
||||
|
||||
$sample_import_id = intval($_GET['edit']);
|
||||
|
||||
$sql = "SELECT si.description, sv.val, sv.var,
|
||||
CONCAT('<input type=\'checkbox\' name=\'',sv.var,'\' value=\'',sv.var,'\' switch=\'yes\' data-size=\'small\' data-on-color=\'danger\' data-on-text=" . TQ_("Yes") . " data-off-text=" . TQ_("No") . " />') as box
|
||||
FROM sample_import as si, sample_var as sv, sample as s
|
||||
WHERE si.sample_import_id = $sample_import_id
|
||||
AND sv.sample_id = s.sample_id
|
||||
AND s.import_id = si.sample_import_id
|
||||
GROUP BY sv.var";
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
print "<h3>" . T_("Sample") . ": " . $rs[0]['description'] . "</h3>";
|
||||
|
||||
if ($rs){
|
||||
print "<div class='alert alert-danger' role='alert'><p>" . T_("Select which fields from this sample to deidentify. Deidentified fields will be permanently deleted from the sample.") . "</p></div>";
|
||||
?>
|
||||
<form action="?" method="post">
|
||||
<?php
|
||||
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Delete")));
|
||||
?>
|
||||
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div>
|
||||
</br>
|
||||
<div class="col-md-offset-3"><button type="submit" name="submit" class="btn btn-danger"> <i class="fa fa-trash-o fa-lg fa-fw "></i> <?php echo T_("Delete selected fields");?></button></div>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$('[switch="yes"]').bootstrapSwitch();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<div class='alert alert-info col-sm-6' role='alert'><h4>" . T_("There's no data in this sample. Probably was deidentified earlier.") . "</h4></div>";
|
||||
}
|
||||
xhtml_foot();
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($_GET['sampledisable']))
|
||||
{
|
||||
$id = intval($_GET['sampledisable']);
|
||||
|
||||
$sql = "UPDATE sample_import
|
||||
SET enabled = 0
|
||||
WHERE sample_import_id = '$id'";
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
if (isset($_GET['sampleenable']))
|
||||
{
|
||||
$id = intval($_GET['sampleenable']);
|
||||
|
||||
$sql = "UPDATE sample_import
|
||||
SET enabled = 1
|
||||
WHERE sample_import_id = '$id'";
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
CONCAT(' <b class=\'badge\'>',sample_import_id,'</b> ') as id,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('  <span class=\'btn label label-default\'>" . TQ_("Disabled") . "</span> ')
|
||||
ELSE
|
||||
CONCAT('  <span class=\'btn label label-primary\'>" . TQ_("Enabled") . "</span> ')
|
||||
END as status,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<a href=\'?sampleenable=',sample_import_id,'\' class=\'btn btn-default col-sm-12\'>" . TQ_("Enable") . " <i class=\'fa fa-play fa-lg\' style=\'color:blue;\'></i></a>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'\' class=\'btn btn-default col-sm-12\' data-toggle=\'confirmation\' data-href=\'?sampledisable=',sample_import_id,'\' data-title=\'" . TQ_("ARE YOU SHURE?") . "\' data-btnOkLabel=\'" . TQ_("Yes") . "\' data-btnCancelLabel=\'" . TQ_("Cancel") . "\'><i class=\'fa fa-ban fa-lg\' style=\'color:red;\'></i>  " . TQ_("Disable") . "</a> ')
|
||||
END
|
||||
as enabledisable,
|
||||
CASE WHEN enabled = 1 THEN
|
||||
CONCAT('<a href=\'?edit=',sample_import_id,'\' class=\'btn btn-default disabled\'><i class=\'fa fa-minus-circle fa-lg fa-fw\' style=\'color:grey;\'></i></a>')
|
||||
ELSE
|
||||
CONCAT('<a href=\'?edit=',sample_import_id,'\' class=\'btn btn-default \' data-toggle=\'tooltip\' title=\'" . TQ_("Deidentify") . "\'><i class=\'fa fa-minus-circle fa-lg fa-fw text-danger \'></i></a>')
|
||||
END as did,
|
||||
CONCAT('<a href=\'?view=',sample_import_id,'\' class=\'btn btn-default\' data-toggle=\'tooltip\' title=\'" . TQ_("Viewing permissions") . "\'><i class=\'fa fa-eye fa-lg fa-fw text-primary\'></i></a>') as vp,
|
||||
CONCAT('<a href=\'?rename=',sample_import_id,'\' class=\'btn btn-default\' data-toggle=\'tooltip\' title=\'" . TQ_("Rename") . "\'><i class=\'fa fa-edit fa-lg fa-fw text-primary\'></i></a>') as rname,
|
||||
CONCAT('<a href=\'samplesearch.php?sample_import_id=',sample_import_id,'\' class=\'btn btn-default\' data-toggle=\'tooltip\' title=\'" . TQ_("Search the sample") . "',sample_import_id,'\'><i class=\'fa fa-search fa-lg fa-fw text-primary\'></i></a>') as ssearch,
|
||||
CONCAT('<a href=\'callhistory.php?sample_import_id=',sample_import_id,'\' class=\'btn btn-default\' data-toggle=\'tooltip\' title=\'" . TQ_("Call history"). " \n" . TQ_("sample"). " ',sample_import_id,'\'><i class=\'fa fa-phone fa-lg text-primary\'></i></a>') as calls,
|
||||
CONCAT('<h4>',description,' </h4>') as description
|
||||
FROM sample_import";
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$subtitle=T_("Sample list");
|
||||
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
|
||||
echo "<div class='form-group'>
|
||||
<a href='' onclick='history.back();return false;' class='btn btn-default'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a>
|
||||
<a href='import.php' class='btn btn-default col-sm-offset-4' ><i class='fa fa-upload fa-lg'></i> " . T_("Import a sample file") . "</a>
|
||||
</div>";
|
||||
$columns = array("id","description","status","enabledisable","calls","did","vp","rname", "ssearch");
|
||||
//$titles = array(T_("ID"),T_("Sample"), T_("Call History"),T_("Enable/Disable"), T_("Status"), T_("Deidentify"), T_("View"), T_("Rename"), T_("Search"));
|
||||
xhtml_table($rs,$columns, false, "table-hover table-condensed ");
|
||||
|
||||
xhtml_foot($js_foot);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
//$('[switch="yes"]').bootstrapSwitch()
|
||||
$('[data-toggle="confirmation"]').confirmation()
|
||||
</script>
|
||||
@@ -1,166 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* Select and search within a sample to see what case(s) is/are assigned to a sample record
|
||||
* and if so to look at them, otherwise give the option to remove a sample record
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@deakin.edu.au>
|
||||
* @copyright Deakin University 2007,2008
|
||||
* @package queXS
|
||||
* @subpackage admin
|
||||
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
include("../config.inc.php");
|
||||
|
||||
/**
|
||||
* Database file
|
||||
*/
|
||||
include ("../db.inc.php");
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
include("../functions/functions.xhtml.php");
|
||||
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
global $db;
|
||||
|
||||
|
||||
if (isset($_GET['sample_id']))
|
||||
{
|
||||
//need to remove this sample record from the sample
|
||||
|
||||
$sample_id = bigintval($_GET['sample_id']);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "DELETE FROM sample_var
|
||||
WHERE sample_id = '$sample_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM sample
|
||||
WHERE sample_id = '$sample_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$db->CompleteTrans();
|
||||
}
|
||||
|
||||
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
|
||||
xhtml_head(T_("Search sample"),true,array("../css/table.css"),array("../js/window.js"));
|
||||
print "<h1>" . T_("Select a sample from the list below") . "</h1>";
|
||||
|
||||
$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");
|
||||
|
||||
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('<a href=\'?sample_import_id=$sample_import_id&sample_id=', sv.sample_id , '\'>" . TQ_("No cases yet assigned: Delete this sample record") . "</a>') ELSE CONCAT('<a href=\'supervisor.php?case_id=', c.case_id , '\'>" . TQ_("Assigned to questionnaire: ") . "', q.description, '</a>') 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";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
if (empty($r))
|
||||
print "<p>" . T_("No records in this sample match this search criteria") . "</p>";
|
||||
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"));
|
||||
|
||||
foreach($rs as $rsw)
|
||||
{
|
||||
$fnames[] = $rsw['var'];
|
||||
$fdesc[] = $rsw['var'];
|
||||
}
|
||||
|
||||
$fnames[] = "link";
|
||||
$fdesc[] = T_("Link");
|
||||
|
||||
foreach($r as &$rw)
|
||||
{
|
||||
$sql = "SELECT var,val
|
||||
FROM sample_var
|
||||
WHERE sample_id = {$rw['sample_id']}";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
foreach($rs as $rsw)
|
||||
$rw[$rsw['var']] = $rsw['val'];
|
||||
}
|
||||
|
||||
xhtml_table($r,$fnames,$fdesc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "<h1>" . T_("Search within this sample") . "</h1>";
|
||||
|
||||
print "<p>" . T_("Use the % character as a wildcard") ."</p>";
|
||||
|
||||
?>
|
||||
<form action="" method="get">
|
||||
<p>
|
||||
<label for="search"><?php echo T_("Search for:"); ?></label><input type="text" name="search" id="search"/><br/>
|
||||
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
|
||||
<input type="submit" name="searchsub" value="<?php echo T_("Start search"); ?>"/>
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
xhtml_foot();
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Select and search within a sample to see what case(s) is/are assigned to a sample record
|
||||
* and if so to look at them, otherwise give the option to remove a sample record
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@deakin.edu.au>
|
||||
* @copyright Deakin University 2007,2008
|
||||
* @package queXS
|
||||
* @subpackage admin
|
||||
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
include("../config.inc.php");
|
||||
|
||||
/**
|
||||
* Database file
|
||||
*/
|
||||
include ("../db.inc.php");
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
include("../functions/functions.xhtml.php");
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
global $db;
|
||||
$css = array(
|
||||
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
|
||||
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
|
||||
"../include/font-awesome-4.3.0/css/font-awesome.css",
|
||||
"../include/bs-data-table/css/jquery.bdt.css",
|
||||
"../css/custom.css"
|
||||
);
|
||||
$js_head = array(
|
||||
"../js/jquery-2.1.3.min.js",
|
||||
"../include/bootstrap-3.3.2/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/window.js",
|
||||
"../js/custom.js"
|
||||
);
|
||||
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
|
||||
$subtitle = T_("Search within this sample");
|
||||
|
||||
xhtml_head(T_("Search the sample"),true,$css,$js_head);
|
||||
|
||||
?>
|
||||
<div class="modal fade delete-confirm" id="delete-confirm" tabindex="-1" role="dialog" aria-labelledby="delete-confirm" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title text-danger " ><?php echo T_("WARNING !");?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><?php echo T_("Are you shure you want to delete") . " " . T_("Sample ID") . " <b class='text-danger'>" . "</b>?";?></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo T_("NOOOO...");?></button>
|
||||
<a class="btn btn-danger" href=" "><?php echo T_("Yes"),", ",T_("Delete");?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
echo "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left' ><i class='fa fa-chevron-left text-primary'></i> " . T_("Go back") . "</a>";
|
||||
|
||||
$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))
|
||||
|
||||
print "<div class=' form-inline form-group col-md-6'><h4 class='control-label form-group col-sm-6 text-right'>" . T_("Select sample ") . " </h4>";
|
||||
display_chooser($r,"sample_import_id","sample_import_id",true,false,true,false);
|
||||
|
||||
print "</div>";
|
||||
|
||||
if (isset($_GET['sample_id']))
|
||||
{
|
||||
//need to remove this sample record from the sample
|
||||
|
||||
$sample_id = bigintval($_GET['sample_id']);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "DELETE FROM sample_var
|
||||
WHERE sample_id = '$sample_id'";
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM sample
|
||||
WHERE sample_id = '$sample_id'";
|
||||
$db->Execute($sql);
|
||||
|
||||
$db->CompleteTrans();
|
||||
|
||||
print "<div class='alert alert-danger pull-left form-group col-sm-6' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button><p>" . T_("Sample ID") . " <b>" . $sample_id . "</b> " . T_("Deleted") . ".</p></div>";
|
||||
}
|
||||
|
||||
print "<div class='clearfix'></div>";
|
||||
|
||||
if ($sample_import_id != false)
|
||||
{
|
||||
$sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN
|
||||
CONCAT('<a href=\'\' data-toggle=\'modal\' data-target=\'.delete-confirm\' data-href=\'?sample_import_id=$sample_import_id&sample_id=', sv.sample_id ,'\' data-sample_id=\' ', sv.sample_id ,' \' class=\'btn center-block\'><i data-toggle=\'tooltip\' title=\'" . TQ_("Delete sample record") . " ', sv.sample_id ,'\' class=\'fa fa-2x fa-trash-o text-danger\'></i></a>')
|
||||
ELSE CONCAT('<a href=\'supervisor.php?case_id=', c.case_id , '\' data-toggle=\'tooltip\' title=\'" . TQ_("Assigned to case ID :") . " ', c.case_id , '\'><b>', c.case_id ,'</b></a>')
|
||||
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 )
|
||||
GROUP BY s.sample_id, c.case_id";
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
if ($r) {
|
||||
|
||||
$sql = "SELECT var
|
||||
FROM sample_var
|
||||
WHERE sample_id = {$r[0]['sample_id']}
|
||||
ORDER by var ASC";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$fnames = array("sample_id");
|
||||
$fdesc = array(T_("Sample id"));
|
||||
|
||||
$fnames[] = "link";
|
||||
$fdesc[] = T_("Case ID");
|
||||
|
||||
foreach($rs as $rsw)
|
||||
{
|
||||
$fnames[] = $rsw['var'];
|
||||
$fdesc[] = $rsw['var'];
|
||||
}
|
||||
foreach($r as &$rw)
|
||||
{
|
||||
$sql = "SELECT var,val
|
||||
FROM sample_var
|
||||
WHERE sample_id = {$rw['sample_id']}";
|
||||
$rs = $db->GetAll($sql);
|
||||
foreach($rs as $rsw)
|
||||
$rw[$rsw['var']] = $rsw['val'];
|
||||
}
|
||||
|
||||
print "<div class='form-group'>";
|
||||
xhtml_table($r,$fnames,$fdesc,"tclass",false,false,"bs-table");
|
||||
print "</div>";
|
||||
}
|
||||
else print "<div class='alert alert-info col-sm-6 ' role='alert'><h4>" . T_("There's no data in this sample.") . "</h4></div>";
|
||||
}
|
||||
xhtml_foot($js_foot);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('#bs-table').bdt();
|
||||
$('#delete-confirm').on('show.bs.modal', function (event) {
|
||||
var a = $(event.relatedTarget)
|
||||
var href = a.data('href')
|
||||
var sample_id =a.data('sample_id')
|
||||
var modal = $(this)
|
||||
modal.find('.modal-body p b').text( +sample_id )
|
||||
modal.find('.modal-footer a').attr('href', href)
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user