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

@@ -56,6 +56,23 @@ include("../include/ckeditor/ckeditor.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",
"../include/font-awesome-4.3.0/css/font-awesome.css",
"../include/bootstrap-toggle/css/bootstrap-toggle.min.css",
"../css/custom.css"
);
$js_head = array(
"../js/jquery-2.1.3.min.js",
"../include/bootstrap-3.3.2/js/bootstrap.min.js"
);
$js_foot = array(
"../js/new.js",
"../include/bootstrap-toggle/js/bootstrap-toggle.min.js",
"../js/bootstrap-confirmation.js",
"../js/custom.js"
);
if (isset($_POST['questionnaire_id']) && isset($_POST['submit'])) if (isset($_POST['questionnaire_id']) && isset($_POST['submit']))
{ {
@@ -192,7 +209,6 @@ if (isset($_POST['questionnaire_id']) && isset($_POST['submit']))
$db->Execute($sql); $db->Execute($sql);
$db->CompleteTrans(); $db->CompleteTrans();
} }
if (isset($_GET['disable'])) if (isset($_GET['disable']))
@@ -243,7 +259,6 @@ if (isset($_POST['update']) && isset($_GET['modify']))
$info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8')); $info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8'));
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8')); $rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8'));
$sql = "UPDATE questionnaire $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 SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws', self_complete = $respsc, referral = $referral
WHERE questionnaire_id = '$questionnaire_id'"; WHERE questionnaire_id = '$questionnaire_id'";
@@ -255,7 +270,6 @@ if (isset($_POST['update']) && isset($_GET['modify']))
$sql = "UPDATE questionnaire $sql = "UPDATE questionnaire
SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine SET rs_intro = $rs_intro, rs_project_intro = $rs_project_intro, rs_callback = $rs_callback, rs_answeringmachine = $rs_answeringmachine
WHERE questionnaire_id = '$questionnaire_id'"; WHERE questionnaire_id = '$questionnaire_id'";
$db->Execute($sql); $db->Execute($sql);
} }
@@ -268,42 +282,17 @@ if (isset($_POST['update']) && isset($_GET['modify']))
$sql = "UPDATE questionnaire $sql = "UPDATE questionnaire
SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl
WHERE questionnaire_id = $questionnaire_id"; WHERE questionnaire_id = $questionnaire_id";
$db->Execute($sql); $db->Execute($sql);
} }
} }
xhtml_head(T_("Questionnaire list"),true,array("../css/table.css"),array("../js/new.js"));
if (isset($_GET['modify'])) if (isset($_GET['modify']))
{ {
$questionnaire_id = intval($_GET['modify']); $questionnaire_id = intval($_GET['modify']);
$CKEditor = new CKEditor();
$CKEditor->basePath = "../include/ckeditor/";
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
"/",
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
array('BidiLtr', 'BidiRtl'),
array('Link','Unlink','Anchor'),
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
"/",
array('Styles','Format','Font','FontSize'),
array('TextColor','BGColor'),
array('About')),
"extraPlugins" => "tokens");
$sql = "SELECT * $sql = "SELECT *
FROM questionnaire FROM questionnaire
WHERE questionnaire_id = $questionnaire_id"; WHERE questionnaire_id = $questionnaire_id";
$rs = $db->GetRow($sql); $rs = $db->GetRow($sql);
$referral = $testing = $rws = $ras = $rsc = "checked=\"checked\""; $referral = $testing = $rws = $ras = $rsc = "checked=\"checked\"";
@@ -314,7 +303,6 @@ if (isset($_GET['modify']))
if ($rs['lime_mode'] == "question") $qbq = "selected=\"selected\""; if ($rs['lime_mode'] == "question") $qbq = "selected=\"selected\"";
if ($rs['lime_mode'] == "group") $gat = "selected=\"selected\""; if ($rs['lime_mode'] == "group") $gat = "selected=\"selected\"";
if ($rs['restrict_appointments_shifts'] != 1) $ras = ""; if ($rs['restrict_appointments_shifts'] != 1) $ras = "";
if ($rs['restrict_work_shifts'] != 1) $rws = ""; if ($rs['restrict_work_shifts'] != 1) $rws = "";
if ($rs['testing'] != 1) $testing = ""; if ($rs['testing'] != 1) $testing = "";
@@ -325,20 +313,71 @@ if (isset($_GET['modify']))
$rscd = "style='display:none;'"; $rscd = "style='display:none;'";
} }
echo "<h1>" . $rs['description'] . "</h1>"; xhtml_head(T_("Modify Questionnaire "),true,$css,$js_head, false, false, false, " &ensp;<span class=' text-uppercase'>" . "$rs[description]" . "</span>");
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_sid']}'>" . T_("Edit instrument in Limesurvey") . "</a></p>"; $CKEditor = new CKEditor();
$CKEditor->basePath = "../include/ckeditor/";
$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"),
array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"),
array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"),
array('Link','Unlink','Anchor'),
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
array('About'),
"/",
array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"),
array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
array('BidiLtr', 'BidiRtl'),
array('Styles','Format','Font','FontSize'),
array('TextColor','BGColor')),
"extraPlugins" => "tokens");
?> ?>
<form action="?modify=<?php echo $questionnaire_id; ?>" method="post"> <div class="form-group">
<p><?php echo T_("Name for questionnaire:"); ?> <input type="text" name="description" value="<?php echo $rs['description']; ?>"/></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_("Restrict appointments to shifts?"); ?> <input name="ras" type="checkbox" <?php echo $ras; ?>/></p> <div class="col-sm-8"><?php // ?> </div>
<p><?php echo T_("Restrict work to shifts?"); ?> <input name="rws" type="checkbox" <?php echo $rws; ?>/></p> <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 for testing only?"); ?> <input name="testing" type="checkbox" disabled="true" <?php echo $testing; ?>/></p> </div>
<p><?php echo T_("Allow operators to generate referrals?"); ?> <input name="referral" type="checkbox" <?php echo $referral; ?>/></p>
<p><?php echo T_("Allow for respondent self completion via email invitation?"); ?> <input name="respsc" type="checkbox" <?php echo $rsc ?> onchange="if(this.checked==true) show(this,'limesc'); else hide(this,'limesc');" /></p> <form action="?modify=<?php echo $questionnaire_id; ?>" method="post" class="form-horizontal col-sm-12">
<div id='limesc' <?php echo $rscd; ?>> <div class="form-group">
<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> <label class="col-sm-4 control-label" ><?php echo T_("Edit"),"&ensp;", T_("Name for questionnaire:"); ?> </label>
<p><?php echo T_("Limesurvey template for respondent");?>: <select name="lime_template"> <div class="col-sm-4"><input type="text" name="description" class="form-control" value="<?php echo $rs['description']; ?>" label="<?php echo T_("Name for questionnaire:") ; ?> "/></div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Restrict appointments to shifts?"); ?> </label>
<div class="col-sm-4" style="height: 30px;"><input name="ras" type="checkbox" <?php echo $ras; ?> data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/> </div>
</div>
<div class="form-group"><label class="col-sm-4 control-label" ><?php echo T_("Restrict work to shifts?"); ?> </label>
<div class="col-sm-4" style="height: 30px;" ><input name="rws" type="checkbox" <?php echo $rws; ?> data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/></div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Questionnaire for testing only?"); ?> </label>
<div class="col-sm-4" style="height: 30px;" ><input name="testing" type="checkbox" disabled="true" data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>" <?php echo $testing; ?> data-onstyle="danger" /></div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Allow operators to generate referrals?"); ?></label>
<div class="col-sm-4" style="height: 30px;"> <input name="referral" type="checkbox" <?php echo $referral; ?> data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/></div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Allow for respondent self completion via email invitation?"); ?> </label>
<div class="col-sm-4" style="height: 30px;"><input name="respsc" id="respsc" type="checkbox" <?php echo $rsc ?> onchange="if(this.checked==true) show(this,'limesc'); else hide(this,'limesc');" data-toggle="toggle" data-on="<?php echo T_("YES"); ?>" data-off="<?php echo T_("NO"); ?>"/></div>
</div>
<div id="limesc" <?php echo $rscd; ?> >
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Questionnaire display mode for respondent");?>: </label>
<div class="col-sm-4">
<select class="form-control" name="lime_mode">
<option <?php echo $aio;?> value="survey"><?php echo T_("All in one"); ?></option>
<option <?php echo $qbq;?> value="question"><?php echo T_("Question by question"); ?></option>
<option <?php echo $gat;?> value="group"><?php echo T_("Group at a time"); ?></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Limesurvey template for respondent");?>: </label>
<div class="col-sm-4">
<select class="form-control" name="lime_template">
<?php <?php
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) { if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
@@ -346,27 +385,36 @@ if (isset($_GET['modify']))
echo "<option value=\"$entry\" "; echo "<option value=\"$entry\" ";
if ($rs['lime_template'] == $entry) echo " selected=\"selected\" "; if ($rs['lime_template'] == $entry) echo " selected=\"selected\" ";
echo ">$entry</option>"; echo ">$entry</option>";
} }
} }
closedir($handle); closedir($handle);
} }
?> ?>
</select></p> </select>
<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> </div>
<?php if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) { ?> </div>
<p><?php echo T_("Respondent selection introduction:"); echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);?></p> <div class="form-group">
<p><?php echo T_("Respondent selection project introduction:"); echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);?></p> <label class="col-sm-4 control-label text-danger" ><?php echo T_("URL to forward respondents on self completion (required)");?>: </label>
<p><?php echo T_("Respondent selection callback (already started questionnaire):"); echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);?> </p> <div class="col-sm-4">
<p><?php echo T_("Message to leave on an answering machine:"); echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);?> </p> <input class="form-control" name="lime_endurl" type="text" value="<?php echo $rs['lime_endurl']; ?>"/>
<?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>"; } ?> </div>
<p><?php echo T_("Project end text (thank you screen):");echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig); ?></p> </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> <?php
if ($rs['respondent_selection'] == 1 && empty($rs['lime_rs_sid'])) {
echo "<p><h4 style='text-align:center;' >" . T_("Respondent selection introduction:") . "</h4>"; echo $CKEditor->editor("rs_intro",$rs['rs_intro'],$ckeditorConfig);
echo "</p><p><h4 style='text-align:center;' >" . T_("Respondent selection project introduction:") . "</h4>"; echo $CKEditor->editor("rs_project_intro",$rs['rs_project_intro'],$ckeditorConfig);
echo "</p><p><h4 style='text-align:center;' >" . T_("Respondent selection callback (already started questionnaire):") . "</h4>"; echo $CKEditor->editor("rs_callback",$rs['rs_callback'],$ckeditorConfig);
echo "</p><p><h4 style='text-align:center;' >" . T_("Message to leave on an answering machine:") . "</h4>"; echo $CKEditor->editor("rs_answeringmachine",$rs['rs_answeringmachine'],$ckeditorConfig);
echo "</p>"; }
else if (!empty($rs['lime_rs_sid'])) { echo "<p><a href='" . LIME_URL . "admin/admin.php?sid={$rs['lime_rs_sid']}'>" . T_("Edit respondent selection instrument in Limesurvey") . "</a></p>"; }
echo "<p><h4 style='text-align:center;' >" . T_("Project end text (thank you screen):") . "</h4>"; echo $CKEditor->editor("rs_project_end",$rs['rs_project_end'],$ckeditorConfig);
echo "</p><p><h4 style='text-align:center;' >" . T_("Project information for interviewers/operators:") . "</h4>"; echo $CKEditor->editor("info",$rs['info'],$ckeditorConfig);
echo "</p>";
?>
<p><a href="questionnairelist.php" class="btn btn-default"><i class="fa fa-chevron-left fa-lg" style="color:blue;"></i>&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> </form>
<?php <?php
} }
else if (isset($_GET['delete'])) else if (isset($_GET['delete']))
{ {
@@ -375,47 +423,89 @@ else if (isset($_GET['delete']))
$sql = "SELECT * $sql = "SELECT *
FROM questionnaire FROM questionnaire
WHERE questionnaire_id = $questionnaire_id"; WHERE questionnaire_id = $questionnaire_id";
$rs = $db->GetRow($sql); $rs = $db->GetRow($sql);
echo "<h1>" . $rs['description'] . "</h1>"; xhtml_head(T_("Delete Questionnaire"),true,$css,$js_head, false, false, false, "&ensp;<span class='text-uppercase'>" . "$rs[description]" . "</span>");
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; print "<div class='alert alert-danger'><p>" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "</p>";
print "<p>" . T_("Any collected data and the limesurvey instrument will NOT be deleted") . "</p>";
print "<p>" . T_("The questionnaire will be deleted from queXS including call history, cases, case notes, respondent details, appointments and the links between operators, clients and the questionnaire") . "</p>"; print "<p>" . T_("The questionnaire will be deleted from queXS including call history, cases, case notes, respondent details, appointments and the links between operators, clients and the questionnaire") . "</p>";
print "<p>" . T_("Please confirm you wish to delete the questionnaire") . "</p>"; print "<p>" . T_("Please confirm you wish to delete the questionnaire") . "</p></div>";
print "<form method='post' action='?'>"; print "<form method='post' action='?'>";
print "<p><input type='submit' name='submit' value=\"" . T_("Delete this questionnaire") . "\"/>"; 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 "<input type='hidden' name='questionnaire_id' value='$questionnaire_id'/></p>";
print "</form>"; print "</form>";
} }
else else
{ {
$columns = array("description","enabledisable","modify","deletee"); xhtml_head(T_("Questionnaire management"),true,$css,$js_head, false, false, false, "Questionnaire list");
$titles = array(T_("Questionnaire"),T_("Enable/Disable"),T_("Modify"),T_("Delete")); 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 $sql = "SELECT
description, CONCAT('&ensp;<b class=\'badge\'>',questionnaire_id,'</b>&ensp;') as qid,
CONCAT('<h4>',description,'</h4>') as description,
CASE WHEN enabled = 0 THEN CASE WHEN enabled = 0 THEN
CONCAT('<a href=\'?enable=',questionnaire_id,'\'>" . TQ_("Enable") . "</a>') CONCAT('&ensp;<span class=\'btn label label-default\'>" . TQ_("Disabled") . "</span>&ensp;')
ELSE ELSE
CONCAT('<a href=\'?disable=',questionnaire_id,'\'>" . TQ_("Disable") . "</a>') CONCAT('&ensp;<span class=\'btn label label-primary\'>" . TQ_("Enabled") . "</span>&ensp;')
END END as status,
as enabledisable, CASE WHEN enabled = 0 THEN
CONCAT('<a href=\'?modify=',questionnaire_id,'\'>" . TQ_("Modify"). "</a>') as modify, 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;')
CONCAT('<a href=\'?delete=',questionnaire_id,'\'>" . TQ_("Delete"). "</a>') as deletee 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"; FROM questionnaire";
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
$columns = array("qid","description","status","enabledisable","outcomes","calls","casestatus","shifts","assample","dataout","modify","inlime","prefill","deletee");
xhtml_table($rs,$columns,false,"table-hover table-condensed ");
xhtml_table($rs,$columns,$titles); print "</div>";
} }
xhtml_foot($js_foot);
xhtml_foot();
?> ?>
<script type="text/javascript">
$('[data-toggle="confirmation"]').confirmation()
</script>

View File

@@ -44,7 +44,22 @@ include_once(dirname(__FILE__).'/../db.inc.php');
*/ */
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",
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
"../include/font-awesome-4.3.0/css/font-awesome.css",
"../css/bootstrap-switch.min.css",
"../css/custom.css"
);
$js_head = array(
"../js/jquery-2.1.3.min.js",
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
"../js/bootstrap-switch.min.js"
);
$js_foot = array(
"../js/bootstrap-confirmation.js",
"../js/custom.js"
);
if (isset($_POST['submitr'])) if (isset($_POST['submitr']))
{ {
@@ -74,7 +89,6 @@ if (isset($_POST['submit']))
(SELECT sample_id (SELECT sample_id
FROM sample FROM sample
WHERE import_id = $sample_import_id)"; WHERE import_id = $sample_import_id)";
$db->Execute($sql); $db->Execute($sql);
} }
@@ -88,13 +102,11 @@ if (isset($_POST['submitvp']))
unset($_POST['submitvp']); unset($_POST['submitvp']);
unset($_POST['sample_import_id']); unset($_POST['sample_import_id']);
$db->StartTrans(); $db->StartTrans();
$sql = "UPDATE sample_import_var_restrict $sql = "UPDATE sample_import_var_restrict
SET `restrict` = 1 SET `restrict` = 1
WHERE sample_import_id = $sample_import_id"; WHERE sample_import_id = $sample_import_id";
$db->Execute($sql); $db->Execute($sql);
foreach($_POST as $p => $val) foreach($_POST as $p => $val)
@@ -103,7 +115,6 @@ if (isset($_POST['submitvp']))
SET `restrict` = 0 SET `restrict` = 0
WHERE sample_import_id = $sample_import_id WHERE sample_import_id = $sample_import_id
AND `var` LIKE " . $db->qstr($p); AND `var` LIKE " . $db->qstr($p);
$db->Execute($sql); $db->Execute($sql);
} }
@@ -114,36 +125,38 @@ if (isset($_POST['submitvp']))
if (isset($_GET['rename'])) if (isset($_GET['rename']))
{ {
xhtml_head(T_("Rename"),true,array("../css/table.css")); $subtitle=T_("Rename sample");
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . T_("Go back") . "</a>";
$sample_import_id = intval($_GET['rename']); $sample_import_id = intval($_GET['rename']);
$sql = "SELECT description $sql = "SELECT description
FROM sample_import FROM sample_import
WHERE sample_import_id = $sample_import_id"; WHERE sample_import_id = $sample_import_id";
$rs = $db->GetOne($sql); $rs = $db->GetOne($sql);
print "<h2>" . T_("Rename") . ": " . $rs. "</h2>"; print "<h3>" . T_("Sample current description") . ":&ensp;<span class='text-primary'>" . $rs . "</span></h3>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
?> ?>
<form action="?" method="post"> <form action="?" method="post" class="form-group " >
<div><label for='description'><?php echo T_("Description") . ": "; ?></label><input type='text' name='description' value="<?php echo $rs;?>"/></div> <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>
<div class="col-sm-4"><input type='text' name='description' class="form-control" value="<?php echo $rs;?>"/></div>
</div>
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div> <div><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> <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>
</form> </form>
<?php <?php
xhtml_foot(); xhtml_foot();
exit(); exit();
} }
if (isset($_GET['view'])) if (isset($_GET['view']))
{ {
xhtml_head(T_("Operator viewing permissions"),true,array("../css/table.css")); $subtitle=T_("Operator viewing permissions");
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . T_("Go back") . "</a>";
$sample_import_id = intval($_GET['view']); $sample_import_id = intval($_GET['view']);
@@ -154,7 +167,7 @@ if (isset($_GET['view']))
$sample_id = $db->GetOne($sql); $sample_id = $db->GetOne($sql);
$sql = "SELECT si.description, sv.val, sv.var, $sql = "SELECT si.description, sv.val, sv.var,
CONCAT('<input type=\'checkbox\' ', CASE WHEN (sir.restrict IS NULL || sir.restrict = 0) THEN 'checked=\"checked\"' ELSE '' END ,' name=\'',sv.var,'\' value=\'11\'/>') as box, 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 sir.restrict IS NULL as existss
FROM sample_import as si FROM sample_import as si
JOIN `sample` as s ON (s.import_id = si.sample_import_id AND s.sample_id = $sample_id) JOIN `sample` as s ON (s.import_id = si.sample_import_id AND s.sample_id = $sample_id)
@@ -171,70 +184,73 @@ if (isset($_GET['view']))
{ {
$sql = "INSERT INTO sample_import_var_restrict (sample_import_id,var,`restrict`) $sql = "INSERT INTO sample_import_var_restrict (sample_import_id,var,`restrict`)
VALUES ($sample_import_id,'{$r['var']}',0)"; VALUES ($sample_import_id,'{$r['var']}',0)";
$db->Execute($sql); $db->Execute($sql);
} }
} }
print "<h2>" . T_("Operator viewing permissions") . ": " . $rs[0]['description'] . "</h2>"; print "<h3>" . T_("Operator viewing permissions") . "&ensp;". T_("for") . "&ensp;" . T_("sample") . ": " . $rs[0]['description'] . "</h3>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>"; 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 "<p>" . T_("Select which fields from this sample should be able to be viewed by operators") . "</p>"; print "<div class='alert alert-info' role='alert'><p>" . T_("Select which fields from this sample should be able to be viewed by operators") . "</p></div>
<form action='?' method='post' class='form-group form-horisontal'>";
?>
<form action="?" method="post">
<?php
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Allow operator to see?"))); xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Allow operator to see?")));
?> ?>
<div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div> <div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div></br>
<div><input type="submit" name="submitvp" value="<?php echo T_("Save changes");?>"/></div> <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>
</form> </form>
<script type="text/javascript">
$('[switch="yes"]').bootstrapSwitch();
</script>
<?php <?php
}
xhtml_foot(); xhtml_foot();
exit(); exit();
} }
if (isset($_GET['edit'])) if (isset($_GET['edit']))
{ {
xhtml_head(T_("Deidentify"),true,array("../css/table.css")); $subtitle=T_("Delete sample variables") ;
xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle);
echo "<a href='?' class='btn btn-default' ><i class='fa fa-chevron-left fa-lg' style='color:blue;'></i>&emsp;" . T_("Go back") . "</a>";
$sample_import_id = intval($_GET['edit']); $sample_import_id = intval($_GET['edit']);
$sql = "SELECT si.description, sv.val, sv.var, $sql = "SELECT si.description, sv.val, sv.var,
CONCAT('<input type=\'checkbox\' name=\'',sv.var,'\' value=\'',sv.var,'\'/>') as box 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 FROM sample_import as si, sample_var as sv, sample as s
WHERE si.sample_import_id = $sample_import_id WHERE si.sample_import_id = $sample_import_id
AND sv.sample_id = s.sample_id AND sv.sample_id = s.sample_id
AND s.import_id = si.sample_import_id AND s.import_id = si.sample_import_id
GROUP BY sv.var"; GROUP BY sv.var";
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
print "<h2>" . T_("Deidentify") . ": " . $rs[0]['description'] . "</h2>"; print "<h3>" . T_("Sample") . ": " . $rs[0]['description'] . "</h3>";
echo "<p><a href='?'>" . T_("Go back") . "</a></p>";
print "<p>" . T_("Select which fields from this sample to deidentify. Deidentified fields will be permanently deleted from the sample.") . "</p>";
if ($rs){
print "<div class='alert alert-danger' role='alert'><p>" . T_("Select which fields from this sample to deidentify. Deidentified fields will be permanently deleted from the sample.") . "</p></div>";
?> ?>
<form action="?" method="post"> <form action="?" method="post">
<?php <?php
xhtml_table($rs,array("var","val","box"),array(T_("Field"),T_("Example data"),T_("Deidentify"))); 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> <div><input type='hidden' name='sample_import_id' value='<?php echo $sample_import_id;?>'/></div>
<div><input type="submit" name="submit" value="<?php echo T_("Delete selected fields");?>"/></div> </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>
</form> </form>
<script type="text/javascript">
$('[switch="yes"]').bootstrapSwitch();
</script>
<?php <?php
}
else
{
print "<div class='alert alert-info col-sm-6' role='alert'><h4>" . T_("There's no data in this sample. Probably was deidentified earlier.") . "</h4></div>";
}
xhtml_foot(); xhtml_foot();
exit(); exit();
} }
if (isset($_GET['sampledisable'])) if (isset($_GET['sampledisable']))
{ {
$id = intval($_GET['sampledisable']); $id = intval($_GET['sampledisable']);
@@ -242,7 +258,6 @@ if (isset($_GET['sampledisable']))
$sql = "UPDATE sample_import $sql = "UPDATE sample_import
SET enabled = 0 SET enabled = 0
WHERE sample_import_id = '$id'"; WHERE sample_import_id = '$id'";
$db->Execute($sql); $db->Execute($sql);
} }
@@ -253,32 +268,48 @@ if (isset($_GET['sampleenable']))
$sql = "UPDATE sample_import $sql = "UPDATE sample_import
SET enabled = 1 SET enabled = 1
WHERE sample_import_id = '$id'"; WHERE sample_import_id = '$id'";
$db->Execute($sql); $db->Execute($sql);
} }
$sql = "SELECT $sql = "SELECT
CONCAT('&ensp;<b class=\'badge\'>',sample_import_id,'</b>&ensp;') as id,
CASE WHEN enabled = 0 THEN CASE WHEN enabled = 0 THEN
CONCAT('<a href=\'?sampleenable=',sample_import_id,'\'>" . TQ_("Enable") . "</a>') CONCAT('&emsp; <span class=\'btn label label-default\'>" . TQ_("Disabled") . "</span>&emsp;')
ELSE ELSE
CONCAT('<a href=\'?sampledisable=',sample_import_id,'\'>" . TQ_("Disable") . "</a>') CONCAT('&emsp; <span class=\'btn label label-primary\'>" . TQ_("Enabled") . "</span>&emsp;')
END as status,
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>')
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 END
as enabledisable, as enabledisable,
CONCAT('<a href=\'?edit=',sample_import_id,'\'>" . TQ_("Deidentify") . "</a>') as did, CASE WHEN enabled = 1 THEN
CONCAT('<a href=\'?view=',sample_import_id,'\'>" . TQ_("Operator viewing permissions") . "</a>') as vp, 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>')
CONCAT('<a href=\'?rename=',sample_import_id,'\'>" . TQ_("Rename") . "</a>') as rname, ELSE
description 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"; FROM sample_import";
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
xhtml_head(T_("Sample list"),true,array("../css/table.css")); $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 ");
$columns = array("description","enabledisable","did","vp","rname"); xhtml_foot($js_foot);
$titles = array(T_("Sample"),T_("Enable/Disable"),T_("Deidentify"),T_("Operator viewing permissions"),T_("Rename"));
xhtml_table($rs,$columns,$titles);
xhtml_foot();
?> ?>
<script type="text/javascript">
//$('[switch="yes"]').bootstrapSwitch()
$('[data-toggle="confirmation"]').confirmation()
</script>

View File

@@ -46,14 +46,68 @@ include ("../db.inc.php");
*/ */
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",
"../include/font-awesome-4.3.0/css/font-awesome.css",
"../include/bs-data-table/css/jquery.bdt.css",
"../css/custom.css"
);
$js_head = array(
"../js/jquery-2.1.3.min.js",
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
);
$js_foot = array(
"../include/bs-data-table/js/vendor/jquery.sortelements.js",
"../include/bs-data-table/js/jquery.bdt.js",
"../js/window.js",
"../js/custom.js"
);
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
$subtitle = T_("Search within this sample");
xhtml_head(T_("Search the sample"),true,$css,$js_head);
?>
<div class="modal fade delete-confirm" id="delete-confirm" tabindex="-1" role="dialog" aria-labelledby="delete-confirm" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title text-danger " ><?php echo T_("WARNING !");?></h4>
</div>
<div class="modal-body">
<p><?php echo T_("Are you shure you want to delete") . "&ensp;" . T_("Sample ID") . "&ensp;<b class='text-danger'>" . "</b>?";?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo T_("NOOOO...");?></button>
<a class="btn btn-danger" href=" "><?php echo T_("Yes"),",&ensp;",T_("Delete");?></a>
</div>
</div>
</div>
</div>
<?php
echo "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left' ><i class='fa fa-chevron-left text-primary'></i>&emsp;" . T_("Go back") . "</a>";
$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM sample_import";
$r = $db->GetAll($sql);
if(!empty($r))
print "<div class=' form-inline form-group col-md-6'><h4 class='control-label form-group col-sm-6 text-right'>" . T_("Select sample ") . "&emsp;</h4>";
display_chooser($r,"sample_import_id","sample_import_id",true,false,true,false);
print "</div>";
if (isset($_GET['sample_id'])) if (isset($_GET['sample_id']))
{ {
@@ -65,102 +119,77 @@ if (isset($_GET['sample_id']))
$sql = "DELETE FROM sample_var $sql = "DELETE FROM sample_var
WHERE sample_id = '$sample_id'"; WHERE sample_id = '$sample_id'";
$db->Execute($sql); $db->Execute($sql);
$sql = "DELETE FROM sample $sql = "DELETE FROM sample
WHERE sample_id = '$sample_id'"; WHERE sample_id = '$sample_id'";
$db->Execute($sql); $db->Execute($sql);
$db->CompleteTrans(); $db->CompleteTrans();
print "<div class='alert alert-danger pull-left form-group col-sm-6' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button><p>" . T_("Sample ID") . "&ensp;<b>" . $sample_id . "</b>&ensp;" . T_("Deleted") . ".</p></div>";
} }
print "<div class='clearfix'></div>";
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
xhtml_head(T_("Search sample"),true,array("../css/table.css"),array("../js/window.js"));
print "<h1>" . T_("Select a sample from the list below") . "</h1>";
$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM sample_import";
$r = $db->GetAll($sql);
if(!empty($r))
display_chooser($r,"sample_import_id","sample_import_id");
if ($sample_import_id != false) if ($sample_import_id != false)
{ {
if (isset($_GET['search'])) $sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN
{ CONCAT('<a href=\'\' data-toggle=\'modal\' data-target=\'.delete-confirm\' data-href=\'?sample_import_id=$sample_import_id&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>')
$search = $db->qstr($_GET['search']); ELSE CONCAT('<a href=\'supervisor.php?case_id=', c.case_id , '\' data-toggle=\'tooltip\' title=\'" . TQ_("Assigned to case ID :") . " ', c.case_id , '\'><b>', c.case_id ,'</b></a>')
END as link
$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 FROM sample_var AS sv
JOIN (sample as s) ON (s.import_id = '$sample_import_id' and sv.sample_id = s.sample_id) 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 ) LEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id )
WHERE sv.val LIKE $search
GROUP BY s.sample_id, c.case_id"; GROUP BY s.sample_id, c.case_id";
$r = $db->GetAll($sql); $r = $db->GetAll($sql);
if (empty($r)) if ($r) {
print "<p>" . T_("No records in this sample match this search criteria") . "</p>";
else
{
//add sample information to results
$sql = "SELECT var $sql = "SELECT var
FROM sample_var FROM sample_var
WHERE sample_id = {$r[0]['sample_id']}"; WHERE sample_id = {$r[0]['sample_id']}
ORDER by var ASC";
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
$fnames = array("sample_id"); $fnames = array("sample_id");
$fdesc = array(T_("Sample id")); $fdesc = array(T_("Sample id"));
$fnames[] = "link";
$fdesc[] = T_("Case ID");
foreach($rs as $rsw) foreach($rs as $rsw)
{ {
$fnames[] = $rsw['var']; $fnames[] = $rsw['var'];
$fdesc[] = $rsw['var']; $fdesc[] = $rsw['var'];
} }
$fnames[] = "link";
$fdesc[] = T_("Link");
foreach($r as &$rw) foreach($r as &$rw)
{ {
$sql = "SELECT var,val $sql = "SELECT var,val
FROM sample_var FROM sample_var
WHERE sample_id = {$rw['sample_id']}"; WHERE sample_id = {$rw['sample_id']}";
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
foreach($rs as $rsw) foreach($rs as $rsw)
$rw[$rsw['var']] = $rsw['val']; $rw[$rsw['var']] = $rsw['val'];
} }
xhtml_table($r,$fnames,$fdesc); 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);
print "<h1>" . T_("Search within this sample") . "</h1>";
print "<p>" . T_("Use the % character as a wildcard") ."</p>";
?>
<form action="" method="get">
<p>
<label for="search"><?php echo T_("Search for:"); ?></label><input type="text" name="search" id="search"/><br/>
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
<input type="submit" name="searchsub" value="<?php echo T_("Start search"); ?>"/>
</p>
</form>
<?php
}
xhtml_foot();
?> ?>
<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);