From 612f3aaea9e154c0acac886ae32d28ae77d59174 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 5 Oct 2015 18:34:02 +0300 Subject: [PATCH 1/5] Added in-page Lime statistics block, Bootstrapted interface --- client/index.php | 41 ++++++++++++++++++++++++----------------- css/custom.css | 4 ++++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/client/index.php b/client/index.php index c3b0728c..3e3ab9ca 100644 --- a/client/index.php +++ b/client/index.php @@ -41,7 +41,7 @@ include_once(dirname(__FILE__).'/../db.inc.php'); /** * Authentication */ -include ("auth-client.php"); +require ("auth-client.php"); /** @@ -62,11 +62,11 @@ include ("../functions/functions.client.php"); $client_id = get_client_id(); -xhtml_head(T_("Questionnaire Outcomes"),true,array("css/table.css")); +xhtml_head(T_("Questionnaire Outcomes"),true,array("../include/bootstrap/css/bootstrap.min.css", "../css/custom.css")); if ($client_id) { - $sql = "SELECT q.questionnaire_id,q.description + $sql = "SELECT q.questionnaire_id,q.description,q.lime_sid FROM questionnaire as q, client_questionnaire as cq WHERE cq.questionnaire_id = q.questionnaire_id AND q.enabled = 1 @@ -75,14 +75,17 @@ if ($client_id) $qs = $db->GetAll($sql); if (empty($qs)) - print "

" . T_("There are no questionnaires assigned to you") . "

"; + print "

" . T_("There are no questionnaires assigned to you") . "

"; else { + print "
"; + foreach($qs as $q) { - print "

{$q['description']}

"; + print "

{$q['description']}

"; $questionnaire_id = $q['questionnaire_id']; + $qsid=$q['lime_sid']; $sql = "SELECT o.calc, count( c.case_id ) FROM `case` AS c, `outcome` AS o @@ -91,15 +94,15 @@ if ($client_id) GROUP BY o.calc"; $a = $db->GetAssoc($sql); + $a = aapor_clean($a); - - print ""; + print "
" . T_("Outcome") . "" . T_("Rate") . "
"; print ""; print ""; print ""; print ""; - print "
" . T_("Outcome") . "" . T_("Rate") . "
" . T_("Response Rate 1") . "" . round(aapor_rr1($a),2) . "
" . T_("Refusal Rate 1") . "" . round(aapor_ref1($a),2) . "
" . T_("Cooperation Rate 1") . "" . round(aapor_coop1($a),2) . "
" . T_("Contact Rate 1") . "" . round(aapor_con1($a),2) . "
"; + print "
"; $sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count @@ -115,20 +118,24 @@ if ($client_id) translate_array($rs,array("des")); xhtml_table($rs,array("des","count"),array(T_("Outcome"),T_("Count")),"tclass",array("des" => "Complete")); } - else - print "

" . T_("No outcomes recorded for this questionnaire") . "

"; - + else print "

" . T_("No outcomes recorded for this questionnaire") . "

"; + + print "
" . T_("Lime results") . "
"; } + + $page =''; if (isset($_GET['page'])) $page = $_GET['page'] . "?action=browse&sid=$qsid"; +?> +
+ +
+ +
+" . T_("You are not a valid client") . "

"; - - + print "

" . T_("You are not a valid client") . "

"; xhtml_foot(); diff --git a/css/custom.css b/css/custom.css index 8dc3463f..9e2441bd 100644 --- a/css/custom.css +++ b/css/custom.css @@ -74,4 +74,8 @@ text-shadow: 1px 2px 1px #ababab; .h1, .h2, .h3, h1, h2, h3 { margin-bottom: 0.4em; margin-top: 0.25em; +} +.full { + width:100%; + height:100%; } \ No newline at end of file From 48068aec5b8090cd7d3cd1c8b17da50e1497ad45 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 5 Oct 2015 18:35:11 +0300 Subject: [PATCH 2/5] remove unused css --- client/css/table.css | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 client/css/table.css diff --git a/client/css/table.css b/client/css/table.css deleted file mode 100644 index cf86e2a9..00000000 --- a/client/css/table.css +++ /dev/null @@ -1,13 +0,0 @@ -tr.odd { - background-color: #eeeeee; -} -.tclass th { - text-align:left; - border: 1px solid #aaa; -} -.tclass td { - border: 1px solid #aaa; -} -.highlight { - background-color: #cccccc; -} From e2f91e470c25f87e9666b0e46724ab695ff6112e Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 5 Oct 2015 18:52:59 +0300 Subject: [PATCH 3/5] let's make clients accounts editable, check for duplicated clients username --- admin/clients.php | 176 +++++++++++++++++++++++++++++++++------------- 1 file changed, 127 insertions(+), 49 deletions(-) diff --git a/admin/clients.php b/admin/clients.php index f9309c2a..4b9e8a2a 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -45,7 +45,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions @@ -57,7 +57,9 @@ global $db; $a = false; -if (isset($_POST['client'])) +$client =""; $firstname="";$lastname="";$email=""; $time_zone_name=""; + +if (isset($_POST['client']) && !empty($_POST['client'])) { $client = $db->qstr($_POST['client'],get_magic_quotes_gpc()); $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); @@ -65,46 +67,108 @@ if (isset($_POST['client'])) $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);"; + /* check if there'a record with this username*/ + $sql = "SELECT `username`,`client_id` from client WHERE `username` LIKE $client"; + $rs = $db->GetAll($sql); - if ($db->Execute($sql)) - { - include_once("../include/limesurvey/admin/classes/core/sha256.php"); - - //Insert into lime_users - $sql = "INSERT INTO " . LIME_PREFIX . "users (`users_name`,`password`,`full_name`,`parent_id`,`superadmin`,`email`,`lang`) - VALUES ($client, '" . SHA256::hashing($_POST['password']) . "',$firstname,1,0,$email,'auto')"; - - $db->Execute($sql); - + if (isset($_GET['edit']) && $_GET['edit'] >0 ) { + + $clid = intval($_GET['edit']); + $uid = intval($_POST['uid']); + } + - $a = T_("Added: $client"); + if (empty($rs) || count($rs)==1 && $rs[0]['client_id'] == $clid){ + + // update client + if (isset($_GET['edit']) && $_GET['edit'] >0 ) { + + $sql = "UPDATE `client` SET `username`= $client,`firstName` = $firstname,`lastName` = $lastname,`Time_zone_name` = $time_zone_name + WHERE `client_id` = $clid "; + + if ($db->Execute($sql)) + { + $sql = "UPDATE " . LIME_PREFIX . "users SET `users_name` = $client, `full_name` = $firstname, `email` = $email"; + + /* rewrite 'password' only if not blank in edit mode */ + if (isset($_GET['edit']) && $_GET['edit'] >0 && isset($_POST['password']) && !empty($_POST['password'])) { + + include_once("../include/limesurvey/admin/classes/core/sha256.php"); + $sql .=",`password` = '" . SHA256::hashing($_POST['password']) . "'"; + } + + $sql .= "WHERE `uid` = $uid"; + + $db->Execute($sql); + + if ($db->Execute($sql)) $a = T_("Updated") . ": " . $client; else $a = T_("Update error"); + } + else + $a = T_("Could not update") . " " . $client; } - else - $a = T_("Could not add") . " " . $client . ". " . T_("There may already be a client of this name"); + else { //save as a new 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)) { + + include_once("../include/limesurvey/admin/classes/core/sha256.php"); + + //Insert into lime_users + $sql = "INSERT INTO " . LIME_PREFIX . "users (`users_name`,`password`,`full_name`,`parent_id`,`superadmin`,`email`,`lang`) + VALUES ($client, '" . SHA256::hashing($_POST['password']) . "', $firstname ,1,0,$email,'auto')"; + + $db->Execute($sql); + + if ($db->Execute($sql)) $a = T_("Added") . ": " . $client; else $a = T_("Error adding client"); + } + else + $a = T_("Could not add") . " " . $client; + } + } + else $a = T_("Username") . " " . $client . ". " . T_("is already in use"); +} + +$header = T_("Add a client"); +$sbut = T_("Add new client"); +$req = "required"; + +if (isset($_GET['edit']) && $_GET['edit'] >0 ) { + + $header = T_("Edit client data"); + + $clid = intval($_GET['edit']); + + $sql = "SELECT client.*, u.email, u.uid from client, " . LIME_PREFIX . "users as u WHERE client_id=$clid and u.users_name=username"; + + $cdata = $db->GetRow($sql); + + if (!$cdata) { + unset($_GET['edit']); + die(T_("NO such client")); + } + else{ + $uid = $cdata['uid']; + $client = $cdata['username']; + $firstname= $cdata['firstName']; + $lastname= $cdata['lastName']; + $email= $cdata['email']; + $time_zone_name = $cdata['Time_zone_name']; + $sbut = T_("Update client data"); + $req = ""; } } - -xhtml_head(T_("Add a client"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css")); +xhtml_head($header,true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css")); $sql = "SELECT Time_zone_name as value, Time_zone_name as description FROM timezone_template"; +$tzs = $db->GetAll($sql); -$rs = $db->GetAll($sql); - - -if ($a) -{ -?> +if ($a) { ?>
- +