* @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 file */ require ("auth-admin.php"); /** * XHTML functions */ include ("../functions/functions.xhtml.php"); /** * Determine if an operator has been assigned to a skill (outcome_type) * * @param int $operator_id Operator id * @param int $outcome_type_id Outcome type id (skill) * @return int 1 if assigned to that skill otherwise 0 * */ function vq($operator_id,$outcome_type_id) { global $db; $sql = "SELECT operator_id,outcome_type_id FROM operator_skill WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'"; $vq = $db->Execute($sql); if ($vq) return $vq->RecordCount(); else return 0; } /** * Assign an operator to a skill (outcome_type) * * @param int $operator_id Operator id * @param int $outcome_type_id Outcome type id (skill) * */ function vqi($operator_id,$outcome_type_id) { global $db; $sql = "INSERT INTO operator_skill (operator_id,outcome_type_id) VALUES('$operator_id','$outcome_type_id')"; $db->Execute($sql); } /** * Delete a skill (outcome_type) from an operator * * @param int $operator_id Operator id * @param int $outcome_type_id Outcome type id (skill) * */ function vqd($operator_id,$outcome_type_id) { global $db; $sql = "DELETE FROM operator_skill WHERE operator_id = '$operator_id' and outcome_type_id = '$outcome_type_id'"; $db->Execute($sql); } if (isset($_POST['submit'])) { $db->StartTrans(); $sql = "DELETE FROM operator_skill WHERE operator_id IN ( SELECT operator_id FROM operator WHERE enabled = 1)"; $db->Execute($sql); foreach ($_POST as $g => $v) { $a = explode("_",$g); if ($a[0] == "cb") vqi($a[2],$a[1]); } $db->CompleteTrans(); } $sql = "SELECT outcome_type_id,description FROM outcome_type ORDER by outcome_type_id ASC"; $outcome_types = $db->GetAll($sql); $sql = "SELECT operator_id, CONCAT(firstName,' ', lastName) as description, username FROM operator WHERE enabled = 1 ORDER by operator_id ASC"; $operators = $db->GetAll($sql); xhtml_head(T_("Assign operators to Skills"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../include/jquery/jquery.min.js","../include/iCheck/icheck.min.js")); print "
| " . T_("Username") . " | " . T_("Operator") . " | "; foreach($outcome_types as $q) { print "" . T_($q['description']) . " | "; } print "
|---|---|---|
| {$v['username']} | {$v['description']} | "; foreach($outcome_types as $q) { $checked = ""; if (vq($v['operator_id'],$q['outcome_type_id'])) $checked="checked=\"checked\""; print ""; } print " |