* @copyright Deakin University 2007,2008 * @package queXS * @subpackage admin * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 * * */ /** * Configuration file */ include("../config.inc.php"); /** * Database file */ include ("../db.inc.php"); /** * Authentication */ require ("auth-admin.php"); /** * XHTML functions */ include("../functions/functions.xhtml.php"); $css = array( "../include/bootstrap/css/bootstrap.min.css", "../include/bootstrap/css/bootstrap-theme.min.css", "../include/font-awesome/css/font-awesome.css", "../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css" ); $js_head = array( "../include/jquery/jquery.min.js", "../include/bootstrap/js/bootstrap.min.js", "../include/bootstrap-toggle/js/bootstrap-toggle.min.js", "../js/window.js" ); $js_foot = array( "../js/custom.js" ); global $db; if (isset($_GET['sort_order']) && isset($_GET['sort'])) { $sort_order = $_GET['sort_order']; if ($_GET['sort'] == "up") $so = $sort_order -1; if ($_GET['sort'] == "down") $so = $sort_order +1; $sql = "UPDATE questionnaire_sample SET sort_order = IF(sort_order = $sort_order, $so, $sort_order) WHERE sort_order IN( $sort_order, $so)"; $db->Execute($sql); unset($_GET['sort']); unset($_GET['sort_order']); } /* auto-set continiuos sort_order values for existing questionnaire_samples if not set before or first-time run */ if ($db->GetOne("SELECT COUNT(sort_order) - COUNT(DISTINCT sort_order ) FROM questionnaire_sample") >0){ $db->Execute("SELECT @i := 0"); $db->Execute("UPDATE `questionnaire_sample` SET sort_order = @i:=@i+1 WHERE 1=1 ORDER BY sort_order ASC"); } $subtitle = T_("List and sort samples"); xhtml_head(T_("Sort questionnaire samples"),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js") print " " . T_("Go back") . ""; print "

 ". T_("Sort order for questionnaire samples") ."

"; $sql = "SELECT q.sort_order as sort_order, si.description as description,si.sample_import_id, q.questionnaire_id, CONCAT('

', qu.description ,'

') as qdesc, CASE WHEN q.call_max = 0 THEN '". TQ_("Unlimited") ."' ELSE q.call_max END as call_max, CASE WHEN q.call_attempt_max = 0 THEN '". TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max, CASE WHEN q.random_select = 0 THEN '". TQ_("Sequential") ."' ELSE '". TQ_("Random") . "' END as random_select, CASE WHEN q.answering_machine_messages = 0 THEN '". TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages, CONCAT('') as edit FROM questionnaire_sample as q, sample_import as si, questionnaire as qu WHERE q.sample_import_id = si.sample_import_id AND q.questionnaire_id = qu.questionnaire_id AND qu.enabled = 1 ORDER BY q.sort_order ASC"; $qs = $db->GetAll($sql); if (!empty($qs)) { $co = count($qs); if ($co > 1) { for($i = 0; $i < $co; $i++) { $down = ""; $up = ""; if ($i == 0) //down only { $qs[$i]['sort_order'] = "
   " . $qs[$i]['sort_order'] . " " . $down . "
"; } else if ($i == ($co - 1)) //up only { $qs[$i]['sort_order'] = "
" .$up . " " . $qs[$i]['sort_order'] . ""; } else { $qs[$i]['sort_order'] = "
" . $up . " " . $qs[$i]['sort_order'] . " " . $down . "
"; } } } else $qs[0]['sort_order'] = "  "; xhtml_table($qs,array("sort_order","qdesc","description","call_max","call_attempt_max","answering_machine_messages","random_select","edit"),array(T_("Sort order"), T_("Questionnaire"),T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Edit"))); } else print "

". T_("No samples assigned to questionnaires") ."

"; print"
"; xhtml_foot($js_foot); ?>