diff --git a/admin/clientquestionnaire.php b/admin/clientquestionnaire.php index 410876f2..5d03321c 100644 --- a/admin/clientquestionnaire.php +++ b/admin/clientquestionnaire.php @@ -1,279 +1,274 @@ - - * @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"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Return if an client has already been assigned to this questionnaire - * - * @param int $client Client id - * @param int $questionnaire_id Questionnaire id - * @return int 1 if assigned otherwise 0 - * - */ -function vq($client_id,$questionnaire_id) -{ - global $db; - - $sql = "SELECT client_id,questionnaire_id - FROM client_questionnaire - WHERE client_id = '$client_id' and questionnaire_id = '$questionnaire_id'"; - - $vq = $db->Execute($sql); - - if ($vq) - return $vq->RecordCount(); - else - return 0; -} - -/** - * Assign an client to a questionnaire - * - * @param int $client_id Client id - * @param int $questionnaire_id Questionnaire id - * - */ -function vqi($client_id,$questionnaire_id) -{ - global $db; - - $sql = "INSERT INTO - client_questionnaire (client_id,questionnaire_id) - VALUES('$client_id','$questionnaire_id')"; - - $db->Execute($sql); -} - - -/** - * Unassign an client from a questionnaire - * - * @param int $client_id Client id - * @param int $questionnaire_id Questionnaire id - * - */ -function vqd($client_id,$questionnaire_id) -{ - global $db; - - $sql = "DELETE FROM - client_questionnaire - WHERE client_id = '$client_id' and questionnaire_id = '$questionnaire_id'"; - - $db->Execute($sql); -} - - - - -if (isset($_POST['submit'])) -{ - $db->StartTrans(); - - $sql = "DELETE - FROM client_questionnaire - WHERE questionnaire_id IN ( - SELECT questionnaire_id - FROM questionnaire - 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 questionnaire_id,description - FROM questionnaire - WHERE enabled = 1 - ORDER by questionnaire_id ASC"; - -$questionnaires = $db->GetAll($sql); - -$sql = "SELECT client_id,firstname as description - FROM client - ORDER by client_id ASC"; - -$clients = $db->GetAll($sql); - - -xhtml_head(T_("Assign clients to questionnaires"),false,array("../css/table.css")); - -?> - - - - - - -"; - -print ""; -foreach($questionnaires as $q) -{ - print ""; -} -print ""; - -$class = 0; - -foreach($clients as $v) -{ - print ""; - print ""; - foreach($questionnaires as $q) - { - $checked = ""; - if (vq($v['client_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; - print ""; - } - - print ""; -} - - -print "
{$q['description']}
{$v['description']}

"; - - -xhtml_foot(); - -?> - - - + + * @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"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Return if an client has already been assigned to this questionnaire + * + * @param int $client Client id + * @param int $questionnaire_id Questionnaire id + * @return int 1 if assigned otherwise 0 + * + */ +function vq($client_id,$questionnaire_id) +{ + global $db; + + $sql = "SELECT client_id,questionnaire_id + FROM client_questionnaire + WHERE client_id = '$client_id' and questionnaire_id = '$questionnaire_id'"; + + $vq = $db->Execute($sql); + + if ($vq) + return $vq->RecordCount(); + else + return 0; +} + +/** + * Assign an client to a questionnaire + * + * @param int $client_id Client id + * @param int $questionnaire_id Questionnaire id + * + */ +function vqi($client_id,$questionnaire_id) +{ + global $db; + + $sql = "INSERT INTO + client_questionnaire (client_id,questionnaire_id) + VALUES('$client_id','$questionnaire_id')"; + + $db->Execute($sql); +} + + +/** + * Unassign an client from a questionnaire + * + * @param int $client_id Client id + * @param int $questionnaire_id Questionnaire id + * + */ +function vqd($client_id,$questionnaire_id) +{ + global $db; + + $sql = "DELETE FROM + client_questionnaire + WHERE client_id = '$client_id' and questionnaire_id = '$questionnaire_id'"; + + $db->Execute($sql); +} + + +if (isset($_POST['submit'])) +{ + $db->StartTrans(); + + $sql = "DELETE + FROM client_questionnaire + WHERE questionnaire_id IN ( + SELECT questionnaire_id + FROM questionnaire + 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 questionnaire_id,description + FROM questionnaire + WHERE enabled = 1 + ORDER by questionnaire_id ASC"; + +$questionnaires = $db->GetAll($sql); + +$sql = "SELECT client_id, CONCAT(firstName,' ', lastName ) as description, username + FROM client + ORDER by client_id ASC"; + +$clients = $db->GetAll($sql); + + +xhtml_head(T_("Assign clients to questionnaires"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/iCheck/icheck.min.js")); + +?> + + + + + + + +"; + +print ""; +foreach($questionnaires as $q) +{ + print ""; +} +print ""; + + +foreach($clients as $v) +{ + print " + + "; + foreach($questionnaires as $q) + { + $checked = ""; + if (vq($v['client_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; + print ""; + } + + print ""; +} + + +print "
 " . T_("Username") . "  " . T_("Client") . " {$q['description']}
 {$v['username']} {$v['description']}
"; + + +xhtml_foot(); + +?> + + \ No newline at end of file diff --git a/admin/clients.php b/admin/clients.php index ef450b1b..40f60b98 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -1,123 +1,179 @@ - - * @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 - * - * - * @todo Make timezone a drop down list - * - */ - -/** - * Configuration file - */ -include ("../config.inc.php"); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - - -global $db; - -$a = false; - -if (isset($_POST['client'])) -{ - $client = $db->qstr($_POST['client'],get_magic_quotes_gpc()); - $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); - $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); - $time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc()); - - if (!empty($_POST['client'])) - { - $sql = "INSERT INTO client - (`client_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`) - VALUES (NULL , $client, $firstname , $lastname, $time_zone_name);"; - - if ($db->Execute($sql)) - { - if (HTPASSWD_PATH !== false && HTGROUP_PATH !== false) - { - //Get password and add it to the configured htpassword - include_once("../functions/functions.htpasswd.php"); - $htp = New Htpasswd(HTPASSWD_PATH); - $htg = New Htgroup(HTGROUP_PATH); - - $htp->addUser($_POST['client'],$_POST['password']); - $htg->addUserToGroup($_POST['client'],HTGROUP_CLIENT); - } - - $a = T_("Added: $client"); - } - else - $a = T_("Could not add") . " " . $client . ". " . T_("There may already be a client of this name"); - } -} - - -xhtml_head(T_("Add a client")); - -$sql = "SELECT Time_zone_name as value, Time_zone_name as description - FROM timezone_template"; - -$rs = $db->GetAll($sql); - - -if ($a) -{ -?> -

- -

-

-

-
-

- -

- -

-

-

"; display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",get_setting("DEFAULT_TIME_ZONE"))); ?>

-

" />

- - - - + + * @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 + * + * + * @todo Make timezone a drop down list + * + */ + +/** + * Configuration file + */ +include ("../config.inc.php"); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + + +global $db; + +$a = false; + +if (isset($_POST['client'])) +{ + $client = $db->qstr($_POST['client'],get_magic_quotes_gpc()); + $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); + $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); + $time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc()); + + if (!empty($_POST['client'])) + { + $sql = "INSERT INTO client + (`client_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`) + VALUES (NULL , $client, $firstname , $lastname, $time_zone_name);"; + + if ($db->Execute($sql)) + { + if (HTPASSWD_PATH !== false && HTGROUP_PATH !== false) + { + //Get password and add it to the configured htpassword + include_once("../functions/functions.htpasswd.php"); + $htp = New Htpasswd(HTPASSWD_PATH); + $htg = New Htgroup(HTGROUP_PATH); + + $htp->addUser($_POST['client'],$_POST['password']); + $htg->addUserToGroup($_POST['client'],HTGROUP_CLIENT); + } + + $a = T_("Added: $client"); + } + else + $a = T_("Could not add") . " " . $client . ". " . T_("There may already be a client of this name"); + } +} + + +xhtml_head(T_("Add a client"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css")); + +$sql = "SELECT Time_zone_name as value, Time_zone_name as description + FROM timezone_template"; + +$rs = $db->GetAll($sql); + + +if ($a) +{ +?> +
+ + + + + +
+

+

+ +
+
+ + +
+ +
+ + +
   + " class="btn btn-default fa" />   + +
+
+ +
+ + +
+
+ + +
+
+ "; + display_chooser($rs,"Time_zone_name","Time_zone_name",false,false,false,false,array("value",get_setting("DEFAULT_TIME_ZONE")),true,"pull-left"); ?> +
+ " class="btn btn-primary col-sm-offset-3 col-sm-3"/> + + + \ No newline at end of file