diff --git a/CHANGELOG b/CHANGELOG index 9e138199..93dc3425 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,5 @@ queXS 1.14.0 - Changes since 1.13.1 - Changes for session authentication: queXS now uses the Limesurvey session based authentication system to authenticate all users. @@ -29,29 +28,47 @@ These queries will: 2. Make all other users regular users, and assign them the password "password" 3. Make all clients regular clients, and assign them the password "password" -Once you have run these - please go to the operator management page and update passwords for all users. +Once you have run these - please go to the operator management page and update passwords for all users AND reassign any extensions. /* Make the first user the admin user - with default password of: password */ INSERT INTO `lime_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang`, `superadmin`) -SELECT username, '0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438', firstName, 0, 'auto', 1 +SELECT username, 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, firstName, 0, 'auto', 1 FROM operator WHERE operator_id = 1; /* Make all other users operators - with default password of: password */ INSERT INTO `lime_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang`, `superadmin`) -SELECT username, '0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438', firstName, 1, 'auto', 0 +SELECT username, 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, firstName, 1, 'auto', 0 FROM operator WHERE operator_id != 1; /* Make all clients - with default password of: password */ INSERT INTO `lime_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang`, `superadmin`) -SELECT username, '0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438', firstName, 1, 'auto', 0 +SELECT username, 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, firstName, 1, 'auto', 0 FROM client WHERE 1; /* Remove redundant table */ DROP TABLE `sessions2`; +/* Add sort order feature to questionnaire sample table */ +ALTER TABLE `questionnaire_sample` ADD `sort_order` INT( 11 ) NOT NULL DEFAULT '0'; +UPDATE `questionnaire_sample` SET sort_order = sample_import_id; + +/* Add default outcomes feature */ + +/* -- add `default` and `permanent` parameters for outcomes -- */ +ALTER TABLE `outcome` ADD `default` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Used as default for questionnaire outcomes' AFTER `calc`, ADD `permanent` TINYINT(1) UNSIGNED NOT NULL COMMENT 'Permanent outcome, used for all questionnaires, not possible to de-select' AFTER `default`; + +/* -- define and set mandatory(constant) outcome_id's --*/ +UPDATE `outcome` SET `permanent` = '1' WHERE `outcome`.`outcome_id` IN (1,2,3,7,9,10,14,17,18,19) ; + +/* -- add `outcomes` parameter , define default list of outcome_ID's to be enabled for new questionnaries --*/ +ALTER TABLE `questionnaire` ADD `outcomes` VARCHAR(256) NULL DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'Comma-separated string of outcomes defined for the questionnaire' AFTER `enabled`; + +/* -- enable all outcomes for existing questionnaires -- */ +UPDATE `questionnaire` SET `outcomes` = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,40,41,42,43,44,45' ; + queXS 1.13.1 - Changes since 1.13.0 diff --git a/DB update CHANGELOG b/DB update CHANGELOG deleted file mode 100644 index ff054ec6..00000000 --- a/DB update CHANGELOG +++ /dev/null @@ -1,19 +0,0 @@ -required DB updates: - -/* -- add `default` and `const` parameters for outcomes -- */ -ALTER TABLE `outcome` ADD `deflt` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Used as default for questionnaire outcomes' AFTER `calc`, ADD `const` TINYINT(1) UNSIGNED NOT NULL COMMENT 'Permanent outcome, used for all questionnaires, not possible to de-select' AFTER `deflt`; - -/* -- define and set mandatory(constant) outcome_id's --*/ -UPDATE `outcome` SET `const` = '1' WHERE `outcome`.`outcome_id` IN (1,2,3,7,9,10,14,17,18,19) ; - -/* -- add `outcomes` parameter , define default list of outcome_ID's to be enabled for new questionnaries --*/ -ALTER TABLE `questionnaire` ADD `outcomes` VARCHAR(256) NULL DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'coma-separated string of outcomes defined for the questionnaire' AFTER `enabled`; - -/* -- enable all outcomes for existing questionnaires -- */ -UPDATE `questionnaire` SET `outcomes` = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,40,41,42,43,44,45' ; - - - - - - diff --git a/admin/addshift.php b/admin/addshift.php index 271e90fc..52089d59 100644 --- a/admin/addshift.php +++ b/admin/addshift.php @@ -42,7 +42,7 @@ include ("../db.inc.php"); /** * Authentication */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions diff --git a/admin/assignsample.php b/admin/assignsample.php index d4522b5a..36f35929 100644 --- a/admin/assignsample.php +++ b/admin/assignsample.php @@ -43,7 +43,7 @@ include ("../db.inc.php"); /** * Authentication */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions @@ -93,8 +93,14 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET[' $an = 0; if (isset($_GET['allownew'])) $an = 1; - $sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new) - VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an')"; + $sql = "SELECT MAX(sort_order) + 1 + FROM questionnaire_sample + WHERE questionnaire_id = '$questionnaire_id'"; + + $so = $db->GetOne($sql); + + $sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new,sort_order) + VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an', '$so')"; $db->Execute($sql); @@ -176,7 +182,6 @@ if (isset($_POST['edit'])) } - if (isset($_GET['questionnaire_id']) && isset($_GET['rsid'])) { $questionnaire_id = bigintval($_GET['questionnaire_id']); @@ -239,7 +244,69 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['rsid'])) GetRow($sql); + + $ssid = $rs['sample_import_id']; + $sso = $rs['sort_order']; + + $sql = "UPDATE questionnaire_sample + SET sort_order = $sso + WHERE sample_import_id = $sid + AND questionnaire_id = $questionnaire_id"; + + $db->Execute($sql); + + $sql = "UPDATE questionnaire_sample + SET sort_order = ($sso + 1) + WHERE sample_import_id = $ssid + AND questionnaire_id = $questionnaire_id"; + + $db->Execute($sql); + } + else + { + //find next in sort order and do a swap + $sql = "SELECT sample_import_id,sort_order + FROM questionnaire_sample + WHERE questionnaire_id = $questionnaire_id + AND sort_order > (SELECT sort_order FROM questionnaire_sample WHERE questionnaire_id = $questionnaire_id AND sample_import_id = $sid) + ORDER BY sort_order ASC LIMIT 1"; + + $rs = $db->GetRow($sql); + + $ssid = $rs['sample_import_id']; + $sso = $rs['sort_order']; + + $sql = "UPDATE questionnaire_sample + SET sort_order = $sso + WHERE sample_import_id = $sid + AND questionnaire_id = $questionnaire_id"; + + $db->Execute($sql); + + $sql = "UPDATE questionnaire_sample + SET sort_order = ($sso - 1) + WHERE sample_import_id = $ssid + AND questionnaire_id = $questionnaire_id"; + + $db->Execute($sql); + + unset($_GET['sort']); + + } + } else { //need to remove rsid from questionnaire @@ -266,7 +333,7 @@ if ($questionnaire_id != false) print "

". T_("Samples selected for this questionnaire") .":

"; - $sql = "SELECT si.description as description, + $sql = "SELECT q.sort_order as sort_order, si.description as description,si.sample_import_id, 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, @@ -276,12 +343,39 @@ if ($questionnaire_id != false) CONCAT('') as unassign FROM questionnaire_sample as q, sample_import as si WHERE q.sample_import_id = si.sample_import_id - AND q.questionnaire_id = '$questionnaire_id'"; + AND q.questionnaire_id = '$questionnaire_id' + ORDER BY q.sort_order ASC"; $qs = $db->GetAll($sql); - if (!empty($qs)) - xhtml_table($qs,array("description","call_max","call_attempt_max","answering_machine_messages","random_select","allow_new","edit","unassign"),array(T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Allow new numbers to be drawn?"), T_("Edit"), T_("Unassign sample"))); + 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'] = " " . $qs[$i]['sort_order'] . " " . $up; + } + else + { + $qs[$i]['sort_order'] = "
" . $qs[$i]['sort_order'] . " " . $up . $down . "
"; + } + } + } + else + $qs[0]['sort_order'] = "  "; + + xhtml_table($qs,array("sort_order","description","call_max","call_attempt_max","answering_machine_messages","random_select","allow_new","edit","unassign"),array(T_("Sort order"),T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Allow new numbers to be drawn?"), T_("Edit"), T_("Unassign sample"))); + } else print "

". T_("No samples selected for this questionnaire") ."

"; diff --git a/admin/assigntimeslots.php b/admin/assigntimeslots.php index ff191027..a0d8a877 100644 --- a/admin/assigntimeslots.php +++ b/admin/assigntimeslots.php @@ -43,7 +43,7 @@ include ("../db.inc.php"); /** * Authentication */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions diff --git a/admin/auth-admin.php b/admin/auth-admin.php index b650c000..660bfddf 100644 --- a/admin/auth-admin.php +++ b/admin/auth-admin.php @@ -48,6 +48,8 @@ $sql = "SELECT stg_value session_name($db->GetOne($sql)); +session_set_cookie_params(0,QUEXS_PATH); + session_start(); //check if the session exists or loginID not set diff --git a/admin/availability.php b/admin/availability.php index 0808e9bf..d6a21d99 100644 --- a/admin/availability.php +++ b/admin/availability.php @@ -42,7 +42,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** diff --git a/admin/availabilitygroup.php b/admin/availabilitygroup.php index 2029f348..cc67f9f6 100644 --- a/admin/availabilitygroup.php +++ b/admin/availabilitygroup.php @@ -43,7 +43,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions diff --git a/admin/bulkappointment.php b/admin/bulkappointment.php index e3afc406..26076971 100644 --- a/admin/bulkappointment.php +++ b/admin/bulkappointment.php @@ -47,7 +47,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * Operator functions diff --git a/admin/callhistory.php b/admin/callhistory.php index 102e3cca..6ac3d177 100644 --- a/admin/callhistory.php +++ b/admin/callhistory.php @@ -42,7 +42,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions @@ -133,7 +133,7 @@ if ($operator_id) while ($r = $rs->FetchRow()) { - translate_array($r,array("des")); + translate_array($r,array("descr")); echo $r['start_date'] . "," .$r['start_time'] . "," . $r['end'] . "," . $r['case_id'] . "," . $r['qd'] . "," . $r['spl'] . "," . $r['cpi'] . "," . $r['opname'] . "," . $r['descr'] . "," . $r['casenotes'] . "," . $r['firstName'] . "\n"; } @@ -151,7 +151,7 @@ if ($operator_id) } else { - translate_array($rs,array("des")); + translate_array($rs,array("descr")); $datacol = array("start_date", "start_time","end","case_id","qd","spl","cpi","opname","descr","casenotes","firstName"); $headers = array(T_("Date"), T_("Start time"), T_("End time"),T_("Case ID"),T_("Questionnaire"),T_("Sample"),T_("Phone number"),T_("Operator"),T_("Outcome"),T_("Case notes"),T_("Respondent")); diff --git a/admin/callrestrict.php b/admin/callrestrict.php index 2d6c591c..044a3d74 100644 --- a/admin/callrestrict.php +++ b/admin/callrestrict.php @@ -42,7 +42,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions diff --git a/admin/casesbyoutcome.php b/admin/casesbyoutcome.php index cb3d5b48..048483f7 100644 --- a/admin/casesbyoutcome.php +++ b/admin/casesbyoutcome.php @@ -42,7 +42,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions @@ -75,7 +75,8 @@ if ($operator_id) if (!empty($rs)){ print "

" . T_("Project") . ": {$rs['qd']}

"; - if($sample_import_id=intval($_GET['sample_import_id'])){ + if( isset($_GET['sample_import_id'])){ + $sample_import_id=intval($_GET['sample_import_id']); $sql = "SELECT si.description as sd FROM `sample_import` as si WHERE si.sample_import_id = '$sample_import_id' ;"; @@ -85,7 +86,8 @@ if ($operator_id) } else{$sid = " ";}; - if($oper_id= intval($_GET['oper_id'])){ + if( isset($_GET['oper_id'])){ + $oper_id= intval($_GET['oper_id']); $sql = "SELECT CONCAT(op.firstname, op.lastname) as opname FROM `operator` as op WHERE op.operator_id = '$oper_id' ;"; diff --git a/admin/casestatus.php b/admin/casestatus.php index f44e201a..72bbee47 100644 --- a/admin/casestatus.php +++ b/admin/casestatus.php @@ -15,7 +15,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions @@ -110,19 +110,24 @@ function case_status_report($questionnaire_id = false, $sample_id = false, $outc LEFT JOIN outcome as co ON (co.outcome_id = ca.outcome_id) LEFT JOIN case_queue as cq ON (cq.case_id = c.case_id) LEFT JOIN operator as oq ON (cq.operator_id = oq.operator_id) + LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id) + LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id) WHERE c.current_operator_id IS NULL $q $o + AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 ) + AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1) ORDER BY c.case_id ASC"; -// print $sql; - print ("
"); + $rs2 = $db->GetAll($sql); + translate_array($rs2,array("outcomes")); + $datacol = array('case_id','samples','timezone','time','nrattempts','nrcalls','outcomes','availableinmin','assignedoperator','ordr','flag'); $headers = array(T_("Case id"),T_("Sample"),T_("Timezone"),T_("Time NOW"),T_("Call attempts"),T_("Calls"),T_("Outcome"),T_("Available in"),T_("Assigned to"),T_("Order"),""); if (isset($_GET['sample_import_id'])){ unset($datacol[1]); unset($headers[1]); } - xhtml_table($db->GetAll($sql),$datacol,$headers,"tclass",false,false,"bs-table"); + xhtml_table($rs2,$datacol,$headers,"tclass",false,false,"bs-table"); $sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected FROM operator @@ -206,7 +211,7 @@ if (isset($_GET['unassign'])) $db->CompleteTrans(); } -xhtml_head(T_("Case status and assignment"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") +xhtml_head(T_("Case status and assignment"),true,$css,$js_head); echo " " . T_("Go back") . " "; ?> @@ -237,7 +242,7 @@ print "

" . T_("Questio display_questionnaire_chooser($questionnaire_id, false, "pull-left", "form-control"); if ($questionnaire_id){ print "

" . T_("Sample") . ":

"; - display_sample_chooser($questionnaire_id,$sample_import_id,false, "pull-left", "form-control"); + display_sample_chooser($questionnaire_id,$sample_import_id,false, "pull-left", "form-control", true); print "
"; diff --git a/admin/centreinfo.php b/admin/centreinfo.php index 9bc2929b..b0cab799 100644 --- a/admin/centreinfo.php +++ b/admin/centreinfo.php @@ -43,7 +43,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions diff --git a/admin/clientquestionnaire.php b/admin/clientquestionnaire.php index 67ad774d..3bf45b3c 100644 --- a/admin/clientquestionnaire.php +++ b/admin/clientquestionnaire.php @@ -42,13 +42,15 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions */ include ("../functions/functions.xhtml.php"); +$msg = ""; + /** * Return if an client has already been assigned to this questionnaire * @@ -78,78 +80,125 @@ function vq($client_id,$questionnaire_id) * * @param int $client_id Client id * @param int $questionnaire_id Questionnaire id + * @param int $lime_sid Lime survey ID + * @param int $uid Lime user ID * */ -function vqi($client_id,$questionnaire_id) +function vqi($client_id,$questionnaire_id,$lime_sid,$uid) { global $db; + + $db->StartTrans(); $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); + + /* Add client questionnaire permissions to view Lime results + statistics and quotas, //preserve superadmin permissions */ + if ($uid != 1 && empty($db->GetAll("SELECT * FROM " . LIME_PREFIX . "survey_permissions WHERE `sid` = '$lime_sid' AND `uid` = '$uid'"))) + { + $sql = "INSERT INTO " . LIME_PREFIX . "survey_permissions (`sid`,`uid`,`permission`,`create_p`,`read_p`,`update_p`,`delete_p`,`import_p`,`export_p`) + VALUES ($lime_sid,$uid,'survey',0,1,0,0,0,0),($lime_sid,$uid,'statistics',0,1,0,0,0,0),($lime_sid,$uid,'quotas',0,1,0,0,0,0)"; + $db->Execute($sql); + } + + $db->CompleteTrans(); } if (isset($_POST['submit'])) { $db->StartTrans(); - - $sql = "DELETE - FROM client_questionnaire - WHERE questionnaire_id IN ( - SELECT questionnaire_id - FROM questionnaire - WHERE enabled = 1)"; - + + /* Unassign a client from a questionnaire , remove survey_permissions*/ + $sql = "DELETE FROM client_questionnaire + WHERE questionnaire_id IN ( SELECT questionnaire_id FROM questionnaire WHERE enabled = 1)"; $db->Execute($sql); +/*Currently disabled -> need to decide how to manage permissions set earlier*/ +/* $questionnaires = $db->GetAll("SELECT lime_sid FROM questionnaire WHERE enabled = 1"); + + $clients = $db->GetAll("SELECT uid FROM client, " . LIME_PREFIX . "users WHERE `users_name` = `username`"); + + foreach($questionnaires as $q){ + foreach($clients as $v){ + $sql = "DELETE FROM " . LIME_PREFIX . "survey_permissions WHERE `uid` = {$v['uid']} AND `sid`={$q['lime_sid']} AND `uid` != 1"; + $db->Execute($sql); + } + } */ + /* - end - */ foreach ($_POST as $g => $v) { $a = explode("_",$g); if ($a[0] == "cb") - vqi($a[2],$a[1]); + vqi($a[2],$a[1],$a[3],$a[4]); } $db->CompleteTrans(); } +/* delete client from quexs and lime tables*/ //requires data-toggle-confirmation to finalize +if (isset($_POST['delete']) && isset($_POST['uid'])) +{ + $client_id = intval($_POST['delete']); + $uid = intval($_POST['uid']); + $uname = $_POST['uname']; + + global $db; + + $db->StartTrans(); + + if ($uid !=1){ //double protect superadmin from being deleted + + $sql = "DELETE FROM " . LIME_PREFIX . "templates_rights WHERE `uid` = '$uid' AND `uid` != 1"; + $db->Execute($sql); + + $sql = "DELETE FROM " . LIME_PREFIX . "survey_permissions WHERE `uid` = '$uid' AND `uid` != 1"; + $db->Execute($sql); + + $sql = "DELETE FROM " . LIME_PREFIX . "user_in_groups WHERE `uid` = '$uid' AND `uid` != 1"; + $db->Execute($sql); + + $sql = "DELETE FROM " . LIME_PREFIX . "users WHERE `uid` = '$uid' AND `uid` != 1"; + $db->Execute($sql); + + } -$sql = "SELECT questionnaire_id,description + $sql = "DELETE FROM `client_questionnaire` WHERE `client_id` = '$client_id' "; + $db->Execute($sql); + + $sql = "DELETE FROM `client` WHERE `client_id` = '$client_id'"; + $db->Execute($sql); + + $db->CompleteTrans(); + + if ($db->CompleteTrans()) $msg = "

". T_("Client with username $uname deleted") . "

"; + else $msg = "

". T_("ERROR deleting client with username $uname") . "

"; + + unset($_POST['delete'], $_POST['uid'], $_POST['uname'], $client_id, $username, $uid); +} + + +$sql = "SELECT questionnaire_id,description, lime_sid 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 +$sql = "SELECT client_id, CONCAT(firstName,' ', lastName ) as description, username, uid + FROM client, " . LIME_PREFIX . "users + WHERE `users_name` = `username` ORDER by client_id ASC"; $clients = $db->GetAll($sql); -xhtml_head(T_("Assign clients to questionnaires"),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")); +xhtml_head(T_("Clients and questionnaires"),true,array("../include/bootstrap/css/bootstrap.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/iCheck/icheck.min.js")); + +if (!empty($msg)) print $msg; ?> @@ -243,7 +292,9 @@ print "{$q['description']}"; + print ""; } print ""; @@ -251,20 +302,24 @@ print ""; foreach($clients as $v) { print " - + "; + foreach($questionnaires as $q) { - $checked = ""; - if (vq($v['client_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; - print ""; + + if (vq($v['client_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; else $checked = ""; + print ""; } print ""; } -print "
" . T_("Questionnaire permissions") . " +
{$q['description']} +
 {$v['username']}  {$v['username']} 
+   +
{$v['description']}  +
"; +print ""; ?> "; - if ($_GET['new'] =='new'){ - $start = $startdate; - $end = $enddate; - $rtz = $_GET['rtz']; - } - if (isset($_GET['appointment_id'])) { + print "
"; + print ""; + + display_chooser($db->GetAll("SELECT respondent_id as value, CONCAT(firstName,' ',lastName) as description, + CASE when respondent_id = '$respondent_id' THEN 'selected=\'selected\'' ELSE '' END as selected + FROM respondent + WHERE case_id = '$case_id'"),"respondent_id","respondent_id",false,false,false,true,false,true,"pull-left"); - $sql = "SELECT a.contact_phone_id,a.call_attempt_id, CONVERT_TZ(a.start,'UTC',r.Time_zone_name) as `start`, CONVERT_TZ(a.end,'UTC',r.Time_zone_name) as `end`, a.respondent_id, a.require_operator_id, r.Time_zone_name as rtz - FROM `appointment` as a, respondent as r - WHERE a.appointment_id = '$appointment_id' - AND a.case_id = '$case_id' - AND r.respondent_id = a.respondent_id"; - - $rs = $db->GetRow($sql); - - if (!empty($rs)){ - $respondent_id = $rs['respondent_id']; - $contact_phone_id = $rs['contact_phone_id']; - $require_operator_id = $rs['require_operator_id']; - $start = $rs['start']; - $end = $rs['end']; - $rtz = $rs['rtz']; - } - } - print ""; - print ""; + print "

"; - display_chooser($db->GetAll("SELECT respondent_id as value, CONCAT(firstName,' ',lastName) as description, - CASE when respondent_id = '$respondent_id' THEN 'selected=\'selected\'' ELSE '' END as selected - FROM respondent - WHERE case_id = '$case_id'"),"respondent_id","respondent_id",false,false,false,true,false,true,"pull-left"); + $sql = "SELECT contact_phone_id as value, phone as description, + CASE when contact_phone_id = '$contact_phone_id' THEN 'selected=\'selected\'' ELSE '' END as selected + FROM contact_phone + WHERE case_id = '$case_id'"; + $rs = $db->GetAll($sql); + +//* added option to add new number + print "
"; - print "

"; - display_chooser($db->GetAll("SELECT contact_phone_id as value, phone as description, - CASE when contact_phone_id = '$contact_phone_id' THEN 'selected=\'selected\'' ELSE '' END as selected - FROM contact_phone - WHERE case_id = '$case_id'"), - "contact_phone_id","contact_phone_id",false,false,false,true,false,true,"pull-left"); - - print "

". T_("ATTENTION! Keep in mind that you're setting 'Start' & 'End' appoinment times in RESPONDENT LOCAL TIME !!!") . "
"; + print ""; +//*end option + + print "

". T_("ATTENTION! Keep in mind that you're setting 'Start' & 'End' appoinment times in RESPONDENT LOCAL TIME !!!") . "
"; + date_default_timezone_set($rtz); - print " -

" . $rtz . "

+ + print " +

" . $rtz . "

"; - print "

+ print "

"; - print "

+ print "

"; - print "

"; + print "

"; $ops = $db->GetAll("SELECT o.operator_id as value, CONCAT(o.firstName, ' ', o.lastName) as description, CASE WHEN o.operator_id = '$require_operator_id' THEN 'selected=\'selected\'' ELSE '' END as selected @@ -225,17 +264,25 @@ if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(isset($_GET[ } } array_unshift($ops,array('value'=>0,'description'=>T_("Any operator"),'selected'=>$selected)); - display_chooser($ops,"require_operator_id","require_operator_id",false,false,false,true,false,true,"pull-left"); - print ""; - if ($_GET['new'] == 'new') { print "";} + display_chooser($ops,"require_operator_id","require_operator_id",false,false,false,true,false,true,"pull-left"); + + print " + + "; + + if (isset($_GET['new']) && $_GET['new'] == 'new') { + print ""; + } print "


- "; + "; - print "
"; + print "
+ +
"; - print ""; + print ""; print "
"; } @@ -243,45 +290,53 @@ if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(isset($_GET[ else { $operator_id = get_operator_id(); $subtitle = T_("Appointments"); - xhtml_head(T_("Display Appointments"),true,$css,$js_head,false,30); //array("../css/table.css") + xhtml_head(T_("Display Appointments"),true,$css,$js_head,false,30); print "

" . T_("All appointments (with times displayed in your time zone)") . "

"; - $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end,CONCAT(r.firstName, ' ', r.lastName) as resp, IFNULL(ou.description,'" . TQ_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName, + $sql = "SELECT q.description, si.description as smpl, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end,CONCAT(r.firstName, ' ', r.lastName) as resp, IFNULL(ou.description,'" . TQ_("Not yet called") . "') as outcome, oo.firstName as makerName, ooo.firstName as callerName, CONCAT('', c.case_id, '') as case_id, CONCAT('  ') as link, CONCAT('  ') as edit,IFNULL(ao.firstName,'" . TQ_("Any operator") . "') as witho FROM appointment as a - JOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc) on (a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_id) + JOIN (`case` as c, respondent as r, questionnaire as q, operator as oo, call_attempt as cc, `sample` as s, sample_import as si) on (c.sample_id = s.sample_id and a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and a.call_attempt_id = cc.call_attempt_id and cc.operator_id = oo.operator_id and si.sample_import_id = s.import_id) LEFT JOIN (`call` as ca, outcome as ou, operator as ooo) ON (ca.call_id = a.completed_call_id and ou.outcome_id = ca.outcome_id and ca.operator_id = ooo.operator_id) LEFT JOIN operator AS ao ON ao.operator_id = a.require_operator_id - WHERE a.end >= CONVERT_TZ(NOW(),'System','UTC') AND c.current_outcome_id !=10 + LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id) + LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id) + WHERE q.enabled=1 AND si.enabled=1 AND a.end >= CONVERT_TZ(NOW(),'System','UTC') AND c.current_outcome_id !=10 + AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1) + AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1) ORDER BY a.start ASC"; $rs = $db->GetAll($sql); if (!empty($rs)) { translate_array($rs,array("outcome")); - xhtml_table($rs,array("description","case_id","start","end","edit","makerName","witho","resp","outcome","callerName","link"),array(T_("Questionnaire"),T_("Case ID"),T_("Start"),T_("End"),"  ",T_("Created by"),T_("Appointment with"),T_("Respondent"),T_("Current outcome"),T_("Operator who called"),"  "),"tclass",false,false,"bs-table"); + xhtml_table($rs,array("description","smpl","case_id","start","end","edit","makerName","witho","resp","outcome","callerName","link"),array(T_("Questionnaire"),T_("Sample"),T_("Case ID"),T_("Start"),T_("End"),"  ",T_("Created by"),T_("Appointment with"),T_("Respondent"),T_("Current outcome"),T_("Operator who called"),"  "),"tclass",false,false,"bs-table"); } else print "

" . T_("No future appointments") . "

"; print "

" . T_("Missed appointments (with times displayed in your time zone)") . "

"; - $sql = "SELECT q.description, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end, CONCAT(r.firstName, ' ', r.lastName) as resp, + $sql = "SELECT q.description, si.description as smpl, CONVERT_TZ(a.start,'UTC',@@session.time_zone) as start, CONVERT_TZ(a.end,'UTC',@@session.time_zone) as end, CONCAT(r.firstName, ' ', r.lastName) as resp, CONCAT('', c.case_id, '') as case_id, CONCAT('  ') as link, CONCAT('  ') as edit FROM appointment as a JOIN (`case` as c, respondent as r, questionnaire as q, `sample` as s, sample_import as si) on (a.case_id = c.case_id and a.respondent_id = r.respondent_id and q.questionnaire_id = c.questionnaire_id and s.sample_id = c.sample_id and s.import_id= si.sample_import_id) LEFT JOIN (`call` as ca) ON (ca.call_id = a.completed_call_id) - WHERE q.enabled=1 AND si.enabled = 1 AND a.end < CONVERT_TZ(NOW(),'System','UTC') AND a.completed_call_id IS NULL AND c.current_outcome_id !=10 + LEFT JOIN (questionnaire_sample_quota as qsq) on (s.import_id = qsq.sample_import_id and c.questionnaire_id = qsq.questionnaire_id) + LEFT JOIN (questionnaire_sample_quota_row as qsqr) on (s.import_id = qsqr.sample_import_id and c.questionnaire_id = qsqr.questionnaire_id) + WHERE q.enabled=1 AND si.enabled=1 AND a.end < CONVERT_TZ(NOW(),'System','UTC') AND a.completed_call_id IS NULL AND c.current_outcome_id !=10 + AND (qsq.quota_reached IS NULL OR qsq.quota_reached != 1 ) + AND (qsqr.quota_reached IS NULL OR qsqr.quota_reached != 1) GROUP BY c.case_id ORDER BY a.start ASC"; $rs = $db->GetAll($sql); if (!empty($rs)) { - xhtml_table($rs,array("description","case_id","start","end","edit","resp","link"),array(T_("Questionnaire"),T_("Case ID"),T_("Start"),T_("End"),"  ",T_("Respondent"),"  "),"tclass",false,false,"bs-table"); + xhtml_table($rs,array("description","smpl","case_id","start","end","edit","resp","link"),array(T_("Questionnaire"),T_("Sample"),T_("Case ID"),T_("Start"),T_("End"),"  ",T_("Respondent"),"  "),"tclass",false,false,"bs-table"); - } else print "

" . T_("No appointments missed") . "

"; + } else print "

" . T_("No missed appointments") . "

"; } xhtml_foot($js_foot); diff --git a/admin/extensionstatus.php b/admin/extensionstatus.php index 97022fba..baf4c0a5 100644 --- a/admin/extensionstatus.php +++ b/admin/extensionstatus.php @@ -41,7 +41,7 @@ include ("../db.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions @@ -185,41 +185,43 @@ if (isset($_GET['edit']) || isset($_GET['addext'])) WHERE extension_id = " . intval($_GET['edit']); $rs = $db->GetRow($sql); - } else $rs = array(); - - print "" . T_("Go back") . ""; + } + ?>
-

+

- - " maxlength="12" required value="" class="form-control"/> + + " maxlength="12" required value="" class="form-control"/>
- - "/>    + + "/>  " class="btn btn-default fa" /> 
-
- " /> -
+
+
+ +
+ + " /> - - " /> + + " />
" . T_("Unassign the operator from this extension to be able to delete it") . ""; } - print "
"; + print "
"; } else { @@ -241,8 +243,10 @@ else $rs = $db->GetAll($sql); + print "
"; + if ($msg != "") - print "

$msg

"; + print "

$msg


"; if (!empty($rs)) { @@ -258,14 +262,15 @@ else if ($rs[$i]['assignment'] == "list") $rs[$i]['assignment'] = display_chooser($ers,"operator_id_" . $rs[$i]["extension_id"],"operator_id_" . $rs[$i]["extension_id"],true,"extension_id=".$rs[$i]["extension_id"],true,false,false,false); } - print "
"; + xhtml_table($rs,array("extension","firstName","assignment","status","case_id","state","calltime"),array(T_("Extension"),T_("Operator"),T_("Assignment"),T_("VoIP Status"),T_("Case ID"),T_("Call state"),T_("Time on call")),"tclass",array("vs" => "1")); - print "
"; + print "
"; } else - print "

" . T_("No extensions") . "

"; + print "

" . T_("No extensions") . "

"; - print "
" . T_("Add extension") . "
"; + print "" . T_("Add extension") . " +
"; } diff --git a/admin/import.php b/admin/import.php index 5cbc9581..3af3f959 100644 --- a/admin/import.php +++ b/admin/import.php @@ -11,7 +11,7 @@ include ("../config.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /** * XHTML functions diff --git a/admin/index.php b/admin/index.php index 9ae27bee..d5d318a3 100644 --- a/admin/index.php +++ b/admin/index.php @@ -41,7 +41,7 @@ include ("../config.inc.php"); /** * Authentication file */ -include ("auth-admin.php"); +require ("auth-admin.php"); /* * XHTML file @@ -84,12 +84,22 @@ include ("../functions/functions.operator.php");