2
0
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:
Alex
2015-02-24 02:19:56 +03:00
parent ce0d06f3de
commit d577f6096d
13 changed files with 1859 additions and 896 deletions

View File

@@ -54,16 +54,11 @@ $css = array(
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", "../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
"../include/font-awesome-4.3.0/css/font-awesome.css", "../include/font-awesome-4.3.0/css/font-awesome.css",
"../include/bs-data-table/css/jquery.bdt.css", "../include/bs-data-table/css/jquery.bdt.css",
//"../css/bootstrap-switch.min.css",
//"../css/table.css",
"../css/custom.css" "../css/custom.css"
); );
$js_head = array( $js_head = array(
//"../js/modernizr.js",
"../js/jquery-2.1.3.min.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"
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
//"../js/bootstrap-switch.min.js"
); );
$js_foot = array( $js_foot = array(
"../include/bs-data-table/js/vendor/jquery.sortelements.js", "../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.... 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/ ) 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 ($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, $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 '&para; &emsp; \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>&para;&emsp;' ) FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes,";
if (isset($_GET['csv'])) if (isset($_GET['csv'])) $sql .= " c.case_id ";
$sql .= " c.case_id "; else $sql .= " CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') ";
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 $sql .= " as case_id, q.description as qd , contact_phone.phone as cpi, sample_import.description as spl
FROM `call` as c 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 (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) 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 (outcome as o) on (c.outcome_id = o.outcome_id)
LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id), LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id),
contact_phone, sample_import, sample 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 AND sample.sample_id = ca.sample_id
ORDER BY c.start DESC"; ORDER BY c.start DESC";
if (!isset($_GET['csv'])) if (!isset($_GET['csv']))
$sql .= " LIMIT 500"; $sql .= " LIMIT 500";
else $sql .= " LIMIT 5000";
$rs = $db->Execute($sql); $rs = $db->Execute($sql);
if (empty($rs)) 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 else
{ {
if (isset($_GET['csv'])) 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-Type: text/csv");
header("Content-Disposition: attachment; filename=$fn"); 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("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
Header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache"); // HTTP/1.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"); 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()) while ($r = $rs->FetchRow())
@@ -127,22 +129,40 @@ if ($operator_id)
translate_array($r,array("des")); 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"; 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; exit;
} }
else else
{ {
$rs = $rs->GetArray(); $rs = $rs->GetArray();
translate_array($rs,array("des")); translate_array($rs,array("des"));
xhtml_head(T_("Call History List"),true,$css,$js_head); //array("../css/table.css") xhtml_head(T_("Call History List"),true,$css,$js_head);
print "<a href='?csv=csv' class='btn btn-default pull-right'><i class='fa fa-download fa-lg text-primary'></i>&emsp;" . T_("Download Call History List") . "</a>"; 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>&emsp;" . T_("Go back") . "</a></div>";
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");
$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") . "&emsp;ID: $qid</small>&emsp;" . $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") . "&emsp;ID: $sid</small>&emsp;" . $ds . "</h3>";
unset($datacol[5]); unset($headers[5]); }
print "<a href='?csv=csv&amp;questionnaire_id=$qid&amp;dq=" . $dq . "&amp;sample_import_id=$sid&amp;ds=" . $ds . "' class='btn btn-default pull-right'><i class='fa fa-download fa-lg text-primary'></i>&emsp;" . T_("Download Call History List") . "</a>";
xhtml_table($rs,$datacol,$headers,"tclass",false,false,"bs-table");
} }
} }
} }
else else
{ {
print "<div class='alert alert-warning col-sm-6'>" . T_("No operator") . "</div>";
print "<div class='alert alert-warning col-sm-4'>" . T_("No operator") . "</div>";
} }
xhtml_foot($js_foot); xhtml_foot($js_foot);

View File

@@ -1,421 +1,511 @@
<?php <?php
/** /**
* Manage questionnaires by editing them or disabling/enabling them * Manage questionnaires by editing them or disabling/enabling them
* *
* *
* This file is part of queXS * This file is part of queXS
* *
* queXS is free software; you can redistribute it and/or modify * queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* queXS is distributed in the hope that it will be useful, * queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software * along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
* *
* @author Adam Zammit <adam.zammit@acspri.org.au> * @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011 * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011
* @package queXS * @package queXS
* @subpackage admin * @subpackage admin
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI * @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 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
* *
*/ */
/** /**
* Configuration file * Configuration file
*/ */
include ("../config.inc.php"); include ("../config.inc.php");
/** /**
* Database file * Database file
*/ */
include ("../db.inc.php"); include ("../db.inc.php");
/** /**
* XHTML functions * XHTML functions
*/ */
include ("../functions/functions.xhtml.php"); include ("../functions/functions.xhtml.php");
/** /**
* Input functions * Input functions
*/ */
include("../functions/functions.input.php"); include("../functions/functions.input.php");
/** /**
* CKEditor * CKEditor
*/ */
include("../include/ckeditor/ckeditor.php"); include("../include/ckeditor/ckeditor.php");
global $db; global $db;
$css = array(
if (isset($_POST['questionnaire_id']) && isset($_POST['submit'])) "../include/bootstrap-3.3.2/css/bootstrap.min.css",
{ "../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
//Delete the questionnaire "../include/font-awesome-4.3.0/css/font-awesome.css",
"../include/bootstrap-toggle/css/bootstrap-toggle.min.css",
$questionnaire_id = intval($_POST['questionnaire_id']); "../css/custom.css"
);
$db->StartTrans(); $js_head = array(
"../js/jquery-2.1.3.min.js",
$sql = "DELETE FROM `appointment` "../include/bootstrap-3.3.2/js/bootstrap.min.js"
WHERE case_id IN );
(SELECT case_id $js_foot = array(
FROM `case` "../js/new.js",
WHERE questionnaire_id = $questionnaire_id)"; "../include/bootstrap-toggle/js/bootstrap-toggle.min.js",
"../js/bootstrap-confirmation.js",
$db->Execute($sql); "../js/custom.js"
);
$sql = "DELETE FROM `call`
WHERE case_id IN if (isset($_POST['questionnaire_id']) && isset($_POST['submit']))
(SELECT case_id {
FROM `case` //Delete the questionnaire
WHERE questionnaire_id = $questionnaire_id)";
$questionnaire_id = intval($_POST['questionnaire_id']);
$db->Execute($sql);
$db->StartTrans();
$sql = "DELETE FROM `call_attempt` $sql = "DELETE FROM `appointment`
WHERE case_id IN WHERE case_id IN
(SELECT case_id (SELECT case_id
FROM `case` FROM `case`
WHERE questionnaire_id = $questionnaire_id)"; WHERE questionnaire_id = $questionnaire_id)";
$db->Execute($sql); $db->Execute($sql);
$sql = "DELETE FROM `call`
$sql = "DELETE FROM `case_availability` WHERE case_id IN
WHERE case_id IN (SELECT case_id
(SELECT case_id FROM `case`
FROM `case` WHERE questionnaire_id = $questionnaire_id)";
WHERE questionnaire_id = $questionnaire_id)";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `case_note` $sql = "DELETE FROM `call_attempt`
WHERE case_id IN WHERE case_id IN
(SELECT case_id (SELECT case_id
FROM `case` FROM `case`
WHERE questionnaire_id = $questionnaire_id)"; WHERE questionnaire_id = $questionnaire_id)";
$db->Execute($sql); $db->Execute($sql);
$sql = "DELETE FROM `contact_phone`
WHERE case_id IN $sql = "DELETE FROM `case_availability`
(SELECT case_id WHERE case_id IN
FROM `case` (SELECT case_id
WHERE questionnaire_id = $questionnaire_id)"; FROM `case`
WHERE questionnaire_id = $questionnaire_id)";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `respondent`
WHERE case_id IN $sql = "DELETE FROM `case_note`
(SELECT case_id WHERE case_id IN
FROM `case` (SELECT case_id
WHERE questionnaire_id = $questionnaire_id)"; FROM `case`
WHERE questionnaire_id = $questionnaire_id)";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `client_questionnaire`
WHERE questionnaire_id = $questionnaire_id"; $sql = "DELETE FROM `contact_phone`
WHERE case_id IN
$db->Execute($sql); (SELECT case_id
FROM `case`
$sql = "DELETE FROM `operator_questionnaire` WHERE questionnaire_id = $questionnaire_id)";
WHERE questionnaire_id = $questionnaire_id";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `respondent`
$sql = "DELETE FROM `questionnaire_availability` WHERE case_id IN
WHERE questionnaire_id = $questionnaire_id"; (SELECT case_id
FROM `case`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id)";
$sql = "DELETE FROM `questionnaire_prefill` $db->Execute($sql);
WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `client_questionnaire`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample` $db->Execute($sql);
WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `operator_questionnaire`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample_exclude_priority` $db->Execute($sql);
WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_availability`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample_quota` $db->Execute($sql);
WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_prefill`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample_quota_row` $db->Execute($sql);
WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample_quota_row_exclude` $db->Execute($sql);
WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `questionnaire_sample_exclude_priority`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id";
$sql = "DELETE FROM `shift_report` $db->Execute($sql);
WHERE shift_id IN
(SELECT shift_id $sql = "DELETE FROM `questionnaire_sample_quota`
FROM `shift` WHERE questionnaire_id = $questionnaire_id";
WHERE questionnaire_id = $questionnaire_id)";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `questionnaire_sample_quota_row`
$sql = "DELETE FROM `shift` WHERE questionnaire_id = $questionnaire_id";
WHERE questionnaire_id = $questionnaire_id";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `questionnaire_sample_quota_row_exclude`
$sql = "DELETE FROM `case` WHERE questionnaire_id = $questionnaire_id";
WHERE questionnaire_id = $questionnaire_id";
$db->Execute($sql);
$db->Execute($sql);
$sql = "DELETE FROM `shift_report`
$sql = "DELETE FROM `questionnaire` WHERE shift_id IN
WHERE questionnaire_id = $questionnaire_id"; (SELECT shift_id
FROM `shift`
$db->Execute($sql); WHERE questionnaire_id = $questionnaire_id)";
$db->CompleteTrans(); $db->Execute($sql);
} $sql = "DELETE FROM `shift`
WHERE questionnaire_id = $questionnaire_id";
if (isset($_GET['disable']))
{ $db->Execute($sql);
$questionnaire_id = intval($_GET['disable']);
$sql = "DELETE FROM `case`
$sql = "UPDATE questionnaire WHERE questionnaire_id = $questionnaire_id";
SET enabled = 0
WHERE questionnaire_id = '$questionnaire_id'"; $db->Execute($sql);
$db->Execute($sql); $sql = "DELETE FROM `questionnaire`
} WHERE questionnaire_id = $questionnaire_id";
if (isset($_GET['enable'])) $db->Execute($sql);
{
$questionnaire_id = intval($_GET['enable']); $db->CompleteTrans();
}
$sql = "UPDATE questionnaire
SET enabled = 1 if (isset($_GET['disable']))
WHERE questionnaire_id = '$questionnaire_id'"; {
$questionnaire_id = intval($_GET['disable']);
$db->Execute($sql);
} $sql = "UPDATE questionnaire
SET enabled = 0
if (isset($_POST['update']) && isset($_GET['modify'])) WHERE questionnaire_id = '$questionnaire_id'";
{
$questionnaire_id = intval($_GET['modify']); $db->Execute($sql);
}
$ras =0;
$rws = 0; if (isset($_GET['enable']))
$rs = 0; {
$respsc = 0; $questionnaire_id = intval($_GET['enable']);
$referral = 0;
if (isset($_POST['ras'])) $ras = 1; $sql = "UPDATE questionnaire
if (isset($_POST['rws'])) $rws = 1; SET enabled = 1
if (isset($_POST['respsc'])) $respsc = 1; WHERE questionnaire_id = '$questionnaire_id'";
if (isset($_POST['referral'])) $referral = 1;
$db->Execute($sql);
$name = $db->qstr(html_entity_decode($_POST['description'],ENT_QUOTES,'UTF-8')); }
if (isset($_POST['rs_intro']))
{ if (isset($_POST['update']) && isset($_GET['modify']))
$rs = 1; {
$rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8')); $questionnaire_id = intval($_GET['modify']);
$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')); $ras =0;
$rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8')); $rws = 0;
} $rs = 0;
$info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8')); $respsc = 0;
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8')); $referral = 0;
if (isset($_POST['ras'])) $ras = 1;
if (isset($_POST['rws'])) $rws = 1;
$sql = "UPDATE questionnaire if (isset($_POST['respsc'])) $respsc = 1;
SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws', self_complete = $respsc, referral = $referral if (isset($_POST['referral'])) $referral = 1;
WHERE questionnaire_id = '$questionnaire_id'";
$name = $db->qstr(html_entity_decode($_POST['description'],ENT_QUOTES,'UTF-8'));
$db->Execute($sql); if (isset($_POST['rs_intro']))
{
if ($rs) $rs = 1;
{ $rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8'));
$sql = "UPDATE questionnaire $rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8'));
SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine $rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8'));
WHERE questionnaire_id = '$questionnaire_id'"; $rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8'));
}
$db->Execute($sql); $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'));
if ($respsc == 1) $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
$lime_mode = $db->qstr($_POST['lime_mode'],get_magic_quotes_gpc()); WHERE questionnaire_id = '$questionnaire_id'";
$lime_template = $db->qstr($_POST['lime_template'],get_magic_quotes_gpc());
$lime_endurl = $db->qstr($_POST['lime_endurl'],get_magic_quotes_gpc()); $db->Execute($sql);
$sql = "UPDATE questionnaire if ($rs)
SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl {
WHERE questionnaire_id = $questionnaire_id"; $sql = "UPDATE questionnaire
SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine
$db->Execute($sql); WHERE questionnaire_id = '$questionnaire_id'";
} $db->Execute($sql);
}
}
if ($respsc == 1)
xhtml_head(T_("Questionnaire list"),true,array("../css/table.css"),array("../js/new.js")); {
$lime_mode = $db->qstr($_POST['lime_mode'],get_magic_quotes_gpc());
$lime_template = $db->qstr($_POST['lime_template'],get_magic_quotes_gpc());
if (isset($_GET['modify'])) $lime_endurl = $db->qstr($_POST['lime_endurl'],get_magic_quotes_gpc());
{
$questionnaire_id = intval($_GET['modify']); $sql = "UPDATE questionnaire
SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl
$CKEditor = new CKEditor(); WHERE questionnaire_id = $questionnaire_id";
$CKEditor->basePath = "../include/ckeditor/"; $db->Execute($sql);
}
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"), }
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"), if (isset($_GET['modify']))
"/", {
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"), $questionnaire_id = intval($_GET['modify']);
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'), $sql = "SELECT *
array('BidiLtr', 'BidiRtl'), FROM questionnaire
array('Link','Unlink','Anchor'), WHERE questionnaire_id = $questionnaire_id";
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'), $rs = $db->GetRow($sql);
"/",
array('Styles','Format','Font','FontSize'), $referral = $testing = $rws = $ras = $rsc = "checked=\"checked\"";
array('TextColor','BGColor'), $rscd = "";
array('About')),
"extraPlugins" => "tokens"); $aio = $qbq = $gat = "";
if ($rs['lime_mode'] == "survey") $aio = "selected=\"selected\"";
$sql = "SELECT * if ($rs['lime_mode'] == "question") $qbq = "selected=\"selected\"";
FROM questionnaire if ($rs['lime_mode'] == "group") $gat = "selected=\"selected\"";
WHERE questionnaire_id = $questionnaire_id";
if ($rs['restrict_appointments_shifts'] != 1) $ras = "";
$rs = $db->GetRow($sql); if ($rs['restrict_work_shifts'] != 1) $rws = "";
if ($rs['testing'] != 1) $testing = "";
$referral = $testing = $rws = $ras = $rsc = "checked=\"checked\""; if ($rs['referral'] != 1) $referral = "";
$rscd = ""; if ($rs['self_complete'] == 0)
{
$aio = $qbq = $gat = ""; $rsc = "";
if ($rs['lime_mode'] == "survey") $aio = "selected=\"selected\""; $rscd = "style='display:none;'";
if ($rs['lime_mode'] == "question") $qbq = "selected=\"selected\""; }
if ($rs['lime_mode'] == "group") $gat = "selected=\"selected\"";
xhtml_head(T_("Modify Questionnaire "),true,$css,$js_head, false, false, false, " &ensp;<span class=' text-uppercase'>" . "$rs[description]" . "</span>");
if ($rs['restrict_appointments_shifts'] != 1) $ras = ""; $CKEditor = new CKEditor();
if ($rs['restrict_work_shifts'] != 1) $rws = ""; $CKEditor->basePath = "../include/ckeditor/";
if ($rs['testing'] != 1) $testing = "";
if ($rs['referral'] != 1) $referral = ""; $ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
if ($rs['self_complete'] == 0) array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
{ array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
$rsc = ""; array('Link','Unlink','Anchor'),
$rscd = "style='display:none;'"; array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
} array('About'),
"/",
echo "<h1>" . $rs['description'] . "</h1>"; array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'>" . T_("Edit instrument in Limesurvey") . "</a></p>"; array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
?> array('BidiLtr', 'BidiRtl'),
<form action="?modify=<?php echo $questionnaire_id; ?>" method="post"> array('Styles','Format','Font','FontSize'),
<p><?php echo T_("Name for questionnaire:"); ?> <input type="text" name="description" value="<?php echo $rs['description']; ?>"/></p> array('TextColor','BGColor')),
<p><?php echo T_("Restrict appointments to shifts?"); ?> <input name="ras" type="checkbox" <?php echo $ras; ?>/></p> "extraPlugins" => "tokens");
<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> <div class="form-group">
<p><?php echo T_("Allow operators to generate referrals?"); ?> <input name="referral" type="checkbox" <?php echo $referral; ?>/></p> <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>&emsp;<?php echo T_("Go back"); ?></a></div>
<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 class="col-sm-8"><?php // ?> </div>
<div id='limesc' <?php echo $rscd; ?>> <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>&emsp;" . T_("Edit instrument in Limesurvey") . "&emsp;</a>"; ?> </div>
<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> </div>
<p><?php echo T_("Limesurvey template for respondent");?>: <select name="lime_template">
<?php <form action="?modify=<?php echo $questionnaire_id; ?>" method="post" class="form-horizontal col-sm-12">
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) { <div class="form-group">
while (false !== ($entry = readdir($handle))) { <label class="col-sm-4 control-label" ><?php echo T_("Edit"),"&ensp;", T_("Name for questionnaire:"); ?> </label>
if ($entry != "." && $entry != ".." && is_dir(dirname(__FILE__)."/../include/limesurvey/templates/" . $entry)){ <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>
echo "<option value=\"$entry\" "; </div>
if ($rs['lime_template'] == $entry) echo " selected=\"selected\" "; <div class="form-group">
echo ">$entry</option>"; <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>
closedir($handle); <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">
</select></p> <label class="col-sm-4 control-label" ><?php echo T_("Questionnaire for testing only?"); ?> </label>
<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 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>
<?php if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) { ?> <div class="form-group">
<p><?php echo T_("Respondent selection introduction:"); echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);?></p> <label class="col-sm-4 control-label" ><?php echo T_("Allow operators to generate referrals?"); ?></label>
<p><?php echo T_("Respondent selection project introduction:"); echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);?></p> <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>
<p><?php echo T_("Respondent selection callback (already started questionnaire):"); echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);?> </p> </div>
<p><?php echo T_("Message to leave on an answering machine:"); echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);?> </p> <div class="form-group">
<?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>"; } ?> <label class="col-sm-4 control-label" ><?php echo T_("Allow for respondent self completion via email invitation?"); ?> </label>
<p><?php echo T_("Project end text (thank you screen):");echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig); ?></p> <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>
<p><?php echo T_("Project information for interviewers/operators:");echo $CKEditor->editor("info",$rs['info'],$ckeditorConfig); ?></p> </div>
<p><input type="submit" name="update" value="<?php echo T_("Update Questionnaire"); ?>"/></p> <div id="limesc" <?php echo $rscd; ?> >
</form> <div class="form-group">
<?php <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">
else if (isset($_GET['delete'])) <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>
$questionnaire_id = intval($_GET['delete']); <option <?php echo $gat;?> value="group"><?php echo T_("Group at a time"); ?></option>
</select>
$sql = "SELECT * </div>
FROM questionnaire </div>
WHERE questionnaire_id = $questionnaire_id"; <div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Limesurvey template for respondent");?>: </label>
$rs = $db->GetRow($sql); <div class="col-sm-4">
<select class="form-control" name="lime_template">
echo "<h1>" . $rs['description'] . "</h1>"; <?php
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) {
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && is_dir(dirname(__FILE__)."/../include/limesurvey/templates/" . $entry)){
print "<p>" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "</p>"; echo "<option value=\"$entry\" ";
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>"; if ($rs['lime_template'] == $entry) echo " selected=\"selected\" ";
print "<p>" . T_("Please confirm you wish to delete the questionnaire") . "</p>"; echo ">$entry</option>";
}
print "<form method='post' action='?'>"; }
print "<p><input type='submit' name='submit' value=\"" . T_("Delete this questionnaire") . "\"/>"; closedir($handle);
print "<input type='hidden' name='questionnaire_id' value='$questionnaire_id'/></p>"; }
print "</form>"; ?>
} </select>
else </div>
{ </div>
$columns = array("description","enabledisable","modify","deletee"); <div class="form-group">
$titles = array(T_("Questionnaire"),T_("Enable/Disable"),T_("Modify"),T_("Delete")); <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">
$sql = "SELECT <input class="form-control" name="lime_endurl" type="text" value="<?php echo $rs['lime_endurl']; ?>"/>
description, </div>
CASE WHEN enabled = 0 THEN </div>
CONCAT('<a href=\'?enable=',questionnaire_id,'\'>" . TQ_("Enable") . "</a>') </div>
ELSE <?php
CONCAT('<a href=\'?disable=',questionnaire_id,'\'>" . TQ_("Disable") . "</a>') if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) {
END echo "<p><h4 style='text-align:center;' >" . T_("Respondent selection introduction:") . "</h4>"; echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);
as enabledisable, 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);
CONCAT('<a href=\'?modify=',questionnaire_id,'\'>" . TQ_("Modify"). "</a>') as modify, 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);
CONCAT('<a href=\'?delete=',questionnaire_id,'\'>" . TQ_("Delete"). "</a>') as deletee 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);
FROM questionnaire"; 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>"; }
$rs = $db->GetAll($sql); 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>";
xhtml_table($rs,$columns,$titles); ?>
} <p><a href="questionnairelist.php" class="btn btn-default"><i class="fa fa-chevron-left fa-lg" style="color:blue;"></i>&emsp;<?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
xhtml_foot(); }
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, "&ensp;<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>&emsp;&emsp;<a href='questionnairelist.php' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . 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>&emsp;" . 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>&emsp;" . T_("Create a new questionnaire") . "</a>
</div>";
print "<div>"; // add timeslots, callattempts, quotas?
$sql = "SELECT
CONCAT('&ensp;<b class=\'badge\'>',questionnaire_id,'</b>&ensp;') as qid,
CONCAT('<h4>',description,'</h4>') as description,
CASE WHEN enabled = 0 THEN
CONCAT('&ensp;<span class=\'btn label label-default\'>" . TQ_("Disabled") . "</span>&ensp;')
ELSE
CONCAT('&ensp;<span class=\'btn label label-primary\'>" . TQ_("Enabled") . "</span>&ensp;')
END as status,
CASE WHEN enabled = 0 THEN
CONCAT('&ensp;<a href=\'?enable=',questionnaire_id,'\'><i data-toggle=\'tooltip\' title=\'" . TQ_("Enable") . "\' class=\'fa fa-toggle-off fa-3x\' style=\'color:grey;\'></i></a>&ensp;')
ELSE
CONCAT('&ensp;<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>&ensp;')
END as enabledisable,
CONCAT('<a href=\'?modify=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Edit Questionnaire") . "&ensp;',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") . "&ensp;',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") . "&ensp;\n" . TQ_("questionnaire") . "&ensp;',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"). "&ensp;',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") . "&ensp;',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"). "&ensp;',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"). "&ensp;\n" . TQ_("questionnaire"). "&ensp;',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"). "&ensp;\n" . TQ_("questionnaire"). "&ensp;',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>

View File

@@ -1,284 +1,315 @@
<?php <?php
/** /**
* List operators and allow for customised VoIP downloads, changing passwords, disabling, etc * List operators and allow for customised VoIP downloads, changing passwords, disabling, etc
* *
* *
* This file is part of queXS * This file is part of queXS
* *
* queXS is free software; you can redistribute it and/or modify * queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* queXS is distributed in the hope that it will be useful, * queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software * along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
* *
* @author Adam Zammit <adam.zammit@acspri.org.au> * @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013 * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013
* @package queXS * @package queXS
* @subpackage admin * @subpackage admin
* @link http://www.acspri.org.au/software queXS was writen for ACSPRI * @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 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
* *
*/ */
/** /**
* Configuration file * Configuration file
*/ */
include_once(dirname(__FILE__).'/../config.inc.php'); include_once(dirname(__FILE__).'/../config.inc.php');
/** /**
* Database * Database
*/ */
include_once(dirname(__FILE__).'/../db.inc.php'); include_once(dirname(__FILE__).'/../db.inc.php');
/** /**
* XHTML functions * XHTML functions
*/ */
include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); include_once(dirname(__FILE__).'/../functions/functions.xhtml.php');
$css = array(
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
if (isset($_POST['submitr'])) "../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
{ "../include/font-awesome-4.3.0/css/font-awesome.css",
$sample_import_id = intval($_POST['sample_import_id']); "../css/bootstrap-switch.min.css",
"../css/custom.css"
$sql = "UPDATE sample_import );
SET description = " . $db->qstr($_POST['description']) . " $js_head = array(
WHERE sample_import_id = $sample_import_id"; "../js/jquery-2.1.3.min.js",
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
$db->Execute($sql); "../js/bootstrap-switch.min.js"
);
$_GET['rename'] = $sample_import_id; $js_foot = array(
} "../js/bootstrap-confirmation.js",
"../js/custom.js"
if (isset($_POST['submit'])) );
{
$sample_import_id = intval($_POST['sample_import_id']); if (isset($_POST['submitr']))
{
unset($_POST['submit']); $sample_import_id = intval($_POST['sample_import_id']);
unset($_POST['sample_import_id']);
$sql = "UPDATE sample_import
foreach($_POST as $p) SET description = " . $db->qstr($_POST['description']) . "
{ WHERE sample_import_id = $sample_import_id";
$sql = "DELETE FROM sample_var
WHERE var LIKE " . $db->qstr($p) . " $db->Execute($sql);
AND sample_id IN
(SELECT sample_id $_GET['rename'] = $sample_import_id;
FROM sample }
WHERE import_id = $sample_import_id)";
if (isset($_POST['submit']))
$db->Execute($sql); {
$sample_import_id = intval($_POST['sample_import_id']);
}
unset($_POST['submit']);
$_GET['edit'] = $sample_import_id; unset($_POST['sample_import_id']);
}
foreach($_POST as $p)
if (isset($_POST['submitvp'])) {
{ $sql = "DELETE FROM sample_var
$sample_import_id = intval($_POST['sample_import_id']); WHERE var LIKE " . $db->qstr($p) . "
AND sample_id IN
unset($_POST['submitvp']); (SELECT sample_id
unset($_POST['sample_import_id']); FROM sample
WHERE import_id = $sample_import_id)";
$db->StartTrans(); $db->Execute($sql);
$sql = "UPDATE sample_import_var_restrict }
SET `restrict` = 1
WHERE sample_import_id = $sample_import_id"; $_GET['edit'] = $sample_import_id;
}
$db->Execute($sql);
if (isset($_POST['submitvp']))
foreach($_POST as $p => $val) {
{ $sample_import_id = intval($_POST['sample_import_id']);
$sql = "UPDATE sample_import_var_restrict
SET `restrict` = 0 unset($_POST['submitvp']);
WHERE sample_import_id = $sample_import_id unset($_POST['sample_import_id']);
AND `var` LIKE " . $db->qstr($p); $db->StartTrans();
$db->Execute($sql); $sql = "UPDATE sample_import_var_restrict
} SET `restrict` = 1
WHERE sample_import_id = $sample_import_id";
$db->CompleteTrans(); $db->Execute($sql);
$_GET['view'] = $sample_import_id; foreach($_POST as $p => $val)
} {
$sql = "UPDATE sample_import_var_restrict
if (isset($_GET['rename'])) SET `restrict` = 0
{ WHERE sample_import_id = $sample_import_id
xhtml_head(T_("Rename"),true,array("../css/table.css")); AND `var` LIKE " . $db->qstr($p);
$db->Execute($sql);
$sample_import_id = intval($_GET['rename']); }
$sql = "SELECT description $db->CompleteTrans();
FROM sample_import
WHERE sample_import_id = $sample_import_id"; $_GET['view'] = $sample_import_id;
}
$rs = $db->GetOne($sql);
if (isset($_GET['rename']))
print "<h2>" . T_("Rename") . ": " . $rs. "</h2>"; {
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; $subtitle=T_("Rename sample");
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
?>
<form action="?" method="post"> echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . T_("Go back") . "</a>";
<div><label for='description'><?php echo T_("Description") . ": "; ?></label><input type='text' name='description' value="<?php echo $rs;?>"/></div> $sample_import_id = intval($_GET['rename']);
<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> $sql = "SELECT description
</form> FROM sample_import
<?php WHERE sample_import_id = $sample_import_id";
$rs = $db->GetOne($sql);
xhtml_foot(); print "<h3>" . T_("Sample current description") . ":&ensp;<span class='text-primary'>" . $rs . "</span></h3>";
exit(); ?>
} <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"),"&ensp;", T_("new"),"&ensp;", T_("Description"), ":" ; ?></h4>
if (isset($_GET['view'])) <div class="col-sm-4"><input type='text' name='description' class="form-control" value="<?php echo $rs;?>"/></div>
{ </div>
xhtml_head(T_("Operator viewing permissions"),true,array("../css/table.css")); <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>&emsp;<?php echo T_("Rename");?></button></div>
$sample_import_id = intval($_GET['view']); </form>
<?php
$sql = "SELECT sample_id xhtml_foot();
FROM `sample` exit();
WHERE import_id = $sample_import_id"; }
$sample_id = $db->GetOne($sql); if (isset($_GET['view']))
{
$sql = "SELECT si.description, sv.val, sv.var, $subtitle=T_("Operator viewing permissions");
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, xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
sir.restrict IS NULL as existss
FROM sample_import as si echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . T_("Go back") . "</a>";
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) $sample_import_id = intval($_GET['view']);
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"; $sql = "SELECT sample_id
FROM `sample`
$rs = $db->GetAll($sql); WHERE import_id = $sample_import_id";
//if not in restrict table, then insert $sample_id = $db->GetOne($sql);
foreach($rs as $r)
{ $sql = "SELECT si.description, sv.val, sv.var,
if ($r['existss'] == 1) 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
$sql = "INSERT INTO sample_import_var_restrict (sample_import_id,var,`restrict`) FROM sample_import as si
VALUES ($sample_import_id,'{$r['var']}',0)"; 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)
$db->Execute($sql); 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);
print "<h2>" . T_("Operator viewing permissions") . ": " . $rs[0]['description'] . "</h2>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; //if not in restrict table, then insert
foreach($rs as $r)
print "<p>" . T_("Select which fields from this sample should be able to be viewed by operators") . "</p>"; {
if ($r['existss'] == 1)
?> {
<form action="?" method="post"> $sql = "INSERT INTO sample_import_var_restrict (sample_import_id,var,`restrict`)
<?php VALUES ($sample_import_id,'{$r['var']}',0)";
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Allow operator to see?"))); $db->Execute($sql);
?> }
<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> print "<h3>" . T_("Operator viewing permissions") . "&ensp;". T_("for") . "&ensp;" . T_("sample") . ": " . $rs[0]['description'] . "</h3>";
<?php 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>
xhtml_foot(); <form action='?' method='post' class='form-group form-horisontal'>";
exit(); 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>&emsp;<?php echo T_("Save changes");?></button></div>
if (isset($_GET['edit'])) </form>
{ <script type="text/javascript">
xhtml_head(T_("Deidentify"),true,array("../css/table.css")); $('[switch="yes"]').bootstrapSwitch();
</script>
$sample_import_id = intval($_GET['edit']); <?php
}
$sql = "SELECT si.description, sv.val, sv.var, xhtml_foot();
CONCAT('<input type=\'checkbox\' name=\'',sv.var,'\' value=\'',sv.var,'\'/>') as box exit();
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 if (isset($_GET['edit']))
AND s.import_id = si.sample_import_id {
GROUP BY sv.var"; $subtitle=T_("Delete sample variables") ;
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
$rs = $db->GetAll($sql);
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . T_("Go back") . "</a>";
print "<h2>" . T_("Deidentify") . ": " . $rs[0]['description'] . "</h2>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; $sample_import_id = intval($_GET['edit']);
print "<p>" . T_("Select which fields from this sample to deidentify. Deidentified fields will be permanently deleted from the sample.") . "</p>"; $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
<form action="?" method="post"> WHERE si.sample_import_id = $sample_import_id
<?php AND sv.sample_id = s.sample_id
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Deidentify"))); AND s.import_id = si.sample_import_id
?> GROUP BY sv.var";
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div> $rs = $db->GetAll($sql);
<div><input type="submit" name="submit" value="<?php echo T_("Delete selected fields");?>"/></div>
</form> print "<h3>" . T_("Sample") . ": " . $rs[0]['description'] . "</h3>";
<?php
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>";
xhtml_foot(); ?>
exit(); <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>
if (isset($_GET['sampledisable'])) </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>&emsp;<?php echo T_("Delete selected fields");?></button></div>
$id = intval($_GET['sampledisable']); </form>
<script type="text/javascript">
$sql = "UPDATE sample_import $('[switch="yes"]').bootstrapSwitch();
SET enabled = 0 </script>
WHERE sample_import_id = '$id'"; <?php
}
$db->Execute($sql); 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>";
if (isset($_GET['sampleenable'])) }
{ xhtml_foot();
$id = intval($_GET['sampleenable']); exit();
}
$sql = "UPDATE sample_import
SET enabled = 1 if (isset($_GET['sampledisable']))
WHERE sample_import_id = '$id'"; {
$id = intval($_GET['sampledisable']);
$db->Execute($sql);
} $sql = "UPDATE sample_import
SET enabled = 0
WHERE sample_import_id = '$id'";
$sql = "SELECT $db->Execute($sql);
CASE WHEN enabled = 0 THEN }
CONCAT('<a href=\'?sampleenable=',sample_import_id,'\'>" . TQ_("Enable") . "</a>')
ELSE if (isset($_GET['sampleenable']))
CONCAT('<a href=\'?sampledisable=',sample_import_id,'\'>" . TQ_("Disable") . "</a>') {
END $id = intval($_GET['sampleenable']);
as enabledisable,
CONCAT('<a href=\'?edit=',sample_import_id,'\'>" . TQ_("Deidentify") . "</a>') as did, $sql = "UPDATE sample_import
CONCAT('<a href=\'?view=',sample_import_id,'\'>" . TQ_("Operator viewing permissions") . "</a>') as vp, SET enabled = 1
CONCAT('<a href=\'?rename=',sample_import_id,'\'>" . TQ_("Rename") . "</a>') as rname, WHERE sample_import_id = '$id'";
description $db->Execute($sql);
FROM sample_import"; }
$rs = $db->GetAll($sql); $sql = "SELECT
CONCAT('&ensp;<b class=\'badge\'>',sample_import_id,'</b>&ensp;') as id,
xhtml_head(T_("Sample list"),true,array("../css/table.css")); CASE WHEN enabled = 0 THEN
CONCAT('&emsp; <span class=\'btn label label-default\'>" . TQ_("Disabled") . "</span>&emsp;')
$columns = array("description","enabledisable","did","vp","rname"); ELSE
$titles = array(T_("Sample"),T_("Enable/Disable"),T_("Deidentify"),T_("Operator viewing permissions"),T_("Rename")); CONCAT('&emsp; <span class=\'btn label label-primary\'>" . TQ_("Enabled") . "</span>&emsp;')
END as status,
xhtml_table($rs,$columns,$titles); CASE WHEN enabled = 0 THEN
CONCAT('<a href=\'?sampleenable=',sample_import_id,'\' class=\'btn btn-default col-sm-12\'>" . TQ_("Enable") . "&emsp;<i class=\'fa fa-play fa-lg\' style=\'color:blue;\'></i></a>')
xhtml_foot(); 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>&ensp;&nbsp;" . 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"). "&ensp;\n" . TQ_("sample"). "&ensp;',sample_import_id,'\'><i class=\'fa fa-phone fa-lg text-primary\'></i></a>') as calls,
CONCAT('<h4>',description,'&emsp;</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>&emsp;" . T_("Go back") . "</a>
<a href='import.php' class='btn btn-default col-sm-offset-4' ><i class='fa fa-upload fa-lg'></i>&emsp;" . 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>

View File

@@ -1,166 +1,195 @@
<?php <?php
/** /**
* Select and search within a sample to see what case(s) is/are assigned to a sample record * 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 * and if so to look at them, otherwise give the option to remove a sample record
* *
* *
* This file is part of queXS * This file is part of queXS
* *
* queXS is free software; you can redistribute it and/or modify * queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* queXS is distributed in the hope that it will be useful, * queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software * along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
* *
* @author Adam Zammit <adam.zammit@deakin.edu.au> * @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008 * @copyright Deakin University 2007,2008
* @package queXS * @package queXS
* @subpackage admin * @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility * @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 * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
* *
* *
*/ */
/** /**
* Configuration file * Configuration file
*/ */
include("../config.inc.php"); include("../config.inc.php");
/** /**
* Database file * Database file
*/ */
include ("../db.inc.php"); include ("../db.inc.php");
/** /**
* XHTML functions * XHTML functions
*/ */
include("../functions/functions.xhtml.php"); include("../functions/functions.xhtml.php");
/**
/** * Input functions
* Input functions */
*/ include("../functions/functions.input.php");
include("../functions/functions.input.php");
global $db;
global $db; $css = array(
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
if (isset($_GET['sample_id'])) "../include/font-awesome-4.3.0/css/font-awesome.css",
{ "../include/bs-data-table/css/jquery.bdt.css",
//need to remove this sample record from the sample "../css/custom.css"
);
$sample_id = bigintval($_GET['sample_id']); $js_head = array(
"../js/jquery-2.1.3.min.js",
$db->StartTrans(); "../include/bootstrap-3.3.2/js/bootstrap.min.js",
);
$sql = "DELETE FROM sample_var $js_foot = array(
WHERE sample_id = '$sample_id'"; "../include/bs-data-table/js/vendor/jquery.sortelements.js",
"../include/bs-data-table/js/jquery.bdt.js",
$db->Execute($sql); "../js/window.js",
"../js/custom.js"
$sql = "DELETE FROM sample );
WHERE sample_id = '$sample_id'";
$sample_import_id = false;
$db->Execute($sql); if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
$db->CompleteTrans(); $subtitle = T_("Search within this sample");
}
xhtml_head(T_("Search the sample"),true,$css,$js_head);
$sample_import_id = false; ?>
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); <div class="modal fade delete-confirm" id="delete-confirm" tabindex="-1" role="dialog" aria-labelledby="delete-confirm" aria-hidden="true">
<div class="modal-dialog">
xhtml_head(T_("Search sample"),true,array("../css/table.css"),array("../js/window.js")); <div class="modal-content">
print "<h1>" . T_("Select a sample from the list below") . "</h1>"; <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected <h4 class="modal-title text-danger " ><?php echo T_("WARNING !");?></h4>
FROM sample_import"; </div>
<div class="modal-body">
$r = $db->GetAll($sql); <p><?php echo T_("Are you shure you want to delete") . "&ensp;" . T_("Sample ID") . "&ensp;<b class='text-danger'>" . "</b>?";?></p>
</div>
if(!empty($r)) <div class="modal-footer">
display_chooser($r,"sample_import_id","sample_import_id"); <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"),",&ensp;",T_("Delete");?></a>
if ($sample_import_id != false) </div>
{ </div>
if (isset($_GET['search'])) </div>
{ </div>
$search = $db->qstr($_GET['search']); <?php
echo "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left' ><i class='fa fa-chevron-left text-primary'></i>&emsp;" . T_("Go back") . "</a>";
$sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN CONCAT('<a href=\'?sample_import_id=$sample_import_id&amp;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 $sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
JOIN (sample as s) ON (s.import_id = '$sample_import_id' and sv.sample_id = s.sample_id) FROM sample_import";
LEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id ) $r = $db->GetAll($sql);
WHERE sv.val LIKE $search
GROUP BY s.sample_id,c.case_id"; if(!empty($r))
$r = $db->GetAll($sql); print "<div class=' form-inline form-group col-md-6'><h4 class='control-label form-group col-sm-6 text-right'>" . T_("Select sample ") . "&emsp;</h4>";
display_chooser($r,"sample_import_id","sample_import_id",true,false,true,false);
if (empty($r))
print "<p>" . T_("No records in this sample match this search criteria") . "</p>"; print "</div>";
else
{ if (isset($_GET['sample_id']))
//add sample information to results {
$sql = "SELECT var //need to remove this sample record from the sample
FROM sample_var
WHERE sample_id = {$r[0]['sample_id']}"; $sample_id = bigintval($_GET['sample_id']);
$rs = $db->GetAll($sql); $db->StartTrans();
$fnames = array("sample_id"); $sql = "DELETE FROM sample_var
$fdesc = array(T_("Sample id")); WHERE sample_id = '$sample_id'";
$db->Execute($sql);
foreach($rs as $rsw)
{ $sql = "DELETE FROM sample
$fnames[] = $rsw['var']; WHERE sample_id = '$sample_id'";
$fdesc[] = $rsw['var']; $db->Execute($sql);
}
$db->CompleteTrans();
$fnames[] = "link";
$fdesc[] = T_("Link"); 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'>&times;</span></button><p>" . T_("Sample ID") . "&ensp;<b>" . $sample_id . "</b>&ensp;" . T_("Deleted") . ".</p></div>";
}
foreach($r as &$rw)
{ print "<div class='clearfix'></div>";
$sql = "SELECT var,val
FROM sample_var if ($sample_import_id != false)
WHERE sample_id = {$rw['sample_id']}"; {
$sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN
$rs = $db->GetAll($sql); CONCAT('<a href=\'\' data-toggle=\'modal\' data-target=\'.delete-confirm\' data-href=\'?sample_import_id=$sample_import_id&amp;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>')
foreach($rs as $rsw) END as link
$rw[$rsw['var']] = $rsw['val']; 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 )
xhtml_table($r,$fnames,$fdesc); GROUP BY s.sample_id, c.case_id";
} $r = $db->GetAll($sql);
} if ($r) {
print "<h1>" . T_("Search within this sample") . "</h1>"; $sql = "SELECT var
FROM sample_var
print "<p>" . T_("Use the % character as a wildcard") ."</p>"; WHERE sample_id = {$r[0]['sample_id']}
ORDER by var ASC";
?>
<form action="" method="get"> $rs = $db->GetAll($sql);
<p>
<label for="search"><?php echo T_("Search for:"); ?></label><input type="text" name="search" id="search"/><br/> $fnames = array("sample_id");
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/> $fdesc = array(T_("Sample id"));
<input type="submit" name="searchsub" value="<?php echo T_("Start search"); ?>"/>
</p> $fnames[] = "link";
</form> $fdesc[] = T_("Case ID");
<?php
} foreach($rs as $rsw)
xhtml_foot(); {
$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>

View File

@@ -2,7 +2,7 @@
body { body {
/* /*
font-size: 1.5em; font-size: 1.5em;
line-height: 1.3em;*/ line-height: 1.5em;*/
/* color: #515a63; or #666 */ /* color: #515a63; or #666 */
/*padding-top: 0px;*/ /*padding-top: 0px;*/
background:#EEEFF2; background:#EEEFF2;
@@ -61,3 +61,17 @@ border-color: gray;
background-color:#CED95B; background-color:#CED95B;
border-color: blue; 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;
}

View File

@@ -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.

View File

@@ -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
<link href="https://gitcdn.github.io/bootstrap-toggle/2.1.0/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.1.0/js/bootstrap-toggle.min.js"></script>
```
### Bower Install
```bash
bower install bootstrap-toggle
```
## Usage
### Basic example
Simply add `data-toggle="toggle"` to convert checkboxes into toggles.
```html
<input type="checkbox" checked data-toggle="toggle">
```
### Stacked checkboxes
Refer to Bootstrap Form Controls documentation to create stacked checkboxes. Simply add `data-toggle="toggle"` to convert checkboxes into toggles.
```html
<div class="checkbox">
<label>
<input type="checkbox" data-toggle="toggle">
Option one is enabled
</label>
</div>
<div class="checkbox disabled">
<label>
<input type="checkbox" disabled data-toggle="toggle">
Option two is disabled
</label>
</div>
```
### Inline Checkboxes
Refer to Bootstrap Form Controls documentation to create inline checkboxes. Simply add `data-toggle="toggle"` to a convert checkboxes into toggles.
```html
<label class="checkbox-inline">
<input type="checkbox" checked data-toggle="toggle"> First
</label>
<label class="checkbox-inline">
<input type="checkbox" data-toggle="toggle"> Second
</label>
<label class="checkbox-inline">
<input type="checkbox" data-toggle="toggle"> Third
</label>
```
## API
### Initialize by JavaScript
Initialize toggles with id `toggle-one` with a single line of JavaScript.
```html
<input id="toggle-one" checked type="checkbox">
<script>
$(function() {
$('#toggle-one').bootstrapToggle();
})
</script>
```
### 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
<input type="checkbox" data-toggle="toggle" data-on="Enabled" data-off="Disabled">
<input type="checkbox" id="toggle-two">
<script>
$(function() {
$('#toggle-two').bootstrapToggle({
on: 'Enabled',
off: 'Disabled'
});
})
</script>
```
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
<input id="toggle-demo" type="checkbox" data-toggle="toggle">
```
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 `<input type="checkbox">` directly rather than look for custom events.
```html
<input id="toggle-event" type="checkbox" data-toggle="toggle">
<div id="console-event"></div>
<script>
$(function() {
$('#toggle-event').change(function() {
$('#console-event').html('Toggle: ' + $(this).prop('checked'))
})
})
</script>
```
### API vs Input
This also means that using the API or Input to trigger events will work both ways.
```html
<input id="toggle-trigger" type="checkbox" data-toggle="toggle">
<button class="btn btn-success" onclick="toggleOn()">On by API</button>
<button class="btn btn-danger" onclick="toggleOff()">Off by API</button>
<button class="btn btn-success" onclick="toggleOnByInput()">On by Input</button>
<button class="btn btn-danger" onclick="toggleOffByInput()">Off by Input</button>
<script>
function toggleOn() {
$('#toggle-trigger').bootstrapToggle('on')
}
function toggleOff() {
$('#toggle-trigger').bootstrapToggle('off')
}
function toggleOnByInput() {
$('#toggle-trigger').prop('checked', true).change()
}
function toggleOffByInput() {
$('#toggle-trigger').prop('checked', false).change()
}
</script>
```
## Demos
Visit http://www.bootstraptoggle.com for demos.

View File

@@ -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; }

View File

@@ -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}

View File

@@ -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 = $('<label class="btn">').html(this.options.on)
.addClass(this._onstyle + ' ' + size)
var $toggleOff = $('<label class="btn">').html(this.options.off)
.addClass(this._offstyle + ' ' + size + ' active')
var $toggleHandle = $('<span class="toggle-handle btn btn-default">')
.addClass(size)
var $toggleGroup = $('<div class="toggle-group">')
.append($toggleOn, $toggleOff, $toggleHandle)
var $toggle = $('<div class="toggle btn" data-toggle="toggle">')
.addClass( this.$element.prop('checked') ? this._onstyle : this._offstyle+' off' )
.addClass(size).addClass(this.options.style)
this.$element.wrap($toggle)
$.extend(this, {
$toggle: this.$element.parent(),
$toggleOn: $toggleOn,
$toggleOff: $toggleOff,
$toggleGroup: $toggleGroup
})
this.$toggle.append($toggleGroup)
var width = this.options.width || Math.max($toggleOn.outerWidth(), $toggleOff.outerWidth())+($toggleHandle.outerWidth()/2)
var height = this.options.height || Math.max($toggleOn.outerHeight(), $toggleOff.outerHeight())
$toggleOn.addClass('toggle-on')
$toggleOff.addClass('toggle-off')
this.$toggle.css({ width: width, height: height })
if (this.options.height) {
$toggleOn.css('line-height', $toggleOn.height() + 'px')
$toggleOff.css('line-height', $toggleOff.height() + 'px')
}
this.update(true)
this.trigger(true)
}
Toggle.prototype.toggle = function () {
if (this.$element.prop('checked')) this.off()
else this.on()
}
Toggle.prototype.on = function (silent) {
if (this.$element.prop('disabled')) return false
this.$toggle.removeClass(this._offstyle + ' off').addClass(this._onstyle)
this.$element.prop('checked', true)
if (!silent) this.trigger()
}
Toggle.prototype.off = function (silent) {
if (this.$element.prop('disabled')) return false
this.$toggle.removeClass(this._onstyle).addClass(this._offstyle + ' off')
this.$element.prop('checked', false)
if (!silent) this.trigger()
}
Toggle.prototype.enable = function () {
this.$toggle.removeAttr('disabled')
this.$element.prop('disabled', false)
}
Toggle.prototype.disable = function () {
this.$toggle.attr('disabled', 'disabled')
this.$element.prop('disabled', true)
}
Toggle.prototype.update = function (silent) {
if (this.$element.prop('disabled')) this.disable()
else this.enable()
if (this.$element.prop('checked')) this.on(silent)
else this.off(silent)
}
Toggle.prototype.trigger = function (silent) {
this.$element.off('change.bs.toggle')
if (!silent) this.$element.change()
this.$element.on('change.bs.toggle', $.proxy(function() {
this.update()
}, this))
}
Toggle.prototype.destroy = function() {
this.$element.off('change.bs.toggle')
this.$toggleGroup.remove()
this.$element.removeData('bs.toggle')
this.$element.unwrap()
}
// TOGGLE PLUGIN DEFINITION
// ========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.toggle')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.toggle', (data = new Toggle(this, options)))
if (typeof option == 'string' && data[option]) data[option]()
})
}
var old = $.fn.bootstrapToggle
$.fn.bootstrapToggle = Plugin
$.fn.bootstrapToggle.Constructor = Toggle
// TOGGLE NO CONFLICT
// ==================
$.fn.toggle.noConflict = function () {
$.fn.bootstrapToggle = old
return this
}
// TOGGLE DATA-API
// ===============
$(function() {
$('input[type=checkbox][data-toggle^=toggle]').bootstrapToggle()
})
$(document).on('click.bs.toggle', 'div[data-toggle^=toggle]', function(e) {
var $checkbox = $(this).find('input[type=checkbox]')
$checkbox.bootstrapToggle('toggle')
e.preventDefault()
})
}(jQuery);

View File

@@ -0,0 +1,9 @@
/*! ========================================================================
* 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(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('<label class="btn">').html(this.options.on).addClass(this._onstyle+" "+b),d=a('<label class="btn">').html(this.options.off).addClass(this._offstyle+" "+b+" active"),e=a('<span class="toggle-handle btn btn-default">').addClass(b),f=a('<div class="toggle-group">').append(c,d,e),g=a('<div class="toggle btn" data-toggle="toggle">').addClass(this.$element.prop("checked")?this._onstyle:this._offstyle+" off").addClass(b).addClass(this.options.style);this.$element.wrap(g),a.extend(this,{$toggle:this.$element.parent(),$toggleOn:c,$toggleOff:d,$toggleGroup:f}),this.$toggle.append(f);var h=this.options.width||Math.max(c.outerWidth(),d.outerWidth())+e.outerWidth()/2,i=this.options.height||Math.max(c.outerHeight(),d.outerHeight());c.addClass("toggle-on"),d.addClass("toggle-off"),this.$toggle.css({width:h,height:i}),this.options.height&&(c.css("line-height",c.height()+"px"),d.css("line-height",d.height()+"px")),this.update(!0),this.trigger(!0)},c.prototype.toggle=function(){this.$element.prop("checked")?this.off():this.on()},c.prototype.on=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._offstyle+" off").addClass(this._onstyle),this.$element.prop("checked",!0),void(a||this.trigger()))},c.prototype.off=function(a){return this.$element.prop("disabled")?!1:(this.$toggle.removeClass(this._onstyle).addClass(this._offstyle+" off"),this.$element.prop("checked",!1),void(a||this.trigger()))},c.prototype.enable=function(){this.$toggle.removeAttr("disabled"),this.$element.prop("disabled",!1)},c.prototype.disable=function(){this.$toggle.attr("disabled","disabled"),this.$element.prop("disabled",!0)},c.prototype.update=function(a){this.$element.prop("disabled")?this.disable():this.enable(),this.$element.prop("checked")?this.on(a):this.off(a)},c.prototype.trigger=function(b){this.$element.off("change.bs.toggle"),b||this.$element.change(),this.$element.on("change.bs.toggle",a.proxy(function(){this.update()},this))},c.prototype.destroy=function(){this.$element.off("change.bs.toggle"),this.$toggleGroup.remove(),this.$element.removeData("bs.toggle"),this.$element.unwrap()};var d=a.fn.bootstrapToggle;a.fn.bootstrapToggle=b,a.fn.bootstrapToggle.Constructor=c,a.fn.toggle.noConflict=function(){return a.fn.bootstrapToggle=d,this},a(function(){a("input[type=checkbox][data-toggle^=toggle]").bootstrapToggle()}),a(document).on("click.bs.toggle","div[data-toggle^=toggle]",function(b){var c=a(this).find("input[type=checkbox]");c.bootstrapToggle("toggle"),b.preventDefault()})}(jQuery);
//# sourceMappingURL=bootstrap-toggle.min.js.map

View File

@@ -0,0 +1,49 @@
+function ($) {
'use strict';
$('.example:not(.skip)').each(function() {
// fetch & encode html
var html = $('<div>').text($(this).html()).html()
// find number of space/tabs on first line (minus line break)
var count = html.match(/^(\s+)/)[0].length - 1
// replace tabs/spaces on each lines with
var regex = new RegExp('\\n\\s{'+count+'}', 'g')
var code = html.replace(regex, '\n').replace(/\t/g, ' ').trim()
// other cleanup
code = code.replace(/=""/g,'')
// add code block to dom
$(this).after( $('<code class="highlight html">').html(code) )
});
$('code.highlight').each(function() {
hljs.highlightBlock(this)
});
}(jQuery);
var Demo = function () {}
Demo.prototype.init = function(selector) {
$(selector).bootstrapToggle(selector)
}
Demo.prototype.destroy = function(selector) {
$(selector).bootstrapToggle('destroy')
}
Demo.prototype.on = function(selector) {
$(selector).bootstrapToggle('on')
}
Demo.prototype.off = function(selector) {
$(selector).bootstrapToggle('off')
}
Demo.prototype.toggle = function(selector) {
$(selector).bootstrapToggle('toggle')
}
Demo.prototype.enable = function(selector) {
$(selector).bootstrapToggle('enable')
}
Demo.prototype.disable = function(selector) {
$(selector).bootstrapToggle('disable')
}
demo = new Demo()

240
js/bootstrap-confirmation.js vendored Normal file
View File

@@ -0,0 +1,240 @@
+function ($) {
'use strict';
//var for check event at body can have only one.
var event_body = false;
// CONFIRMATION PUBLIC CLASS DEFINITION
// ===============================
var Confirmation = function (element, options) {
var that = this;
this.init('confirmation', element, options);
$(element).on('show.bs.confirmation', function(e) {
that.options.onShow(e, this);
$(this).addClass('open');
var options = that.options;
var all = options.all_selector;
if(options.singleton) {
$(all+'.in').not(that.$element).confirmation('hide');
}
});
$(element).on('hide.bs.confirmation', function(e) {
that.options.onHide(e, this);
$(this).removeClass('open');
});
$(element).on('shown.bs.confirmation', function(e) {
var options = that.options;
var all = options.all_selector;
that.$element.on('click.dismiss.bs.confirmation', '[data-dismiss="confirmation"]', $.proxy(that.hide, that));
if(that.isPopout()) {
if(!event_body) {
event_body = $('body').on('click', function (e) {
if(that.$element.is(e.target)) return;
if(that.$element.has(e.target).length) return;
if($('.popover').has(e.target).length) return;
that.$element.confirmation('hide');
$('body').unbind(e);
event_body = false;
return;
});
}
}
});
$(element).on('click', function(e) {
e.preventDefault();
});
}
if (!$.fn.popover || !$.fn.tooltip) throw new Error('Confirmation requires popover.js and tooltip.js');
Confirmation.DEFAULTS = $.extend({}, $.fn.popover.Constructor.DEFAULTS, {
placement : 'right',
title : 'Are you sure?',
btnOkClass : 'btn btn-sm btn-danger',
btnOkLabel : '&emsp;Yes',
btnOkIcon : 'fa fa-check fa-lg',
btnCancelClass : 'btn btn-sm btn-default',
btnCancelLabel : '&ensp;Cancel',
btnCancelIcon : 'fa fa-times fa-lg',
href : '#',
target : '_self',
singleton : true,
popout : true,
onShow : function(event, element){},
onHide : function(event, element){},
onConfirm : function(event, element){},
onCancel : function(event, element){},
template : '<div class="popover"><div class="arrow"></div>'
+ '<h3 class="popover-title"></h3>'
+ '<div class="popover-content">'
+ '<a data-apply="confirmation">Yes</a>'
+ '<a data-dismiss="confirmation">No</a>'
+ '</div>'
+ '</div>'
});
// NOTE: CONFIRMATION EXTENDS popover.js
// ================================
Confirmation.prototype = $.extend({}, $.fn.popover.Constructor.prototype);
Confirmation.prototype.constructor = Confirmation;
Confirmation.prototype.getDefaults = function () {
return Confirmation.DEFAULTS;
}
Confirmation.prototype.setContent = function () {
var that = this;
var $tip = this.tip();
var title = this.getTitle();
var $btnOk = $tip.find('[data-apply="confirmation"]');
var $btnCancel = $tip.find('[data-dismiss="confirmation"]');
var options = this.options
$btnOk.addClass(this.getBtnOkClass())
.html(this.getBtnOkLabel())
.prepend($('<i></i>').addClass(this.getBtnOkIcon()), " ")
.attr('href', this.getHref())
.attr('target', this.getTarget())
.off('click').on('click', function(event) {
options.onConfirm(event, that.$element);
that.$element.confirmation('hide');
});
$btnCancel.addClass(this.getBtnCancelClass())
.html(this.getBtnCancelLabel())
.prepend($('<i></i>').addClass(this.getBtnCancelIcon()), " ")
.off('click').on('click', function(event){
options.onCancel(event, that.$element);
that.$element.confirmation('hide');
});
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title);
$tip.removeClass('fade top bottom left right in');
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
// this manually by checking the contents.
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide();
}
Confirmation.prototype.getBtnOkClass = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnOkClass') || (typeof o.btnOkClass == 'function' ? o.btnOkClass.call($e[0]) : o.btnOkClass);
}
Confirmation.prototype.getBtnOkLabel = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnOkLabel') || (typeof o.btnOkLabel == 'function' ? o.btnOkLabel.call($e[0]) : o.btnOkLabel);
}
Confirmation.prototype.getBtnOkIcon = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnOkIcon') || (typeof o.btnOkIcon == 'function' ? o.btnOkIcon.call($e[0]) : o.btnOkIcon);
}
Confirmation.prototype.getBtnCancelClass = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnCancelClass') || (typeof o.btnCancelClass == 'function' ? o.btnCancelClass.call($e[0]) : o.btnCancelClass);
}
Confirmation.prototype.getBtnCancelLabel = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnCancelLabel') || (typeof o.btnCancelLabel == 'function' ? o.btnCancelLabel.call($e[0]) : o.btnCancelLabel);
}
Confirmation.prototype.getBtnCancelIcon = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-btnCancelIcon') || (typeof o.btnCancelIcon == 'function' ? o.btnCancelIcon.call($e[0]) : o.btnCancelIcon);
}
Confirmation.prototype.getHref = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-href') || (typeof o.href == 'function' ? o.href.call($e[0]) : o.href);
}
Confirmation.prototype.getTarget = function () {
var $e = this.$element;
var o = this.options;
return $e.attr('data-target') || (typeof o.target == 'function' ? o.target.call($e[0]) : o.target);
}
Confirmation.prototype.isPopout = function () {
var popout;
var $e = this.$element;
var o = this.options;
popout = $e.attr('data-popout') || (typeof o.popout == 'function' ? o.popout.call($e[0]) : o.popout);
if(popout == 'false') popout = false;
return popout
}
// CONFIRMATION PLUGIN DEFINITION
// =========================
var old = $.fn.confirmation;
$.fn.confirmation = function (option) {
var that = this;
return this.each(function () {
var $this = $(this);
var data = $this.data('bs.confirmation');
var options = typeof option == 'object' && option;
options = options || {};
options.all_selector = that.selector;
if (!data && option == 'destroy') return;
if (!data) $this.data('bs.confirmation', (data = new Confirmation(this, options)));
if (typeof option == 'string') data[option]();
});
}
$.fn.confirmation.Constructor = Confirmation
// CONFIRMATION NO CONFLICT
// ===================
$.fn.confirmation.noConflict = function () {
$.fn.confirmation = old;
return this;
}
}(jQuery);