* @copyright Deakin University 2007,2008,2009 * @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 file */ require ("auth-admin.php"); /** * XHTML functions */ include("../functions/functions.xhtml.php"); /** * Display functions */ include("../functions/functions.display.php"); /** * Input functions */ include("../functions/functions.input.php"); /** * Limesurvey functions */ include("../functions/functions.limesurvey.php"); /** * Operator functions */ include("../functions/functions.operator.php"); global $db; if (isset($_POST['submitdelete'])) { foreach($_POST as $key => $val) { if (substr($key,0,7) == "select_") { $tmp = bigintval(substr($key,7)); open_row_quota($tmp); } } } if (isset($_POST['submitexport'])) { $csv = array(); foreach($_POST as $key => $val) { if (substr($key,0,7) == "select_") { $tmp = bigintval(substr($key,7)); $sql = "SELECT description,completions,autoprioritise FROM questionnaire_sample_quota_row WHERE questionnaire_sample_quota_row_id = $tmp"; $rs = $db->GetRow($sql); $sql = "SELECT lime_sgqa,comparison,value FROM qsqr_question WHERE questionnaire_sample_quota_row_id = $tmp"; $q2 = $db->GetAll($sql); $sql = "SELECT exclude_var_id, exclude_var as samplerecord,comparison,exclude_val as value FROM qsqr_sample WHERE questionnaire_sample_quota_row_id = $tmp"; $q3 = $db->GetAll($sql); $ta = array($rs['description'],$rs['completions'],$rs['autoprioritise']); //just search where col 1 looks like 333X2X2 and assume it is a question foreach($q2 as $qr) foreach($qr as $qe => $val) $ta[] = $val; foreach($q3 as $qr) foreach($qr as $qe => $val) $ta[] = $val; $csv[] = $ta; } } if (!empty($csv)) { $fn = T_("Quota") .".csv"; header("Content-Type: text/csv"); header("Content-Disposition: attachment; filename=$fn"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); Header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); // HTTP/1.0 foreach($csv as $cr) { for ($i = 0; $i < count($cr); $i++) { echo str_replace(","," ",$cr[$i]); if ($i < (count($cr) - 1)) echo ","; } echo "\n"; } die(); } } if (isset($_GET['delete'])) { $qsqri = bigintval($_GET['qsqri']); if (isset($_GET['qsqrqi'])) { $qsqrqi = bigintval($_GET['qsqrqi']); $sql = "DELETE FROM qsqr_question WHERE qsqr_question_id = $qsqrqi"; $db->Execute($sql); //Make sure to calculate on the spot update_single_row_quota($qsqri); } if (isset($_GET['qsqrsi'])) { $qsqrsi = bigintval($_GET['qsqrsi']); $sql = "DELETE FROM qsqr_sample WHERE qsqr_sample_id = $qsqrsi"; $db->Execute($sql); //Make sure to calculate on the spot update_single_row_quota($qsqri); } } if (isset($_POST['add_quota'])) /* if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison']) && isset($_GET['exclude_var_id']) && isset($_GET['exclude_var']) && isset($_GET['exclude_val'])) */ { //need to add quota $completions = intval($_POST['completions']); $autoprioritise = 0; if (isset($_POST['autoprioritise'])) $autoprioritise = 1; $priority = intval($_POST['priority']); $questionnaire_id = bigintval($_GET['questionnaire_id']); $sample_import_id = bigintval($_GET['sample_import_id']); $description = $db->quote($_POST['description']); $sql = "INSERT INTO questionnaire_sample_quota_row(questionnaire_id, sample_import_id, completions, description, priority, autoprioritise) VALUES ($questionnaire_id, $sample_import_id, $completions, $description, $priority, $autoprioritise)"; $db->Execute($sql); $qq = $db->Insert_ID(); //Make sure to calculate on the spot update_single_row_quota($qq); } if (isset($_POST['edit_quota'])) { $completions = intval($_POST['completions']); $autoprioritise = 0; if (isset($_POST['autoprioritise'])) $autoprioritise = 1; $priority = intval($_POST['priority']); $description = $db->quote($_POST['description']); $qsqri = bigintval($_POST['qsqri']); $sql = "UPDATE questionnaire_sample_quota_row SET completions = $completions, autoprioritise = $autoprioritise, priority = $priority, description = $description WHERE questionnaire_sample_quota_row_id = $qsqri"; $db->Execute($sql); $_GET['qsqri'] = $qsqri; $_GET['edit'] = "edit"; //Make sure to calculate on the spot update_single_row_quota($qsqri); } $qsqri = false; $qsqrid = false; if (isset($_GET['qsqri']) & isset($_GET['edit'])) { $qsqri = bigintval($_GET['qsqri']); $sql = "SELECT questionnaire_id,sample_import_id,description,autoprioritise,priority,completions FROM questionnaire_sample_quota_row WHERE questionnaire_sample_quota_row_id = $qsqri"; $rs = $db->GetRow($sql); $_GET['questionnaire_id'] = $rs['questionnaire_id']; $_GET['sample_import_id'] = $rs['sample_import_id']; $qsqrid = $rs['description']; $qsqrich = ""; if ($rs['autoprioritise'] == 1) $qsqrich = "checked=\"checked\""; $qsqric = $rs['completions']; $qsqrip = $rs['priority']; if (isset($_POST['adds'])) { $exvar_id = $db->qstr(substr($_POST['sample_var_id'],15,strpos($_POST['sample_var_id'],'&')-15)); $exvar = $db->qstr($_POST['sample_var']); $exval = $db->qstr($_POST['exclude_val']); $comparison = $db->qstr($_POST['comparisons']); $description = $db->qstr($_POST['description']); //add ssample $sql = "INSERT INTO qsqr_sample (questionnaire_sample_quota_row_id,exclude_var_id,exclude_var,exclude_val,comparison,description) VALUES ($qsqri,$exvar_id,$exvar,$exval,$comparison,$description)"; $db->Execute($sql); //Make sure to calculate on the spot update_single_row_quota($qsqri); } if (isset($_POST['addq'])) { $sgqa = $db->qstr(substr($_POST['sgqa'],6,strpos($_POST['sgqa'],'&')-6)); $value = $db->qstr($_POST['value']); $comparison = $db->qstr($_POST['comparison']); $description = $db->qstr($_POST['description']); //add ssample $sql = "INSERT INTO qsqr_question (questionnaire_sample_quota_row_id,lime_sgqa,value,comparison,description) VALUES ($qsqri,$sgqa,$value,$comparison,$description)"; $db->Execute($sql); //Make sure to calculate on the spot update_single_row_quota($qsqri); } } $questionnaire_id = false; if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); xhtml_head(T_("Quota row management"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../include/font-awesome/css/font-awesome.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../include/jquery/jquery.min.js","../include/bootstrap/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../include/iCheck/icheck.min.js","../js/window.js")); print "
" . T_("Currently no row quotas") . "
"; } else { print ""; } print "