From d577f6096d173900e54dc525b3fc8480f2368176 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 24 Feb 2015 02:19:56 +0300 Subject: [PATCH] NEW Admin panel pages: questionnairelist.php, samplelist.php, samplesearch.php, updated callhistory.php, custom.css aded library bootstrap-toggle, bootstrap-confirmation.js --- admin/callhistory.php | 68 +- admin/questionnairelist.php | 932 ++++++++++-------- admin/samplelist.php | 599 +++++------ admin/samplesearch.php | 361 +++---- css/custom.css | 16 +- include/bootstrap-toggle/LICENSE | 21 + include/bootstrap-toggle/README.md | 169 ++++ .../bootstrap-toggle/css/bootstrap-toggle.css | 83 ++ .../css/bootstrap-toggle.min.css | 28 + .../bootstrap-toggle/js/bootstrap-toggle.js | 180 ++++ .../js/bootstrap-toggle.min.js | 9 + include/bootstrap-toggle/script.js | 49 + js/bootstrap-confirmation.js | 240 +++++ 13 files changed, 1859 insertions(+), 896 deletions(-) create mode 100644 include/bootstrap-toggle/LICENSE create mode 100644 include/bootstrap-toggle/README.md create mode 100644 include/bootstrap-toggle/css/bootstrap-toggle.css create mode 100644 include/bootstrap-toggle/css/bootstrap-toggle.min.css create mode 100644 include/bootstrap-toggle/js/bootstrap-toggle.js create mode 100644 include/bootstrap-toggle/js/bootstrap-toggle.min.js create mode 100644 include/bootstrap-toggle/script.js create mode 100644 js/bootstrap-confirmation.js diff --git a/admin/callhistory.php b/admin/callhistory.php index 27ab37e0..5b300ab4 100644 --- a/admin/callhistory.php +++ b/admin/callhistory.php @@ -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 '
¶ ' ) 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 , 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 "
" . T_("No calls ever made") . "
"; + print "
" . T_("No calls ever made") . "
"; } 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 " " . T_("Download Call History List") . ""; - 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 "
 " . T_("Go back") . "
"; + + $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 "

" . T_("Questionnaire") . " ID: $qid " . $dq . "

"; + 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 "

" . T_("Sample") . " ID: $sid " . $ds . "

"; + unset($datacol[5]); unset($headers[5]); } + + print " " . T_("Download Call History List") . ""; + + xhtml_table($rs,$datacol,$headers,"tclass",false,false,"bs-table"); } } } else { - - print "
" . T_("No operator") . "
"; + print "
" . T_("No operator") . "
"; } xhtml_foot($js_foot); diff --git a/admin/questionnairelist.php b/admin/questionnairelist.php index d9c37803..53c7d97c 100644 --- a/admin/questionnairelist.php +++ b/admin/questionnairelist.php @@ -1,421 +1,511 @@ - - * @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 "

" . $rs['description'] . "

"; - echo "

" . T_("Go back") . "

"; - echo "

" . T_("Edit instrument in Limesurvey") . "

"; - ?> -
-

-

/>

-

/>

-

/>

-

/>

-

onchange="if(this.checked==true) show(this,'limesc'); else hide(this,'limesc');" />

-
> -

:

-

:

-

:

-
- -

editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);?>

-

editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);?>

-

editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);?>

-

editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);?>

- " . T_("Edit respondent selection instrument in Limesurvey") . "

"; } ?> -

editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig); ?>

-

editor("info",$rs['info'],$ckeditorConfig); ?>

-

"/>

-
- GetRow($sql); - - echo "

" . $rs['description'] . "

"; - - echo "

" . T_("Go back") . "

"; - - 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 "
"; - print "

"; - print "

"; - print "
"; -} -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('" . TQ_("Enable") . "') - ELSE - CONCAT('" . TQ_("Disable") . "') - END - as enabledisable, - CONCAT('" . TQ_("Modify"). "') as modify, - CONCAT('" . TQ_("Delete"). "') as deletee - FROM questionnaire"; - - $rs = $db->GetAll($sql); - - - xhtml_table($rs,$columns,$titles); -} - - -xhtml_foot(); - - -?> + + * @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, "  " . "$rs[description]" . ""); + + $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"); +?> +
+ +
+
 " . T_("Edit instrument in Limesurvey") . " "; ?>
+
+ +
+
+ +
"/>
+
+
+ +
data-toggle="toggle" data-on="" data-off=""/>
+
+
+
data-toggle="toggle" data-on="" data-off=""/>
+
+
+ +
" data-off="" data-onstyle="danger" />
+
+
+ +
data-toggle="toggle" data-on="" data-off=""/>
+
+
+ +
onchange="if(this.checked==true) show(this,'limesc'); else hide(this,'limesc');" data-toggle="toggle" data-on="" data-off=""/>
+
+
> +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+

" . T_("Respondent selection introduction:") . "

"; echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig); + echo "

" . T_("Respondent selection project introduction:") . "

"; echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig); + echo "

" . T_("Respondent selection callback (already started questionnaire):") . "

"; echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig); + echo "

" . T_("Message to leave on an answering machine:") . "

"; echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig); + echo "

"; } +else if (!empty($rs['lime_rs_sid'])) { echo "

" . T_("Edit respondent selection instrument in Limesurvey") . "

"; } + echo "

" . T_("Project end text (thank you screen):") . "

"; echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig); + echo "

" . T_("Project information for interviewers/operators:") . "

"; echo $CKEditor->editor("info",$rs['info'],$ckeditorConfig); + echo "

"; +?> +

"/>

+
+GetRow($sql); + + xhtml_head(T_("Delete Questionnaire"),true,$css,$js_head, false, false, false, " " . "$rs[description]" . ""); + + 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 "
"; + print "

   " . T_("Go back") . ""; + print "

"; + print "
"; +} +else +{ + xhtml_head(T_("Questionnaire management"),true,$css,$js_head, false, false, false, "Questionnaire list"); + echo "
+  " . T_("Go back") . " +  " . T_("Create a new questionnaire") . " +
"; + print "
"; // add timeslots, callattempts, quotas? + + $sql = "SELECT + CONCAT(' ',questionnaire_id,' ') as qid, + CONCAT('

',description,'

') 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 "); + +print "
"; +} +xhtml_foot($js_foot); +?> + \ No newline at end of file diff --git a/admin/samplelist.php b/admin/samplelist.php index 1e63e2af..9f8ee985 100644 --- a/admin/samplelist.php +++ b/admin/samplelist.php @@ -1,284 +1,315 @@ - - * @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 "

" . T_("Rename") . ": " . $rs. "

"; - echo "

" . T_("Go back") . "

"; - - ?> -
-
-
-
"/>
-
- 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); - } - } - - print "

" . T_("Operator viewing permissions") . ": " . $rs[0]['description'] . "

"; - echo "

" . T_("Go back") . "

"; - - print "

" . T_("Select which fields from this sample should be able to be viewed by operators") . "

"; - - ?> -
- -
-
"/>
-
- ') 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 "

" . T_("Deidentify") . ": " . $rs[0]['description'] . "

"; - echo "

" . T_("Go back") . "

"; - - print "

" . T_("Select which fields from this sample to deidentify. Deidentified fields will be permanently deleted from the sample.") . "

"; - - ?> -
- -
-
"/>
-
- 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('" . 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"; - -$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(); -?> + + * @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 " " . T_("Go back") . ""; + $sample_import_id = intval($_GET['rename']); + + $sql = "SELECT description + FROM sample_import + WHERE sample_import_id = $sample_import_id"; + $rs = $db->GetOne($sql); + + print "

" . T_("Sample current description") . ": " . $rs . "

"; +?> +
+
+

+
+
+
+
+
+ " . T_("Go back") . ""; + + $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('') 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 "

" . T_("Operator viewing permissions") . " ". T_("for") . " " . T_("sample") . ": " . $rs[0]['description'] . "

"; + if (!$rs) print ""; + else { + print " +
"; + xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Allow operator to see?"))); +?> +

+
+
+ + " . T_("Go back") . ""; + + $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 + 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 "

" . T_("Sample") . ": " . $rs[0]['description'] . "

"; + +if ($rs){ + print ""; +?> +
+ +
+
+
+
+ +

" . T_("There's no data in this sample. Probably was deidentified earlier.") . "

"; +} + 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(' ',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, + CONCAT('') as vp, + CONCAT('') as rname, + CONCAT('') as ssearch, + CONCAT('') as calls, + CONCAT('

',description,' 

') 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 "
+  " . T_("Go back") . " +  " . T_("Import a sample file") . " +
"; +$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); +?> + \ No newline at end of file diff --git a/admin/samplesearch.php b/admin/samplesearch.php index 4e2fedd0..159c1ba5 100644 --- a/admin/samplesearch.php +++ b/admin/samplesearch.php @@ -1,166 +1,195 @@ - - * @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 "

" . T_("Select a sample from the list below") . "

"; - -$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('" . TQ_("No cases yet assigned: Delete this sample record") . "') ELSE CONCAT('" . TQ_("Assigned to questionnaire: ") . "', q.description, '') 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 "

" . 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")); - - 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 "

" . T_("Search within this sample") . "

"; - - print "

" . T_("Use the % character as a wildcard") ."

"; - - ?> -
-

-
- - "/> -

-
- + + * @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); + +?> + + " . T_("Go back") . ""; + +$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 "

" . T_("Select sample ") . " 

"; + display_chooser($r,"sample_import_id","sample_import_id",true,false,true,false); + + print "
"; + +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 ""; +} + +print "
"; + +if ($sample_import_id != false) +{ + $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 ) + 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 "
"; + xhtml_table($r,$fnames,$fdesc,"tclass",false,false,"bs-table"); + print "
"; + } + else print ""; +} +xhtml_foot($js_foot); +?> + \ No newline at end of file diff --git a/css/custom.css b/css/custom.css index 8d2dbc67..b203ce04 100644 --- a/css/custom.css +++ b/css/custom.css @@ -2,7 +2,7 @@ body { /* font-size: 1.5em; -line-height: 1.3em;*/ +line-height: 1.5em;*/ /* color: #515a63; or #666 */ /*padding-top: 0px;*/ background:#EEEFF2; @@ -61,3 +61,17 @@ border-color: gray; background-color:#CED95B; border-color: blue; } +.fa{ +text-shadow: 1px 2px 1px #ababab; +} +.h1, h1 { +font-weight: 500; +text-shadow: 2px 2px 3px #ababab; +} +.h2, .h3, h2, h3 { +text-shadow: 1px 2px 1px #ababab; +} +.h1, .h2, .h3, h1, h2, h3 { +margin-bottom: 0.4em; +margin-top: 0.4em; +} \ No newline at end of file diff --git a/include/bootstrap-toggle/LICENSE b/include/bootstrap-toggle/LICENSE new file mode 100644 index 00000000..88bb5abf --- /dev/null +++ b/include/bootstrap-toggle/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2011-2014 Min Hur, The New York Times Company + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/include/bootstrap-toggle/README.md b/include/bootstrap-toggle/README.md new file mode 100644 index 00000000..2fda963b --- /dev/null +++ b/include/bootstrap-toggle/README.md @@ -0,0 +1,169 @@ +# Bootstrap Toggle +Bootstrap Toggle is a highly flexible Bootstrap plugin that converts checkboxes into toggles. + +Visit http://www.bootstraptoggle.com for demos. + +## Getting Started + +### Installation +You can [download](https://github.com/minhur/bootstrap-toggle/archive/master.zip) the latest version of Bootstrap Toggle or use CDN to load the library. + +`Warning` If you are using Bootstrap v2.3.2, use `bootstrap2-toggle.min.js` and `bootstrap2-toggle.min.css` instead. + +```html + + +``` + +### Bower Install +```bash +bower install bootstrap-toggle +``` + +## Usage + +### Basic example +Simply add `data-toggle="toggle"` to convert checkboxes into toggles. + +```html + +``` + +### Stacked checkboxes +Refer to Bootstrap Form Controls documentation to create stacked checkboxes. Simply add `data-toggle="toggle"` to convert checkboxes into toggles. + +```html +
+ +
+
+ +
+``` + +### Inline Checkboxes +Refer to Bootstrap Form Controls documentation to create inline checkboxes. Simply add `data-toggle="toggle"` to a convert checkboxes into toggles. + +```html + + + +``` + +## API + +### Initialize by JavaScript +Initialize toggles with id `toggle-one` with a single line of JavaScript. + +```html + + +``` + +### Options +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-on="Enabled"`. + +```html + + + +``` + +Name|Type|Default|Description| +---|---|---|--- +on|string/html|"On"|Text of the on toggle +off|string/html|"Off"|Text of the off toggle +size|string|"normal"|Size of the toggle. Possible values are `large`, `normal`, `small`, `mini`. +onstyle|string|"primary"|Style of the on toggle. Possible values are `default`, `primary`, `success`, `info`, `warning`, `danger` +offstyle|string|"default"|Style of the off toggle. Possible values are `default`, `primary`, `success`, `info`, `warning`, `danger` +style|string| |Appends the value to the class attribute of the toggle. This can be used to apply custom styles. Refer to Custom Styles for reference. +width|integer|*null*|Sets the width of the toggle. if set to *null*, width will be calculated. +height|integer|*null*|Sets the height of the toggle. if set to *null*, height will be calculated. + +### Methods +Methods can be used to control toggles directly. + +```html + +``` + +Method|Example|Description +---|---|--- +initialize|$('#toggle-demo').bootstrapToggle()|Initializes the toggle plugin with options +destroy|$('#toggle-demo').bootstrapToggle('destroy')|Destroys the toggle +on|$('#toggle-demo').bootstrapToggle('on')|Sets the toggle to 'On' state +off|$('#toggle-demo').bootstrapToggle('off')|Sets the toggle to 'Off' state +toggle|$('#toggle-demo').bootstrapToggle('toggle')|Toggles the state of the toggle +enable|$('#toggle-demo').bootstrapToggle('enable')|Enables the toggle +disable|$('#toggle-demo').bootstrapToggle('disable')|Disables the toggle + +## Events + +### Event Propagation +Note All events are propagated to and from input element to the toggle. + +You should listen to events from the `` directly rather than look for custom events. + +```html + +
+ +``` + +### API vs Input +This also means that using the API or Input to trigger events will work both ways. + +```html + + + + + + +``` + +## Demos + +Visit http://www.bootstraptoggle.com for demos. diff --git a/include/bootstrap-toggle/css/bootstrap-toggle.css b/include/bootstrap-toggle/css/bootstrap-toggle.css new file mode 100644 index 00000000..057d08b3 --- /dev/null +++ b/include/bootstrap-toggle/css/bootstrap-toggle.css @@ -0,0 +1,83 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * ======================================================================== */ + + +.checkbox label .toggle, +.checkbox-inline .toggle { + margin-left: -20px; + margin-right: 5px; +} + +.toggle { + position: relative; + overflow: hidden; +} +.toggle input[type="checkbox"] { + display: none; +} +.toggle-group { + position: absolute; + width: 200%; + top: 0; + bottom: 0; + left: 0; + transition: left 0.35s; + -webkit-transition: left 0.35s; + -moz-user-select: none; + -webkit-user-select: none; +} +.toggle.off .toggle-group { + left: -100%; +} +.toggle-on { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 50%; + margin: 0; + border: 0; + border-radius: 0; +} +.toggle-off { + position: absolute; + top: 0; + bottom: 0; + left: 50%; + right: 0; + margin: 0; + border: 0; + border-radius: 0; +} +.toggle-handle { + position: relative; + margin: 0 auto; + padding-top: 0px; + padding-bottom: 0px; + height: 100%; + width: 0px; + border-width: 0 1px; +} + +.toggle.btn { min-width: 59px; min-height: 34px; } +.toggle-on.btn { padding-right: 24px; } +.toggle-off.btn { padding-left: 24px; } + +.toggle.btn-lg { min-width: 79px; min-height: 45px; } +.toggle-on.btn-lg { padding-right: 31px; } +.toggle-off.btn-lg { padding-left: 31px; } +.toggle-handle.btn-lg { width: 40px; } + +.toggle.btn-sm { min-width: 50px; min-height: 30px;} +.toggle-on.btn-sm { padding-right: 20px; } +.toggle-off.btn-sm { padding-left: 20px; } + +.toggle.btn-xs { min-width: 35px; min-height: 22px;} +.toggle-on.btn-xs { padding-right: 12px; } +.toggle-off.btn-xs { padding-left: 12px; } + diff --git a/include/bootstrap-toggle/css/bootstrap-toggle.min.css b/include/bootstrap-toggle/css/bootstrap-toggle.min.css new file mode 100644 index 00000000..0d42ed09 --- /dev/null +++ b/include/bootstrap-toggle/css/bootstrap-toggle.min.css @@ -0,0 +1,28 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * ======================================================================== */ +.checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px} +.toggle{position:relative;overflow:hidden} +.toggle input[type=checkbox]{display:none} +.toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none} +.toggle.off .toggle-group{left:-100%} +.toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0} +.toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0} +.toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px} +.toggle.btn{min-width:59px;min-height:34px} +.toggle-on.btn{padding-right:24px} +.toggle-off.btn{padding-left:24px} +.toggle.btn-lg{min-width:79px;min-height:45px} +.toggle-on.btn-lg{padding-right:31px} +.toggle-off.btn-lg{padding-left:31px} +.toggle-handle.btn-lg{width:40px} +.toggle.btn-sm{min-width:50px;min-height:30px} +.toggle-on.btn-sm{padding-right:20px} +.toggle-off.btn-sm{padding-left:20px} +.toggle.btn-xs{min-width:35px;min-height:22px} +.toggle-on.btn-xs{padding-right:12px} +.toggle-off.btn-xs{padding-left:12px} \ No newline at end of file diff --git a/include/bootstrap-toggle/js/bootstrap-toggle.js b/include/bootstrap-toggle/js/bootstrap-toggle.js new file mode 100644 index 00000000..533914ed --- /dev/null +++ b/include/bootstrap-toggle/js/bootstrap-toggle.js @@ -0,0 +1,180 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * ======================================================================== */ + + + +function ($) { + 'use strict'; + + // TOGGLE PUBLIC CLASS DEFINITION + // ============================== + + var Toggle = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, this.defaults(), options) + this.render() + } + + Toggle.VERSION = '2.2.0' + + Toggle.DEFAULTS = { + on: 'On', + off: 'Off', + onstyle: 'primary', + offstyle: 'default', + size: 'normal', + style: '', + width: null, + height: null + } + + Toggle.prototype.defaults = function() { + return { + on: this.$element.attr('data-on') || Toggle.DEFAULTS.on, + off: this.$element.attr('data-off') || Toggle.DEFAULTS.off, + onstyle: this.$element.attr('data-onstyle') || Toggle.DEFAULTS.onstyle, + offstyle: this.$element.attr('data-offstyle') || Toggle.DEFAULTS.offstyle, + size: this.$element.attr('data-size') || Toggle.DEFAULTS.size, + style: this.$element.attr('data-style') || Toggle.DEFAULTS.style, + width: this.$element.attr('data-width') || Toggle.DEFAULTS.width, + height: this.$element.attr('data-height') || Toggle.DEFAULTS.height + } + } + + Toggle.prototype.render = function () { + this._onstyle = 'btn-' + this.options.onstyle + this._offstyle = 'btn-' + this.options.offstyle + var size = this.options.size === 'large' ? 'btn-lg' + : this.options.size === 'small' ? 'btn-sm' + : this.options.size === 'mini' ? 'btn-xs' + : '' + var $toggleOn = $('