diff --git a/admin/addshift.php b/admin/addshift.php index ab838dd8..ffed2451 100644 --- a/admin/addshift.php +++ b/admin/addshift.php @@ -1,278 +1,278 @@ - - * @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"); - -/** - * Operator functions - */ -include ("../functions/functions.operator.php"); - -/** - * Display functions - */ -include ("../functions/functions.display.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -global $db; - - -/** - * Add shifts to the DB based on the shift_template table - */ - - -if (isset($_POST['year'])) $year = bigintval($_POST['year']); else $year = "YEAR(NOW())"; -if (isset($_POST['woy'])) $woy = bigintval($_POST['woy']); else $woy = "WEEK(NOW(), 3)"; -if (isset($_POST['qid'])) $questionnaire_id = bigintval($_POST['qid']); else $questionnaire_id = false; -if (isset($_GET['year'])) $year = bigintval($_GET['year']); -if (isset($_GET['woy'])) $woy = bigintval($_GET['woy']); -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); - -$y = $db->GetRow("SELECT $year as y"); -$year = $y['y']; -$y = $db->GetRow("SELECT $woy as y"); -$woy = $y['y']; - - -$operator_id = get_operator_id(); - -if (!$operator_id) -{ - xhtml_head(T_("Add shifts")); - print "

" . T_("You must be an operator (as well as have administrator access) to add/edit shifts") . "

"; - xhtml_foot(); - exit(); -} - - -if (isset($_POST['submit'])) -{ - //process - //update or delete existing shifts - foreach($_POST as $key => $val) - { - if (substr($key,0,5) == "start") - { - $num = bigintval(substr($key,6)); - if (isset($_POST["use_$num"])) - { - $sql = "UPDATE shift as s, operator as o - SET s.start = CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["dow_$num"]}),'%x %v %w'),' ','" . $_POST["start_$num"] . "'), o.Time_zone_name, 'UTC'), - s.end = CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["dow_$num"]}),'%x %v %w'),' ','" . $_POST["end_$num"] . "'), o.Time_zone_name, 'UTC') - WHERE o.operator_id = '$operator_id' - AND shift_id = '$num'"; - - $db->Execute($sql); - } - else - { - $sql = "DELETE FROM shift - WHERE shift_id = '$num'"; - $db->Execute($sql); - } - } - } - //insert new shifts - foreach($_POST as $key => $val) - { - if (substr($key,0,7) == "NEW_use") - { - if ($val == "on") - { - $num = bigintval(substr($key,8)); - $sql = "INSERT INTO shift (shift_id,questionnaire_id,start,end) - SELECT NULL,'$questionnaire_id', CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["NEW_dow_$num"]}),'%x %v %w'),' ','" . $_POST["NEW_start_$num"] . "'), Time_zone_name, 'UTC') , CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["NEW_dow_$num"]}),'%x %v %w'),' ','" . $_POST["NEW_end_$num"] . "'), Time_zone_name, 'UTC') - FROM operator - WHERE operator_id = '$operator_id'"; - $db->Execute($sql); - } - } - } -} - - -xhtml_head(T_("Shift management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/clockpicker/dist/bootstrap-clockpicker.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/clockpicker/dist/bootstrap-clockpicker.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../js/window.js")); -//"../css/shifts.css", -/** - * Display warning if timezone data not installed - * - */ - -$sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM','UTC') as t"; -$rs = $db->GetRow($sql); - -if (empty($rs) || !$rs || empty($rs['t'])) - print "
" . T_("Your database does not have timezones installed, please see here for details") . "
"; - - -/** - * display years including current selected year - * display weeks of year including current selected week of year - * find if there are already shifts defined for this week of year / year and display them as selected, else show from template - * when submitted, add checked shifts, and delete unchecked shifts if they exist - * - * @todo Use javascript to add shifts if necessarry outside the template - */ - -print "

" . T_("Add shifts in your Time Zone") . "

"; - - -print "

" . T_("Shifts allow you to restrict appointments being made, and interviewers to working on a particlar project at defined times.") . "

"; - -print "

" . T_("Select a questionnaire") . ":

"; -display_questionnaire_chooser($questionnaire_id,false, "form-inline", "form-control"); -print "
"; - -if ($questionnaire_id != false) -{ - print "

" . T_("Select year") . ":  "; - for ($i = $year - 1; $i < $year + 4; $i++) - { - if ($i == $year) - print "$i"; - else - print " $i "; - } - print "

"; - - - print "

" . T_("Select week") . ": "; - for ($i = 1; $i <= 53; $i++) - { - if ($i == $woy) - print "$i"; - else - print " $i "; - } - print "

"; - - $sql = "SELECT shift_id, dt, dta,start,end - FROM ( - ( - SELECT shift_id, DATE_FORMAT( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) , '%W %d %m %Y' ) AS dt, - DATE( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) AS dta, - TIME( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) AS start, - TIME( CONVERT_TZ( s.end, 'UTC', o.Time_zone_name ) ) AS end - FROM shift AS s, operator AS o - WHERE WEEK( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) , 3 ) = '$woy' - AND YEAR( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) = '$year' - AND o.operator_id = '$operator_id' - AND s.questionnaire_id = '$questionnaire_id' - ) - UNION ( - SELECT NULL AS shift_id, - DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W %d %m %Y' ) AS dt, - STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) AS dta, - start,end - FROM shift_template - ) - ) AS sb - GROUP BY dta,start,end"; - - - $shifts = $db->GetAll($sql); - - - $sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W %d %m %Y') as dt, - DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as dtd, - DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%d %m %Y') as dto, - day_of_week - 1 as value - FROM day_of_week - GROUP BY value"; - - $daysofweek = $db->GetAll($sql); - translate_array($daysofweek,array("dtd")); - foreach($daysofweek as $key => $val) - $daysofweek[$key]['description'] = $val['dtd'] . " " . $val['dto']; - - ?> -
- -  "; - $count = 1; - foreach($shifts as $shift) - { - $checked=""; - $shift_id=""; - $prefix=""; - if (!empty($shift['shift_id'])) - { - $checked="checked=\"checked\""; $shift_id = $shift['shift_id']; - } - else - { - $shift_id = $count; - $prefix = "NEW_"; - } - print ""; - $count++; - } - ?> - -
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "" . T_("Use shift?") . "
"; - display_chooser($daysofweek, $prefix . "dow_$shift_id", false, true, false, false, false, array("dt",$shift['dt'])); - print "

- - " class="btn btn-primary"/> - - - -
- "; -xhtml_foot(); - -?> - \ No newline at end of file + + * @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"); + +/** + * Operator functions + */ +include ("../functions/functions.operator.php"); + +/** + * Display functions + */ +include ("../functions/functions.display.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +global $db; + + +/** + * Add shifts to the DB based on the shift_template table + */ + + +if (isset($_POST['year'])) $year = bigintval($_POST['year']); else $year = "YEAR(NOW())"; +if (isset($_POST['woy'])) $woy = bigintval($_POST['woy']); else $woy = "WEEK(NOW(), 3)"; +if (isset($_POST['qid'])) $questionnaire_id = bigintval($_POST['qid']); else $questionnaire_id = false; +if (isset($_GET['year'])) $year = bigintval($_GET['year']); +if (isset($_GET['woy'])) $woy = bigintval($_GET['woy']); +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); + +$y = $db->GetRow("SELECT $year as y"); +$year = $y['y']; +$y = $db->GetRow("SELECT $woy as y"); +$woy = $y['y']; + + +$operator_id = get_operator_id(); + +if (!$operator_id) +{ + xhtml_head(T_("Add shifts")); + print "

" . T_("You must be an operator (as well as have administrator access) to add/edit shifts") . "

"; + xhtml_foot(); + exit(); +} + + +if (isset($_POST['submit'])) +{ + //process + //update or delete existing shifts + foreach($_POST as $key => $val) + { + if (substr($key,0,5) == "start") + { + $num = bigintval(substr($key,6)); + if (isset($_POST["use_$num"])) + { + $sql = "UPDATE shift as s, operator as o + SET s.start = CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["dow_$num"]}),'%x %v %w'),' ','" . $_POST["start_$num"] . "'), o.Time_zone_name, 'UTC'), + s.end = CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["dow_$num"]}),'%x %v %w'),' ','" . $_POST["end_$num"] . "'), o.Time_zone_name, 'UTC') + WHERE o.operator_id = '$operator_id' + AND shift_id = '$num'"; + + $db->Execute($sql); + } + else + { + $sql = "DELETE FROM shift + WHERE shift_id = '$num'"; + $db->Execute($sql); + } + } + } + //insert new shifts + foreach($_POST as $key => $val) + { + if (substr($key,0,7) == "NEW_use") + { + if ($val == "on") + { + $num = bigintval(substr($key,8)); + $sql = "INSERT INTO shift (shift_id,questionnaire_id,start,end) + SELECT NULL,'$questionnaire_id', CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["NEW_dow_$num"]}),'%x %v %w'),' ','" . $_POST["NEW_start_$num"] . "'), Time_zone_name, 'UTC') , CONVERT_TZ(CONCAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ', {$_POST["NEW_dow_$num"]}),'%x %v %w'),' ','" . $_POST["NEW_end_$num"] . "'), Time_zone_name, 'UTC') + FROM operator + WHERE operator_id = '$operator_id'"; + $db->Execute($sql); + } + } + } +} + + +xhtml_head(T_("Shift management"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/clockpicker/dist/bootstrap-clockpicker.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../css/custom.css"),array("../include/jquery/jquery.min.js","../include/bootstrap/js/bootstrap.min.js","../include/clockpicker/dist/bootstrap-clockpicker.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../js/window.js")); +//"../css/shifts.css", +/** + * Display warning if timezone data not installed + * + */ + +$sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM','UTC') as t"; +$rs = $db->GetRow($sql); + +if (empty($rs) || !$rs || empty($rs['t'])) + print "
" . T_("Your database does not have timezones installed, please see here for details") . "
"; + + +/** + * display years including current selected year + * display weeks of year including current selected week of year + * find if there are already shifts defined for this week of year / year and display them as selected, else show from template + * when submitted, add checked shifts, and delete unchecked shifts if they exist + * + * @todo Use javascript to add shifts if necessarry outside the template + */ + +print "

" . T_("Add shifts in your Time Zone") . "

"; + + +print "

" . T_("Shifts allow you to restrict appointments being made, and interviewers to working on a particlar project at defined times.") . "

"; + +print "

" . T_("Select a questionnaire") . ":

"; +display_questionnaire_chooser($questionnaire_id,false, "form-inline", "form-control"); +print "
"; + +if ($questionnaire_id != false) +{ + print "

" . T_("Select year") . ":  "; + for ($i = $year - 1; $i < $year + 4; $i++) + { + if ($i == $year) + print "$i"; + else + print " $i "; + } + print "

"; + + + print "

" . T_("Select week") . ": "; + for ($i = 1; $i <= 53; $i++) + { + if ($i == $woy) + print "$i"; + else + print " $i "; + } + print "

"; + + $sql = "SELECT shift_id, dt, dta,start,end + FROM ( + ( + SELECT shift_id, DATE_FORMAT( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) , '%W %d %m %Y' ) AS dt, + DATE( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) AS dta, + TIME( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) AS start, + TIME( CONVERT_TZ( s.end, 'UTC', o.Time_zone_name ) ) AS end + FROM shift AS s, operator AS o + WHERE WEEK( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) , 3 ) = '$woy' + AND YEAR( CONVERT_TZ( s.start, 'UTC', o.Time_zone_name ) ) = '$year' + AND o.operator_id = '$operator_id' + AND s.questionnaire_id = '$questionnaire_id' + ) + UNION ( + SELECT NULL AS shift_id, + DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W %d %m %Y' ) AS dt, + STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) AS dta, + start,end + FROM shift_template + ) + ) AS sb + GROUP BY dta,start,end"; + + + $shifts = $db->GetAll($sql); + + + $sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W %d %m %Y') as dt, + DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as dtd, + DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%d %m %Y') as dto, + day_of_week - 1 as value + FROM day_of_week + GROUP BY value"; + + $daysofweek = $db->GetAll($sql); + translate_array($daysofweek,array("dtd")); + foreach($daysofweek as $key => $val) + $daysofweek[$key]['description'] = $val['dtd'] . " " . $val['dto']; + + ?> +
+ +  "; + $count = 1; + foreach($shifts as $shift) + { + $checked=""; + $shift_id=""; + $prefix=""; + if (!empty($shift['shift_id'])) + { + $checked="checked=\"checked\""; $shift_id = $shift['shift_id']; + } + else + { + $shift_id = $count; + $prefix = "NEW_"; + } + print ""; + $count++; + } + ?> + +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "" . T_("Use shift?") . "
"; + display_chooser($daysofweek, $prefix . "dow_$shift_id", false, true, false, false, false, array("dt",$shift['dt'])); + print "

+ + " class="btn btn-primary"/> + + + +
+ "; +xhtml_foot(); + +?> + diff --git a/admin/assignsample.php b/admin/assignsample.php index 5ac280ad..fc3798fe 100644 --- a/admin/assignsample.php +++ b/admin/assignsample.php @@ -1,282 +1,282 @@ - - * @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"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/font-awesome-4.3.0/css/font-awesome.css", -"../include/bootstrap-toggle/css/bootstrap-toggle.min.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -"../include/bootstrap-toggle/js/bootstrap-toggle.min.js", -"../js/window.js" - ); -$js_foot = array( -"../js/bootstrap-confirmation.js", -"../js/custom.js" - ); -global $db; - -if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max'])) -{ - //need to add sample to questionnaire - - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sid = bigintval($_GET['sample']); - $cm = bigintval($_GET['call_max']); - $cam = bigintval($_GET['call_attempt_max']); - $am = bigintval($_GET['answering_machine_messages']); - $selecttype = 0; - if (isset($_GET['selecttype'])) $selecttype = 1; - $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')"; - - $db->Execute($sql); -} - -if (isset($_POST['edit'])) -{ - //need to add sample to questionnaire - $questionnaire_id = bigintval($_POST['questionnaire_id']); - $sid = bigintval($_POST['sample_import_id']); - $cm = bigintval($_POST['call_max']); - $cam = bigintval($_POST['call_attempt_max']); - $am = bigintval($_POST['answering_machine_messages']); - $selecttype = 0; - if (isset($_POST['selecttype'])) $selecttype = 1; - $an = 0; - if (isset($_POST['allownew'])) $an = 1; - - $sql = "UPDATE questionnaire_sample - SET call_max = '$cm', - call_attempt_max = '$cam', - random_select = '$selecttype', - answering_machine_messages = '$am', - allow_new = '$an' - WHERE questionnaire_id = '$questionnaire_id' - AND sample_import_id = '$sid'"; - - $db->Execute($sql); -} - - - -if (isset($_GET['questionnaire_id']) && isset($_GET['rsid'])) -{ - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sid = bigintval($_GET['rsid']); - - if (isset($_GET['edit'])) - { - $subtitle = T_("Edit assignment parameters"); - xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js") - - $sql = "SELECT si.description as description, - qr.description as qdescription, - q.call_max, - q.call_attempt_max, - q.random_select, - q.answering_machine_messages, - q.allow_new - FROM questionnaire_sample as q, sample_import as si, questionnaire as qr - WHERE q.sample_import_id = si.sample_import_id - AND q.questionnaire_id = '$questionnaire_id' - AND si.sample_import_id = '$sid' - AND qr.questionnaire_id = q.questionnaire_id"; - - $qs = $db->GetRow($sql); - - //print "

" . T_("Edit sample details") . "

"; - print "

 " . T_("Go back") . "

-

" . T_("Questionnaire") . ": " . $qs['qdescription'] . "

-

" . T_("Sample") . ": " . $qs['description'] . "

-
"; - - $allownew = $selected =""; - if ($qs['random_select'] == 1) - $selected = "checked=\"checked\""; - if ($qs['allow_new'] == 1) - $allownew = "checked=\"checked\""; - ?> -
- - -
-

- -
-

- -
-

- -
data-toggle="toggle" data-size="small" data-on="" data-off="" data-width="85"/>
-

- -
class="col-sm-1" data-toggle="toggle" data-size="small" data-on="" data-off="" data-width="85"/>



- - -
-
- - - Execute($sql); - } -} - -$questionnaire_id = false; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); -$subtitle = T_("List & Add Sample"); -xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js") - -print " " . T_("Go back") . ""; -print "

" . T_("Select a questionnaire") . ":

"; -display_questionnaire_chooser($questionnaire_id,false, "pull-left", "form-control"); - -if ($questionnaire_id != false) -{ - - print "
-

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

"; - - $sql = "SELECT si.description as description, - 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, - CASE WHEN q.answering_machine_messages = 0 THEN '". TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages, - CASE WHEN q.allow_new = 0 THEN '". TQ_("No") ."' ELSE '".TQ_("Yes")."' END as allow_new, - CONCAT('') as edit, - 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'"; - - $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"))); - else - print "

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

"; - - $sql = "SELECT si.sample_import_id,si.description - FROM sample_import as si - LEFT JOIN questionnaire_sample as q ON (q.questionnaire_id = '$questionnaire_id' AND q.sample_import_id = si.sample_import_id) - WHERE q.questionnaire_id is NULL - AND si.enabled = 1"; - - $qs = $db->GetAll($sql); - print"
"; - - if (!empty($qs)) - { - print "
"; - print "

" . T_("Add a sample to this questionnaire:") . "

"; - ?> -
- -


- - -
-

- - -
-

- - -
-

- - -
" data-off="" data-width="85"/>
-

- - -
" data-off="" data-width="85"/>



- - - -
- -
- - \ No newline at end of file + + * @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"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +"../include/bootstrap/css/bootstrap-theme.min.css", +"../include/font-awesome/css/font-awesome.css", +"../include/bootstrap-toggle/css/bootstrap-toggle.min.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js", +"../include/bootstrap-toggle/js/bootstrap-toggle.min.js", +"../js/window.js" + ); +$js_foot = array( +"../js/bootstrap-confirmation.js", +"../js/custom.js" + ); +global $db; + +if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max'])) +{ + //need to add sample to questionnaire + + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sid = bigintval($_GET['sample']); + $cm = bigintval($_GET['call_max']); + $cam = bigintval($_GET['call_attempt_max']); + $am = bigintval($_GET['answering_machine_messages']); + $selecttype = 0; + if (isset($_GET['selecttype'])) $selecttype = 1; + $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')"; + + $db->Execute($sql); +} + +if (isset($_POST['edit'])) +{ + //need to add sample to questionnaire + $questionnaire_id = bigintval($_POST['questionnaire_id']); + $sid = bigintval($_POST['sample_import_id']); + $cm = bigintval($_POST['call_max']); + $cam = bigintval($_POST['call_attempt_max']); + $am = bigintval($_POST['answering_machine_messages']); + $selecttype = 0; + if (isset($_POST['selecttype'])) $selecttype = 1; + $an = 0; + if (isset($_POST['allownew'])) $an = 1; + + $sql = "UPDATE questionnaire_sample + SET call_max = '$cm', + call_attempt_max = '$cam', + random_select = '$selecttype', + answering_machine_messages = '$am', + allow_new = '$an' + WHERE questionnaire_id = '$questionnaire_id' + AND sample_import_id = '$sid'"; + + $db->Execute($sql); +} + + + +if (isset($_GET['questionnaire_id']) && isset($_GET['rsid'])) +{ + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sid = bigintval($_GET['rsid']); + + if (isset($_GET['edit'])) + { + $subtitle = T_("Edit assignment parameters"); + xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js") + + $sql = "SELECT si.description as description, + qr.description as qdescription, + q.call_max, + q.call_attempt_max, + q.random_select, + q.answering_machine_messages, + q.allow_new + FROM questionnaire_sample as q, sample_import as si, questionnaire as qr + WHERE q.sample_import_id = si.sample_import_id + AND q.questionnaire_id = '$questionnaire_id' + AND si.sample_import_id = '$sid' + AND qr.questionnaire_id = q.questionnaire_id"; + + $qs = $db->GetRow($sql); + + //print "

" . T_("Edit sample details") . "

"; + print "

 " . T_("Go back") . "

+

" . T_("Questionnaire") . ": " . $qs['qdescription'] . "

+

" . T_("Sample") . ": " . $qs['description'] . "

+
"; + + $allownew = $selected =""; + if ($qs['random_select'] == 1) + $selected = "checked=\"checked\""; + if ($qs['allow_new'] == 1) + $allownew = "checked=\"checked\""; + ?> +
+ + +
+

+ +
+

+ +
+

+ +
data-toggle="toggle" data-size="small" data-on="" data-off="" data-width="85"/>
+

+ +
class="col-sm-1" data-toggle="toggle" data-size="small" data-on="" data-off="" data-width="85"/>



+ + +
+
+ + + Execute($sql); + } +} + +$questionnaire_id = false; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); +$subtitle = T_("List & Add Sample"); +xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js") + +print " " . T_("Go back") . ""; +print "

" . T_("Select a questionnaire") . ":

"; +display_questionnaire_chooser($questionnaire_id,false, "pull-left", "form-control"); + +if ($questionnaire_id != false) +{ + + print "
+

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

"; + + $sql = "SELECT si.description as description, + 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, + CASE WHEN q.answering_machine_messages = 0 THEN '". TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages, + CASE WHEN q.allow_new = 0 THEN '". TQ_("No") ."' ELSE '".TQ_("Yes")."' END as allow_new, + CONCAT('') as edit, + 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'"; + + $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"))); + else + print "

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

"; + + $sql = "SELECT si.sample_import_id,si.description + FROM sample_import as si + LEFT JOIN questionnaire_sample as q ON (q.questionnaire_id = '$questionnaire_id' AND q.sample_import_id = si.sample_import_id) + WHERE q.questionnaire_id is NULL + AND si.enabled = 1"; + + $qs = $db->GetAll($sql); + print"
"; + + if (!empty($qs)) + { + print "
"; + print "

" . T_("Add a sample to this questionnaire:") . "

"; + ?> +
+ +


+ + +
+

+ + +
+

+ + +
+

+ + +
" data-off="" data-width="85"/>
+

+ + +
" data-off="" data-width="85"/>



+ + + +
+ +
+ + diff --git a/admin/assigntimeslots.php b/admin/assigntimeslots.php index f0cf0c2a..1e92ec99 100644 --- a/admin/assigntimeslots.php +++ b/admin/assigntimeslots.php @@ -1,313 +1,313 @@ - - * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au queXS was writen for ACSPRI - * @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"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -//"../include/font-awesome-4.3.0/css/font-awesome.css", -"../css/custom.css" - ); -$js_head = array( - ); -$js_foot = array( -"../js/window.js", -//"../js/custom.js" - ); - -global $db; - -//block availability -if (isset($_GET['questionnaire_id']) && isset($_GET['av_availability_group'])) -{ - //need to add availability_group to questionnaire - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $availability_group = bigintval($_GET['av_availability_group']); - - $sql = "INSERT INTO questionnaire_availability(questionnaire_id,availability_group_id) - VALUES('$questionnaire_id','$availability_group')"; - $db->Execute($sql); -} - -if (isset($_GET['questionnaire_id']) && isset($_GET['av_ravailability_group'])) -{ - //need to remove rsid from questionnaire - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $availability_group = bigintval($_GET['av_ravailability_group']); - - $sql = "DELETE FROM questionnaire_availability - WHERE questionnaire_id = '$questionnaire_id' - AND availability_group_id = '$availability_group'"; - $db->Execute($sql); -} - -//block call_attempts -if (isset($_GET['questionnaire_id']) && isset($_GET['ca_availability_group'])) -{ - //need to add availability_group to questionnaire - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $availability_group = bigintval($_GET['ca_availability_group']); - - $sql = "INSERT INTO questionnaire_timeslot(questionnaire_id,availability_group_id) - VALUES('$questionnaire_id','$availability_group')"; - $db->Execute($sql); -} - -if (isset($_GET['questionnaire_id']) && isset($_GET['ca_ravailability_group'])) -{ - //need to remove rsid from questionnaire - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $availability_group = bigintval($_GET['ca_ravailability_group']); - - $sql = "DELETE FROM questionnaire_timeslot - WHERE questionnaire_id = '$questionnaire_id' - AND availability_group_id = '$availability_group'"; - $db->Execute($sql); -} - - -//block call_attempts by sample -if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['qs_availability_group'])) -{ - //need to add availability_group to questionnaire - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sample_import_id = bigintval($_GET['sample_import_id']); - $availability_group = bigintval($_GET['qs_availability_group']); - - $sql = "INSERT INTO questionnaire_sample_timeslot (questionnaire_id,sample_import_id,availability_group_id) - VALUES('$questionnaire_id','$sample_import_id','$availability_group')"; - $db->Execute($sql); -} - -if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['qs_ravailability_group'])) -{ - //need to remove rsid from questionnaire - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sample_import_id = bigintval($_GET['sample_import_id']); - $availability_group = bigintval($_GET['qs_ravailability_group']); - - $sql = "DELETE FROM questionnaire_sample_timeslot - WHERE questionnaire_id = '$questionnaire_id' - AND sample_import_id = '$sample_import_id' - AND availability_group_id = '$availability_group'"; - $db->Execute($sql); -} - -$questionnaire_id = false; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); -$sample_import_id = false; -if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); - -xhtml_head(T_("Assign Time slots"),true,$css,$js_head);//false,array("../js/window.js") - -print "

" . T_("Select a questionnaire") . ":

"; -display_questionnaire_chooser($questionnaire_id,false, "form-inline", "form-control"); -print "
"; -if ($questionnaire_id != false) -{ - -//page questionnaireavailability.php -print "

" . T_("Time slot groups") . "

"; -print "
" . T_("Assigning an availability group to a questionnaire will allow interviewers to select from those groups to restrict calls to a particular case to the times within the group") ."
"; - - $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link - FROM questionnaire_availability as q, availability_group as a - WHERE q.availability_group_id = a.availability_group_id - AND q.questionnaire_id = '$questionnaire_id'"; - - $qs = $db->GetAll($sql); - print "


"; - - if (empty($qs)) - { - print "

" . T_("There are no time slots groups selected for this questionnaire") . "

"; - } - else - { - print "

" . T_("Time slots groups selected for this questionnaire") . "

"; - xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover"); - } - print "
"; - $sql = "SELECT si.availability_group_id,si.description - FROM availability_group as si - LEFT JOIN questionnaire_availability as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id) - WHERE q.questionnaire_id is NULL"; - - $qs = $db->GetAll($sql); - - if (!empty($qs)) - { - print "
"; - //print "

" . T_("Add time slot to this questionnaire:") . "

"; - print "
- -   -
"; - } - -print "
"; - - - -//page questionnairecatimeslots.php -print "

" . T_("Call attempt time slots") . "

"; -print "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
"; - - $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link - - FROM questionnaire_timeslot as q, availability_group as a - WHERE q.availability_group_id = a.availability_group_id - AND q.questionnaire_id = '$questionnaire_id'"; - - $qs = $db->GetAll($sql); - print "
"; - if (empty($qs)) - { - print "

" . T_("There are no call attempt time slots selected for this questionnaire") . "

"; - } - else - { - print "

" . T_("Call attempt time slots selected for this questionnaire") . "

"; - xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover"); - } - print "
"; - - $sql = "SELECT si.availability_group_id,si.description - FROM availability_group as si - LEFT JOIN questionnaire_timeslot as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id) - WHERE q.questionnaire_id is NULL"; - - $qs = $db->GetAll($sql); - - if (!empty($qs)) - { - print "
"; - //print "

" . T_("Add a call attempt time slot to this questionnaire:") . "

"; - print "
- -   -
"; - } -print "
"; - -//page questionnairetimeslosample.php -print "

" . T_("Call attempt time slots for sample") . "

"; -print "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
"; - - print "

" . T_("Sample") . ": 

"; - - $sample_import_id = false; - if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); - display_sample_chooser($questionnaire_id,$sample_import_id,false, "form-inline", "form-control"); - - if ($sample_import_id !== false) - { - $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link - FROM questionnaire_sample_timeslot as q, availability_group as a - WHERE q.availability_group_id = a.availability_group_id - AND q.questionnaire_id = '$questionnaire_id' - AND q.sample_import_id = '$sample_import_id'"; - - $qs = $db->GetAll($sql); - - if (empty($qs)) - { - print "

" . T_("There are no call attempt time slots selected for this questionnaire sample") . "

"; - } - else - { - print "

" . T_("Call attempt time slots selected for this sample") . ":

"; - xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover"); - } - - $sql = "SELECT si.availability_group_id,si.description - FROM availability_group as si - LEFT JOIN questionnaire_sample_timeslot as q ON (q.sample_import_id = '$sample_import_id' AND q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id) - WHERE q.questionnaire_id is NULL"; - - $qs = $db->GetAll($sql); - - if (!empty($qs)) - { - print "
"; - //print "

" . T_("Add a call attempt time slot to this questionnaire sample:") . "

"; - print "
- - -   -
"; - } - } -print "
"; -} - -xhtml_foot($js_foot); -?> \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au queXS was writen for ACSPRI + * @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"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +"../include/bootstrap/css/bootstrap-theme.min.css", +//"../include/font-awesome/css/font-awesome.css", +"../css/custom.css" + ); +$js_head = array( + ); +$js_foot = array( +"../js/window.js", +//"../js/custom.js" + ); + +global $db; + +//block availability +if (isset($_GET['questionnaire_id']) && isset($_GET['av_availability_group'])) +{ + //need to add availability_group to questionnaire + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $availability_group = bigintval($_GET['av_availability_group']); + + $sql = "INSERT INTO questionnaire_availability(questionnaire_id,availability_group_id) + VALUES('$questionnaire_id','$availability_group')"; + $db->Execute($sql); +} + +if (isset($_GET['questionnaire_id']) && isset($_GET['av_ravailability_group'])) +{ + //need to remove rsid from questionnaire + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $availability_group = bigintval($_GET['av_ravailability_group']); + + $sql = "DELETE FROM questionnaire_availability + WHERE questionnaire_id = '$questionnaire_id' + AND availability_group_id = '$availability_group'"; + $db->Execute($sql); +} + +//block call_attempts +if (isset($_GET['questionnaire_id']) && isset($_GET['ca_availability_group'])) +{ + //need to add availability_group to questionnaire + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $availability_group = bigintval($_GET['ca_availability_group']); + + $sql = "INSERT INTO questionnaire_timeslot(questionnaire_id,availability_group_id) + VALUES('$questionnaire_id','$availability_group')"; + $db->Execute($sql); +} + +if (isset($_GET['questionnaire_id']) && isset($_GET['ca_ravailability_group'])) +{ + //need to remove rsid from questionnaire + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $availability_group = bigintval($_GET['ca_ravailability_group']); + + $sql = "DELETE FROM questionnaire_timeslot + WHERE questionnaire_id = '$questionnaire_id' + AND availability_group_id = '$availability_group'"; + $db->Execute($sql); +} + + +//block call_attempts by sample +if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['qs_availability_group'])) +{ + //need to add availability_group to questionnaire + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sample_import_id = bigintval($_GET['sample_import_id']); + $availability_group = bigintval($_GET['qs_availability_group']); + + $sql = "INSERT INTO questionnaire_sample_timeslot (questionnaire_id,sample_import_id,availability_group_id) + VALUES('$questionnaire_id','$sample_import_id','$availability_group')"; + $db->Execute($sql); +} + +if (isset($_GET['questionnaire_id']) && isset($_GET['sample_import_id']) && isset($_GET['qs_ravailability_group'])) +{ + //need to remove rsid from questionnaire + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sample_import_id = bigintval($_GET['sample_import_id']); + $availability_group = bigintval($_GET['qs_ravailability_group']); + + $sql = "DELETE FROM questionnaire_sample_timeslot + WHERE questionnaire_id = '$questionnaire_id' + AND sample_import_id = '$sample_import_id' + AND availability_group_id = '$availability_group'"; + $db->Execute($sql); +} + +$questionnaire_id = false; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); +$sample_import_id = false; +if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); + +xhtml_head(T_("Assign Time slots"),true,$css,$js_head);//false,array("../js/window.js") + +print "

" . T_("Select a questionnaire") . ":

"; +display_questionnaire_chooser($questionnaire_id,false, "form-inline", "form-control"); +print "
"; +if ($questionnaire_id != false) +{ + +//page questionnaireavailability.php +print "

" . T_("Time slot groups") . "

"; +print "
" . T_("Assigning an availability group to a questionnaire will allow interviewers to select from those groups to restrict calls to a particular case to the times within the group") ."
"; + + $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link + FROM questionnaire_availability as q, availability_group as a + WHERE q.availability_group_id = a.availability_group_id + AND q.questionnaire_id = '$questionnaire_id'"; + + $qs = $db->GetAll($sql); + print "


"; + + if (empty($qs)) + { + print "

" . T_("There are no time slots groups selected for this questionnaire") . "

"; + } + else + { + print "

" . T_("Time slots groups selected for this questionnaire") . "

"; + xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover"); + } + print "
"; + $sql = "SELECT si.availability_group_id,si.description + FROM availability_group as si + LEFT JOIN questionnaire_availability as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id) + WHERE q.questionnaire_id is NULL"; + + $qs = $db->GetAll($sql); + + if (!empty($qs)) + { + print "
"; + //print "

" . T_("Add time slot to this questionnaire:") . "

"; + print "
+ +   +
"; + } + +print "
"; + + + +//page questionnairecatimeslots.php +print "

" . T_("Call attempt time slots") . "

"; +print "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
"; + + $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link + + FROM questionnaire_timeslot as q, availability_group as a + WHERE q.availability_group_id = a.availability_group_id + AND q.questionnaire_id = '$questionnaire_id'"; + + $qs = $db->GetAll($sql); + print "
"; + if (empty($qs)) + { + print "

" . T_("There are no call attempt time slots selected for this questionnaire") . "

"; + } + else + { + print "

" . T_("Call attempt time slots selected for this questionnaire") . "

"; + xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover"); + } + print "
"; + + $sql = "SELECT si.availability_group_id,si.description + FROM availability_group as si + LEFT JOIN questionnaire_timeslot as q ON (q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id) + WHERE q.questionnaire_id is NULL"; + + $qs = $db->GetAll($sql); + + if (!empty($qs)) + { + print "
"; + //print "

" . T_("Add a call attempt time slot to this questionnaire:") . "

"; + print "
+ +   +
"; + } +print "
"; + +//page questionnairetimeslosample.php +print "

" . T_("Call attempt time slots for sample") . "

"; +print "
" . T_("Assigning call attempt time slots to questionnaires will only allow cases to be attempted in a time slot for the n + 1th time where it has been attempted at least n times in all assigned timeslots. Please note timeslots must cover all possible time periods otherwise no cases will be available during missing timeslots.") ."
"; + + print "

" . T_("Sample") . ": 

"; + + $sample_import_id = false; + if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); + display_sample_chooser($questionnaire_id,$sample_import_id,false, "form-inline", "form-control"); + + if ($sample_import_id !== false) + { + $sql = "SELECT q.availability_group_id,a.description as description, CONCAT('" . T_("Click to unassign") . "') as link + FROM questionnaire_sample_timeslot as q, availability_group as a + WHERE q.availability_group_id = a.availability_group_id + AND q.questionnaire_id = '$questionnaire_id' + AND q.sample_import_id = '$sample_import_id'"; + + $qs = $db->GetAll($sql); + + if (empty($qs)) + { + print "

" . T_("There are no call attempt time slots selected for this questionnaire sample") . "

"; + } + else + { + print "

" . T_("Call attempt time slots selected for this sample") . ":

"; + xhtml_table ($qs,array("availability_group_id","description","link"),false,"table table-hover"); + } + + $sql = "SELECT si.availability_group_id,si.description + FROM availability_group as si + LEFT JOIN questionnaire_sample_timeslot as q ON (q.sample_import_id = '$sample_import_id' AND q.questionnaire_id = '$questionnaire_id' AND q.availability_group_id = si.availability_group_id) + WHERE q.questionnaire_id is NULL"; + + $qs = $db->GetAll($sql); + + if (!empty($qs)) + { + print "
"; + //print "

" . T_("Add a call attempt time slot to this questionnaire sample:") . "

"; + print "
+ + +   +
"; + } + } +print "
"; +} + +xhtml_foot($js_foot); +?> diff --git a/admin/availability.php b/admin/availability.php index 91bbb460..09f23a24 100644 --- a/admin/availability.php +++ b/admin/availability.php @@ -1,190 +1,190 @@ - - * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/ queXS was writen for ACSPRI - * @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"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/clockpicker/dist/bootstrap-clockpicker.min.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -"../js/addrow-v2.js", - ); -$js_foot = array( -"../include/clockpicker/dist/bootstrap-clockpicker.js", -"../js/custom.js" - ); - -global $db; - -$year="2008"; -$woy="1"; - -if (isset($_GET['availability_group'])) - $availability_group = intval($_GET['availability_group']); -else if (isset($_POST['availability_group'])) - $availability_group = intval($_POST['availability_group']); -else - die(T_("No time slot group set")); - - -if (isset($_POST['day'])) -{ - $db->StartTrans(); - - $sql = "DELETE FROM availability - WHERE availability_group_id = $availability_group"; - $db->Execute($sql); - - foreach($_POST['day'] as $key => $val) - { - if (!empty($val)) - { - $val = intval($val); - $key = intval($key); - - $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); - $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); - - $sql = "INSERT INTO availability (day_of_week,start,end,availability_group_id) - VALUES ('$val',$start,$end,$availability_group)"; - $db->Execute($sql); - } - } - - $sql = "UPDATE availability_group - SET description = " . $db->qstr($_POST['description']) . " - WHERE availability_group_id= $availability_group"; - $db->Execute($sql); - $db->CompleteTrans(); -} - -xhtml_head(T_("Modify time slots"),true,$css,$js_head);//,true,array("../css/shifts.css"),array("../js/addrow-v2.js") - -/** - * Display warning if timezone data not installed - * - */ - -$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria' -$rs = $db->GetRow($sql); - -if (empty($rs) || !$rs || empty($rs['t'])) - print ""; - - -print "
" . T_("Go back") . "

"; - - -$sql = "SELECT description - FROM availability_group - WHERE availability_group_id = $availability_group"; - -$rs = $db->GetRow($sql); - -$description = $rs['description']; - -print "

" . T_("Time slot") . " : " . $rs['description'] . "

"; - -/** - * Begin displaying currently loaded restriction times - */ - -$sql = "SELECT DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W' ) AS dt,day_of_week,start,end - FROM availability - WHERE availability_group_id = $availability_group"; - -$availabilitys = $db->GetAll($sql); -translate_array($availabilitys,array("dt")); - -$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected - FROM day_of_week"; - -$daysofweek = $db->GetAll($sql); -translate_array($daysofweek,array("description")); - -?> -
-

- -" . T_("Enter the start and end times for each day of the week to restrict calls within") . ""; - - print ""; - $count = 0; - foreach($availabilitys as $availability) - { - print ""; - $count++; - } - print ""; - - -?> -
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
";//class='row_to_clone' - display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$availability['dt'])); - print "
"; - display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); - print "
-

- "/> - -


-
- "/> - -
- - \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Inc (ACSPRI) 2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", +"../include/clockpicker/dist/bootstrap-clockpicker.min.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js", +"../js/addrow-v2.js", + ); +$js_foot = array( +"../include/clockpicker/dist/bootstrap-clockpicker.js", +"../js/custom.js" + ); + +global $db; + +$year="2008"; +$woy="1"; + +if (isset($_GET['availability_group'])) + $availability_group = intval($_GET['availability_group']); +else if (isset($_POST['availability_group'])) + $availability_group = intval($_POST['availability_group']); +else + die(T_("No time slot group set")); + + +if (isset($_POST['day'])) +{ + $db->StartTrans(); + + $sql = "DELETE FROM availability + WHERE availability_group_id = $availability_group"; + $db->Execute($sql); + + foreach($_POST['day'] as $key => $val) + { + if (!empty($val)) + { + $val = intval($val); + $key = intval($key); + + $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); + $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); + + $sql = "INSERT INTO availability (day_of_week,start,end,availability_group_id) + VALUES ('$val',$start,$end,$availability_group)"; + $db->Execute($sql); + } + } + + $sql = "UPDATE availability_group + SET description = " . $db->qstr($_POST['description']) . " + WHERE availability_group_id= $availability_group"; + $db->Execute($sql); + $db->CompleteTrans(); +} + +xhtml_head(T_("Modify time slots"),true,$css,$js_head);//,true,array("../css/shifts.css"),array("../js/addrow-v2.js") + +/** + * Display warning if timezone data not installed + * + */ + +$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria' +$rs = $db->GetRow($sql); + +if (empty($rs) || !$rs || empty($rs['t'])) + print ""; + + +print "
" . T_("Go back") . "

"; + + +$sql = "SELECT description + FROM availability_group + WHERE availability_group_id = $availability_group"; + +$rs = $db->GetRow($sql); + +$description = $rs['description']; + +print "

" . T_("Time slot") . " : " . $rs['description'] . "

"; + +/** + * Begin displaying currently loaded restriction times + */ + +$sql = "SELECT DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W' ) AS dt,day_of_week,start,end + FROM availability + WHERE availability_group_id = $availability_group"; + +$availabilitys = $db->GetAll($sql); +translate_array($availabilitys,array("dt")); + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected + FROM day_of_week"; + +$daysofweek = $db->GetAll($sql); +translate_array($daysofweek,array("description")); + +?> +
+

+ +" . T_("Enter the start and end times for each day of the week to restrict calls within") . ""; + + print ""; + $count = 0; + foreach($availabilitys as $availability) + { + print ""; + $count++; + } + print ""; + + +?> +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
";//class='row_to_clone' + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$availability['dt'])); + print "
"; + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); + print "
+

+ "/> + +


+
+ "/> + +
+ + diff --git a/admin/availabilitygroup.php b/admin/availabilitygroup.php index 137abc47..4b7db070 100644 --- a/admin/availabilitygroup.php +++ b/admin/availabilitygroup.php @@ -1,141 +1,141 @@ - - * @copyright Australian Consortium for Social and Political Research Inc (2011) - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/ queXS was writen for ACSPRI - * @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"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -/** - * Limesurvey functions - */ -include("../functions/functions.limesurvey.php"); - -/** - * Operator functions - */ -include("../functions/functions.operator.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../css/custom.css" - ); -$js_head = array( - ); -$js_foot = array( -"../js/window.js", -"../js/custom.js" - ); -global $db; - -xhtml_head(T_("Time slots"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") - -if (isset($_POST['subdel'])) -{ - $availability_group = intval($_POST['availability_group']); - - $db->StartTrans(); - - $sql = "DELETE FROM availability - WHERE availability_group_id = $availability_group"; - - $db->Execute($sql); - - $sql = "DELETE FROM questionnaire_availability - WHERE availability_group_id = $availability_group"; - - $db->Execute($sql); - - $sql = "DELETE FROM availability_group - WHERE availability_group_id = $availability_group"; - - $db->Execute($sql); - - $db->CompleteTrans(); -} -else if (isset($_POST['availability_group'])) -{ - $availability_group = $db->qstr($_POST['availability_group']); - - $sql = "INSERT INTO `availability_group` (availability_group_id,description) - VALUES (NULL,$availability_group)"; - - $db->Execute($sql); -} - -//view groups -$sql = "SELECT availability_group_id,description, - CONCAT('". TQ_("Modify") . "') as link - FROM availability_group"; - - $rs = $db->GetAll($sql); - -print "
" . T_("Time slots define periods of time during particular days of the week. These are used for the availability function and also the call attempt time slot function.") . "
"; - -if (empty($rs)) - print "
" . T_("No time slots") . "
"; -else{ - print "
"; - xhtml_table($rs,array("availability_group_id","description","link"),array(T_("ID"),T_("Time slot name"),T_("Modify")),"table table-hover"); - print "
"; -} - -//add a time slot (ex- availablity group) -?> -
-

-

"/>

-

"/>

-
- + + * @copyright Australian Consortium for Social and Political Research Inc (2011) + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +/** + * Limesurvey functions + */ +include("../functions/functions.limesurvey.php"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +"../css/custom.css" + ); +$js_head = array( + ); +$js_foot = array( +"../js/window.js", +"../js/custom.js" + ); +global $db; + +xhtml_head(T_("Time slots"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") + +if (isset($_POST['subdel'])) +{ + $availability_group = intval($_POST['availability_group']); + + $db->StartTrans(); + + $sql = "DELETE FROM availability + WHERE availability_group_id = $availability_group"; + + $db->Execute($sql); + + $sql = "DELETE FROM questionnaire_availability + WHERE availability_group_id = $availability_group"; + + $db->Execute($sql); + + $sql = "DELETE FROM availability_group + WHERE availability_group_id = $availability_group"; + + $db->Execute($sql); + + $db->CompleteTrans(); +} +else if (isset($_POST['availability_group'])) +{ + $availability_group = $db->qstr($_POST['availability_group']); + + $sql = "INSERT INTO `availability_group` (availability_group_id,description) + VALUES (NULL,$availability_group)"; + + $db->Execute($sql); +} + +//view groups +$sql = "SELECT availability_group_id,description, + CONCAT('". TQ_("Modify") . "') as link + FROM availability_group"; + + $rs = $db->GetAll($sql); + +print "
" . T_("Time slots define periods of time during particular days of the week. These are used for the availability function and also the call attempt time slot function.") . "
"; + +if (empty($rs)) + print "
" . T_("No time slots") . "
"; +else{ + print "
"; + xhtml_table($rs,array("availability_group_id","description","link"),array(T_("ID"),T_("Time slot name"),T_("Modify")),"table table-hover"); + print "
"; +} + +//add a time slot (ex- availablity group) +?> +
+

+

"/>

+

"/>

+
+ diff --git a/admin/bulkappointment.php b/admin/bulkappointment.php index 518ad57a..567bc8f6 100644 --- a/admin/bulkappointment.php +++ b/admin/bulkappointment.php @@ -1,289 +1,289 @@ - - * @copyright Australian Consortium for Social and Political Research (ACSPRI) 2012 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/software queXS was writen for ACSPRI - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include ("../config.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Database functions - */ -include ("../db.inc.php"); - -/** - * Operator functions - */ -include("../functions/functions.operator.php"); - -/** - * Validate that an uploaded CSV file contains a caseid, starttime and endtime column and generate - * an array containing the details for confirming on screen or updating the database - * - * @param string $tmpfname File name of uploaded CSV file - * - * @return bool|array False if invalid otherwise an array of arrays containing caseid,starttime,endtime and note - * @author Adam Zammit - * @since 2012-11-02 - */ -function validate_bulk_appointment($tmpfname) -{ - $handle = fopen($tmpfname, "r"); - $row = 1; - $cols = array("caseid" => -1,"starttime" => -1,"endtime" => -1); - $index = array(); - $optcols = array("note" => -1); - - $todo = array(); - - while (($data = fgetcsv($handle)) !== FALSE) - { - //data contains an array of elements in the csv - //selected contains an indexed array of elements to import with the type attached - - - if ($row == 1) //validate - { - $colcount = 0; - $ic = 0; - foreach($data as $col) - { - if (array_key_exists(strtolower($col),$cols)) - { - $cols[strtolower($col)] = $ic; - $colcount++; - } - if (array_key_exists(strtolower($col),$optcols)) - { - $optcols[strtolower($col)] = $ic; - } - $ic++; - } - if ($colcount != 3) - { - return false; - } - } - else - { - $note = ""; - if (isset($data[$optcols['note']])) - $note = $data[$optcols['note']]; - - $sd = getdate(strtotime($data[$cols['starttime']])); - $s = $sd['year'] . "-" . str_pad($sd['mon'],2,"0", STR_PAD_LEFT) . "-" . str_pad($sd['mday'],2,"0",STR_PAD_LEFT) . " " . str_pad($sd['hours'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['minutes'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['seconds'],2,"0",STR_PAD_LEFT); - - $sd = getdate(strtotime($data[$cols['endtime']])); - $e = $sd['year'] . "-" . str_pad($sd['mon'],2,"0", STR_PAD_LEFT) . "-" . str_pad($sd['mday'],2,"0",STR_PAD_LEFT) . " " . str_pad($sd['hours'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['minutes'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['seconds'],2,"0",STR_PAD_LEFT); - - $todor = array($data[$cols['caseid']],$s,$e,$note); - - $todo[] = $todor; - } - - $row++; - } - - fclose($handle); - - return $todo; -} - - -if (isset($_POST['tmpfname'])) -{ - $subtitle = T_("Result"); - xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),false,false,false,false,$subtitle); - $todo = validate_bulk_appointment($_POST['tmpfname']); - - if (is_array($todo)) - { - $res = array(); - foreach($todo as $r) - { - $db->StartTrans(); - - //check the current case id exists and outcome is not final - $sql = "SELECT c.case_id - FROM `case` as c, `outcome` as o - WHERE c.current_outcome_id = o.outcome_id - AND o.outcome_type_id != 4 - AND c.case_id = {$r[0]} - AND c.current_operator_id IS NULL"; - - $caseid = $db->GetOne($sql); - - if (!empty($caseid)) - { - //insert an appointment in respondent time - $sql = "SELECT respondent_id - FROM respondent - WHERE case_id = {$r[0]}"; - - $rid = $db->GetOne($sql); - - $sql = "SELECT contact_phone_id - FROM contact_phone - WHERE case_id = {$r[0]} - ORDER BY priority ASC"; - - $cid = $db->GetOne($sql); - - $oid = get_operator_id(); - - $sql = "INSERT INTO call_attempt (call_attempt_id,case_id,operator_id,respondent_id,start,end) - VALUES (NULL,{$r[0]},$oid,$rid,CONVERT_TZ(NOW(),'System','UTC'),CONVERT_TZ(NOW(),'System','UTC'))"; - - $db->Execute($sql); - - $call_attempt_id = $db->Insert_ID(); - - $sql = "INSERT INTO appointment (case_id,contact_phone_id,`start`,`end`,respondent_id,call_attempt_id) - SELECT {$r[0]},$cid,CONVERT_TZ('{$r[1]}',Time_zone_name,'UTC'),CONVERT_TZ('{$r[2]}',Time_zone_name,'UTC'),$rid,$call_attempt_id - FROM respondent - WHERE respondent_id = $rid"; - - $db->Execute($sql); - - $aid = $db->Insert_ID(); - - //change the outcome to unspecified appointment, other - $sql = "UPDATE `case` - SET current_outcome_id = 22 - WHERE case_id = {$r[0]}"; - - $db->Execute($sql); - - //add a note if not blank - if (!empty($r[3])) - { - $note = $db->qstr($r[3]); - $sql = "INSERT INTO case_note (case_id,operator_id,note,datetime) - VALUES ({$r[0]},$oid,$note,CONVERT_TZ(NOW(),'System','UTC'))"; - $db->Execute($sql); - - } - - $cnote = T_("Added appointment") . " $aid"; - } - else - { - $cnote = T_("No such case id, or case set to a final outcome, or case currently assigned to an operator"); - } - - $res[] = array("" . $r[0] . "",$cnote); - $db->CompleteTrans(); - } - xhtml_table($res,array(0,1),array(T_("Case id"),T_("Result"))); - } - xhtml_foot(); -} -else if (isset($_POST['import_file'])) -{ - //file has been submitted - $subtitle = T_("Check data to submit"); - xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),false,false,false,false,$subtitle); - ?> -
- " . T_("Please check the case id's, appointment start and end times and notes are correct before accepting below") . "

"; - $todoh = array(T_("Case id"), T_("Start time"), T_("End time"), T_("Note")); - xhtml_table($todo,array(0,1,2,3),$todoh); - ?> - - - " class="btn btn-primary"/> -
- " . T_("The file does not contain at least caseid, starttime and endtime columns. Please try again.") ."

"; - - print ""; - - - xhtml_foot(); - -} -else -{ - //need to supply file to upload - $subtitle = T_("Import: Select file to upload"); - xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../js/bootstrap-filestyle.min.js"),false,false,false,$subtitle ); - - $ua = $_SERVER['HTTP_USER_AGENT']; - if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; - - ?> - -

Optionally you can include a note column to attach a note to the case in addition to setting an appointment.
Only cases that have temporary (non final) outcomes will have appointments generated, and the outcome of the case will be updated to an appointment outcome."); ?>

- -

-
- - - - - -
caseidstarttimeendtimenote
12012-08-15 11:00:002012-08-15 13:00:00Appointment automatically generated
22012-08-15 12:00:002012-08-15 14:00:00Appointment automatically generated
32012-08-15 13:00:002012-08-15 15:00:00Appointment automatically generated
-
- -
- - -

: 

- -
- " type="file" accept=""/>  -
- - -
- - \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research (ACSPRI) 2012 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/software queXS was writen for ACSPRI + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include ("../config.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Database functions + */ +include ("../db.inc.php"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +/** + * Validate that an uploaded CSV file contains a caseid, starttime and endtime column and generate + * an array containing the details for confirming on screen or updating the database + * + * @param string $tmpfname File name of uploaded CSV file + * + * @return bool|array False if invalid otherwise an array of arrays containing caseid,starttime,endtime and note + * @author Adam Zammit + * @since 2012-11-02 + */ +function validate_bulk_appointment($tmpfname) +{ + $handle = fopen($tmpfname, "r"); + $row = 1; + $cols = array("caseid" => -1,"starttime" => -1,"endtime" => -1); + $index = array(); + $optcols = array("note" => -1); + + $todo = array(); + + while (($data = fgetcsv($handle)) !== FALSE) + { + //data contains an array of elements in the csv + //selected contains an indexed array of elements to import with the type attached + + + if ($row == 1) //validate + { + $colcount = 0; + $ic = 0; + foreach($data as $col) + { + if (array_key_exists(strtolower($col),$cols)) + { + $cols[strtolower($col)] = $ic; + $colcount++; + } + if (array_key_exists(strtolower($col),$optcols)) + { + $optcols[strtolower($col)] = $ic; + } + $ic++; + } + if ($colcount != 3) + { + return false; + } + } + else + { + $note = ""; + if (isset($data[$optcols['note']])) + $note = $data[$optcols['note']]; + + $sd = getdate(strtotime($data[$cols['starttime']])); + $s = $sd['year'] . "-" . str_pad($sd['mon'],2,"0", STR_PAD_LEFT) . "-" . str_pad($sd['mday'],2,"0",STR_PAD_LEFT) . " " . str_pad($sd['hours'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['minutes'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['seconds'],2,"0",STR_PAD_LEFT); + + $sd = getdate(strtotime($data[$cols['endtime']])); + $e = $sd['year'] . "-" . str_pad($sd['mon'],2,"0", STR_PAD_LEFT) . "-" . str_pad($sd['mday'],2,"0",STR_PAD_LEFT) . " " . str_pad($sd['hours'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['minutes'],2,"0",STR_PAD_LEFT) . ":" . str_pad($sd['seconds'],2,"0",STR_PAD_LEFT); + + $todor = array($data[$cols['caseid']],$s,$e,$note); + + $todo[] = $todor; + } + + $row++; + } + + fclose($handle); + + return $todo; +} + + +if (isset($_POST['tmpfname'])) +{ + $subtitle = T_("Result"); + xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),false,false,false,false,$subtitle); + $todo = validate_bulk_appointment($_POST['tmpfname']); + + if (is_array($todo)) + { + $res = array(); + foreach($todo as $r) + { + $db->StartTrans(); + + //check the current case id exists and outcome is not final + $sql = "SELECT c.case_id + FROM `case` as c, `outcome` as o + WHERE c.current_outcome_id = o.outcome_id + AND o.outcome_type_id != 4 + AND c.case_id = {$r[0]} + AND c.current_operator_id IS NULL"; + + $caseid = $db->GetOne($sql); + + if (!empty($caseid)) + { + //insert an appointment in respondent time + $sql = "SELECT respondent_id + FROM respondent + WHERE case_id = {$r[0]}"; + + $rid = $db->GetOne($sql); + + $sql = "SELECT contact_phone_id + FROM contact_phone + WHERE case_id = {$r[0]} + ORDER BY priority ASC"; + + $cid = $db->GetOne($sql); + + $oid = get_operator_id(); + + $sql = "INSERT INTO call_attempt (call_attempt_id,case_id,operator_id,respondent_id,start,end) + VALUES (NULL,{$r[0]},$oid,$rid,CONVERT_TZ(NOW(),'System','UTC'),CONVERT_TZ(NOW(),'System','UTC'))"; + + $db->Execute($sql); + + $call_attempt_id = $db->Insert_ID(); + + $sql = "INSERT INTO appointment (case_id,contact_phone_id,`start`,`end`,respondent_id,call_attempt_id) + SELECT {$r[0]},$cid,CONVERT_TZ('{$r[1]}',Time_zone_name,'UTC'),CONVERT_TZ('{$r[2]}',Time_zone_name,'UTC'),$rid,$call_attempt_id + FROM respondent + WHERE respondent_id = $rid"; + + $db->Execute($sql); + + $aid = $db->Insert_ID(); + + //change the outcome to unspecified appointment, other + $sql = "UPDATE `case` + SET current_outcome_id = 22 + WHERE case_id = {$r[0]}"; + + $db->Execute($sql); + + //add a note if not blank + if (!empty($r[3])) + { + $note = $db->qstr($r[3]); + $sql = "INSERT INTO case_note (case_id,operator_id,note,datetime) + VALUES ({$r[0]},$oid,$note,CONVERT_TZ(NOW(),'System','UTC'))"; + $db->Execute($sql); + + } + + $cnote = T_("Added appointment") . " $aid"; + } + else + { + $cnote = T_("No such case id, or case set to a final outcome, or case currently assigned to an operator"); + } + + $res[] = array("" . $r[0] . "",$cnote); + $db->CompleteTrans(); + } + xhtml_table($res,array(0,1),array(T_("Case id"),T_("Result"))); + } + xhtml_foot(); +} +else if (isset($_POST['import_file'])) +{ + //file has been submitted + $subtitle = T_("Check data to submit"); + xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),false,false,false,false,$subtitle); + ?> +
+ " . T_("Please check the case id's, appointment start and end times and notes are correct before accepting below") . "

"; + $todoh = array(T_("Case id"), T_("Start time"), T_("End time"), T_("Note")); + xhtml_table($todo,array(0,1,2,3),$todoh); + ?> + + + " class="btn btn-primary"/> +
+ " . T_("The file does not contain at least caseid, starttime and endtime columns. Please try again.") ."

"; + + print ""; + + + xhtml_foot(); + +} +else +{ + //need to supply file to upload + $subtitle = T_("Import: Select file to upload"); + xhtml_head(T_("Bulk appointment generator"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/font-awesome/css/font-awesome.css","../css/custom.css"),array("../include/jquery/jquery.min.js","../js/bootstrap-filestyle.min.js"),false,false,false,$subtitle ); + + $ua = $_SERVER['HTTP_USER_AGENT']; + if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; + + ?> + +

Optionally you can include a note column to attach a note to the case in addition to setting an appointment.
Only cases that have temporary (non final) outcomes will have appointments generated, and the outcome of the case will be updated to an appointment outcome."); ?>

+ +

+
+ + + + + +
caseidstarttimeendtimenote
12012-08-15 11:00:002012-08-15 13:00:00Appointment automatically generated
22012-08-15 12:00:002012-08-15 14:00:00Appointment automatically generated
32012-08-15 13:00:002012-08-15 15:00:00Appointment automatically generated
+
+ +
+ + +

: 

+ +
+ " type="file" accept=""/>  +
+ + +
+ + diff --git a/admin/callhistory.php b/admin/callhistory.php index e4a7a7c9..2e27bea8 100644 --- a/admin/callhistory.php +++ b/admin/callhistory.php @@ -1,181 +1,181 @@ - - * @copyright Deakin University 2007,2008 - * @package queXS - * @subpackage user - * @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"); - -/** - * Operator functions - */ -include("../functions/functions.operator.php"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/font-awesome-4.3.0/css/font-awesome.css", -"../include/bs-data-table/css/jquery.bdt.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js" - ); -$js_foot = array( -"../include/bs-data-table/js/vendor/jquery.sortelements.js", -"../include/bs-data-table/js/jquery.bdt.js", -"../js/custom.js" - ); - -//List the case call history -$operator_id = get_operator_id(); -/* - Modified Call history list to have more information more suitable way with filtering, soring, paging and submenu for Cse history with asterisk records.... - Need to be linked with cdr records from asterisk!! for monitoring (requires addtional field for call_attempt table to request and store asterisk UniqueID as a reference to CDR .wav file list at /var/spool/asterisk/monitor/ ) -*/ - -if ($operator_id) -{ - if (isset($_GET['questionnaire_id'])) $qid = $_GET['questionnaire_id']; - if (isset($_GET['sample_import_id'])) $sid = $_GET['sample_import_id']; - $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_FORMAT."') as start_date, DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as start_time, DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as descr, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname, - (SELECT GROUP_CONCAT(cn1.note SEPARATOR '
¶ ' ) FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes,"; - - if (isset($_GET['csv'])) $sql .= " c.case_id "; - else $sql .= " CONCAT('', c.case_id, '') "; - - $sql .= " as case_id, q.description as qd , contact_phone.phone as cpi, sample_import.description as spl - FROM `call` as c - JOIN (operator as op, respondent as r) on (op.operator_id = '$operator_id' and r.respondent_id = c.respondent_id)"; - if ($qid) $quest = "$qid and q.questionnaire_id= $qid"; else $quest = "q.questionnaire_id"; - if ($sid) $samimpid = "$sid and sample_import.sample_import_id=$sid"; else $samimpid = "sample_import.sample_import_id"; - - $sql .= " - JOIN (`case` as ca, questionnaire as q) ON (ca.case_id = c.case_id AND ca.questionnaire_id = $quest) - LEFT JOIN (outcome as o) on (c.outcome_id = o.outcome_id) - LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id), - contact_phone, sample_import, sample - WHERE c.contact_phone_id = contact_phone.contact_phone_id AND sample.import_id = $samimpid - AND sample.sample_id = ca.sample_id - ORDER BY c.start DESC"; - - if (!isset($_GET['csv'])) - $sql .= " LIMIT 500"; - else $sql .= " LIMIT 5000"; - - $rs = $db->Execute($sql); - if (empty($rs)) - { - print "

" . T_("No calls ever made") . "

"; - } - else - { - if (isset($_GET['csv'])) - { - $qds = str_replace(' ','_',$_GET['dq']); $smpds = str_replace(' ','_',$_GET['ds']); - $fn = "callhistory-" . $qds . $smpds . date("_d-M-Y_H-i") . ".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 - - echo(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") . "\n"); - - while ($r = $rs->FetchRow()) - { - translate_array($r,array("des")); - 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"; - } - - exit; - } - else - { - xhtml_head(T_("Call History List"),true,$css,$js_head); - echo ""; - - $rs = $rs->GetArray(); - if (count($rs) ==0) - { - print "

" . T_("NO Call history records for Your query") . "

"; - } - else - { - translate_array($rs,array("des")); - - $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")); - - if (isset($_GET['questionnaire_id'])){ - $sql = "SELECT description FROM `questionnaire` WHERE `questionnaire_id` = $qid "; - $dq = $db->GetOne($sql); - print "

" . T_("Questionnaire") . " ID: $qid " . $dq . "

"; - unset($datacol[4]); unset($headers[4]); } - - if (isset($_GET['sample_import_id'])){ - $sql = "SELECT description FROM `sample_import` WHERE `sample_import_id` = $sid "; - $ds = $db->GetOne($sql); - print "

" . T_("Sample") . " ID: $sid " . $ds . "

"; - unset($datacol[5]); unset($headers[5]); } - - print "  " . T_("Download Call History List") . " - "; // " . T_("Go to Call History Report") . "  - - xhtml_table($rs,$datacol,$headers,"tclass",false,false,"bs-table"); - - } - } - } -} -else -{ - print "
" . T_("No operator") . "
"; -} - -xhtml_foot($js_foot); -?> - \ No newline at end of file + + * @copyright Deakin University 2007,2008 + * @package queXS + * @subpackage user + * @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"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +"../include/bootstrap/css/bootstrap-theme.min.css", +"../include/font-awesome/css/font-awesome.css", +"../include/bs-data-table/css/jquery.bdt.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js" + ); +$js_foot = array( +"../include/bs-data-table/js/vendor/jquery.sortelements.js", +"../include/bs-data-table/js/jquery.bdt.js", +"../js/custom.js" + ); + +//List the case call history +$operator_id = get_operator_id(); +/* + Modified Call history list to have more information more suitable way with filtering, soring, paging and submenu for Cse history with asterisk records.... + Need to be linked with cdr records from asterisk!! for monitoring (requires addtional field for call_attempt table to request and store asterisk UniqueID as a reference to CDR .wav file list at /var/spool/asterisk/monitor/ ) +*/ + +if ($operator_id) +{ + if (isset($_GET['questionnaire_id'])) $qid = $_GET['questionnaire_id']; + if (isset($_GET['sample_import_id'])) $sid = $_GET['sample_import_id']; + $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".DATE_FORMAT."') as start_date, DATE_FORMAT(CONVERT_TZ(c.start,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as start_time, DATE_FORMAT(CONVERT_TZ(c.end,'UTC',op.Time_zone_name),'".TIME_FORMAT."') as end, o.description as descr, (CONCAT(r.firstName,' ',r.lastName)) as firstName, opp.firstName as opname, + (SELECT GROUP_CONCAT(cn1.note SEPARATOR '
¶ ' ) FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes,"; + + if (isset($_GET['csv'])) $sql .= " c.case_id "; + else $sql .= " CONCAT('', c.case_id, '') "; + + $sql .= " as case_id, q.description as qd , contact_phone.phone as cpi, sample_import.description as spl + FROM `call` as c + JOIN (operator as op, respondent as r) on (op.operator_id = '$operator_id' and r.respondent_id = c.respondent_id)"; + if ($qid) $quest = "$qid and q.questionnaire_id= $qid"; else $quest = "q.questionnaire_id"; + if ($sid) $samimpid = "$sid and sample_import.sample_import_id=$sid"; else $samimpid = "sample_import.sample_import_id"; + + $sql .= " + JOIN (`case` as ca, questionnaire as q) ON (ca.case_id = c.case_id AND ca.questionnaire_id = $quest) + LEFT JOIN (outcome as o) on (c.outcome_id = o.outcome_id) + LEFT JOIN (operator as opp) on (opp.operator_id = c.operator_id), + contact_phone, sample_import, sample + WHERE c.contact_phone_id = contact_phone.contact_phone_id AND sample.import_id = $samimpid + AND sample.sample_id = ca.sample_id + ORDER BY c.start DESC"; + + if (!isset($_GET['csv'])) + $sql .= " LIMIT 500"; + else $sql .= " LIMIT 5000"; + + $rs = $db->Execute($sql); + if (empty($rs)) + { + print "

" . T_("No calls ever made") . "

"; + } + else + { + if (isset($_GET['csv'])) + { + $qds = str_replace(' ','_',$_GET['dq']); $smpds = str_replace(' ','_',$_GET['ds']); + $fn = "callhistory-" . $qds . $smpds . date("_d-M-Y_H-i") . ".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 + + echo(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") . "\n"); + + while ($r = $rs->FetchRow()) + { + translate_array($r,array("des")); + 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"; + } + + exit; + } + else + { + xhtml_head(T_("Call History List"),true,$css,$js_head); + echo ""; + + $rs = $rs->GetArray(); + if (count($rs) ==0) + { + print "

" . T_("NO Call history records for Your query") . "

"; + } + else + { + translate_array($rs,array("des")); + + $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")); + + if (isset($_GET['questionnaire_id'])){ + $sql = "SELECT description FROM `questionnaire` WHERE `questionnaire_id` = $qid "; + $dq = $db->GetOne($sql); + print "

" . T_("Questionnaire") . " ID: $qid " . $dq . "

"; + unset($datacol[4]); unset($headers[4]); } + + if (isset($_GET['sample_import_id'])){ + $sql = "SELECT description FROM `sample_import` WHERE `sample_import_id` = $sid "; + $ds = $db->GetOne($sql); + print "

" . T_("Sample") . " ID: $sid " . $ds . "

"; + unset($datacol[5]); unset($headers[5]); } + + print "  " . T_("Download Call History List") . " + "; // " . T_("Go to Call History Report") . "  + + xhtml_table($rs,$datacol,$headers,"tclass",false,false,"bs-table"); + + } + } + } +} +else +{ + print "
" . T_("No operator") . "
"; +} + +xhtml_foot($js_foot); +?> + diff --git a/admin/callrestrict.php b/admin/callrestrict.php index 21996bfd..6d3d3b4a 100644 --- a/admin/callrestrict.php +++ b/admin/callrestrict.php @@ -1,163 +1,163 @@ - - * @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"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -//"../include/font-awesome-4.3.0/css/font-awesome.css", -"../include/clockpicker/dist/bootstrap-clockpicker.min.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -"../js/addrow-v2.js", - ); -$js_foot = array( -"../include/clockpicker/dist/bootstrap-clockpicker.js", -"../js/custom.js" - ); - -global $db; - -$year="2008"; -$woy="1"; - - -if (isset($_POST['day'])) -{ - $db->StartTrans(); - - $sql = "DELETE FROM call_restrict - WHERE 1"; - - $db->Execute($sql); - - foreach($_POST['day'] as $key => $val) - { - if (!empty($val)) - { - $val = intval($val); - $key = intval($key); - - $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); - $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); - - $sql = "INSERT INTO call_restrict (day_of_week,start,end) - VALUES ('$val',$start,$end)"; - - $db->Execute($sql); - } - } - - $db->CompleteTrans(); -} - -xhtml_head(T_("Set call restriction times"),true,$css,$js_head);//,array("../css/shifts.css"),array("../js/addrow-v2.js") - -/** - * Display warning if timezone data not installed - * - */ - -$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria' -$rs = $db->GetRow($sql); - -if (empty($rs) || !$rs || empty($rs['t'])) - print ""; - - -print "
" . T_("Enter the start and end times for each day of the week to restrict calls within") . "
"; - -/** - * Begin displaying currently loaded restriction times - */ - -$sql = "SELECT DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W' ) AS dt,day_of_week,start,end - FROM call_restrict"; - -$shifts = $db->GetAll($sql); -translate_array($shifts,array("dt")); - -$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected - FROM day_of_week"; - -$daysofweek = $db->GetAll($sql); -translate_array($daysofweek,array("description")); - -?> -
- -"; - $count = 0; - foreach($shifts as $shift) - { - print " - "; - $count++; - } - print " - "; - - -?> -
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
";//class='row_to_clone' /* these are not the rows to clone...*/ - display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$shift['dt'])); - print "
"; - display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); - print "
-

- "/> -
- - \ No newline at end of file + + * @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"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", +//"../include/font-awesome/css/font-awesome.css", +"../include/clockpicker/dist/bootstrap-clockpicker.min.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js", +"../js/addrow-v2.js", + ); +$js_foot = array( +"../include/clockpicker/dist/bootstrap-clockpicker.js", +"../js/custom.js" + ); + +global $db; + +$year="2008"; +$woy="1"; + + +if (isset($_POST['day'])) +{ + $db->StartTrans(); + + $sql = "DELETE FROM call_restrict + WHERE 1"; + + $db->Execute($sql); + + foreach($_POST['day'] as $key => $val) + { + if (!empty($val)) + { + $val = intval($val); + $key = intval($key); + + $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); + $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); + + $sql = "INSERT INTO call_restrict (day_of_week,start,end) + VALUES ('$val',$start,$end)"; + + $db->Execute($sql); + } + } + + $db->CompleteTrans(); +} + +xhtml_head(T_("Set call restriction times"),true,$css,$js_head);//,array("../css/shifts.css"),array("../js/addrow-v2.js") + +/** + * Display warning if timezone data not installed + * + */ + +$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria' +$rs = $db->GetRow($sql); + +if (empty($rs) || !$rs || empty($rs['t'])) + print ""; + + +print "
" . T_("Enter the start and end times for each day of the week to restrict calls within") . "
"; + +/** + * Begin displaying currently loaded restriction times + */ + +$sql = "SELECT DATE_FORMAT( STR_TO_DATE( CONCAT( '$year', ' ', '$woy', ' ', day_of_week -1 ) , '%x %v %w' ) , '%W' ) AS dt,day_of_week,start,end + FROM call_restrict"; + +$shifts = $db->GetAll($sql); +translate_array($shifts,array("dt")); + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year, ' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected + FROM day_of_week"; + +$daysofweek = $db->GetAll($sql); +translate_array($daysofweek,array("description")); + +?> +
+ +"; + $count = 0; + foreach($shifts as $shift) + { + print " + "; + $count++; + } + print " + "; + + +?> +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
";//class='row_to_clone' /* these are not the rows to clone...*/ + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$shift['dt'])); + print "
"; + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); + print "
+

+ "/> +
+ + diff --git a/admin/casesbyoutcome.php b/admin/casesbyoutcome.php index 2bf0d14f..61704e6d 100644 --- a/admin/casesbyoutcome.php +++ b/admin/casesbyoutcome.php @@ -1,121 +1,121 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2012 - * @package queXS - * @subpackage user - * @link http://www.acspri.org.au/software queXS was writen for ACSPRI - * @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"); - -/** - * Operator functions - */ -include("../functions/functions.operator.php"); - -xhtml_head(T_("Cases by outcome"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css")); - -print ""; - -//List the cases by outcome -$operator_id = get_operator_id(); - -if ($operator_id) -{ - //get the outcome and the questionnaire - $outcome_id = intval($_GET['outcome_id']); - $questionnaire_id = intval($_GET['questionnaire_id']); - $sql = "SELECT o.description, q.description as qd - FROM `outcome` as o, questionnaire as q - WHERE o.outcome_id = '$outcome_id' - AND q.questionnaire_id = '$questionnaire_id'"; - - $rs = $db->GetRow($sql); - - if (!empty($rs)){ - print "

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

"; - if($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' ;"; - $sd = $db->GetRow($sql); - print "

". T_("Sample:") ." " . T_($sd['sd']) . "

"; - $sid = "AND s.import_id= '$sample_import_id'"; - } - else{$sid = " ";}; - - if($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' ;"; - $on = $db->GetRow($sql); - print "

". T_("Operator") ." : " . T_($on['opname']) . "

oper_id = $oper_id "; - $opn = "AND c.current_operator_id= '$oper_id'"; - } - else{$opn = " ";}; - - print "

". T_("Current outcome:") ." " . T_($rs['description']) . "

"; - - $sql = "SELECT CONCAT('', c.case_id, '') as case_id - FROM `case` as c - LEFT JOIN `sample` as s ON ( s.sample_id = c.sample_id ) - WHERE c.questionnaire_id = '$questionnaire_id' - AND c.current_outcome_id = '$outcome_id' - $sid - $opn - LIMIT 500"; - - $rs = $db->GetAll($sql); - print "
"; - if (empty($rs)) - print "

" . T_("No cases with this outcome") . "

"; - else - { - xhtml_table($rs,array("case_id"),array(T_("Case ID"))); - } - } - else - print "

" . T_("Error with input") . "

"; -} -else - print "

" . T_("No operator") . "

"; -print "
"; - -xhtml_foot(); -?> \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2012 + * @package queXS + * @subpackage user + * @link http://www.acspri.org.au/software queXS was writen for ACSPRI + * @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"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +xhtml_head(T_("Cases by outcome"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css")); + +print ""; + +//List the cases by outcome +$operator_id = get_operator_id(); + +if ($operator_id) +{ + //get the outcome and the questionnaire + $outcome_id = intval($_GET['outcome_id']); + $questionnaire_id = intval($_GET['questionnaire_id']); + $sql = "SELECT o.description, q.description as qd + FROM `outcome` as o, questionnaire as q + WHERE o.outcome_id = '$outcome_id' + AND q.questionnaire_id = '$questionnaire_id'"; + + $rs = $db->GetRow($sql); + + if (!empty($rs)){ + print "

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

"; + if($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' ;"; + $sd = $db->GetRow($sql); + print "

". T_("Sample:") ." " . T_($sd['sd']) . "

"; + $sid = "AND s.import_id= '$sample_import_id'"; + } + else{$sid = " ";}; + + if($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' ;"; + $on = $db->GetRow($sql); + print "

". T_("Operator") ." : " . T_($on['opname']) . "

oper_id = $oper_id "; + $opn = "AND c.current_operator_id= '$oper_id'"; + } + else{$opn = " ";}; + + print "

". T_("Current outcome:") ." " . T_($rs['description']) . "

"; + + $sql = "SELECT CONCAT('', c.case_id, '') as case_id + FROM `case` as c + LEFT JOIN `sample` as s ON ( s.sample_id = c.sample_id ) + WHERE c.questionnaire_id = '$questionnaire_id' + AND c.current_outcome_id = '$outcome_id' + $sid + $opn + LIMIT 500"; + + $rs = $db->GetAll($sql); + print "
"; + if (empty($rs)) + print "

" . T_("No cases with this outcome") . "

"; + else + { + xhtml_table($rs,array("case_id"),array(T_("Case ID"))); + } + } + else + print "

" . T_("Error with input") . "

"; +} +else + print "

" . T_("No operator") . "

"; +print "
"; + +xhtml_foot(); +?> diff --git a/admin/casestatus.php b/admin/casestatus.php index 33c31bb7..25fbfb70 100644 --- a/admin/casestatus.php +++ b/admin/casestatus.php @@ -1,254 +1,252 @@ - - * @since 2012-10-02 - */ - - -function case_status_report($questionnaire_id = false, $sample_id = false, $outcome_id = false) -{ - global $db; - - $q = ""; - if ($questionnaire_id !== false) - $q = "AND c.questionnaire_id = $questionnaire_id"; - - $s = ""; - if ($sample_id !== false) - $s = "AND s.import_id = '$sample_id'"; - - $o = ""; - if ($outcome_id !== false) - $o = "AND c.current_outcome_id = $outcome_id"; - - $sql = "SELECT CONCAT('', c.case_id, '') as case_id, - o.description as outcomes, - si.description as samples, s.Time_zone_name as timezone, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time, (SELECT COUNT(*) FROM `call` WHERE `call`.case_id = c.case_id) as nrcalls, (SELECT COUNT(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) as nrattempts, - CASE WHEN ca.end IS NULL THEN '" . TQ_("Available") . "' - WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Available") . "' - ELSE CONCAT(ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60),' " . TQ_("minutes") . "') - END AS availableinmin, - CASE WHEN oq.operator_id IS NULL THEN - CONCAT('') - ELSE CONCAT('', oq.firstName,' ',oq.lastName,'') - END AS assignedoperator, - CASE WHEN oq.operator_id IS NULL THEN - CONCAT('') - ELSE CONCAT('   ', cq.sortorder ,' ') - END AS ordr, - CASE WHEN oq.operator_id IS NULL THEN - CONCAT('') - ELSE CONCAT('') - END AS flag - FROM `case` as c - JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1) - JOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1) - JOIN sample as s ON (s.sample_id = c.sample_id $s) - JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1) - JOIN questionnaire_sample as qs ON (qs.questionnaire_id = $questionnaire_id AND qs.sample_import_id = s.import_id) - LEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id) - 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) - WHERE c.current_operator_id IS NULL $q $o - ORDER BY c.case_id ASC"; - -// print $sql; - - print ("
"); - - $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"); - - $sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected - FROM operator - WHERE enabled = 1"; - - $rs3 = $db->GetAll($sql); - - print "

" . T_("Assign selected cases to") . " " . T_("operator") . " : 

"; - display_chooser($rs3, "operator_id", "operator_id",true,false,false,true,false,true,"pull-left"); - - print " "; - print "

"; - - return true; -} - -if (isset($_POST['operator_id']) && !empty($_POST['operator_id'])) -{ - $operator_id = intval($_POST['operator_id']); - - $db->StartTrans(); - - $sql = "SELECT MAX(sortorder) - FROM case_queue - WHERE operator_id = '$operator_id'"; - - $sortorder = $db->GetOne($sql); - - foreach($_POST as $key => $val) - { - $sortorder++; - - if (substr($key,0,1) == "c") - { - $sql = "INSERT INTO case_queue (case_id,operator_id,sortorder) - VALUES ('" . bigintval($val) . "', '$operator_id', '$sortorder')"; - - $db->Execute($sql); - } - } - - $db->CompleteTrans(); -} - -if (isset($_GET['unassign'])) -{ - $case_queue_id = bigintval($_GET['unassign']); - - $db->StartTrans(); - - $sql = "SELECT operator_id - FROM case_queue - WHERE case_queue_id = '$case_queue_id'"; - - $operator_id = $db->GetOne($sql); - - $sql = "DELETE FROM case_queue - WHERE case_queue_id = '$case_queue_id'"; - - $db->Execute($sql); - - $sql = "SELECT case_queue_id - FROM case_queue - WHERE operator_id = '$operator_id' - ORDER BY sortorder ASC"; - - $rs = $db->GetAll($sql); - - $sortorder = 1; - foreach($rs as $r) - { - $sql = "UPDATE case_queue - SET sortorder = '$sortorder' - WHERE case_queue_id = '{$r['case_queue_id']}'"; - - $db->Execute($sql); - - $sortorder++; - } - - $db->CompleteTrans(); -} - -xhtml_head(T_("Case status and assignment"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") -echo " " . T_("Go back") . " - "; - ?> - -

" . T_("Questionnaire") . ":

"; -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"); - print "
-
"; - - case_status_report($questionnaire_id,$sample_import_id,$outcome_id); -} -xhtml_foot($js_foot); -?> - \ No newline at end of file + + * @since 2012-10-02 + */ + + +function case_status_report($questionnaire_id = false, $sample_id = false, $outcome_id = false) +{ + global $db; + + $q = ""; + if ($questionnaire_id !== false) + $q = "AND c.questionnaire_id = $questionnaire_id"; + + $s = ""; + if ($sample_id !== false) + $s = "AND s.import_id = '$sample_id'"; + + $o = ""; + if ($outcome_id !== false) + $o = "AND c.current_outcome_id = $outcome_id"; + + $sql = "SELECT CONCAT('', c.case_id, '') as case_id, + o.description as outcomes, + si.description as samples, s.Time_zone_name as timezone, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time, (SELECT COUNT(*) FROM `call` WHERE `call`.case_id = c.case_id) as nrcalls, (SELECT COUNT(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) as nrattempts, + CASE WHEN ca.end IS NULL THEN '" . TQ_("Available") . "' + WHEN TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) < 0 THEN '" . TQ_("Available") . "' + ELSE CONCAT(ROUND(TIME_TO_SEC(TIMEDIFF(ca.end,CONVERT_TZ(DATE_SUB(NOW(), INTERVAL co.default_delay_minutes MINUTE),'System','UTC'))) / 60),' " . TQ_("minutes") . "') + END AS availableinmin, + CASE WHEN oq.operator_id IS NULL THEN + CONCAT('') + ELSE CONCAT('', oq.firstName,' ',oq.lastName,'') + END AS assignedoperator, + CASE WHEN oq.operator_id IS NULL THEN + CONCAT('') + ELSE CONCAT('   ', cq.sortorder ,' ') + END AS ordr, + CASE WHEN oq.operator_id IS NULL THEN + CONCAT('') + ELSE CONCAT('') + END AS flag + FROM `case` as c + JOIN questionnaire as q ON (q.questionnaire_id = c.questionnaire_id and q.enabled = 1) + JOIN outcome as o ON (o.outcome_id = c.current_outcome_id AND o.outcome_type_id = 1) + JOIN sample as s ON (s.sample_id = c.sample_id $s) + JOIN sample_import as si ON (s.import_id = si.sample_import_id AND si.enabled = 1) + JOIN questionnaire_sample as qs ON (qs.questionnaire_id = $questionnaire_id AND qs.sample_import_id = s.import_id) + LEFT JOIN `call` as ca ON (ca.call_id = c.last_call_id) + 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) + WHERE c.current_operator_id IS NULL $q $o + ORDER BY c.case_id ASC"; + +// print $sql; + + print ("
"); + + $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"); + + $sql = "SELECT operator_id as value,CONCAT(firstName,' ', lastName) as description, '' selected + FROM operator + WHERE enabled = 1"; + + $rs3 = $db->GetAll($sql); + + print "

" . T_("Assign selected cases to") . " " . T_("operator") . " : 

"; + display_chooser($rs3, "operator_id", "operator_id",true,false,false,true,false,true,"pull-left"); + + print " "; + print "

"; + + return true; +} + +if (isset($_POST['operator_id']) && !empty($_POST['operator_id'])) +{ + $operator_id = intval($_POST['operator_id']); + + $db->StartTrans(); + + $sql = "SELECT MAX(sortorder) + FROM case_queue + WHERE operator_id = '$operator_id'"; + + $sortorder = $db->GetOne($sql); + + foreach($_POST as $key => $val) + { + $sortorder++; + + if (substr($key,0,1) == "c") + { + $sql = "INSERT INTO case_queue (case_id,operator_id,sortorder) + VALUES ('" . bigintval($val) . "', '$operator_id', '$sortorder')"; + + $db->Execute($sql); + } + } + + $db->CompleteTrans(); +} + +if (isset($_GET['unassign'])) +{ + $case_queue_id = bigintval($_GET['unassign']); + + $db->StartTrans(); + + $sql = "SELECT operator_id + FROM case_queue + WHERE case_queue_id = '$case_queue_id'"; + + $operator_id = $db->GetOne($sql); + + $sql = "DELETE FROM case_queue + WHERE case_queue_id = '$case_queue_id'"; + + $db->Execute($sql); + + $sql = "SELECT case_queue_id + FROM case_queue + WHERE operator_id = '$operator_id' + ORDER BY sortorder ASC"; + + $rs = $db->GetAll($sql); + + $sortorder = 1; + foreach($rs as $r) + { + $sql = "UPDATE case_queue + SET sortorder = '$sortorder' + WHERE case_queue_id = '{$r['case_queue_id']}'"; + + $db->Execute($sql); + + $sortorder++; + } + + $db->CompleteTrans(); +} + +xhtml_head(T_("Case status and assignment"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") +echo " " . T_("Go back") . " + "; + ?> + +

" . T_("Questionnaire") . ":

"; +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"); + print "
+
"; + + case_status_report($questionnaire_id,$sample_import_id,$outcome_id); +} +xhtml_foot($js_foot); +?> + diff --git a/admin/centreinfo.php b/admin/centreinfo.php index c9ebfa0b..cd14a844 100644 --- a/admin/centreinfo.php +++ b/admin/centreinfo.php @@ -1,72 +1,72 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/ queXS was writen for ACSPRI - * @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"); - -/** - * CKEditor - */ -include("../include/ckeditor/ckeditor.php"); - -global $db; - -$CKEditor = new CKEditor(); -$CKEditor->basePath = "../include/ckeditor/"; - -if (isset($_POST['information'])) -{ - set_setting("information",$_POST['information']); -} - -xhtml_head(T_("Set centre information"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); -?> -
- - editor("information",get_setting("information")); ?> -
"/> -
- + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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"); + +/** + * CKEditor + */ +include("../include/ckeditor/ckeditor.php"); + +global $db; + +$CKEditor = new CKEditor(); +$CKEditor->basePath = "../include/ckeditor/"; + +if (isset($_POST['information'])) +{ + set_setting("information",$_POST['information']); +} + +xhtml_head(T_("Set centre information"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); +?> +
+ + editor("information",get_setting("information")); ?> +
"/> +
+ diff --git a/admin/clientquestionnaire.php b/admin/clientquestionnaire.php index 5d03321c..ba20596f 100644 --- a/admin/clientquestionnaire.php +++ b/admin/clientquestionnaire.php @@ -1,274 +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, 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 + + * @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/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 ""; +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(); + +?> + + diff --git a/admin/clients.php b/admin/clients.php index 40f60b98..c59cb1ef 100644 --- a/admin/clients.php +++ b/admin/clients.php @@ -1,179 +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"),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 + + * @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/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"/> + + + diff --git a/admin/dataoutput.php b/admin/dataoutput.php index 60e05618..5874df97 100644 --- a/admin/dataoutput.php +++ b/admin/dataoutput.php @@ -1,242 +1,242 @@ - - * @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 - * - */ - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -/** - * Configuration file - */ -include_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -if (isset($_GET['key']) || isset($_GET['sample'])) -{ - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sample_import_id = bigintval($_GET['sample_import_id']); - - $sql = "SELECT sivr.var as value, sivr.var_id as var_id - FROM `sample_import_var_restrict` as sivr - WHERE sivr.sample_import_id = $sample_import_id"; - - $svars = $db->GetAll($sql); - - $fn = "key_"; - if (isset($_GET['sample'])) $fn = "sample_"; - - $fn .= T_("ALL") . "_Qid=" . $questionnaire_id . "_Sid=" . $sample_import_id .".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 - - echo("token,".T_("Case ID").""); - foreach($svars as $s) - { - echo("," . $s['value']); - } - - if (isset($_GET['sample'])) - { - echo(",".T_("Current Outcome").",".T_("Number of call attempts").",".T_("Number of calls").",".T_("Case notes").",".T_("Total interview time over all calls (mins)").",".T_("Interview time for last call (mins)").",".T_("Last number dialled").",".T_("DATE/TIME Last number dialled").",".T_("Operator username for last call").",".T_("Shift report").", AAPOR"); - } - - echo("\n"); - - $sql = "SELECT c.token,c.case_id "; - - if (isset($_GET['sample'])) $sql .= ", o.description, - (SELECT COUNT(ca.call_attempt_id) FROM `call_attempt` as ca WHERE ca.case_id = c.case_id ) as callattempts, - (SELECT COUNT(cl.call_id) FROM `call` as cl WHERE cl.case_id = c.case_id ) as calls, - (SELECT GROUP_CONCAT(cn1.note SEPARATOR '|') FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes, - (SELECT ROUND(SUM( TIMESTAMPDIFF(SECOND , cl2.start,IFNULL(cl2.end,CONVERT_TZ(NOW(),'System','UTC'))))/60,2) FROM `call_attempt` as cl2 WHERE cl2.case_id = c.case_id) as interviewtimec, - (SELECT ROUND(TIMESTAMPDIFF(SECOND , cl3.start,IFNULL(cl3.end,CONVERT_TZ(NOW(),'System','UTC')))/60,2) FROM `call_attempt` as cl3 WHERE cl3.case_id = c.case_id ORDER BY cl3.call_attempt_id DESC LIMIT 1) as interviewtimel, - (SELECT cp1.phone FROM `call` as cl4, `contact_phone` as cp1 WHERE cl4.call_id = c.last_call_id AND cp1.contact_phone_id = cl4.contact_phone_id ) as lastnumber, - (SELECT cl55.start FROM `call` as cl55 WHERE cl55.call_id = c.last_call_id ) as lastcallstart, - (SELECT op1.username FROM `call` as cl5, `operator` as op1 WHERE cl5.call_id = c.last_call_id AND op1.operator_id = cl5.operator_id) as operatoru, - (SELECT GROUP_CONCAT(DISTINCT sr1.report SEPARATOR '|') FROM `call` as cl6, `shift` as sh1, `shift_report` as sr1 WHERE cl6.case_id = c.case_id AND sr1.shift_id = sh1.shift_id AND sh1.questionnaire_id = c.questionnaire_id AND cl6.start >= sh1.start AND cl6.end < sh1.end GROUP BY sr1.shift_id) as shiftr, - o.aapor_id "; - - $i = 0; - foreach ($svars as $s) - { - $sql .= ", sv$i.val as v$i"; - $i++; - } - - $sql .= " FROM sample "; - - //left join if getting whole sample file - if (isset($_GET['sample'])) $sql .= "LEFT "; - - $sql .= "JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id' AND c.sample_id = `sample`.sample_id) "; - - if (isset($_GET['sample'])) $sql .= " LEFT JOIN `outcome` as o ON (o.outcome_id = c.current_outcome_id)"; - - $i = 0; - foreach ($svars as $s) - { - $sql .= " LEFT JOIN sample_var AS sv$i ON (sv$i.sample_id = `sample`.sample_id AND sv$i.var_id = '{$s['var_id']}') "; - $i++; - } - - $sql .= " WHERE `sample`.import_id = '$sample_import_id'"; - - $list = $db->GetAll($sql); - - if (!empty($list)) - { - foreach($list as $l) - { - echo $l['token'] . "," . $l['case_id']; - $i = 0; - foreach ($svars as $s) - { - echo "," . str_replace(","," ",$l["v$i"]); - $i++; - } - if (isset($_GET['sample'])) - { - echo "," . str_replace(","," ",$l['description']) . "," .$l['callattempts']."," .$l['calls']."," .$l['casenotes'].",".$l['interviewtimec'].",".$l['interviewtimel'].",".$l['lastnumber'].",".$l['lastcallstart'].",".$l['operatoru'].",".$l['shiftr'].",". $l['aapor_id']; - } - echo "\n"; - } - } - exit; -} - -if (isset($_GET['sample_var'])){ - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sample_import_id = bigintval($_GET['sample_import_id']); - $varid = intval($_GET['sample_var']); - - $sql = "SELECT c.token, c.case_id, sv.val, sivr.var - FROM `case` as c, `sample_import_var_restrict` as sivr, `sample_var` as sv - WHERE c.questionnaire_id = $questionnaire_id - AND sivr.sample_import_id = $sample_import_id - AND c.sample_id = sv.sample_id - AND sivr.var_id = sv.var_id - AND sivr.var_id = $varid"; - - $list = $db->GetAll($sql); - $sample_var = $list[0]['var']; - - $fn = "key-" . $sample_var . "_Qid=$questionnaire_id" . "_Sid=" . $sample_import_id .".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 - - echo("token,caseid,$sample_var\n"); - - if (!empty($list)) - { - foreach($list as $l) - { - echo $l['token'] . "," . $l['case_id'] . "," . $l['val'] . "\n"; - } - } - - exit; -} - - -xhtml_head(T_("Data output"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); - -print "

" . T_("Please select a questionnaire") . ": 

"; -$questionnaire_id = false; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); -display_questionnaire_chooser($questionnaire_id,false,"form-inline col-sm-3 pull-left", "form-control"); - -if ($questionnaire_id) -{ - $sql = "SELECT lime_sid - FROM questionnaire - WHERE questionnaire_id = $questionnaire_id"; - - $ls = $db->GetRow($sql); - $lsid = $ls['lime_sid']; - - print " 
". T_("Download data for this questionnaire via Limesurvey") . "
"; - - print "

" . T_("Please select a sample") . ": 

"; - $sample_import_id = false; - if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); - display_sample_chooser($questionnaire_id,$sample_import_id,false,"form-inline col-sm-3 pull-left", "form-control"); - - if ($sample_import_id) - { - print " " . T_("Download data for this sample via Limesurvey") . "
"; - //get sample vars - $sql = "SELECT sivr.var_id as value, sivr.var as description - FROM `sample_import_var_restrict` as sivr - WHERE sivr.sample_import_id = $sample_import_id"; - $rs = $db->GetAll($sql); - - //download a key file linking the caseid to the sample - print "

" . T_("Download key file: select sample var") . ": 

"; - - display_chooser($rs,"sample_var","sample_var",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id",true,true,false,true,"form-inline col-sm-3 pull-left"); - - print "
"; - - //download complete key file - print "" . T_("Download complete key file") . "

"; - - //download complete sample file with outcomes - print "" . T_("Download complete sample file with current outcomes") . "
"; - } -} - -xhtml_foot(); - -?> \ No newline at end of file + + * @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 + * + */ + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +/** + * Configuration file + */ +include_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +if (isset($_GET['key']) || isset($_GET['sample'])) +{ + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sample_import_id = bigintval($_GET['sample_import_id']); + + $sql = "SELECT sivr.var as value, sivr.var_id as var_id + FROM `sample_import_var_restrict` as sivr + WHERE sivr.sample_import_id = $sample_import_id"; + + $svars = $db->GetAll($sql); + + $fn = "key_"; + if (isset($_GET['sample'])) $fn = "sample_"; + + $fn .= T_("ALL") . "_Qid=" . $questionnaire_id . "_Sid=" . $sample_import_id .".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 + + echo("token,".T_("Case ID").""); + foreach($svars as $s) + { + echo("," . $s['value']); + } + + if (isset($_GET['sample'])) + { + echo(",".T_("Current Outcome").",".T_("Number of call attempts").",".T_("Number of calls").",".T_("Case notes").",".T_("Total interview time over all calls (mins)").",".T_("Interview time for last call (mins)").",".T_("Last number dialled").",".T_("DATE/TIME Last number dialled").",".T_("Operator username for last call").",".T_("Shift report").", AAPOR"); + } + + echo("\n"); + + $sql = "SELECT c.token,c.case_id "; + + if (isset($_GET['sample'])) $sql .= ", o.description, + (SELECT COUNT(ca.call_attempt_id) FROM `call_attempt` as ca WHERE ca.case_id = c.case_id ) as callattempts, + (SELECT COUNT(cl.call_id) FROM `call` as cl WHERE cl.case_id = c.case_id ) as calls, + (SELECT GROUP_CONCAT(cn1.note SEPARATOR '|') FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes, + (SELECT ROUND(SUM( TIMESTAMPDIFF(SECOND , cl2.start,IFNULL(cl2.end,CONVERT_TZ(NOW(),'System','UTC'))))/60,2) FROM `call_attempt` as cl2 WHERE cl2.case_id = c.case_id) as interviewtimec, + (SELECT ROUND(TIMESTAMPDIFF(SECOND , cl3.start,IFNULL(cl3.end,CONVERT_TZ(NOW(),'System','UTC')))/60,2) FROM `call_attempt` as cl3 WHERE cl3.case_id = c.case_id ORDER BY cl3.call_attempt_id DESC LIMIT 1) as interviewtimel, + (SELECT cp1.phone FROM `call` as cl4, `contact_phone` as cp1 WHERE cl4.call_id = c.last_call_id AND cp1.contact_phone_id = cl4.contact_phone_id ) as lastnumber, + (SELECT cl55.start FROM `call` as cl55 WHERE cl55.call_id = c.last_call_id ) as lastcallstart, + (SELECT op1.username FROM `call` as cl5, `operator` as op1 WHERE cl5.call_id = c.last_call_id AND op1.operator_id = cl5.operator_id) as operatoru, + (SELECT GROUP_CONCAT(DISTINCT sr1.report SEPARATOR '|') FROM `call` as cl6, `shift` as sh1, `shift_report` as sr1 WHERE cl6.case_id = c.case_id AND sr1.shift_id = sh1.shift_id AND sh1.questionnaire_id = c.questionnaire_id AND cl6.start >= sh1.start AND cl6.end < sh1.end GROUP BY sr1.shift_id) as shiftr, + o.aapor_id "; + + $i = 0; + foreach ($svars as $s) + { + $sql .= ", sv$i.val as v$i"; + $i++; + } + + $sql .= " FROM sample "; + + //left join if getting whole sample file + if (isset($_GET['sample'])) $sql .= "LEFT "; + + $sql .= "JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id' AND c.sample_id = `sample`.sample_id) "; + + if (isset($_GET['sample'])) $sql .= " LEFT JOIN `outcome` as o ON (o.outcome_id = c.current_outcome_id)"; + + $i = 0; + foreach ($svars as $s) + { + $sql .= " LEFT JOIN sample_var AS sv$i ON (sv$i.sample_id = `sample`.sample_id AND sv$i.var_id = '{$s['var_id']}') "; + $i++; + } + + $sql .= " WHERE `sample`.import_id = '$sample_import_id'"; + + $list = $db->GetAll($sql); + + if (!empty($list)) + { + foreach($list as $l) + { + echo $l['token'] . "," . $l['case_id']; + $i = 0; + foreach ($svars as $s) + { + echo "," . str_replace(","," ",$l["v$i"]); + $i++; + } + if (isset($_GET['sample'])) + { + echo "," . str_replace(","," ",$l['description']) . "," .$l['callattempts']."," .$l['calls']."," .$l['casenotes'].",".$l['interviewtimec'].",".$l['interviewtimel'].",".$l['lastnumber'].",".$l['lastcallstart'].",".$l['operatoru'].",".$l['shiftr'].",". $l['aapor_id']; + } + echo "\n"; + } + } + exit; +} + +if (isset($_GET['sample_var'])){ + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sample_import_id = bigintval($_GET['sample_import_id']); + $varid = intval($_GET['sample_var']); + + $sql = "SELECT c.token, c.case_id, sv.val, sivr.var + FROM `case` as c, `sample_import_var_restrict` as sivr, `sample_var` as sv + WHERE c.questionnaire_id = $questionnaire_id + AND sivr.sample_import_id = $sample_import_id + AND c.sample_id = sv.sample_id + AND sivr.var_id = sv.var_id + AND sivr.var_id = $varid"; + + $list = $db->GetAll($sql); + $sample_var = $list[0]['var']; + + $fn = "key-" . $sample_var . "_Qid=$questionnaire_id" . "_Sid=" . $sample_import_id .".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 + + echo("token,caseid,$sample_var\n"); + + if (!empty($list)) + { + foreach($list as $l) + { + echo $l['token'] . "," . $l['case_id'] . "," . $l['val'] . "\n"; + } + } + + exit; +} + + +xhtml_head(T_("Data output"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); + +print "

" . T_("Please select a questionnaire") . ": 

"; +$questionnaire_id = false; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); +display_questionnaire_chooser($questionnaire_id,false,"form-inline col-sm-3 pull-left", "form-control"); + +if ($questionnaire_id) +{ + $sql = "SELECT lime_sid + FROM questionnaire + WHERE questionnaire_id = $questionnaire_id"; + + $ls = $db->GetRow($sql); + $lsid = $ls['lime_sid']; + + print " ". T_("Download data for this questionnaire via Limesurvey") . "
"; + + print "

" . T_("Please select a sample") . ": 

"; + $sample_import_id = false; + if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); + display_sample_chooser($questionnaire_id,$sample_import_id,false,"form-inline col-sm-3 pull-left", "form-control"); + + if ($sample_import_id) + { + print " " . T_("Download data for this sample via Limesurvey") . "
"; + //get sample vars + $sql = "SELECT sivr.var_id as value, sivr.var as description + FROM `sample_import_var_restrict` as sivr + WHERE sivr.sample_import_id = $sample_import_id"; + $rs = $db->GetAll($sql); + + //download a key file linking the caseid to the sample + print "

" . T_("Download key file: select sample var") . ": 

"; + + display_chooser($rs,"sample_var","sample_var",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id",true,true,false,true,"form-inline col-sm-3 pull-left"); + + print "
"; + + //download complete key file + print "" . T_("Download complete key file") . "

"; + + //download complete sample file with outcomes + print "" . T_("Download complete sample file with current outcomes") . "
"; + } +} + +xhtml_foot(); + +?> diff --git a/admin/displayappointments.php b/admin/displayappointments.php index ceb103bc..b9b5c95d 100644 --- a/admin/displayappointments.php +++ b/admin/displayappointments.php @@ -1,279 +1,279 @@ -qstr($_GET['start']); - $end = $db->qstr($_GET['end']); - $contact_phone_id = bigintval($_GET['contact_phone_id']); - $respondent_id = bigintval($_GET['respondent_id']); - $require_operator_id = "NULL"; - if ($_GET['require_operator_id'] > 1) $require_operator_id = bigintval($_GET['require_operator_id']); - - if ($_GET['new'] == 'create'){ - $case_id = bigintval($_GET['case_id']); - $operator_id = get_operator_id(); - if ($operator_id == false) die(); - $sql = "SELECT Time_zone_name FROM respondent WHERE respondent_id = '$respondent_id'"; - $respondent_tz = $db->GetOne($sql); - - // create a call attempt - $sql = "INSERT INTO call_attempt (call_attempt_id,case_id,operator_id,respondent_id,start,end) - VALUES (NULL,$case_id,$operator_id,$respondent_id,CONVERT_TZ(NOW(),@@session.time_zone,'UTC'),CONVERT_TZ(NOW(),@@session.time_zone,'UTC'))"; - $db->Execute($sql); - - $call_attempt_id = $db->Insert_ID(); - - $sql = "INSERT INTO `appointment` (appointment_id,case_id,contact_phone_id,call_attempt_id,start,end,require_operator_id,respondent_id,completed_call_id) - VALUES(NULL,$case_id,$contact_phone_id,$call_attempt_id,CONVERT_TZ($start,'$respondent_tz','UTC'),CONVERT_TZ($end,'$respondent_tz','UTC'),$require_operator_id,$respondent_id,NULL)"; - $db->Execute($sql); - - $appointment_id = $db->Insert_ID(); - - $_GET['appointment_id'] = $appointment_id; - $appointment_id = bigintval($_GET['appointment_id']); - - } else { - - $appointment_id = bigintval($_GET['appointment_id']); - - //Edit this appointment in the database - $sql = "UPDATE appointment as a, respondent as r - SET a.start = CONVERT_TZ($start,r.Time_zone_name,'UTC'), a.end = CONVERT_TZ($end,r.Time_zone_name,'UTC'), a.contact_phone_id = $contact_phone_id, a.respondent_id = $respondent_id, a.require_operator_id = $require_operator_id - WHERE a.appointment_id = $appointment_id - AND r.respondent_id = $respondent_id"; - - $db->Execute($sql); - } - unset ($_GET['start'],$_GET['end'],$_GET['appointment_id'],$_GET['case_id'],$_GET['new'],$_GET['update']); -} - - -if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(($_GET['new'] == 'new') && isset($_GET['case_id']))) -{ - $appointment_id = bigintval($_GET['appointment_id']); - $case_id = bigintval($_GET['case_id']); - - if (isset($_GET['delete'])) - { - $sql = "DELETE FROM appointment - WHERE appointment_id = '$appointment_id'"; - $db->Execute($sql); - - xhtml_head(T_("Now modify case outcome"),true,$css,$js_head); - - print "

" . T_("The appointment has been deleted. Now you must modify the case outcome") . "

- " . T_("Modify case outcome") . "
"; - } - else - { - //Display an edit form - - if ($_GET['new'] == 'new'){$title = T_("Create NEW appointment");} else{$title = T_("Edit appointment"); $subtitle = "ID " . $appointment_id;} - - xhtml_head($title,true,$css,$js_head,false,false,false,$subtitle); - $lang = DEFAULT_LOCALE; - $sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM',r.Time_zone_name) as startdate, CONVERT_TZ(s.end,'UTC',r.Time_zone_name) as enddate FROM `shift` as s, `case` as c, `respondent` as r WHERE s.questionnaire_id = c.questionnaire_id AND c.case_id = $case_id AND r.case_id = c.case_id ORDER BY s.end DESC LIMIT 1"; - $rs = $db->GetRow($sql); $startdate = $rs['startdate'];$enddate = $rs['enddate']; - - print ""; - - if ($_GET['new'] =='new'){ - $start = $startdate; - $end = $enddate; - $rtz = $_GET['rtz']; - } - if (isset($_GET['appointment_id'])) { - - $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 ""; - - 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"); - - 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 !!!") . "
"; - date_default_timezone_set($rtz); - print " -

" . $rtz . "

- "; - - 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 - FROM operator as o"); - $selected = "selected=\'selected\'"; - foreach($ops as $o) - { - if (!empty($o['selected'])) - { - $selected = ""; - break; - } - } - 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 "";} - - print "


-
 " . T_("Cancel edit") . "
"; - - print "
"; - - print "
 " . T_("Delete this appointment") . "
"; - - print "
"; - } -} -else { - $operator_id = get_operator_id(); - $subtitle = T_("Appointments"); - xhtml_head(T_("Display Appointments"),true,$css,$js_head,false,30); //array("../css/table.css") - 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, - 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) - 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 - 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"); - - } 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, - 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 - 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"); - - } else print "

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

"; - -} -xhtml_foot($js_foot); -?> - \ No newline at end of file +qstr($_GET['start']); + $end = $db->qstr($_GET['end']); + $contact_phone_id = bigintval($_GET['contact_phone_id']); + $respondent_id = bigintval($_GET['respondent_id']); + $require_operator_id = "NULL"; + if ($_GET['require_operator_id'] > 1) $require_operator_id = bigintval($_GET['require_operator_id']); + + if ($_GET['new'] == 'create'){ + $case_id = bigintval($_GET['case_id']); + $operator_id = get_operator_id(); + if ($operator_id == false) die(); + $sql = "SELECT Time_zone_name FROM respondent WHERE respondent_id = '$respondent_id'"; + $respondent_tz = $db->GetOne($sql); + + // create a call attempt + $sql = "INSERT INTO call_attempt (call_attempt_id,case_id,operator_id,respondent_id,start,end) + VALUES (NULL,$case_id,$operator_id,$respondent_id,CONVERT_TZ(NOW(),@@session.time_zone,'UTC'),CONVERT_TZ(NOW(),@@session.time_zone,'UTC'))"; + $db->Execute($sql); + + $call_attempt_id = $db->Insert_ID(); + + $sql = "INSERT INTO `appointment` (appointment_id,case_id,contact_phone_id,call_attempt_id,start,end,require_operator_id,respondent_id,completed_call_id) + VALUES(NULL,$case_id,$contact_phone_id,$call_attempt_id,CONVERT_TZ($start,'$respondent_tz','UTC'),CONVERT_TZ($end,'$respondent_tz','UTC'),$require_operator_id,$respondent_id,NULL)"; + $db->Execute($sql); + + $appointment_id = $db->Insert_ID(); + + $_GET['appointment_id'] = $appointment_id; + $appointment_id = bigintval($_GET['appointment_id']); + + } else { + + $appointment_id = bigintval($_GET['appointment_id']); + + //Edit this appointment in the database + $sql = "UPDATE appointment as a, respondent as r + SET a.start = CONVERT_TZ($start,r.Time_zone_name,'UTC'), a.end = CONVERT_TZ($end,r.Time_zone_name,'UTC'), a.contact_phone_id = $contact_phone_id, a.respondent_id = $respondent_id, a.require_operator_id = $require_operator_id + WHERE a.appointment_id = $appointment_id + AND r.respondent_id = $respondent_id"; + + $db->Execute($sql); + } + unset ($_GET['start'],$_GET['end'],$_GET['appointment_id'],$_GET['case_id'],$_GET['new'],$_GET['update']); +} + + +if ( (isset($_GET['appointment_id']) && isset($_GET['case_id'])) ||(($_GET['new'] == 'new') && isset($_GET['case_id']))) +{ + $appointment_id = bigintval($_GET['appointment_id']); + $case_id = bigintval($_GET['case_id']); + + if (isset($_GET['delete'])) + { + $sql = "DELETE FROM appointment + WHERE appointment_id = '$appointment_id'"; + $db->Execute($sql); + + xhtml_head(T_("Now modify case outcome"),true,$css,$js_head); + + print "

" . T_("The appointment has been deleted. Now you must modify the case outcome") . "

+ " . T_("Modify case outcome") . "
"; + } + else + { + //Display an edit form + + if ($_GET['new'] == 'new'){$title = T_("Create NEW appointment");} else{$title = T_("Edit appointment"); $subtitle = "ID " . $appointment_id;} + + xhtml_head($title,true,$css,$js_head,false,false,false,$subtitle); + $lang = DEFAULT_LOCALE; + $sql = "SELECT CONVERT_TZ(NOW(),'SYSTEM',r.Time_zone_name) as startdate, CONVERT_TZ(s.end,'UTC',r.Time_zone_name) as enddate FROM `shift` as s, `case` as c, `respondent` as r WHERE s.questionnaire_id = c.questionnaire_id AND c.case_id = $case_id AND r.case_id = c.case_id ORDER BY s.end DESC LIMIT 1"; + $rs = $db->GetRow($sql); $startdate = $rs['startdate'];$enddate = $rs['enddate']; + + print ""; + + if ($_GET['new'] =='new'){ + $start = $startdate; + $end = $enddate; + $rtz = $_GET['rtz']; + } + if (isset($_GET['appointment_id'])) { + + $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 ""; + + 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"); + + 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 !!!") . "
"; + date_default_timezone_set($rtz); + print " +

" . $rtz . "

+ "; + + 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 + FROM operator as o"); + $selected = "selected=\'selected\'"; + foreach($ops as $o) + { + if (!empty($o['selected'])) + { + $selected = ""; + break; + } + } + 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 "";} + + print "


+
 " . T_("Cancel edit") . "
"; + + print "
"; + + print "
 " . T_("Delete this appointment") . "
"; + + print "
"; + } +} +else { + $operator_id = get_operator_id(); + $subtitle = T_("Appointments"); + xhtml_head(T_("Display Appointments"),true,$css,$js_head,false,30); //array("../css/table.css") + 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, + 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) + 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 + 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"); + + } 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, + 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 + 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"); + + } else print "

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

"; + +} +xhtml_foot($js_foot); +?> + diff --git a/admin/extensionstatus.php b/admin/extensionstatus.php index be32f8f1..97a94a7d 100644 --- a/admin/extensionstatus.php +++ b/admin/extensionstatus.php @@ -1,269 +1,269 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2010 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/software/ queXS was writen for ACSPRI - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -$msg = ""; - -if (isset($_GET)) -{ - foreach($_GET as $key=>$val) - { - if (substr($key,0,12) == "operator_id_") - { - if (isset($_GET['extension_id'])) - { - $ex = intval($_GET['extension_id']); - $op = intval($val); - - $sql = "UPDATE `extension` - SET current_operator_id = $op - WHERE extension_id = $ex - AND current_operator_id IS NULL"; - - $db->Execute($sql); - } - } - } -} - -if (isset($_POST['extension'])) -{ - $extension = $db->qstr($_POST['extension']); - $password = $db->qstr($_POST['password']); - $extension_id = "NULL"; - - if (isset($_POST['extensionid'])) - $extension_id = intval($_POST['extensionid']); - - if (isset($_POST['delete'])) - { - $sql = "DELETE FROM `extension` - WHERE current_operator_id IS NULL - AND extension_id = $extension_id"; - - $rs = $db->Execute($sql); - - if (!$rs) - $msg = ("Failed to delete extension. There may be an operator currently assigned to it"); - } - else - { - if (!empty($_POST['extension'])) - { - $sql = "INSERT INTO `extension` (extension_id,extension,password) - VALUES ($extension_id,$extension,$password) - ON DUPLICATE KEY UPDATE extension=$extension,password=$password"; - - $rs = $db->Execute($sql); - - if (!$rs) - $msg = T_("Failed to add extension. There already may be an extension of this name"); - } - } -} - -if (isset($_GET['unassign'])) -{ - $e = intval($_GET['unassign']); - - $db->StartTrans(); - - $sql = "SELECT e.current_operator_id - FROM `extension` as e - LEFT JOIN `case` as c ON (c.current_operator_id = e.current_operator_id) - WHERE e.extension_id = $e - AND c.case_id IS NULL"; - - $cid = $db->GetOne($sql); - - if (!empty($cid)) - { - $sql = "UPDATE `extension` as e - SET current_operator_id = NULL - WHERE extension_id = $e - AND current_operator_id = $cid"; - - $db->Execute($sql); - } - - $db->CompleteTrans(); -} - -xhtml_head(T_("Extensions & status"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); -?> - - -GetRow($sql); - } - - print "" . T_("Go back") . ""; -?> -
-

-
-
- - " 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 "
"; -} -else -{ - $sql= "SELECT CONCAT('',o.firstName,' ', o.lastname,'') as firstName, - CONCAT('',e.extension,'') as extension, - IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list' - ,CONCAT('". TQ_("Unassign") ."')),'". TQ_("End case to change assignment")."') as assignment, - CASE e.status WHEN 0 THEN '" . TQ_("VoIP Offline") . "' ELSE '" . TQ_("VoIP Online") . "' END as status, - CASE ca.state WHEN 0 THEN '" . TQ_("Not called") . "' WHEN 1 THEN '" . TQ_("Requesting call") . "' WHEN 2 THEN '" . TQ_("Ringing") . "' WHEN 3 THEN '" . TQ_("Answered") . "' WHEN 4 THEN '" . TQ_("Requires coding") . "' ELSE '" . TQ_("Done") . "' END as state, - CONCAT('' , c.case_id, '') as case_id, SEC_TO_TIME(TIMESTAMPDIFF(SECOND,cal.start,CONVERT_TZ(NOW(),'SYSTEM','UTC'))) as calltime, - e.status as vs, - e.extension_id - FROM extension as e - LEFT JOIN `operator` as o ON (o.operator_id = e.current_operator_id) - LEFT JOIN `case` as c ON (c.current_operator_id = o.operator_id) - LEFT JOIN `call_attempt` as cal ON (cal.operator_id = o.operator_id AND cal.end IS NULL and cal.case_id = c.case_id) - LEFT JOIN `call` as ca ON (ca.case_id = c.case_id AND ca.operator_id = o.operator_id AND ca.outcome_id= 0 AND ca.call_attempt_id = cal.call_attempt_id) - ORDER BY e.extension_id ASC"; - - $rs = $db->GetAll($sql); - - if ($msg != "") - print "

$msg

"; - - if (!empty($rs)) - { - $sql = "SELECT o.operator_id as value, o.firstName as description - FROM `operator` as o - LEFT JOIN `extension` as e ON (e.current_operator_id = o.operator_id) - WHERE e.extension_id IS NULL"; - - $ers = $db->GetAll($sql); - - for ($i = 0; $i < count($rs); $i++) - { - 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 "
"; - } - else - print "

" . T_("No extensions") . "

"; - - print "
" . T_("Add extension") . "
"; - -} - -xhtml_foot(); - -?> \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2010 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/software/ queXS was writen for ACSPRI + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +$msg = ""; + +if (isset($_GET)) +{ + foreach($_GET as $key=>$val) + { + if (substr($key,0,12) == "operator_id_") + { + if (isset($_GET['extension_id'])) + { + $ex = intval($_GET['extension_id']); + $op = intval($val); + + $sql = "UPDATE `extension` + SET current_operator_id = $op + WHERE extension_id = $ex + AND current_operator_id IS NULL"; + + $db->Execute($sql); + } + } + } +} + +if (isset($_POST['extension'])) +{ + $extension = $db->qstr($_POST['extension']); + $password = $db->qstr($_POST['password']); + $extension_id = "NULL"; + + if (isset($_POST['extensionid'])) + $extension_id = intval($_POST['extensionid']); + + if (isset($_POST['delete'])) + { + $sql = "DELETE FROM `extension` + WHERE current_operator_id IS NULL + AND extension_id = $extension_id"; + + $rs = $db->Execute($sql); + + if (!$rs) + $msg = ("Failed to delete extension. There may be an operator currently assigned to it"); + } + else + { + if (!empty($_POST['extension'])) + { + $sql = "INSERT INTO `extension` (extension_id,extension,password) + VALUES ($extension_id,$extension,$password) + ON DUPLICATE KEY UPDATE extension=$extension,password=$password"; + + $rs = $db->Execute($sql); + + if (!$rs) + $msg = T_("Failed to add extension. There already may be an extension of this name"); + } + } +} + +if (isset($_GET['unassign'])) +{ + $e = intval($_GET['unassign']); + + $db->StartTrans(); + + $sql = "SELECT e.current_operator_id + FROM `extension` as e + LEFT JOIN `case` as c ON (c.current_operator_id = e.current_operator_id) + WHERE e.extension_id = $e + AND c.case_id IS NULL"; + + $cid = $db->GetOne($sql); + + if (!empty($cid)) + { + $sql = "UPDATE `extension` as e + SET current_operator_id = NULL + WHERE extension_id = $e + AND current_operator_id = $cid"; + + $db->Execute($sql); + } + + $db->CompleteTrans(); +} + +xhtml_head(T_("Extensions & status"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); +?> + + +GetRow($sql); + } + + print "" . T_("Go back") . ""; +?> +
+

+
+
+ + " 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 "
"; +} +else +{ + $sql= "SELECT CONCAT('',o.firstName,' ', o.lastname,'') as firstName, + CONCAT('',e.extension,'') as extension, + IF(c.case_id IS NULL,IF(e.current_operator_id IS NULL,'list' + ,CONCAT('". TQ_("Unassign") ."')),'". TQ_("End case to change assignment")."') as assignment, + CASE e.status WHEN 0 THEN '" . TQ_("VoIP Offline") . "' ELSE '" . TQ_("VoIP Online") . "' END as status, + CASE ca.state WHEN 0 THEN '" . TQ_("Not called") . "' WHEN 1 THEN '" . TQ_("Requesting call") . "' WHEN 2 THEN '" . TQ_("Ringing") . "' WHEN 3 THEN '" . TQ_("Answered") . "' WHEN 4 THEN '" . TQ_("Requires coding") . "' ELSE '" . TQ_("Done") . "' END as state, + CONCAT('' , c.case_id, '') as case_id, SEC_TO_TIME(TIMESTAMPDIFF(SECOND,cal.start,CONVERT_TZ(NOW(),'SYSTEM','UTC'))) as calltime, + e.status as vs, + e.extension_id + FROM extension as e + LEFT JOIN `operator` as o ON (o.operator_id = e.current_operator_id) + LEFT JOIN `case` as c ON (c.current_operator_id = o.operator_id) + LEFT JOIN `call_attempt` as cal ON (cal.operator_id = o.operator_id AND cal.end IS NULL and cal.case_id = c.case_id) + LEFT JOIN `call` as ca ON (ca.case_id = c.case_id AND ca.operator_id = o.operator_id AND ca.outcome_id= 0 AND ca.call_attempt_id = cal.call_attempt_id) + ORDER BY e.extension_id ASC"; + + $rs = $db->GetAll($sql); + + if ($msg != "") + print "

$msg

"; + + if (!empty($rs)) + { + $sql = "SELECT o.operator_id as value, o.firstName as description + FROM `operator` as o + LEFT JOIN `extension` as e ON (e.current_operator_id = o.operator_id) + WHERE e.extension_id IS NULL"; + + $ers = $db->GetAll($sql); + + for ($i = 0; $i < count($rs); $i++) + { + 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 "
"; + } + else + print "

" . T_("No extensions") . "

"; + + print "
" . T_("Add extension") . "
"; + +} + +xhtml_foot(); + +?> diff --git a/admin/import.php b/admin/import.php index 1ac79e58..b247cb0e 100644 --- a/admin/import.php +++ b/admin/import.php @@ -1,155 +1,155 @@ - " . T_("Go back") . ""; - - - //verify each GET field is unique (except import_form) - $sfields = array(); - foreach($_POST as $getv => $val) - //clean up? - $sfields[$getv] = $val; - - $error = verify_fields($sfields); - - $description = $_POST['description']; - - if ($error == "") - { //verified so upload - if (import_file($_POST['filename'],$description,$sfields)) - { - print "

" . T_("Successfully imported sample") . " 

$description

"; - } - else - { - print -"

" . T_("Error importing file. Please try again") . "

"; - } - } - else - print "

" . T_("Error:") . " $error

" . T_("Please check imported file, go back in your browser and fix the problem") . "

"; - - //verifiy that exactly one primary phone number is selected - //upload to database - - xhtml_foot($js_foot); - -} -else if (isset($_POST['import_file'])) -{ - //file has been submitted - $subtitle = T_("Select columns to import"); - xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); - echo " " . T_("Go back") . ""; - - - print "
"; - - $tmpfname = tempnam(TEMPORARY_DIRECTORY, "FOO"); - move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname); - - display_table(get_first_row($tmpfname)); - - ?> - - -
- -
- -
-
- -
- - -  " . T_("Go back") . ""; - - $ua = $_SERVER['HTTP_USER_AGENT']; - if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; - //print "ua=" . $_SERVER['HTTP_USER_AGENT']; - ?> - -
-
- - - - -
- - -
- ..." type="file" accept="" /> -
-
- - -
- -
- " class="form-control"> -
-
- - -
- -
- -
-
- -
-
- - \ No newline at end of file + " . T_("Go back") . ""; + + + //verify each GET field is unique (except import_form) + $sfields = array(); + foreach($_POST as $getv => $val) + //clean up? + $sfields[$getv] = $val; + + $error = verify_fields($sfields); + + $description = $_POST['description']; + + if ($error == "") + { //verified so upload + if (import_file($_POST['filename'],$description,$sfields)) + { + print "

" . T_("Successfully imported sample") . " 

$description

"; + } + else + { + print -"

" . T_("Error importing file. Please try again") . "

"; + } + } + else + print "

" . T_("Error:") . " $error

" . T_("Please check imported file, go back in your browser and fix the problem") . "

"; + + //verifiy that exactly one primary phone number is selected + //upload to database + + xhtml_foot($js_foot); + +} +else if (isset($_POST['import_file'])) +{ + //file has been submitted + $subtitle = T_("Select columns to import"); + xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); + echo " " . T_("Go back") . ""; + + + print "
"; + + $tmpfname = tempnam(TEMPORARY_DIRECTORY, "FOO"); + move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname); + + display_table(get_first_row($tmpfname)); + + ?> + + +
+ +
+ +
+
+ +
+ + +  " . T_("Go back") . ""; + + $ua = $_SERVER['HTTP_USER_AGENT']; + if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; + //print "ua=" . $_SERVER['HTTP_USER_AGENT']; + ?> + +
+
+ + + + +
+ + +
+ ..." type="file" accept="" /> +
+
+ + +
+ +
+ " class="form-control"> +
+
+ + +
+ +
+ +
+
+ +
+
+ + diff --git a/admin/index.php b/admin/index.php index 09c285a6..600ef3b3 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,198 +1,198 @@ - - * @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 - */ - -/** - * Language file - */ -include ("../lang.inc.php"); - -/** - * Config file - */ - include ("../config.inc.php"); - include ("../functions/functions.xhtml.php"); - $username = $_SERVER['PHP_AUTH_USER']; - ?> - - - - <?php echo T_("Administrative Tools") ;?> - - - - - - - - - - - - - - - -
- - - - - - -
- -
-
- - - - - - - + + * @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 + */ + +/** + * Language file + */ +include ("../lang.inc.php"); + +/** + * Config file + */ + include ("../config.inc.php"); + include ("../functions/functions.xhtml.php"); + $username = $_SERVER['PHP_AUTH_USER']; + ?> + + + + <?php echo T_("Administrative Tools") ;?> + + + + + + + + + + + + + + + +
+ + + + + + +
+ +
+
+ + + + + + + diff --git a/admin/new.php b/admin/new.php index 2f8dc713..1d96424e 100644 --- a/admin/new.php +++ b/admin/new.php @@ -1,378 +1,378 @@ -qstr($_POST['description']); - $rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8')); - $rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8')); - $rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8')); - $rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8')); - $rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8')); - $info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8')); - - //use existing lime instrument - $lime_sid = bigintval($_POST['select']); - - - if (is_numeric($_POST['selectrs'])) - { - $lime_rs_sid = bigintval($_POST['selectrs']); - } - - $sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info,self_complete,referral) - VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info,$respsc,$referral)"; - - $rs = $db->Execute($sql); - - if ($rs) - { - $qid = $db->Insert_ID(); - if ($respsc == 1) - { - $lime_mode = $db->qstr($_POST['lime_mode']); - $lime_template = $db->qstr($_POST['lime_template']); - $lime_endurl = $db->qstr($_POST['lime_endurl']); - - $sql = "UPDATE questionnaire - SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl - WHERE questionnaire_id = $qid"; - - $db->Execute($sql); - } - $cl = info; - $message = T_("Successfully inserted") . " " . T_("with ID") . "  $qid,

" . T_("linked to survey") . "  $lime_sid "; - - } - else{ - $cl = danger; - $message = T_("Error: Failed to insert questionnaire"); - } - - -?> - - - - - - - - - - - - - - - -
- - -
- -
- " title="" /> -
-
- -GetAll($sql); -?> -
- -
- - - - -
-
- - -
-
- -
- -
- -
-
- -
- -
- " data-off="" data-width="80" /> -
-
- -
- -
- " data-off="" data-width="80"/> -
-
- -
- -
- " data-off="" data-onstyle="danger" data-width="80" /> -
-
- -
- -
- " data-off="" data-width="80"/> -
-
- -
- -
- " data-off="" data-width="80"/> -
-
- - - - -basePath = "../include/ckeditor/"; - -$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"), - array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"), - array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"), - array('Link','Unlink','Anchor'), - array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'), - array('About'), - "/", - array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"), - array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"), - array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'), - array('BidiLtr', 'BidiRtl'), - array('Styles','Format','Font','FontSize'), - array('TextColor','BGColor')), - "extraPlugins" => "tokens"); -?> - -
- -
-
- " style="margin-top: -5px;"> -

-
-
- editor("rs_intro","",$ckeditorConfig);?> -
-
- -
-
- " style="margin-top: -5px;"> -

-
-
- editor("rs_project_intro","",$ckeditorConfig);?> -
-
- -
-
- " style="margin-top: -5px;"> -

-
-
- editor("rs_callback","",$ckeditorConfig);?> -
-
- -
-
- " style="margin-top: -5px;"> -

-
-
- editor("rs_answeringmachine","",$ckeditorConfig);?> -
-
-
- - -
-
- " style="margin-top: -5px;"> -

-
-
- editor("rs_project_end","",$ckeditorConfig); ?> -
-
- -
-
- " style="margin-top: -5px;"> -

-
-
- editor("info","",$ckeditorConfig);?> -
-
- -
-
- -
-
- -
-
-
- - \ No newline at end of file +qstr($_POST['description']); + $rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8')); + $rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8')); + $rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8')); + $rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8')); + $rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8')); + $info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8')); + + //use existing lime instrument + $lime_sid = bigintval($_POST['select']); + + + if (is_numeric($_POST['selectrs'])) + { + $lime_rs_sid = bigintval($_POST['selectrs']); + } + + $sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info,self_complete,referral) + VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info,$respsc,$referral)"; + + $rs = $db->Execute($sql); + + if ($rs) + { + $qid = $db->Insert_ID(); + if ($respsc == 1) + { + $lime_mode = $db->qstr($_POST['lime_mode']); + $lime_template = $db->qstr($_POST['lime_template']); + $lime_endurl = $db->qstr($_POST['lime_endurl']); + + $sql = "UPDATE questionnaire + SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl + WHERE questionnaire_id = $qid"; + + $db->Execute($sql); + } + $cl = info; + $message = T_("Successfully inserted") . " " . T_("with ID") . "  $qid,

" . T_("linked to survey") . "  $lime_sid "; + + } + else{ + $cl = danger; + $message = T_("Error: Failed to insert questionnaire"); + } + + +?> + + + + + + + + + + + + + + + +
+ + +
+ +
+ " title="" /> +
+
+ +GetAll($sql); +?> +
+ +
+ + + + +
+
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ " data-off="" data-width="80" /> +
+
+ +
+ +
+ " data-off="" data-width="80"/> +
+
+ +
+ +
+ " data-off="" data-onstyle="danger" data-width="80" /> +
+
+ +
+ +
+ " data-off="" data-width="80"/> +
+
+ +
+ +
+ " data-off="" data-width="80"/> +
+
+ + + + +basePath = "../include/ckeditor/"; + +$ckeditorConfig = array("toolbar" => array(array("tokens","-","Source"), + array("Cut","Copy","Paste","PasteText","PasteFromWord","-","Print","SpellChecker"), + array("Undo","Redo","-","Find","Replace","-","SelectAll","RemoveFormat"), + array('Link','Unlink','Anchor'), + array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'), + array('About'), + "/", + array("Bold","Italic","Underline","Strike","-","Subscript","Superscript"), + array("NumberedList","BulletedList","-","Outdent","Indent","Blockquote"), + array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'), + array('BidiLtr', 'BidiRtl'), + array('Styles','Format','Font','FontSize'), + array('TextColor','BGColor')), + "extraPlugins" => "tokens"); +?> + +
+ +
+
+ " style="margin-top: -5px;"> +

+
+
+ editor("rs_intro","",$ckeditorConfig);?> +
+
+ +
+
+ " style="margin-top: -5px;"> +

+
+
+ editor("rs_project_intro","",$ckeditorConfig);?> +
+
+ +
+
+ " style="margin-top: -5px;"> +

+
+
+ editor("rs_callback","",$ckeditorConfig);?> +
+
+ +
+
+ " style="margin-top: -5px;"> +

+
+
+ editor("rs_answeringmachine","",$ckeditorConfig);?> +
+
+
+ + +
+
+ " style="margin-top: -5px;"> +

+
+
+ editor("rs_project_end","",$ckeditorConfig); ?> +
+
+ +
+
+ " style="margin-top: -5px;"> +

+
+
+ editor("info","",$ckeditorConfig);?> +
+
+ +
+
+ +
+
+ +
+
+
+ + diff --git a/admin/operatorlist.php b/admin/operatorlist.php index 57504329..f459f787 100644 --- a/admin/operatorlist.php +++ b/admin/operatorlist.php @@ -1,406 +1,406 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2007,2008,2009,2010,2011 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/software queXS was writen for ACSPRI - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database - */ -include_once(dirname(__FILE__).'/../db.inc.php'); - -/** - * XHTML functions - */ -include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); - -$display = true; -$msg = ""; - -if (isset($_POST['submit'])) -{ - $operator_id = intval($_POST['operator_id']); - $chat_enable = $voip = $enabled = 0; - if (isset($_POST['voip'])) $voip = 1; - if (isset($_POST['chat_enable'])) $chat_enable = 1; - if (isset($_POST['enabled'])) $enabled = 1; - - if (HTPASSWD_PATH !== false && $_POST['existing_username'] != $_POST['username'] && empty($_POST['password'])) - { - $msg = "

" . T_("If changing usernames, you must specify a new password") . "

"; - } - else - { - $sql = "UPDATE operator - SET username = " . $db->qstr($_POST['username']) . ", - lastName = " . $db->qstr($_POST['lastName']) . ", - firstName = " . $db->qstr($_POST['firstName']) . ", - chat_user = " . $db->qstr($_POST['chat_user']) . ", - chat_password = " . $db->qstr($_POST['chat_password']) . ", - Time_zone_name = " . $db->qstr($_POST['timezone']) . ", - voip = $voip, enabled = $enabled, chat_enable = $chat_enable - WHERE operator_id = $operator_id"; - - $rs = $db->Execute($sql); - - if (!empty($rs)) - { - //only update extension if we aren't on a case - $sql = "SELECT case_id - FROM `case` - WHERE current_operator_id = $operator_id"; - - $cc= $db->GetOne($sql); - - if (empty($cc)) - { - $sql = "UPDATE extension - SET current_operator_id = NULL - WHERE current_operator_id= $operator_id"; - - $db->Execute($sql); - - if (!empty($_POST['extension_id'])) - { - $sql = "UPDATE extension - SET current_operator_id = $operator_id - WHERE extension_id = " . intval($_POST['extension_id']); - - $db->Execute($sql); - } - } - - if (HTPASSWD_PATH !== false && !empty($_POST['password'])) - { - //update password in htaccess - include_once(dirname(__FILE__).'/../functions/functions.htpasswd.php'); - $htp = New Htpasswd(HTPASSWD_PATH); - $htp->deleteUser($_POST["existing_username"]); - $htp->deleteUser($_POST["username"]); - $htp->addUser($_POST["username"],$_POST["password"]); - $htg = New Htgroup(HTGROUP_PATH); - $htg->deleteUserFromGroup($_POST["existing_username"],HTGROUP_INTERVIEWER); - $htg->addUserToGroup($_POST["username"],HTGROUP_INTERVIEWER); - } - - $msg = "

" . T_("Successfully updated user") . ": " . $_POST['username'] . "

"; - } - else - { - $msg = "

" . T_("Failed to update user") . ": " . $_POST['username'] . " " . T_("Please make sure the username is unique") . "

"; - } - } - $_GET['edit'] = $operator_id; -} - - -if (isset($_GET['edit'])) -{ - xhtml_head(T_("Edit Operator settings"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); - - $operator_id = intval($_GET['edit']); - - $sql = "SELECT * - FROM operator - WHERE operator_id = $operator_id"; - - $rs = $db->GetRow($sql); - - $sql = "SELECT Time_zone_name as value, Time_zone_name as description - FROM timezone_template"; - - $tz = $db->GetAll($sql); -?> - - - -
-" . T_("Operator") . ": " . $rs['username'] . "

"; - echo ""; - - if (!empty($msg)) echo $msg; - - $sql = "SELECT extension_id as value, extension as description, - CASE WHEN current_operator_id = $operator_id THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM extension - WHERE current_operator_id IS NULL - OR current_operator_id = $operator_id"; - - $ers = $db->GetAll($sql); - -?> -
-
- -
-
- -
- -
"/>
-
  - " class="btn btn-default"/>   - -
-
- -
- -
-
-
- -
-
-
- -
-
- - -
-
-
- -
-
- - -
-
-
- -
" data-off="" value="1" />
-
-
- -
-
-
- -
-
-
- -
" data-off="" value="1"/>
-
-
- -
" data-off="" value="1" />
-
-
-
- -
"/>
-
- - - Execute($sql); -} - -if (isset($_GET['voipenable'])) -{ - $operator_id = intval($_GET['voipenable']); - - $sql = "UPDATE operator - SET voip = 1 - WHERE operator_id = '$operator_id'"; - - $db->Execute($sql); -} - -if (isset($_GET['disable'])) -{ - $operator_id = intval($_GET['disable']); - - $sql = "UPDATE operator - SET enabled = 0 - WHERE operator_id = '$operator_id'"; - - $db->Execute($sql); -} - -if (isset($_GET['enable'])) -{ - $operator_id = intval($_GET['enable']); - - $sql = "UPDATE operator - SET enabled = 1 - WHERE operator_id = '$operator_id'"; - - $db->Execute($sql); -} - -if (isset($_GET['operator_id'])) -{ - $operator_id = intval($_GET['operator_id']); - - $sql = "SELECT *,SUBSTRING_INDEX(e.extension, '/', -1) as ext - FROM extension as e - WHERE e.current_operator_id = $operator_id"; - - $rs = $db->GetRow($sql); - - if (!empty($rs)) - { - $display = false; - - if (isset($_GET['winbat']) || isset($_GET['sh'])) - { - header("Content-Type: text/txt"); - if (isset($_GET['winbat'])) - header("Content-Disposition: attachment; filename=operator_$operator_id.bat"); - else - header("Content-Disposition: attachment; filename=operator_$operator_id.sh"); - 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("Pragma: public"); // HTTP/1.0 - - if (isset($_GET['winbat'])) - echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; - else - echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; - } - } -} - -if ($display) -{ - $sql = "SELECT operator_id, - CONCAT(firstName, ' ', lastName) as name, - CONCAT ('', e.extension ,'') as `extension`, - CONCAT('" . TQ_("Win .bat file") . "') as winbat, - CONCAT('" . TQ_("*nix script file") . "') as sh, - CASE WHEN enabled = 0 THEN - CONCAT('  ') - ELSE - CONCAT('  ') - END as enabledisable, - CASE WHEN voip = 0 THEN - CONCAT('" . TQ_("Enable VoIP") . "') - ELSE - CONCAT('" . TQ_("Disable VoIP") . "') - END as voipenabledisable, - CONCAT('  ') as edit, username - FROM operator - LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)"; - - $rs = $db->GetAll($sql); - - xhtml_head(T_("Operator list"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../css/custom.css")); - - $columns = array("operator_id","name","username","extension","enabledisable","edit"); - $titles = array("ID",T_("Operator"),T_("Username"),T_("Extension")," "," "); - - if (VOIP_ENABLED) - { - $columns[] = "voipenabledisable"; - $columns[] = "winbat"; - $columns[] = "sh"; - $titles[] = T_("VoIP ON/Off"); - $titles[] = T_("Win file");//Windows VoIP - $titles[] = T_("*nix flle");//*nix VoIP - } - echo "
"; - xhtml_table($rs,$columns,$titles); - echo "
"; - - echo "
-
 " . T_("Add an operator") . "
-
 " . T_("Extensions") . "
-
" . T_("Assign to questionnaire") . "
-
 " . T_("Operator skills") . "
-
 " . T_("Operator performance") . "
"; - - if (VOIP_ENABLED) - { - print "
" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server"). "

"; - - print " " . T_("Download Win file") . "
"; - print " " . T_("Download Linux file") . "
"; - - } - print "
"; - - xhtml_foot(); -} -?> \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2007,2008,2009,2010,2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/software queXS was writen for ACSPRI + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database + */ +include_once(dirname(__FILE__).'/../db.inc.php'); + +/** + * XHTML functions + */ +include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); + +$display = true; +$msg = ""; + +if (isset($_POST['submit'])) +{ + $operator_id = intval($_POST['operator_id']); + $chat_enable = $voip = $enabled = 0; + if (isset($_POST['voip'])) $voip = 1; + if (isset($_POST['chat_enable'])) $chat_enable = 1; + if (isset($_POST['enabled'])) $enabled = 1; + + if (HTPASSWD_PATH !== false && $_POST['existing_username'] != $_POST['username'] && empty($_POST['password'])) + { + $msg = "

" . T_("If changing usernames, you must specify a new password") . "

"; + } + else + { + $sql = "UPDATE operator + SET username = " . $db->qstr($_POST['username']) . ", + lastName = " . $db->qstr($_POST['lastName']) . ", + firstName = " . $db->qstr($_POST['firstName']) . ", + chat_user = " . $db->qstr($_POST['chat_user']) . ", + chat_password = " . $db->qstr($_POST['chat_password']) . ", + Time_zone_name = " . $db->qstr($_POST['timezone']) . ", + voip = $voip, enabled = $enabled, chat_enable = $chat_enable + WHERE operator_id = $operator_id"; + + $rs = $db->Execute($sql); + + if (!empty($rs)) + { + //only update extension if we aren't on a case + $sql = "SELECT case_id + FROM `case` + WHERE current_operator_id = $operator_id"; + + $cc= $db->GetOne($sql); + + if (empty($cc)) + { + $sql = "UPDATE extension + SET current_operator_id = NULL + WHERE current_operator_id= $operator_id"; + + $db->Execute($sql); + + if (!empty($_POST['extension_id'])) + { + $sql = "UPDATE extension + SET current_operator_id = $operator_id + WHERE extension_id = " . intval($_POST['extension_id']); + + $db->Execute($sql); + } + } + + if (HTPASSWD_PATH !== false && !empty($_POST['password'])) + { + //update password in htaccess + include_once(dirname(__FILE__).'/../functions/functions.htpasswd.php'); + $htp = New Htpasswd(HTPASSWD_PATH); + $htp->deleteUser($_POST["existing_username"]); + $htp->deleteUser($_POST["username"]); + $htp->addUser($_POST["username"],$_POST["password"]); + $htg = New Htgroup(HTGROUP_PATH); + $htg->deleteUserFromGroup($_POST["existing_username"],HTGROUP_INTERVIEWER); + $htg->addUserToGroup($_POST["username"],HTGROUP_INTERVIEWER); + } + + $msg = "

" . T_("Successfully updated user") . ": " . $_POST['username'] . "

"; + } + else + { + $msg = "

" . T_("Failed to update user") . ": " . $_POST['username'] . " " . T_("Please make sure the username is unique") . "

"; + } + } + $_GET['edit'] = $operator_id; +} + + +if (isset($_GET['edit'])) +{ + xhtml_head(T_("Edit Operator settings"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"),array("../include/jquery/jquery.min.js","../include/bootstrap/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); + + $operator_id = intval($_GET['edit']); + + $sql = "SELECT * + FROM operator + WHERE operator_id = $operator_id"; + + $rs = $db->GetRow($sql); + + $sql = "SELECT Time_zone_name as value, Time_zone_name as description + FROM timezone_template"; + + $tz = $db->GetAll($sql); +?> + + + +
+" . T_("Operator") . ": " . $rs['username'] . ""; + echo "
"; + + if (!empty($msg)) echo $msg; + + $sql = "SELECT extension_id as value, extension as description, + CASE WHEN current_operator_id = $operator_id THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM extension + WHERE current_operator_id IS NULL + OR current_operator_id = $operator_id"; + + $ers = $db->GetAll($sql); + +?> +
+
+ +
+
+ +
+ +
"/>
+
  + " class="btn btn-default"/>   + +
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ + +
+
+
+ +
+
+ + +
+
+
+ +
" data-off="" value="1" />
+
+
+ +
+
+
+ +
+
+
+ +
" data-off="" value="1"/>
+
+
+ +
" data-off="" value="1" />
+
+
+
+ +
"/>
+
+ + + Execute($sql); +} + +if (isset($_GET['voipenable'])) +{ + $operator_id = intval($_GET['voipenable']); + + $sql = "UPDATE operator + SET voip = 1 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['disable'])) +{ + $operator_id = intval($_GET['disable']); + + $sql = "UPDATE operator + SET enabled = 0 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['enable'])) +{ + $operator_id = intval($_GET['enable']); + + $sql = "UPDATE operator + SET enabled = 1 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['operator_id'])) +{ + $operator_id = intval($_GET['operator_id']); + + $sql = "SELECT *,SUBSTRING_INDEX(e.extension, '/', -1) as ext + FROM extension as e + WHERE e.current_operator_id = $operator_id"; + + $rs = $db->GetRow($sql); + + if (!empty($rs)) + { + $display = false; + + if (isset($_GET['winbat']) || isset($_GET['sh'])) + { + header("Content-Type: text/txt"); + if (isset($_GET['winbat'])) + header("Content-Disposition: attachment; filename=operator_$operator_id.bat"); + else + header("Content-Disposition: attachment; filename=operator_$operator_id.sh"); + 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("Pragma: public"); // HTTP/1.0 + + if (isset($_GET['winbat'])) + echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; + else + echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; + } + } +} + +if ($display) +{ + $sql = "SELECT operator_id, + CONCAT(firstName, ' ', lastName) as name, + CONCAT ('', e.extension ,'') as `extension`, + CONCAT('" . TQ_("Win .bat file") . "') as winbat, + CONCAT('" . TQ_("*nix script file") . "') as sh, + CASE WHEN enabled = 0 THEN + CONCAT('  ') + ELSE + CONCAT('  ') + END as enabledisable, + CASE WHEN voip = 0 THEN + CONCAT('" . TQ_("Enable VoIP") . "') + ELSE + CONCAT('" . TQ_("Disable VoIP") . "') + END as voipenabledisable, + CONCAT('  ') as edit, username + FROM operator + LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)"; + + $rs = $db->GetAll($sql); + + xhtml_head(T_("Operator list"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/font-awesome/css/font-awesome.css","../css/custom.css")); + + $columns = array("operator_id","name","username","extension","enabledisable","edit"); + $titles = array("ID",T_("Operator"),T_("Username"),T_("Extension")," "," "); + + if (VOIP_ENABLED) + { + $columns[] = "voipenabledisable"; + $columns[] = "winbat"; + $columns[] = "sh"; + $titles[] = T_("VoIP ON/Off"); + $titles[] = T_("Win file");//Windows VoIP + $titles[] = T_("*nix flle");//*nix VoIP + } + echo "
"; + xhtml_table($rs,$columns,$titles); + echo "
"; + + echo "
+
 " . T_("Add an operator") . "
+
 " . T_("Extensions") . "
+
" . T_("Assign to questionnaire") . "
+
 " . T_("Operator skills") . "
+
 " . T_("Operator performance") . "
"; + + if (VOIP_ENABLED) + { + print "
" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server"). "

"; + + print " " . T_("Download Win file") . "
"; + print " " . T_("Download Linux file") . "
"; + + } + print "
"; + + xhtml_foot(); +} +?> diff --git a/admin/operatorperformance.php b/admin/operatorperformance.php index cbb0801d..0b81c3a9 100644 --- a/admin/operatorperformance.php +++ b/admin/operatorperformance.php @@ -1,110 +1,110 @@ - - * @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_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Performance functions - */ -include("../functions/functions.performance.php"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -/** - * Operator functions - */ -include("../functions/functions.operator.php"); - -xhtml_head(T_("Operator Performance"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); - -//$rs = get_stats_total(get_stats()); -//print "

" . T_("Overall") . "

"; -//xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); - -$questionnaire_id = false; -print "

" . T_("Please select a questionnaire") . " 

"; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); -display_questionnaire_chooser($questionnaire_id,false,"form-inline clearfix", "form-control"); - -if ($questionnaire_id) -{ - $rs = get_stats_total(get_stats_by_questionnaire($questionnaire_id)); - print "

" . T_("This project") . "

"; - xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); - - $operator_id = get_operator_id(); - - $shift_id = false; - if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']); - - $sql = "SELECT s.shift_id as value,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT . "'),' " . TQ_("till") . " ',DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as description,CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM shift as s - LEFT JOIN (operator as o) on (o.operator_id = '$operator_id') - WHERE s.questionnaire_id = '$questionnaire_id' - ORDER BY s.start ASC"; - - $rs = $db->GetAll($sql); - - print "

" . T_("Please select a shift") . " 

"; - - display_chooser($rs,"shift_id","shift_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"form-inline form-group");//,false,true,false,true,"pull-left" - - if ($shift_id) - { - $rs = get_stats_total(get_stats_by_shift($questionnaire_id,$shift_id)); - print "

" . T_("This shift") . "

"; - xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); - } -} - -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_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Performance functions + */ +include("../functions/functions.performance.php"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +xhtml_head(T_("Operator Performance"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); + +//$rs = get_stats_total(get_stats()); +//print "

" . T_("Overall") . "

"; +//xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); + +$questionnaire_id = false; +print "

" . T_("Please select a questionnaire") . " 

"; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); +display_questionnaire_chooser($questionnaire_id,false,"form-inline clearfix", "form-control"); + +if ($questionnaire_id) +{ + $rs = get_stats_total(get_stats_by_questionnaire($questionnaire_id)); + print "

" . T_("This project") . "

"; + xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); + + $operator_id = get_operator_id(); + + $shift_id = false; + if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']); + + $sql = "SELECT s.shift_id as value,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT . "'),' " . TQ_("till") . " ',DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as description,CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM shift as s + LEFT JOIN (operator as o) on (o.operator_id = '$operator_id') + WHERE s.questionnaire_id = '$questionnaire_id' + ORDER BY s.start ASC"; + + $rs = $db->GetAll($sql); + + print "

" . T_("Please select a shift") . " 

"; + + display_chooser($rs,"shift_id","shift_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"form-inline form-group");//,false,true,false,true,"pull-left" + + if ($shift_id) + { + $rs = get_stats_total(get_stats_by_shift($questionnaire_id,$shift_id)); + print "

" . T_("This shift") . "

"; + xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness"))); + } +} + +xhtml_foot(); +?> + diff --git a/admin/operatorquestionnaire.php b/admin/operatorquestionnaire.php index 3b62f12f..8b80e3ef 100644 --- a/admin/operatorquestionnaire.php +++ b/admin/operatorquestionnaire.php @@ -1,279 +1,279 @@ - - * @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 operator has already been assigned to this questionnaire - * - * @param int $operator_id Operator id - * @param int $questionnaire_id Questionnaire id - * @return int 1 if assigned otherwise 0 - * - */ -function vq($operator_id,$questionnaire_id) -{ - global $db; - - $sql = "SELECT operator_id,questionnaire_id - FROM operator_questionnaire - WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; - - $vq = $db->Execute($sql); - - if ($vq) - return $vq->RecordCount(); - else - return 0; -} - -/** - * Assign an operator to a questionnaire - * - * @param int $operator_id Operator id - * @param int $questionnaire_id Questionnaire id - * - */ -function vqi($operator_id,$questionnaire_id) -{ - global $db; - - $sql = "INSERT INTO - operator_questionnaire (operator_id,questionnaire_id) - VALUES('$operator_id','$questionnaire_id')"; - - $db->Execute($sql); -} - - -/** - * Unassign an operator from a questionnaire - * - * @param int $operator_id Operator id - * @param int $questionnaire_id Questionnaire id - * - */ -function vqd($operator_id,$questionnaire_id) -{ - global $db; - - $sql = "DELETE FROM - operator_questionnaire - WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; - - $db->Execute($sql); -} - - -if (isset($_POST['submit'])) -{ - $db->StartTrans(); - - $sql = "DELETE - FROM operator_questionnaire - WHERE questionnaire_id IN ( - SELECT questionnaire_id - FROM questionnaire - WHERE enabled = 1) - AND 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 questionnaire_id,description - FROM questionnaire - WHERE enabled = 1 - ORDER by questionnaire_id DESC"; - -$questionnaires = $db->GetAll($sql); - -$sql = "SELECT operator_id, CONCAT(firstName,' ', lastName ) as opname, username - FROM operator - WHERE enabled = 1 - ORDER by operator_id ASC"; - -$operators = $db->GetAll($sql); - - -xhtml_head(T_("Assign operators 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($operators as $v) -{ - - print " - - "; - foreach($questionnaires as $q) - { - $checked = ""; - if (vq($v['operator_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; - print ""; - } - - print ""; -} - - -print "
 " . T_("Username") . "  " . T_("Operator") . " {$q['description']}
 {$v['username']} {$v['opname']}
"; - - -xhtml_foot(); - -?> - - \ No newline at end of file + + * @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 operator has already been assigned to this questionnaire + * + * @param int $operator_id Operator id + * @param int $questionnaire_id Questionnaire id + * @return int 1 if assigned otherwise 0 + * + */ +function vq($operator_id,$questionnaire_id) +{ + global $db; + + $sql = "SELECT operator_id,questionnaire_id + FROM operator_questionnaire + WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; + + $vq = $db->Execute($sql); + + if ($vq) + return $vq->RecordCount(); + else + return 0; +} + +/** + * Assign an operator to a questionnaire + * + * @param int $operator_id Operator id + * @param int $questionnaire_id Questionnaire id + * + */ +function vqi($operator_id,$questionnaire_id) +{ + global $db; + + $sql = "INSERT INTO + operator_questionnaire (operator_id,questionnaire_id) + VALUES('$operator_id','$questionnaire_id')"; + + $db->Execute($sql); +} + + +/** + * Unassign an operator from a questionnaire + * + * @param int $operator_id Operator id + * @param int $questionnaire_id Questionnaire id + * + */ +function vqd($operator_id,$questionnaire_id) +{ + global $db; + + $sql = "DELETE FROM + operator_questionnaire + WHERE operator_id = '$operator_id' and questionnaire_id = '$questionnaire_id'"; + + $db->Execute($sql); +} + + +if (isset($_POST['submit'])) +{ + $db->StartTrans(); + + $sql = "DELETE + FROM operator_questionnaire + WHERE questionnaire_id IN ( + SELECT questionnaire_id + FROM questionnaire + WHERE enabled = 1) + AND 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 questionnaire_id,description + FROM questionnaire + WHERE enabled = 1 + ORDER by questionnaire_id DESC"; + +$questionnaires = $db->GetAll($sql); + +$sql = "SELECT operator_id, CONCAT(firstName,' ', lastName ) as opname, username + FROM operator + WHERE enabled = 1 + ORDER by operator_id ASC"; + +$operators = $db->GetAll($sql); + + +xhtml_head(T_("Assign operators 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")); + +?> + + + + + + + +"; + +print ""; +foreach($questionnaires as $q) +{ + print ""; +} +print ""; + + +foreach($operators as $v) +{ + + print " + + "; + foreach($questionnaires as $q) + { + $checked = ""; + if (vq($v['operator_id'],$q['questionnaire_id'])) $checked="checked=\"checked\""; + print ""; + } + + print ""; +} + + +print "
 " . T_("Username") . "  " . T_("Operator") . " {$q['description']}
 {$v['username']} {$v['opname']}
"; + + +xhtml_foot(); + +?> + + diff --git a/admin/operators.php b/admin/operators.php index e8b8d854..8860ab08 100644 --- a/admin/operators.php +++ b/admin/operators.php @@ -1,316 +1,316 @@ - - * @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"); - - -global $db; - -$a = false; - -if (isset($_POST['operator']) && isset($_POST['adduser'])) -{ - $operator = $db->qstr($_POST['operator'],get_magic_quotes_gpc()); - $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); - $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); - $chat_user = $db->qstr($_POST['chat_user'],get_magic_quotes_gpc()); - $chat_password = $db->qstr($_POST['chat_password'],get_magic_quotes_gpc()); - $time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc()); - $extension = ""; - if (FREEPBX_PATH != false) - { - //Generate new extension from last one in database and random password - $sql = "SELECT SUBSTRING_INDEX(extension, '/', -1) as ext - FROM extension - ORDER BY ext DESC - LIMIT 1"; - - $laste = $db->GetRow($sql); - - $extensionn = "2000"; - $extension = "'IAX2/2000'"; - - //increment if exists - if (!empty($laste)) - { - $extensionn = $laste['ext'] + 1; - $extension = "'IAX2/$extensionn'"; - } - - //generate random 8 length password - $extensionnp = ""; - $length = 25; - $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; - for ($i = 0; $i < $length; $i++) - $extensionnp .= $chars[(mt_rand() % strlen($chars))]; - - //quote for SQL - $extensionp = "'$extensionnp'"; - - } - $supervisor = 0; - $temporary = 0; - $refusal = 0; - $voip = 0; - $chat = 0; - if (isset($_POST['supervisor']) && $_POST['supervisor'] == "on") $supervisor = 1; - if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1; - if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1; - if (isset($_POST['voip']) && $_POST['voip'] == "on") $voip = 1; - if (isset($_POST['chat_enable']) && $_POST['chat_enable'] == "on") $chat = 1; - - if (!empty($_POST['operator'])) - { - $sql = "INSERT INTO operator - (`operator_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`,`voip`,`chat_enable`,`chat_user`,`chat_password`) - VALUES (NULL , $operator, $firstname , $lastname, $time_zone_name, $voip, $chat, $chat_user, $chat_password);"; - - if ($db->Execute($sql)) - { - $oid = $db->Insert_ID(); - - if (FREEPBX_PATH !== false) - { - //add extension - $sql = "INSERT INTO extension (`extension`,`password`,`current_operator_id`) - VALUES ($extension, $extensionp, $oid)"; - - $db->Execute($sql); - - //Generate new extension in freepbx - include_once("../functions/functions.freepbx.php"); - freepbx_add_extension($extensionn, $_POST["firstname"] . " " . $_POST["lastname"], $extensionnp); - } - else if (!empty($_POST['extension_id'])) - { - $sql = "UPDATE extension - SET current_operator_id = $oid - WHERE extension_id = " . intval($_POST['extension_id']); - $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['operator'],$_POST['password']); - $htg->addUserToGroup($_POST['operator'],HTGROUP_INTERVIEWER); - - if ($supervisor) - $htg->addUserGroup(HTGROUP_ADMIN); - } - - $a = "

" . T_("Added operator :") . " " . $operator . "

"; - - if (FREEPBX_PATH !== false) - $a .= "
" . T_("FreePBX has been reloaded for the new VoIP extension to take effect"); - - print "
"; - - if ($temporary) - { - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','1')"); - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','5')"); //and appointment - } - - if ($supervisor) - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','2')"); - - if ($refusal) - $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) - VALUES ('$oid','3')"); - } - else - { - $a = T_("Could not add operator. There may already be an operator of this name:") . " $operator "; - } - } -} - - -xhtml_head(T_("Add an operator"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"), array("../js/jquery-2.1.3.min.js", "../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); - -if ($a) { - echo $a; -} -else { - echo "
"; - //echo "

" . T_("Adding an operator here will give the user the ability to call cases") . "" . T_("Assign Operator to Questionnaire") . "" . T_("tool") . ".

"; - echo "

" . T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here.") . "

"; - echo "

" . T_("The username and extension must be unique for each operator.") . "

"; - echo "
"; -} - -$sql = "SELECT Time_zone_name as value, Time_zone_name as description - FROM timezone_template"; - -$rs = $db->GetAll($sql); - -$sql = "SELECT extension_id as value, extension as description - FROM extension - WHERE current_operator_id IS NULL"; - -$ers = $db->GetAll($sql); -?> - - - -
-
- -
-
- -
- -
-
  - " class="btn btn-default fa" />   - -
-
- -
- -
-
-
- -
-
-
- -
-
- - -
-
- -
- -
-
- - -
-
- - -
- -
" data-off="" checked="checked"/>
-
-
- -
-
-
- -
-
-
- -
" data-off="" />
-
-
- -
" data-off="" data-offstyle="danger" checked="checked"/>
-
-
- -
" data-off="" data-onstyle="danger" data-offstyle="primary"/>
-
-
- -
" data-off="" data-onstyle="danger" data-offstyle="primary"/>
-
- -
" />
-
- - \ No newline at end of file + + * @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"); + + +global $db; + +$a = false; + +if (isset($_POST['operator']) && isset($_POST['adduser'])) +{ + $operator = $db->qstr($_POST['operator'],get_magic_quotes_gpc()); + $firstname = $db->qstr($_POST['firstname'],get_magic_quotes_gpc()); + $lastname = $db->qstr($_POST['lastname'],get_magic_quotes_gpc()); + $chat_user = $db->qstr($_POST['chat_user'],get_magic_quotes_gpc()); + $chat_password = $db->qstr($_POST['chat_password'],get_magic_quotes_gpc()); + $time_zone_name = $db->qstr($_POST['Time_zone_name'],get_magic_quotes_gpc()); + $extension = ""; + if (FREEPBX_PATH != false) + { + //Generate new extension from last one in database and random password + $sql = "SELECT SUBSTRING_INDEX(extension, '/', -1) as ext + FROM extension + ORDER BY ext DESC + LIMIT 1"; + + $laste = $db->GetRow($sql); + + $extensionn = "2000"; + $extension = "'IAX2/2000'"; + + //increment if exists + if (!empty($laste)) + { + $extensionn = $laste['ext'] + 1; + $extension = "'IAX2/$extensionn'"; + } + + //generate random 8 length password + $extensionnp = ""; + $length = 25; + $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; + for ($i = 0; $i < $length; $i++) + $extensionnp .= $chars[(mt_rand() % strlen($chars))]; + + //quote for SQL + $extensionp = "'$extensionnp'"; + + } + $supervisor = 0; + $temporary = 0; + $refusal = 0; + $voip = 0; + $chat = 0; + if (isset($_POST['supervisor']) && $_POST['supervisor'] == "on") $supervisor = 1; + if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1; + if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1; + if (isset($_POST['voip']) && $_POST['voip'] == "on") $voip = 1; + if (isset($_POST['chat_enable']) && $_POST['chat_enable'] == "on") $chat = 1; + + if (!empty($_POST['operator'])) + { + $sql = "INSERT INTO operator + (`operator_id` ,`username` ,`firstName` ,`lastName`, `Time_zone_name`,`voip`,`chat_enable`,`chat_user`,`chat_password`) + VALUES (NULL , $operator, $firstname , $lastname, $time_zone_name, $voip, $chat, $chat_user, $chat_password);"; + + if ($db->Execute($sql)) + { + $oid = $db->Insert_ID(); + + if (FREEPBX_PATH !== false) + { + //add extension + $sql = "INSERT INTO extension (`extension`,`password`,`current_operator_id`) + VALUES ($extension, $extensionp, $oid)"; + + $db->Execute($sql); + + //Generate new extension in freepbx + include_once("../functions/functions.freepbx.php"); + freepbx_add_extension($extensionn, $_POST["firstname"] . " " . $_POST["lastname"], $extensionnp); + } + else if (!empty($_POST['extension_id'])) + { + $sql = "UPDATE extension + SET current_operator_id = $oid + WHERE extension_id = " . intval($_POST['extension_id']); + $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['operator'],$_POST['password']); + $htg->addUserToGroup($_POST['operator'],HTGROUP_INTERVIEWER); + + if ($supervisor) + $htg->addUserGroup(HTGROUP_ADMIN); + } + + $a = "

" . T_("Added operator :") . " " . $operator . "

"; + + if (FREEPBX_PATH !== false) + $a .= "
" . T_("FreePBX has been reloaded for the new VoIP extension to take effect"); + + print "
"; + + if ($temporary) + { + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','1')"); + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','5')"); //and appointment + } + + if ($supervisor) + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','2')"); + + if ($refusal) + $db->Execute(" INSERT INTO operator_skill (operator_id,outcome_type_id) + VALUES ('$oid','3')"); + } + else + { + $a = T_("Could not add operator. There may already be an operator of this name:") . " $operator "; + } + } +} + + +xhtml_head(T_("Add an operator"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"), array("../include/jquery/jquery.min.js", "../include/bootstrap/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); + +if ($a) { + echo $a; +} +else { + echo "
"; + //echo "

" . T_("Adding an operator here will give the user the ability to call cases") . "" . T_("Assign Operator to Questionnaire") . "" . T_("tool") . ".

"; + echo "

" . T_("Use this form to enter the username of a user based on your directory security system. For example, if you have secured the base directory of queXS using Apache file based security, enter the usernames of the users here.") . "

"; + echo "

" . T_("The username and extension must be unique for each operator.") . "

"; + echo "
"; +} + +$sql = "SELECT Time_zone_name as value, Time_zone_name as description + FROM timezone_template"; + +$rs = $db->GetAll($sql); + +$sql = "SELECT extension_id as value, extension as description + FROM extension + WHERE current_operator_id IS NULL"; + +$ers = $db->GetAll($sql); +?> + + + +
+
+ +
+
+ +
+ +
+
  + " class="btn btn-default fa" />   + +
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+
+ + +
+ +
" data-off="" checked="checked"/>
+
+
+ +
+
+
+ +
+
+
+ +
" data-off="" />
+
+
+ +
" data-off="" data-offstyle="danger" checked="checked"/>
+
+
+ +
" data-off="" data-onstyle="danger" data-offstyle="primary"/>
+
+
+ +
" data-off="" data-onstyle="danger" data-offstyle="primary"/>
+
+ +
" />
+
+ + diff --git a/admin/operatorskill.php b/admin/operatorskill.php index 10dfa6fc..40ed7bbd 100644 --- a/admin/operatorskill.php +++ b/admin/operatorskill.php @@ -1,279 +1,279 @@ - - * @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"); - -/** - * 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-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 "
" . T_("Set which types of cases will be made available to each operator.
Please note that all operators will be allowed to assign all possible outcomes to a case. This restricts which ones will be assigned to an operator.") . "
"; - - -?> - - - - - -"; - -print ""; -foreach($outcome_types as $q) -{ - print ""; -} -print ""; - - -foreach($operators as $v) -{ - print " - - "; - foreach($outcome_types as $q) - { - $checked = ""; - if (vq($v['operator_id'],$q['outcome_type_id'])) $checked="checked=\"checked\""; - print ""; - } - - print ""; -} - - -print "
 " . T_("Username") . "  " . T_("Operator") . " " . T_($q['description']) . "
 {$v['username']} {$v['description']}
"; - -xhtml_foot(); - -?> - - \ No newline at end of file + + * @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"); + +/** + * 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_("Set which types of cases will be made available to each operator.
Please note that all operators will be allowed to assign all possible outcomes to a case. This restricts which ones will be assigned to an operator.") . "
"; + + +?> + + + + + +"; + +print ""; +foreach($outcome_types as $q) +{ + print ""; +} +print ""; + + +foreach($operators as $v) +{ + print " + + "; + foreach($outcome_types as $q) + { + $checked = ""; + if (vq($v['operator_id'],$q['outcome_type_id'])) $checked="checked=\"checked\""; + print ""; + } + + print ""; +} + + +print "
 " . T_("Username") . "  " . T_("Operator") . " " . T_($q['description']) . "
 {$v['username']} {$v['description']}
"; + +xhtml_foot(); + +?> + + diff --git a/admin/outcomes.php b/admin/outcomes.php index 800619c8..26aa5208 100644 --- a/admin/outcomes.php +++ b/admin/outcomes.php @@ -1,306 +1,306 @@ -" . T_("Select a questionnaire") . ""; -display_questionnaire_chooser($questionnaire_id, false, "pull-left col-sm-4", "form-control"); -print "
"; -if ($questionnaire_id != false) -{ - //print "

" . T_("Outcomes") . "

"; - print "
" . T_("Sample status") . "
"; - - $sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn, - count(*) as count - FROM sample as s - JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id) - LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id) - GROUP BY (c.sample_id is not null)"; - if ($db->GetAll($sql)) xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")), "table-hover table table-condensed", false, array("count")); - else print "
" . T_("No samples assigned") . ". 
"; - print "
"; - - print "
" . T_("Case availability (cases with temporary or appointment outcomes)") ."
"; - - $sql = "SELECT count(c.case_id) as available, si.description - FROM `case` as c - LEFT JOIN `call` as a on (a.call_id = c.last_call_id) - JOIN (sample as s, sample_import as si) on (s.sample_id = c.sample_id and si.sample_import_id = s.import_id) - JOIN (questionnaire_sample as qs, questionnaire as q, outcome as ou) on (q.questionnaire_id = $questionnaire_id and c.questionnaire_id = q.questionnaire_id and qs.sample_import_id = s.import_id and qs.questionnaire_id = q.questionnaire_id and ou.outcome_id = c.current_outcome_id) - LEFT JOIN shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end)) - LEFT JOIN appointment as ap on (ap.case_id = c.case_id AND ap.completed_call_id is NULL AND (ap.start > CONVERT_TZ(NOW(),'System','UTC'))) - LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end)) - LEFT JOIN call_restrict as cr on (cr.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= cr.start and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= cr.end) - LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id) - LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id) - LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id) - WHERE c.current_operator_id IS NULL - AND ou.outcome_type_id IN (1,5) - AND (casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end )) - AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC'))) - AND ap.case_id is NULL - AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0) - AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL AND ou.outcome_type_id != 2) - AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL AND ou.outcome_type_id != 2) - AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) < qs.call_attempt_max)) - AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE `call`.case_id = c.case_id) < qs.call_max)) - AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE `questionnaire_sample_quota`.questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND `questionnaire_sample_quota`.quota_reached = 1) = 0 - -group by s.import_id"; - - $rs = $db->GetAll($sql); - - if (empty($rs)) - { - print "
" . T_("No cases currently available to call") . "
"; - } - else - { - xhtml_table($rs,array("description","available"),array(T_("Sample"),T_("Cases currently available to call")),"tclass",false,array("available")); - } - print "
"; - - $atime = get_average_time_questionnaire(10,$questionnaire_id); - $mins = intval($atime / 60); - $secs = $atime % 60; - - print "
" . T_("Average time on a completed questionnaire") . ": $mins " . T_("Min") . " $secs " . T_("Secs") . "
"; - - $sql = "SELECT o.calc, count( c.case_id ) - FROM `case` AS c, `outcome` AS o - WHERE c.questionnaire_id = '$questionnaire_id' - AND c.current_outcome_id = o.outcome_id - GROUP BY o.calc"; - - $a = $db->GetAssoc($sql); - $a = aapor_clean($a); - - print ""; // table-hover table table-condensed - 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) . "
"; - - $sql = "SELECT count(case_id) FROM `case` WHERE `case`.questionnaire_id = '$questionnaire_id'"; - $cases = $db->GetOne($sql); - - $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count, ROUND((count( c.case_id ) / $cases) * 100,2) as perc - FROM `case` AS c, `outcome` AS o - WHERE c.questionnaire_id = '$questionnaire_id' - AND c.current_outcome_id = o.outcome_id - GROUP BY o.outcome_id"; - - $rs = $db->GetAll($sql); - - if (!empty($rs)) - { print "
"; - //print "

" . T_("Total cases for questionnaire") . " = $cases

"; - translate_array($rs,array("des")); - xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count")," " . T_("%")),"tclass",false,array("count","perc"));//array("des" => "Complete") - print "
"; - - $sample_import_id = false; - if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); - - //display a list of samples - $sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM sample_import as s, questionnaire_sample as q - WHERE s.sample_import_id = q.sample_import_id - AND q.questionnaire_id = '$questionnaire_id'"; - - $r = $db->GetAll($sql); - - - print "

" . T_("Sample") . ": " . "

"; - if(!empty($r)) - display_chooser($r,"sample_import_id","sample_import_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left col-sm-4"); - else print "

" . T_("No samples assigned") . "

"; - if ($sample_import_id != false) - { - print "

" . T_("Sample status") . "

"; - - $sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn, - count(*) as count - FROM sample as s - JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id) - LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id) - WHERE s.import_id = '$sample_import_id' - GROUP BY (c.sample_id is not null)"; - - xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")), "tclass", false, array("count")); - print "
"; - - print "
"; //

" . T_("Outcomes") . "

"; - - - $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count,ROUND(count(c.case_id) / (SELECT count(case_id) FROM `case` JOIN sample ON (`case`.sample_id = sample.sample_id AND sample.import_id = '$sample_import_id') WHERE questionnaire_id = '$questionnaire_id' ) * 100,2) as perc - - FROM `case` AS c, `outcome` AS o, sample as s - WHERE c.questionnaire_id = '$questionnaire_id' - AND c.sample_id = s.sample_id - AND s.import_id = '$sample_import_id' - AND c.current_outcome_id = o.outcome_id - GROUP BY o.outcome_id"; - - $rs = $db->GetAll($sql); - - if (!empty($rs)) - { - translate_array($rs,array("des")); - xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc")); - } - else - print "

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

"; - - print "
"; - } - $operator_id = false; - if (isset($_GET['operator_id'])) $operator_id = bigintval($_GET['operator_id']); - - //display a list of operators !!!worked for this questionnaire_id !!!! - $sql = "SELECT s.operator_id as value, s.firstname as description, CASE WHEN s.operator_id = '$operator_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM `call` as c , `operator`as s, `case` as ca - WHERE ca.questionnaire_id = '$questionnaire_id' - AND ca.case_id = c.case_id - AND c.operator_id = s.operator_id - GROUP by c.operator_id"; - - $r = $db->GetAll($sql); - - print "

" . T_("Operator") . ": " . "

"; - if(!empty($r)) - display_chooser($r,"operator_id","operator_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left col-sm-4"); - else print "

" . T_("No operators assigned") . ". 

"; - print "" ; - if ($operator_id != false) - { - print "

" . T_("Operator call outcomes") . "

"; - - $sql = "SELECT o.description as des, o.outcome_id, count( c.call_id ) as count, ROUND((count(c.call_id) / (SELECT count(call.call_id) FROM `call` JOIN `case` ON (call.case_id = `case`.case_id AND `case`.questionnaire_id = $questionnaire_id ) WHERE call.operator_id = '$operator_id')) * 100,2) as perc - FROM `call` AS c, `case` as ca, `outcome` AS o - WHERE ca.questionnaire_id = '$questionnaire_id' - AND ca.case_id = c.case_id - AND c.operator_id = '$operator_id' - AND c.outcome_id = o.outcome_id - GROUP BY o.outcome_id"; - - $rs = $db->GetAll($sql); - - if (!empty($rs)) - { - translate_array($rs,array("des")); - xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc")); - } - print "
"; - } - - } - else - print "

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

"; - - - //display a list of shifts with completions and a link to either add a report or view reports - print "
"; - print "

" . T_("Shifts") . ":

"; - - $sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_FORMAT . "')) as sdate,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "'),'-', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as stime, - CASE WHEN sr.shift_id IS NULL THEN - CONCAT('') - ELSE CONCAT('') - END AS link, - c.completions as completions, - CONCAT('') as operform - FROM `shift` as s - JOIN operator as o on (o.operator_id = '$admin_operator_id') - LEFT JOIN shift_report as sr on (sr.shift_id = s.shift_id) - LEFT JOIN ( SELECT count(*) as completions,sh.shift_id - FROM `call` as a, `case` as b, shift as sh - WHERE a.outcome_id = '10' - AND a.case_id = b.case_id - AND b.questionnaire_id = '$questionnaire_id' - AND sh.start <= a.start - AND sh.end >= a.start - GROUP BY sh.shift_id) as c on (s.shift_id = c.shift_id) - WHERE s.questionnaire_id = '$questionnaire_id' - GROUP BY shift_id - ORDER BY s.start ASC"; - - $r = $db->GetAll($sql); - - if (empty($r)) - print "

" . T_("No shifts defined for this questionnaire") . "

"; - else { - print "
"; - print "
"; - xhtml_table($r,array("sdate","stime","completions","link","operform"),array(T_("Date"),T_("Shift time"),T_("Completions"),T_("Shift report"),T_("Operator performance")),"tclass"); - print "
"; - } -} - -xhtml_foot($js_foot); - -?> \ No newline at end of file +" . T_("Select a questionnaire") . ""; +display_questionnaire_chooser($questionnaire_id, false, "pull-left col-sm-4", "form-control"); +print "
"; +if ($questionnaire_id != false) +{ + //print "

" . T_("Outcomes") . "

"; + print "
" . T_("Sample status") . "
"; + + $sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn, + count(*) as count + FROM sample as s + JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id) + LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id) + GROUP BY (c.sample_id is not null)"; + if ($db->GetAll($sql)) xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")), "table-hover table table-condensed", false, array("count")); + else print "
" . T_("No samples assigned") . ". 
"; + print "
"; + + print "
" . T_("Case availability (cases with temporary or appointment outcomes)") ."
"; + + $sql = "SELECT count(c.case_id) as available, si.description + FROM `case` as c + LEFT JOIN `call` as a on (a.call_id = c.last_call_id) + JOIN (sample as s, sample_import as si) on (s.sample_id = c.sample_id and si.sample_import_id = s.import_id) + JOIN (questionnaire_sample as qs, questionnaire as q, outcome as ou) on (q.questionnaire_id = $questionnaire_id and c.questionnaire_id = q.questionnaire_id and qs.sample_import_id = s.import_id and qs.questionnaire_id = q.questionnaire_id and ou.outcome_id = c.current_outcome_id) + LEFT JOIN shift as sh on (sh.questionnaire_id = q.questionnaire_id and (CONVERT_TZ(NOW(),'System','UTC') >= sh.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= sh.end)) + LEFT JOIN appointment as ap on (ap.case_id = c.case_id AND ap.completed_call_id is NULL AND (ap.start > CONVERT_TZ(NOW(),'System','UTC'))) + LEFT JOIN appointment as apn on (apn.case_id = c.case_id AND apn.completed_call_id is NULL AND (CONVERT_TZ(NOW(),'System','UTC') >= apn.start) AND (CONVERT_TZ(NOW(),'System','UTC') <= apn.end)) + LEFT JOIN call_restrict as cr on (cr.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= cr.start and TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= cr.end) + LEFT JOIN questionnaire_sample_exclude_priority AS qsep ON (qsep.questionnaire_id = c.questionnaire_id AND qsep.sample_id = c.sample_id) + LEFT JOIN case_availability AS casa ON (casa.case_id = c.case_id) + LEFT JOIN availability AS ava ON (ava.availability_group_id = casa.availability_group_id) + WHERE c.current_operator_id IS NULL + AND ou.outcome_type_id IN (1,5) + AND (casa.case_id IS NULL OR (ava.day_of_week = DAYOFWEEK(CONVERT_TZ(NOW(),'System',s.Time_zone_name)) AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) >= ava.start AND TIME(CONVERT_TZ(NOW(), 'System' , s.Time_zone_name)) <= ava.end )) + AND (a.call_id is NULL or (a.end < CONVERT_TZ(DATE_SUB(NOW(), INTERVAL ou.default_delay_minutes MINUTE),'System','UTC'))) + AND ap.case_id is NULL + AND ((qsep.questionnaire_id is NULL) or qsep.exclude = 0) + AND !(q.restrict_work_shifts = 1 AND sh.shift_id IS NULL AND ou.outcome_type_id != 2) + AND !(si.call_restrict = 1 AND cr.day_of_week IS NULL AND ou.outcome_type_id != 2) + AND ((apn.appointment_id IS NOT NULL) or qs.call_attempt_max = 0 or ((SELECT count(*) FROM call_attempt WHERE call_attempt.case_id = c.case_id) < qs.call_attempt_max)) + AND ((apn.appointment_id IS NOT NULL) or qs.call_max = 0 or ((SELECT count(*) FROM `call` WHERE `call`.case_id = c.case_id) < qs.call_max)) + AND (SELECT count(*) FROM `questionnaire_sample_quota` WHERE `questionnaire_sample_quota`.questionnaire_id = c.questionnaire_id AND sample_import_id = s.import_id AND `questionnaire_sample_quota`.quota_reached = 1) = 0 + +group by s.import_id"; + + $rs = $db->GetAll($sql); + + if (empty($rs)) + { + print "
" . T_("No cases currently available to call") . "
"; + } + else + { + xhtml_table($rs,array("description","available"),array(T_("Sample"),T_("Cases currently available to call")),"tclass",false,array("available")); + } + print "
"; + + $atime = get_average_time_questionnaire(10,$questionnaire_id); + $mins = intval($atime / 60); + $secs = $atime % 60; + + print "
" . T_("Average time on a completed questionnaire") . ": $mins " . T_("Min") . " $secs " . T_("Secs") . "
"; + + $sql = "SELECT o.calc, count( c.case_id ) + FROM `case` AS c, `outcome` AS o + WHERE c.questionnaire_id = '$questionnaire_id' + AND c.current_outcome_id = o.outcome_id + GROUP BY o.calc"; + + $a = $db->GetAssoc($sql); + $a = aapor_clean($a); + + print ""; // table-hover table table-condensed + 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) . "
"; + + $sql = "SELECT count(case_id) FROM `case` WHERE `case`.questionnaire_id = '$questionnaire_id'"; + $cases = $db->GetOne($sql); + + $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count, ROUND((count( c.case_id ) / $cases) * 100,2) as perc + FROM `case` AS c, `outcome` AS o + WHERE c.questionnaire_id = '$questionnaire_id' + AND c.current_outcome_id = o.outcome_id + GROUP BY o.outcome_id"; + + $rs = $db->GetAll($sql); + + if (!empty($rs)) + { print "
"; + //print "

" . T_("Total cases for questionnaire") . " = $cases

"; + translate_array($rs,array("des")); + xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count")," " . T_("%")),"tclass",false,array("count","perc"));//array("des" => "Complete") + print "
"; + + $sample_import_id = false; + if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); + + //display a list of samples + $sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM sample_import as s, questionnaire_sample as q + WHERE s.sample_import_id = q.sample_import_id + AND q.questionnaire_id = '$questionnaire_id'"; + + $r = $db->GetAll($sql); + + + print "

" . T_("Sample") . ": " . "

"; + if(!empty($r)) + display_chooser($r,"sample_import_id","sample_import_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left col-sm-4"); + else print "

" . T_("No samples assigned") . "

"; + if ($sample_import_id != false) + { + print "

" . T_("Sample status") . "

"; + + $sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn, + count(*) as count + FROM sample as s + JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id) + LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id) + WHERE s.import_id = '$sample_import_id' + GROUP BY (c.sample_id is not null)"; + + xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")), "tclass", false, array("count")); + print "
"; + + print "
"; //

" . T_("Outcomes") . "

"; + + + $sql = "SELECT CONCAT('', o.description, '') as des, o.outcome_id, count( c.case_id ) as count,ROUND(count(c.case_id) / (SELECT count(case_id) FROM `case` JOIN sample ON (`case`.sample_id = sample.sample_id AND sample.import_id = '$sample_import_id') WHERE questionnaire_id = '$questionnaire_id' ) * 100,2) as perc + + FROM `case` AS c, `outcome` AS o, sample as s + WHERE c.questionnaire_id = '$questionnaire_id' + AND c.sample_id = s.sample_id + AND s.import_id = '$sample_import_id' + AND c.current_outcome_id = o.outcome_id + GROUP BY o.outcome_id"; + + $rs = $db->GetAll($sql); + + if (!empty($rs)) + { + translate_array($rs,array("des")); + xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc")); + } + else + print "

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

"; + + print "
"; + } + $operator_id = false; + if (isset($_GET['operator_id'])) $operator_id = bigintval($_GET['operator_id']); + + //display a list of operators !!!worked for this questionnaire_id !!!! + $sql = "SELECT s.operator_id as value, s.firstname as description, CASE WHEN s.operator_id = '$operator_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM `call` as c , `operator`as s, `case` as ca + WHERE ca.questionnaire_id = '$questionnaire_id' + AND ca.case_id = c.case_id + AND c.operator_id = s.operator_id + GROUP by c.operator_id"; + + $r = $db->GetAll($sql); + + print "

" . T_("Operator") . ": " . "

"; + if(!empty($r)) + display_chooser($r,"operator_id","operator_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left col-sm-4"); + else print "

" . T_("No operators assigned") . ". 

"; + print "" ; + if ($operator_id != false) + { + print "

" . T_("Operator call outcomes") . "

"; + + $sql = "SELECT o.description as des, o.outcome_id, count( c.call_id ) as count, ROUND((count(c.call_id) / (SELECT count(call.call_id) FROM `call` JOIN `case` ON (call.case_id = `case`.case_id AND `case`.questionnaire_id = $questionnaire_id ) WHERE call.operator_id = '$operator_id')) * 100,2) as perc + FROM `call` AS c, `case` as ca, `outcome` AS o + WHERE ca.questionnaire_id = '$questionnaire_id' + AND ca.case_id = c.case_id + AND c.operator_id = '$operator_id' + AND c.outcome_id = o.outcome_id + GROUP BY o.outcome_id"; + + $rs = $db->GetAll($sql); + + if (!empty($rs)) + { + translate_array($rs,array("des")); + xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc")); + } + print "
"; + } + + } + else + print "

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

"; + + + //display a list of shifts with completions and a link to either add a report or view reports + print "
"; + print "

" . T_("Shifts") . ":

"; + + $sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_FORMAT . "')) as sdate,CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "'),'-', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT . "')) as stime, + CASE WHEN sr.shift_id IS NULL THEN + CONCAT('') + ELSE CONCAT('') + END AS link, + c.completions as completions, + CONCAT('') as operform + FROM `shift` as s + JOIN operator as o on (o.operator_id = '$admin_operator_id') + LEFT JOIN shift_report as sr on (sr.shift_id = s.shift_id) + LEFT JOIN ( SELECT count(*) as completions,sh.shift_id + FROM `call` as a, `case` as b, shift as sh + WHERE a.outcome_id = '10' + AND a.case_id = b.case_id + AND b.questionnaire_id = '$questionnaire_id' + AND sh.start <= a.start + AND sh.end >= a.start + GROUP BY sh.shift_id) as c on (s.shift_id = c.shift_id) + WHERE s.questionnaire_id = '$questionnaire_id' + GROUP BY shift_id + ORDER BY s.start ASC"; + + $r = $db->GetAll($sql); + + if (empty($r)) + print "

" . T_("No shifts defined for this questionnaire") . "

"; + else { + print "
"; + print "
"; + xhtml_table($r,array("sdate","stime","completions","link","operform"),array(T_("Date"),T_("Shift time"),T_("Completions"),T_("Shift report"),T_("Operator performance")),"tclass"); + print "
"; + } +} + +xhtml_foot($js_foot); + +?> diff --git a/admin/questionnairelist.php b/admin/questionnairelist.php index 4795dd79..04629512 100644 --- a/admin/questionnairelist.php +++ b/admin/questionnairelist.php @@ -72,15 +72,15 @@ include("../include/ckeditor/ckeditor.php"); global $db; $css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/font-awesome-4.3.0/css/font-awesome.css", +"../include/bootstrap/css/bootstrap.min.css", +"../include/bootstrap/css/bootstrap-theme.min.css", +"../include/font-awesome/css/font-awesome.css", "../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css" ); $js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js" +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js" ); $js_foot = array( "../js/new.js", @@ -598,4 +598,4 @@ xhtml_foot($js_foot); ?> \ No newline at end of file + diff --git a/admin/questionnaireprefill.php b/admin/questionnaireprefill.php index 50562740..a5562098 100644 --- a/admin/questionnaireprefill.php +++ b/admin/questionnaireprefill.php @@ -1,196 +1,196 @@ - - * @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"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -global $db; - - -if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value'])) -{ - //need to add prefill to questionnaire - - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $value = $db->quote($_GET['value']); - $svar = $db->quote($_GET['svar']); - $sgqa = $db->quote($_GET['sgqa']); - - if (!empty($_GET['svar']) && empty($_GET['value'])) - $value = $svar; - - $sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value) - VALUES('$questionnaire_id',$sgqa,$value)"; - - $db->Execute($sql); - -} - -if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id'])) -{ - //need to remove prefill from questionnaire - - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']); - - $sql = "DELETE FROM questionnaire_prefill - WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'"; - - $db->Execute($sql); - -} - - -$questionnaire_id = false; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); - -xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); -print "

" . T_("Select a questionnaire") . ": 

"; - -$sql = "SELECT questionnaire_id as value,description, - CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM questionnaire - WHERE enabled = 1"; -display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline form-group"); - - -if ($questionnaire_id != false) -{ - print "

" . T_("Current pre fills") . "

"; - - $sql = "SELECT questionnaire_prefill_id,lime_sgqa,value - FROM questionnaire_prefill - WHERE questionnaire_id = '$questionnaire_id'"; - - $r = $db->GetAll($sql); - - if (empty($r)) - { - print "

" . T_("Currently no pre fills") . "

"; - } - else - { - foreach($r as $v) - { - print ""; - } - } - print ""; - - print "

" . T_("Select a question to pre fill") . " 

"; - - $sql = "SELECT lime_sid - FROM questionnaire - WHERE questionnaire_id = '$questionnaire_id'"; - - $r = $db->GetRow($sql); - - $lime_sid = $r['lime_sid']; - - $sgqa = false; - if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa']; - - $sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid) AS value, - CASE WHEN qo.question IS NULL THEN q.question ELSE CONCAT(qo.question,' : ',q.question) END as description, - CASE WHEN CONCAT(q.sid, 'X', q.gid, 'X', q.qid) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM `" . LIME_PREFIX . "questions` AS q - LEFT JOIN `" . LIME_PREFIX . "questions` as qo ON (qo.qid = q.parent_qid) - WHERE q.sid = '$lime_sid' - ORDER BY CASE WHEN qo.question_order IS NULL THEN q.question_order ELSE qo.question_order + (q.question_order / 1000) END ASC"; - - $rs = $db->GetAll($sql); - - for ($i=0; $i"; - - if ($sgqa != false) - { - print "

" . T_("Enter a value to pre fill this question with:") . "

"; - print "

"; - print T_("Possible uses:"); - print "

"; - - $sql = "SELECT sivr.var as description, CONCAT('{Sample:', sivr.var, '}') as value - FROM `sample_import_var_restrict` as sivr, questionnaire_sample as qs - WHERE qs.questionnaire_id = '$questionnaire_id' - AND sivr.sample_import_id = qs.sample_import_id"; - ?> -
- - -GetAll($sql),"svar","svar",true,false,false,true,false,true,"form-group"); -?> - - - "/> -
- \ No newline at end of file + + * @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"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +global $db; + + +if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value'])) +{ + //need to add prefill to questionnaire + + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $value = $db->quote($_GET['value']); + $svar = $db->quote($_GET['svar']); + $sgqa = $db->quote($_GET['sgqa']); + + if (!empty($_GET['svar']) && empty($_GET['value'])) + $value = $svar; + + $sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value) + VALUES('$questionnaire_id',$sgqa,$value)"; + + $db->Execute($sql); + +} + +if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id'])) +{ + //need to remove prefill from questionnaire + + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']); + + $sql = "DELETE FROM questionnaire_prefill + WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'"; + + $db->Execute($sql); + +} + + +$questionnaire_id = false; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); + +xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); +print "

" . T_("Select a questionnaire") . ": 

"; + +$sql = "SELECT questionnaire_id as value,description, + CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM questionnaire + WHERE enabled = 1"; +display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline form-group"); + + +if ($questionnaire_id != false) +{ + print "

" . T_("Current pre fills") . "

"; + + $sql = "SELECT questionnaire_prefill_id,lime_sgqa,value + FROM questionnaire_prefill + WHERE questionnaire_id = '$questionnaire_id'"; + + $r = $db->GetAll($sql); + + if (empty($r)) + { + print "

" . T_("Currently no pre fills") . "

"; + } + else + { + foreach($r as $v) + { + print ""; + } + } + print ""; + + print "

" . T_("Select a question to pre fill") . " 

"; + + $sql = "SELECT lime_sid + FROM questionnaire + WHERE questionnaire_id = '$questionnaire_id'"; + + $r = $db->GetRow($sql); + + $lime_sid = $r['lime_sid']; + + $sgqa = false; + if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa']; + + $sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid) AS value, + CASE WHEN qo.question IS NULL THEN q.question ELSE CONCAT(qo.question,' : ',q.question) END as description, + CASE WHEN CONCAT(q.sid, 'X', q.gid, 'X', q.qid) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM `" . LIME_PREFIX . "questions` AS q + LEFT JOIN `" . LIME_PREFIX . "questions` as qo ON (qo.qid = q.parent_qid) + WHERE q.sid = '$lime_sid' + ORDER BY CASE WHEN qo.question_order IS NULL THEN q.question_order ELSE qo.question_order + (q.question_order / 1000) END ASC"; + + $rs = $db->GetAll($sql); + + for ($i=0; $i"; + + if ($sgqa != false) + { + print "

" . T_("Enter a value to pre fill this question with:") . "

"; + print "

"; + print T_("Possible uses:"); + print "

    "; + print "
  • " . T_("{Respondent:firstName} First name of the respondent") . "
  • "; + print "
  • " . T_("{Respondent:lastName} Last name of the respondent") . "
  • "; + print "
  • " . T_("{Sample:var} A record from the sample where the column name is 'var'") . "
  • "; + print "
"; + + $sql = "SELECT sivr.var as description, CONCAT('{Sample:', sivr.var, '}') as value + FROM `sample_import_var_restrict` as sivr, questionnaire_sample as qs + WHERE qs.questionnaire_id = '$questionnaire_id' + AND sivr.sample_import_id = qs.sample_import_id"; + ?> +
+ + +GetAll($sql),"svar","svar",true,false,false,true,false,true,"form-group"); +?> + + + "/> +
+ diff --git a/admin/quota.php b/admin/quota.php index 54614f16..e3ea4bde 100755 --- a/admin/quota.php +++ b/admin/quota.php @@ -1,261 +1,261 @@ - - * @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"); - -/** - * 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($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison'])) -{ - //need to add quota - - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $sample_import_id = bigintval($_GET['sample_import_id']); - $value = $db->quote($_GET['value']); - $completions = $db->quote($_GET['completions']); - $sgqa = $db->quote($_GET['sgqa']); - $comparison = $db->quote($_GET['comparison']); - - $sql = "INSERT INTO questionnaire_sample_quota(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison) - VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison)"; - - $db->Execute($sql); - - //Make sure to calculate on the spot - update_quotas($questionnaire_id); -} - -if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_id'])) -{ - //need to remove quota - - $questionnaire_id = bigintval($_GET['questionnaire_id']); - $questionnaire_sample_quota_id = bigintval($_GET['questionnaire_sample_quota_id']); - - $sql = "DELETE FROM questionnaire_sample_quota - WHERE questionnaire_sample_quota_id = '$questionnaire_sample_quota_id'"; - - $db->Execute($sql); - -} - -$questionnaire_id = false; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); - -xhtml_head(T_("Quota management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); -print "

" . T_("Questionnaire") . ": 

"; - -$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM questionnaire - WHERE enabled = 1"; -display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline pull-left "); - -if ($questionnaire_id != false) -{ - $sample_import_id = false; - if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); - - - - $sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM sample_import as s, questionnaire_sample as q - WHERE q.questionnaire_id = $questionnaire_id - AND q.sample_import_id = s.sample_import_id"; - $s = $db->GetAll($sql); - if (!empty($s)){ - - print "

   " . T_("Sample") . ":  

"; - display_chooser($db->GetAll($sql),"sample","sample_import_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left"); - - } else { - print "
" . T_("No samples assigned to this questionnaire.") . "
"; - - } - - print "
"; - - if ($sample_import_id != false) - { - print "

" . T_("Current quotas") . ":

";//(click to delete) - - $sql = "SELECT questionnaire_sample_quota_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison - FROM questionnaire_sample_quota as qsq, questionnaire as q - WHERE qsq.questionnaire_id = '$questionnaire_id' - AND qsq.sample_import_id = '$sample_import_id' - AND q.questionnaire_id = '$questionnaire_id'"; - - $r = $db->GetAll($sql); - - if (empty($r)) - { - print "

" . T_("Currently no quotas") . "

"; - } - else - { - foreach($r as $v) - { - print "
" . T_("Stop calling this sample when:") . " {$v['lime_sgqa']} {$v['comparison']} {$v['value']} " . T_("for") . ": {$v['completions']} " . T_("completions") ." - "; - - if ($v['quota_reached'] == 1) - print T_("Quota reached"); - else - print T_("Quota not yet reached"); - - print " - " . T_("Current completions: ") . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']); - - print "
"; - - } - } - - - print "

" . T_("Select a question for the quota") . "

"; - - $sql = "SELECT lime_sid - FROM questionnaire - WHERE questionnaire_id = '$questionnaire_id'"; - - $r = $db->GetRow($sql); - - $lime_sid = $r['lime_sid']; - - $sgqa = false; - if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa']; - - $sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, - CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, - CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM `" . LIME_PREFIX . "questions` AS lq - LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid ) - JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid) - WHERE lq.sid = '$lime_sid' - ORDER BY CASE WHEN lq2.question_order IS NULL THEN lq.question_order ELSE lq2.question_order + (lq.question_order / 1000) END ASC"; - - display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id",true,true,false,true,"form-group"); - - print "
"; - - if ($sgqa != false) - { - - print "

" . T_("Enter the details for creating the quota:") . "

"; - - ?> -
- -

-

- -

-

- -

-

- - - - - -

" class="btn btn-primary fa"/>

-
- "; - - print "

" . T_("Code values for this question") . ":

"; - - $qid = explode("X", $sgqa); - $qid = $qid[2]; - - $sql = "SELECT CONCAT(' ', l.code , '')as code,l.answer as title - FROM `" . LIME_PREFIX . "answers` as l - WHERE l.qid = '$qid'"; - - $rs = $db->GetAll($sql); - - if (!isset($rs) || empty($rs)) - print "

" . T_("No labels defined for this question") ."

"; - else - xhtml_table($rs,array('code','title'),array(T_("Code value"), T_("Description"))); - - - print "
"; - - } - } -} - -xhtml_foot(); - -?> \ No newline at end of file + + * @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"); + +/** + * 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($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison'])) +{ + //need to add quota + + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $sample_import_id = bigintval($_GET['sample_import_id']); + $value = $db->quote($_GET['value']); + $completions = $db->quote($_GET['completions']); + $sgqa = $db->quote($_GET['sgqa']); + $comparison = $db->quote($_GET['comparison']); + + $sql = "INSERT INTO questionnaire_sample_quota(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison) + VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison)"; + + $db->Execute($sql); + + //Make sure to calculate on the spot + update_quotas($questionnaire_id); +} + +if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_id'])) +{ + //need to remove quota + + $questionnaire_id = bigintval($_GET['questionnaire_id']); + $questionnaire_sample_quota_id = bigintval($_GET['questionnaire_sample_quota_id']); + + $sql = "DELETE FROM questionnaire_sample_quota + WHERE questionnaire_sample_quota_id = '$questionnaire_sample_quota_id'"; + + $db->Execute($sql); + +} + +$questionnaire_id = false; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); + +xhtml_head(T_("Quota management"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); +print "

" . T_("Questionnaire") . ": 

"; + +$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM questionnaire + WHERE enabled = 1"; +display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline pull-left "); + +if ($questionnaire_id != false) +{ + $sample_import_id = false; + if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); + + + + $sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM sample_import as s, questionnaire_sample as q + WHERE q.questionnaire_id = $questionnaire_id + AND q.sample_import_id = s.sample_import_id"; + $s = $db->GetAll($sql); + if (!empty($s)){ + + print "

   " . T_("Sample") . ":  

"; + display_chooser($db->GetAll($sql),"sample","sample_import_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left"); + + } else { + print "
" . T_("No samples assigned to this questionnaire.") . "
"; + + } + + print "
"; + + if ($sample_import_id != false) + { + print "

" . T_("Current quotas") . ":

";//(click to delete) + + $sql = "SELECT questionnaire_sample_quota_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison + FROM questionnaire_sample_quota as qsq, questionnaire as q + WHERE qsq.questionnaire_id = '$questionnaire_id' + AND qsq.sample_import_id = '$sample_import_id' + AND q.questionnaire_id = '$questionnaire_id'"; + + $r = $db->GetAll($sql); + + if (empty($r)) + { + print "

" . T_("Currently no quotas") . "

"; + } + else + { + foreach($r as $v) + { + print "
" . T_("Stop calling this sample when:") . " {$v['lime_sgqa']} {$v['comparison']} {$v['value']} " . T_("for") . ": {$v['completions']} " . T_("completions") ." - "; + + if ($v['quota_reached'] == 1) + print T_("Quota reached"); + else + print T_("Quota not yet reached"); + + print " - " . T_("Current completions: ") . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']); + + print "
"; + + } + } + + + print "

" . T_("Select a question for the quota") . "

"; + + $sql = "SELECT lime_sid + FROM questionnaire + WHERE questionnaire_id = '$questionnaire_id'"; + + $r = $db->GetRow($sql); + + $lime_sid = $r['lime_sid']; + + $sgqa = false; + if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa']; + + $sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, + CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, + CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM `" . LIME_PREFIX . "questions` AS lq + LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid ) + JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid) + WHERE lq.sid = '$lime_sid' + ORDER BY CASE WHEN lq2.question_order IS NULL THEN lq.question_order ELSE lq2.question_order + (lq.question_order / 1000) END ASC"; + + display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id",true,true,false,true,"form-group"); + + print "
"; + + if ($sgqa != false) + { + + print "

" . T_("Enter the details for creating the quota:") . "

"; + + ?> +
+ +

+

+ +

+

+ +

+

+ + + + + +

" class="btn btn-primary fa"/>

+
+ "; + + print "

" . T_("Code values for this question") . ":

"; + + $qid = explode("X", $sgqa); + $qid = $qid[2]; + + $sql = "SELECT CONCAT(' ', l.code , '')as code,l.answer as title + FROM `" . LIME_PREFIX . "answers` as l + WHERE l.qid = '$qid'"; + + $rs = $db->GetAll($sql); + + if (!isset($rs) || empty($rs)) + print "

" . T_("No labels defined for this question") ."

"; + else + xhtml_table($rs,array('code','title'),array(T_("Code value"), T_("Description"))); + + + print "
"; + + } + } +} + +xhtml_foot(); + +?> diff --git a/admin/quotareport.php b/admin/quotareport.php index 880effc2..a915574d 100644 --- a/admin/quotareport.php +++ b/admin/quotareport.php @@ -106,7 +106,7 @@ if (isset($_POST['submit'])) $db->CompleteTrans(); } -xhtml_head(T_("Quota report"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/iCheck/icheck.min.js","../js/window.js")); +xhtml_head(T_("Quota report"),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/bootstrap/js/bootstrap.min.js","../include/iCheck/icheck.min.js","../js/window.js")); print "

" . T_("Select a questionnaire") . ": 

"; @@ -310,4 +310,4 @@ $('input').iCheck({ checkboxClass: 'icheckbox_square-blue', increaseArea: '30%' }); - \ No newline at end of file + diff --git a/admin/quotarow.php b/admin/quotarow.php index 2a9db12a..ce222500 100755 --- a/admin/quotarow.php +++ b/admin/quotarow.php @@ -284,7 +284,7 @@ if (isset($_GET['qsqri']) & isset($_GET['edit'])) $questionnaire_id = false; if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); -xhtml_head(T_("Quota row management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../include/iCheck/icheck.min.js","../js/window.js")); +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_("Questionnaire") . ": 

"; $sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected @@ -623,4 +623,4 @@ $('input').iCheck({ checkboxClass: 'icheckbox_square-blue', increaseArea: '30%' }); - \ No newline at end of file + diff --git a/admin/samplecallattempts.php b/admin/samplecallattempts.php index 5ea6e597..5cf2a794 100644 --- a/admin/samplecallattempts.php +++ b/admin/samplecallattempts.php @@ -181,7 +181,7 @@ function sample_call_attempt_report($questionnaire_id = false, $sample_id = fals } -xhtml_head(T_("Sample call attempt"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); +xhtml_head(T_("Sample call attempt"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); print "

" . T_("Please select a questionnaire") . " 

"; $questionnaire_id = false; diff --git a/admin/samplelist.php b/admin/samplelist.php index bf0c7c34..3acd3f08 100644 --- a/admin/samplelist.php +++ b/admin/samplelist.php @@ -1,506 +1,506 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/software queXS was writen for ACSPRI - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database - */ -include_once(dirname(__FILE__).'/../db.inc.php'); - -/** - * XHTML functions - */ -include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/font-awesome-4.3.0/css/font-awesome.css", -"../include/bootstrap-toggle/css/bootstrap-toggle.min.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -"../include/bootstrap-toggle/js/bootstrap-toggle.min.js", - ); -$js_foot = array( -"../js/bootstrap-confirmation.js", -"../js/custom.js" - ); - -if (isset($_POST['ren'])) -{ - $sample_import_id = intval($_POST['sample_import_id']); - - unset($_POST['ren']); - unset($_POST['sample_import_id']); - - $sql = "UPDATE sample_import - SET description = " . $db->qstr($_POST['description']) . " - WHERE sample_import_id = $sample_import_id"; - - $db->Execute($sql); - - $_GET['edit'] = $sample_import_id; -} - - -if (isset($_POST['ed'])) -{ - $sample_import_id = intval($_POST['sample_import_id']); - - unset($_POST['ed']); - unset($_POST['sample_import_id']); - -// print_r($_POST). "
"; //ïîñìîòðèì ÷åãî îòðàâëÿåòñÿ - - if (isset($_POST['del']) && isset($_POST['type']) ) { - $a = array(); $b = array(); $cert = array(); $a = $_POST['type']; - - //echo "

type before unset->>"; foreach($_POST['type'] as $key => $val) { echo ' | ', $key,' => ',$val,' | '; }; print "

"; - - foreach($_POST['del'] as $p) { - unset ($_POST['type'][$p]); - $deleted[] = $p; - } - $b = $_POST['type']; $cert = array_diff_assoc($a, $b); - - foreach($cert as $key => $val ) { - - if ($val == 3 || $val==4 || $val == 5 || $val == 6 || $val == 7){ - echo "
", T_("Attention!! It's not recommended to delete string '$key'.
Please BE Careful and check again strings to delete."), "
"; - } - /* else { echo "
", T_("You can delete string '$key'. "), "
"; } */ - } - //echo "

del ->>"; foreach($_POST['del'] as $key => $val) { echo ' | ', $key,' => ',$val,' | '; }; print "

"; - } - - if (isset($_POST['type'])){ - - //check that we have correct var types and quantity - $prph = 0; $pcd = 0; $st = 0; $fn = 0; $eml =0; - foreach($_POST['type'] as $key => $val) { - if ($val == 3) $prph++; - else if ($val == 5) $pcd++; - else if ($val == 4) $st++; - else if ($val == 6) $fn++; - else if ($val == 7) $ln++; - else if ($val == 8) $eml++; - } - /* if($prph == 1) {$ch1 = true;} - else { echo "
", T_("Please check that One and One Only Primary Phone number is selected"), "
";} - - if (( ($pcd +$st) <= 2 )&&($pcd == 1 || $st == 1)) {$ch2 = true;} - else { echo "
", T_("Please check selected types for Postcode and/or State"), "
";} -// ! need to add DB tables check for existing timezone data in tables and additional check if prefix_timezone selected - if (( ($fn + $ln) <= 2 )&&($fn == 1 || $ln == 1)) {$ch3 = true;} - else { echo "
", T_("Please check selected types for Firstname and/or Lastname"), "
";} - if ($eml < 2) {$ch4 = true;} - else { echo "
", T_("Too many e-mail fields. Please check selected types for E-mail."), "
"; } - - if ($ch1 && $ch2 && $ch3 && $ch4) */$typecheck = true; //echo $ch1,$ch2,$ch3,$ch4, "typecheck=",$typecheck, "
" ; - - if ($typecheck){ - - foreach($_POST['type'] as $p => $val) - { - $sql = "UPDATE sample_import_var_restrict - SET `type` = $val - WHERE `var_id` = $p"; - $db->Execute($sql); - } - - if (isset($_POST['del'])) { - $db->StartTrans(); - - foreach($_POST["del"] as $p) { - $sql = "DELETE FROM `sample_import_var_restrict` - WHERE var_id = $p"; - $db->Execute($sql); - echo "
", T_(" String $p DELETED"), "
"; - - $sql = "DELETE FROM `sample_var` - WHERE var_id = $p - AND sample_id IN (SELECT sample_id FROM `sample` WHERE import_id = $sample_import_id)"; - $db->Execute($sql); - echo "
", T_(" Sample_Var data for variable $p DELETED from this sample"), "
"; - } - unset($_POST['del']); - - $db->CompleteTrans(); - - } - } - else { - echo "
", T_("Smth wrong with selected field types.
Please check again var types selection and/or fields that you supposed to delete."), "
"; - //exit (); - } - } - - if (isset($_POST['var'])){ - - foreach($_POST['var'] as $p => $val) - {// echo '| ',$p,' => ',$val,'+ '; - $v = str_replace(" ", "_", $val); - - $sql = "UPDATE sample_import_var_restrict - SET `var` = '$v' - WHERE sample_import_id = $sample_import_id - AND `var_id` = $p"; - $db->Execute($sql); - } - - unset($_POST['var']); - } - - if (isset($_POST['see'])){ - - $sql = "UPDATE sample_import_var_restrict - SET `restrict` = 1 - WHERE sample_import_id = $sample_import_id"; - $db->Execute($sql); - - foreach($_POST['see'] as $p => $val) - {// echo $p,' => ',$val,' + '; - $sql = "UPDATE sample_import_var_restrict - SET `restrict` = 0 - WHERE sample_import_id = $sample_import_id - AND `var_id` = $val"; - $db->Execute($sql); - } - unset($_POST['see']); - } - - unset($_POST['type']); - - $_GET['edit'] = $sample_import_id; - -} - -if (isset($_GET['delete_sample'])){ - - $sample_import_id = $_GET['delete_sample']; - - // -->check questionnaire_sample - unassign sample if assigned - $sql = "SELECT questionnaire_id FROM `questionnaire_sample` WHERE sample_import_id = $sample_import_id"; - $rs = $db->GetAll($sql); - if (count($rs) != 0){ - echo "
", T_("Sample $sample_import_id is still assigned to questionnaire.
Please unassign sample prior to delete."), "
"; - } - else{ - //get the string list of sample_id's - $sql = "SELECT sample_id FROM `sample` where import_id = $sample_import_id"; - $rs = $db->GetAll($sql); - for($i=0;$i<=count($rs)-1;$i++){ $samimdel[] = $rs[$i]['sample_id'] ;} - $samimdel_s = implode(",",$samimdel); - - $db->StartTrans(); - - //del from questionnaire_sample_exclude_priority - $sql = "DELETE FROM `questionnaire_sample_exclude_priority` WHERE sample_id IN ($samimdel_s)"; - $db->Execute($sql); - - //del from questionnaire_sample_quota - $sql = "DELETE FROM `questionnaire_sample_quota` WHERE sample_import_id = $sample_import_id"; - $db->Execute($sql); - - //del from questionnaire_sample_quota_row - $sql = "DELETE FROM `questionnaire_sample_quota_row` WHERE sample_import_id = $sample_import_id"; - $db->Execute($sql); - - //del from questionnaire_sample_quota_row_exclude - $sql = "DELETE FROM `questionnaire_sample_quota_row_exclude` WHERE sample_id IN ($samimdel_s)"; - $db->Execute($sql); - - //del from questionnaire_sample_timeslot - $sql = "DELETE FROM `questionnaire_sample_timeslot` WHERE sample_import_id = $sample_import_id"; - $db->Execute($sql); - - //delete from sample_var - $sql = "DELETE FROM `sample_var` WHERE sample_id IN ($samimdel_s)"; - $db->Execute($sql); - - //del from sample_import_var_restrict - $sql = "DELETE FROM `sample_import_var_restrict` WHERE sample_import_id = $sample_import_id"; - $db->Execute($sql); - - //del from sample - $sql = "DELETE FROM `sample` WHERE import_id = $sample_import_id"; - $db->Execute($sql); - - //del from sample_import - $sql = "DELETE FROM `sample_import` WHERE sample_import_id = $sample_import_id"; - $db->Execute($sql); - - $db->CompleteTrans(); - - if (mysql_errno() == 0){echo "
", T_("Sample $sample_import_id was deleted."), "
"; } - else {echo "
ERROR ".mysql_errno()." ".mysql_error()."\n
";} - } - - unset($_GET['delete_sample']); - $samimdel_s = ''; -} - - -if (isset($_GET['edit']) ) -{ - $subtitle=T_("Rename, Set viewing permissions & Manage sample variables") ; - xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle); - - echo ""; - - $sample_import_id = intval($_GET['edit']); - - $sql = "SELECT * FROM sample_import WHERE sample_import_id = $sample_import_id"; - $sd = $db->GetRow($sql); - - if($sd['enabled'] == 1) $dis = disabled; // -> disable edit and delete if sample is enabled - - $sql = "SELECT type, description - FROM sample_var_type"; - $rd = $db->GetAll($sql); - - $sql = "SELECT sir.var_id, - CONCAT('') as var, - CONCAT ('') as type, sv.val, - CONCAT('') as see, - CONCAT('') as del, - sir.restrict IS NULL as existss - FROM sample_import as si, sample_var as sv, sample as s, sample_import_var_restrict as sir, sample_var_type as svt - WHERE si.sample_import_id = $sample_import_id - AND sir.sample_import_id = si.sample_import_id - AND sir.var_id = sv.var_id - AND sv.sample_id = s.sample_id - AND s.import_id = si.sample_import_id - AND svt.type = sir.type - GROUP BY sir.var_id"; - $rs = $db->GetAll($sql); - - print "

" . T_("Sample") . ": " . $sd['description'] . " ID $sample_import_id

"; - print ""; - print "
"; - - if($sd['enabled'] == 0){ - -?> -
-
-

-
/>
-
-
-
-
- -
- -
-
-
-
-
- -

" . T_("Select which fields from this sample to deidentify.

Deidentified fields will be permanently deleted from the sample.") . "

"; - } -else -{ - print ""; - - /*check `Time_zone_name` and `phone` values for deidentified records*/ - $sql = "SELECT `sample`.sample_id FROM `sample` - LEFT JOIN `sample_var` ON (`sample`.sample_id = `sample_var`.sample_id) - WHERE `sample_var`.sample_id IS NULL - AND `sample`.import_id = $sample_import_id - AND (`sample`.Time_zone_name !='' || `sample`.phone !='')"; - $rs = $db->GetAll($sql); - - if (!empty($rs)) { - $num = count($rs); - print "

" . T_("There're still $num records for `Time_zone_name` and `phone` values for deidentified records") . "

"; - - print "
"; - } - -} - - unset ($rs); - - /*check if there's sample_var data not matching sample_import_var_restrict.var_id */ - $sql = "SELECT `sv`.var_id, `sv`.var, `sv`.type FROM `sample_var` as sv - LEFT JOIN `sample_import_var_restrict` as sivr ON (`sivr`.var_id = `sv`.var_id) - WHERE `sivr`.var_id IS NULL - AND `sv`.sample_id IN (SELECT sample_id FROM `sample` WHERE import_id = $sample_import_id) - GROUP BY `sv`.var_id"; - - $rs = $db->GetAll($sql); - if (!empty($rs)) { - $count = count($rs); - //print_r($rs); - print "

" . T_("Fix this sample ") . "

"; - print "

" . $count . " var id's not match

"; - -/* print "
- - - -
"; */ - print "
"; - - /* if (isset($_POST['restore___'])){ - $sql = "INSERT INTO sample_import_var_restrict - (`sample_import_id`,`var_id`,`var`,`type`,`restrict`) - VALUES ($sample_import_id,' ',' ',' ',1)"; - - $db->Execute($sql); - unset($_POST['restore___']); - } - if (isset($_POST['delvarf___'])){ - $sql = ""; - - $db->Execute($sql); - unset($_POST['delvarf___']); - } */ - - unset($rs); - } - - if (isset($_POST['dtzph'])){ - - /*delete `Time_zone_name` and `phone` values for deidentified records*/ - $db->StartTrans(); - - $sql = "UPDATE `sample` - LEFT JOIN `sample_var` ON (`sample`.sample_id = `sample_var`.sample_id) - SET `Time_zone_name`='',`phone`='' - WHERE `sample_var`.sample_id IS NULL - AND `sample`.import_id = $sample_import_id"; - $db->Execute($sql); - - unset($_POST['dtzph']); - - $db->CompleteTrans(); - } - - xhtml_foot($js_foot); - exit(); -} - -if (isset($_GET['sampledisable'])) -{ - $id = intval($_GET['sampledisable']); - - $sql = "UPDATE sample_import - SET enabled = 0 - WHERE sample_import_id = '$id'"; - $db->Execute($sql); -} - -if (isset($_GET['sampleenable'])) -{ - $id = intval($_GET['sampleenable']); - - $sql = "UPDATE sample_import - SET enabled = 1 - WHERE sample_import_id = '$id'"; - $db->Execute($sql); -} - -$sql = "SELECT - CONCAT(' ',sample_import_id,' ') as id, - CASE WHEN enabled = 0 THEN - CONCAT('  " . TQ_("Disabled") . " ') - ELSE - CONCAT('  " . TQ_("Enabled") . " ') - END as status, - CASE WHEN enabled = 0 THEN - CONCAT('" . TQ_("Enable") . " ') - ELSE - CONCAT('  " . TQ_("Disable") . " ') - END - as enabledisable, - CASE WHEN enabled = 1 THEN - CONCAT('') - ELSE - CONCAT(' + + ') - END as did, - CASE WHEN enabled = 1 THEN - CONCAT('') - ELSE - CONCAT('') - END as delsample, - CONCAT('') as ssearch, - CONCAT('') as calls, - CONCAT('

',description,' 

') as description, - CONCAT('

',(SELECT COUNT( DISTINCT`sample_var`.sample_id) FROM `sample_var`, `sample` WHERE `sample`.sample_id = `sample_var`.sample_id AND `sample`.import_id = sample_import_id ),' 

') as cnt - FROM sample_import ORDER BY sample_import_id DESC"; - - $rs = $db->GetAll($sql); - -$subtitle=T_("Sample list"); -xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle); -echo ""; -$columns = array("id","description","cnt","status","enabledisable","calls","did","ssearch","delsample"); //"vp","rname", -//$titles = array(T_("ID"),T_("Sample"),T_("Records"), T_("Call History"),T_("Enable/Disable"), T_("Status"), T_("Deidentify"), T_("View"), T_("Rename"), T_("Search"), T_("Delete sample")); -xhtml_table($rs,$columns, false, "table-hover table-condensed "); - -xhtml_foot($js_foot); -?> - \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/software queXS was writen for ACSPRI + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database + */ +include_once(dirname(__FILE__).'/../db.inc.php'); + +/** + * XHTML functions + */ +include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +"../include/bootstrap/css/bootstrap-theme.min.css", +"../include/font-awesome/css/font-awesome.css", +"../include/bootstrap-toggle/css/bootstrap-toggle.min.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js", +"../include/bootstrap-toggle/js/bootstrap-toggle.min.js", + ); +$js_foot = array( +"../js/bootstrap-confirmation.js", +"../js/custom.js" + ); + +if (isset($_POST['ren'])) +{ + $sample_import_id = intval($_POST['sample_import_id']); + + unset($_POST['ren']); + unset($_POST['sample_import_id']); + + $sql = "UPDATE sample_import + SET description = " . $db->qstr($_POST['description']) . " + WHERE sample_import_id = $sample_import_id"; + + $db->Execute($sql); + + $_GET['edit'] = $sample_import_id; +} + + +if (isset($_POST['ed'])) +{ + $sample_import_id = intval($_POST['sample_import_id']); + + unset($_POST['ed']); + unset($_POST['sample_import_id']); + +// print_r($_POST). "
"; //ïîñìîòðèì ÷åãî îòðàâëÿåòñÿ + + if (isset($_POST['del']) && isset($_POST['type']) ) { + $a = array(); $b = array(); $cert = array(); $a = $_POST['type']; + + //echo "

type before unset->>"; foreach($_POST['type'] as $key => $val) { echo ' | ', $key,' => ',$val,' | '; }; print "

"; + + foreach($_POST['del'] as $p) { + unset ($_POST['type'][$p]); + $deleted[] = $p; + } + $b = $_POST['type']; $cert = array_diff_assoc($a, $b); + + foreach($cert as $key => $val ) { + + if ($val == 3 || $val==4 || $val == 5 || $val == 6 || $val == 7){ + echo "
", T_("Attention!! It's not recommended to delete string '$key'.
Please BE Careful and check again strings to delete."), "
"; + } + /* else { echo "
", T_("You can delete string '$key'. "), "
"; } */ + } + //echo "

del ->>"; foreach($_POST['del'] as $key => $val) { echo ' | ', $key,' => ',$val,' | '; }; print "

"; + } + + if (isset($_POST['type'])){ + + //check that we have correct var types and quantity + $prph = 0; $pcd = 0; $st = 0; $fn = 0; $eml =0; + foreach($_POST['type'] as $key => $val) { + if ($val == 3) $prph++; + else if ($val == 5) $pcd++; + else if ($val == 4) $st++; + else if ($val == 6) $fn++; + else if ($val == 7) $ln++; + else if ($val == 8) $eml++; + } + /* if($prph == 1) {$ch1 = true;} + else { echo "
", T_("Please check that One and One Only Primary Phone number is selected"), "
";} + + if (( ($pcd +$st) <= 2 )&&($pcd == 1 || $st == 1)) {$ch2 = true;} + else { echo "
", T_("Please check selected types for Postcode and/or State"), "
";} +// ! need to add DB tables check for existing timezone data in tables and additional check if prefix_timezone selected + if (( ($fn + $ln) <= 2 )&&($fn == 1 || $ln == 1)) {$ch3 = true;} + else { echo "
", T_("Please check selected types for Firstname and/or Lastname"), "
";} + if ($eml < 2) {$ch4 = true;} + else { echo "
", T_("Too many e-mail fields. Please check selected types for E-mail."), "
"; } + + if ($ch1 && $ch2 && $ch3 && $ch4) */$typecheck = true; //echo $ch1,$ch2,$ch3,$ch4, "typecheck=",$typecheck, "
" ; + + if ($typecheck){ + + foreach($_POST['type'] as $p => $val) + { + $sql = "UPDATE sample_import_var_restrict + SET `type` = $val + WHERE `var_id` = $p"; + $db->Execute($sql); + } + + if (isset($_POST['del'])) { + $db->StartTrans(); + + foreach($_POST["del"] as $p) { + $sql = "DELETE FROM `sample_import_var_restrict` + WHERE var_id = $p"; + $db->Execute($sql); + echo "
", T_(" String $p DELETED"), "
"; + + $sql = "DELETE FROM `sample_var` + WHERE var_id = $p + AND sample_id IN (SELECT sample_id FROM `sample` WHERE import_id = $sample_import_id)"; + $db->Execute($sql); + echo "
", T_(" Sample_Var data for variable $p DELETED from this sample"), "
"; + } + unset($_POST['del']); + + $db->CompleteTrans(); + + } + } + else { + echo "
", T_("Smth wrong with selected field types.
Please check again var types selection and/or fields that you supposed to delete."), "
"; + //exit (); + } + } + + if (isset($_POST['var'])){ + + foreach($_POST['var'] as $p => $val) + {// echo '| ',$p,' => ',$val,'+ '; + $v = str_replace(" ", "_", $val); + + $sql = "UPDATE sample_import_var_restrict + SET `var` = '$v' + WHERE sample_import_id = $sample_import_id + AND `var_id` = $p"; + $db->Execute($sql); + } + + unset($_POST['var']); + } + + if (isset($_POST['see'])){ + + $sql = "UPDATE sample_import_var_restrict + SET `restrict` = 1 + WHERE sample_import_id = $sample_import_id"; + $db->Execute($sql); + + foreach($_POST['see'] as $p => $val) + {// echo $p,' => ',$val,' + '; + $sql = "UPDATE sample_import_var_restrict + SET `restrict` = 0 + WHERE sample_import_id = $sample_import_id + AND `var_id` = $val"; + $db->Execute($sql); + } + unset($_POST['see']); + } + + unset($_POST['type']); + + $_GET['edit'] = $sample_import_id; + +} + +if (isset($_GET['delete_sample'])){ + + $sample_import_id = $_GET['delete_sample']; + + // -->check questionnaire_sample - unassign sample if assigned + $sql = "SELECT questionnaire_id FROM `questionnaire_sample` WHERE sample_import_id = $sample_import_id"; + $rs = $db->GetAll($sql); + if (count($rs) != 0){ + echo "
", T_("Sample $sample_import_id is still assigned to questionnaire.
Please unassign sample prior to delete."), "
"; + } + else{ + //get the string list of sample_id's + $sql = "SELECT sample_id FROM `sample` where import_id = $sample_import_id"; + $rs = $db->GetAll($sql); + for($i=0;$i<=count($rs)-1;$i++){ $samimdel[] = $rs[$i]['sample_id'] ;} + $samimdel_s = implode(",",$samimdel); + + $db->StartTrans(); + + //del from questionnaire_sample_exclude_priority + $sql = "DELETE FROM `questionnaire_sample_exclude_priority` WHERE sample_id IN ($samimdel_s)"; + $db->Execute($sql); + + //del from questionnaire_sample_quota + $sql = "DELETE FROM `questionnaire_sample_quota` WHERE sample_import_id = $sample_import_id"; + $db->Execute($sql); + + //del from questionnaire_sample_quota_row + $sql = "DELETE FROM `questionnaire_sample_quota_row` WHERE sample_import_id = $sample_import_id"; + $db->Execute($sql); + + //del from questionnaire_sample_quota_row_exclude + $sql = "DELETE FROM `questionnaire_sample_quota_row_exclude` WHERE sample_id IN ($samimdel_s)"; + $db->Execute($sql); + + //del from questionnaire_sample_timeslot + $sql = "DELETE FROM `questionnaire_sample_timeslot` WHERE sample_import_id = $sample_import_id"; + $db->Execute($sql); + + //delete from sample_var + $sql = "DELETE FROM `sample_var` WHERE sample_id IN ($samimdel_s)"; + $db->Execute($sql); + + //del from sample_import_var_restrict + $sql = "DELETE FROM `sample_import_var_restrict` WHERE sample_import_id = $sample_import_id"; + $db->Execute($sql); + + //del from sample + $sql = "DELETE FROM `sample` WHERE import_id = $sample_import_id"; + $db->Execute($sql); + + //del from sample_import + $sql = "DELETE FROM `sample_import` WHERE sample_import_id = $sample_import_id"; + $db->Execute($sql); + + $db->CompleteTrans(); + + if (mysql_errno() == 0){echo "
", T_("Sample $sample_import_id was deleted."), "
"; } + else {echo "
ERROR ".mysql_errno()." ".mysql_error()."\n
";} + } + + unset($_GET['delete_sample']); + $samimdel_s = ''; +} + + +if (isset($_GET['edit']) ) +{ + $subtitle=T_("Rename, Set viewing permissions & Manage sample variables") ; + xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle); + + echo ""; + + $sample_import_id = intval($_GET['edit']); + + $sql = "SELECT * FROM sample_import WHERE sample_import_id = $sample_import_id"; + $sd = $db->GetRow($sql); + + if($sd['enabled'] == 1) $dis = disabled; // -> disable edit and delete if sample is enabled + + $sql = "SELECT type, description + FROM sample_var_type"; + $rd = $db->GetAll($sql); + + $sql = "SELECT sir.var_id, + CONCAT('') as var, + CONCAT ('') as type, sv.val, + CONCAT('') as see, + CONCAT('') as del, + sir.restrict IS NULL as existss + FROM sample_import as si, sample_var as sv, sample as s, sample_import_var_restrict as sir, sample_var_type as svt + WHERE si.sample_import_id = $sample_import_id + AND sir.sample_import_id = si.sample_import_id + AND sir.var_id = sv.var_id + AND sv.sample_id = s.sample_id + AND s.import_id = si.sample_import_id + AND svt.type = sir.type + GROUP BY sir.var_id"; + $rs = $db->GetAll($sql); + + print "

" . T_("Sample") . ": " . $sd['description'] . " ID $sample_import_id

"; + print ""; + print "
"; + + if($sd['enabled'] == 0){ + +?> +
+
+

+
/>
+
+
+
+
+ +
+ +
+
+
+
+
+ +

" . T_("Select which fields from this sample to deidentify.

Deidentified fields will be permanently deleted from the sample.") . "

"; + } +else +{ + print ""; + + /*check `Time_zone_name` and `phone` values for deidentified records*/ + $sql = "SELECT `sample`.sample_id FROM `sample` + LEFT JOIN `sample_var` ON (`sample`.sample_id = `sample_var`.sample_id) + WHERE `sample_var`.sample_id IS NULL + AND `sample`.import_id = $sample_import_id + AND (`sample`.Time_zone_name !='' || `sample`.phone !='')"; + $rs = $db->GetAll($sql); + + if (!empty($rs)) { + $num = count($rs); + print "

" . T_("There're still $num records for `Time_zone_name` and `phone` values for deidentified records") . "

"; + + print "
"; + } + +} + + unset ($rs); + + /*check if there's sample_var data not matching sample_import_var_restrict.var_id */ + $sql = "SELECT `sv`.var_id, `sv`.var, `sv`.type FROM `sample_var` as sv + LEFT JOIN `sample_import_var_restrict` as sivr ON (`sivr`.var_id = `sv`.var_id) + WHERE `sivr`.var_id IS NULL + AND `sv`.sample_id IN (SELECT sample_id FROM `sample` WHERE import_id = $sample_import_id) + GROUP BY `sv`.var_id"; + + $rs = $db->GetAll($sql); + if (!empty($rs)) { + $count = count($rs); + //print_r($rs); + print "

" . T_("Fix this sample ") . "

"; + print "

" . $count . " var id's not match

"; + +/* print "
+ + + +
"; */ + print "
"; + + /* if (isset($_POST['restore___'])){ + $sql = "INSERT INTO sample_import_var_restrict + (`sample_import_id`,`var_id`,`var`,`type`,`restrict`) + VALUES ($sample_import_id,' ',' ',' ',1)"; + + $db->Execute($sql); + unset($_POST['restore___']); + } + if (isset($_POST['delvarf___'])){ + $sql = ""; + + $db->Execute($sql); + unset($_POST['delvarf___']); + } */ + + unset($rs); + } + + if (isset($_POST['dtzph'])){ + + /*delete `Time_zone_name` and `phone` values for deidentified records*/ + $db->StartTrans(); + + $sql = "UPDATE `sample` + LEFT JOIN `sample_var` ON (`sample`.sample_id = `sample_var`.sample_id) + SET `Time_zone_name`='',`phone`='' + WHERE `sample_var`.sample_id IS NULL + AND `sample`.import_id = $sample_import_id"; + $db->Execute($sql); + + unset($_POST['dtzph']); + + $db->CompleteTrans(); + } + + xhtml_foot($js_foot); + exit(); +} + +if (isset($_GET['sampledisable'])) +{ + $id = intval($_GET['sampledisable']); + + $sql = "UPDATE sample_import + SET enabled = 0 + WHERE sample_import_id = '$id'"; + $db->Execute($sql); +} + +if (isset($_GET['sampleenable'])) +{ + $id = intval($_GET['sampleenable']); + + $sql = "UPDATE sample_import + SET enabled = 1 + WHERE sample_import_id = '$id'"; + $db->Execute($sql); +} + +$sql = "SELECT + CONCAT(' ',sample_import_id,' ') as id, + CASE WHEN enabled = 0 THEN + CONCAT('  " . TQ_("Disabled") . " ') + ELSE + CONCAT('  " . TQ_("Enabled") . " ') + END as status, + CASE WHEN enabled = 0 THEN + CONCAT('" . TQ_("Enable") . " ') + ELSE + CONCAT('  " . TQ_("Disable") . " ') + END + as enabledisable, + CASE WHEN enabled = 1 THEN + CONCAT('') + ELSE + CONCAT(' + + ') + END as did, + CASE WHEN enabled = 1 THEN + CONCAT('') + ELSE + CONCAT('') + END as delsample, + CONCAT('') as ssearch, + CONCAT('') as calls, + CONCAT('

',description,' 

') as description, + CONCAT('

',(SELECT COUNT( DISTINCT`sample_var`.sample_id) FROM `sample_var`, `sample` WHERE `sample`.sample_id = `sample_var`.sample_id AND `sample`.import_id = sample_import_id ),' 

') as cnt + FROM sample_import ORDER BY sample_import_id DESC"; + + $rs = $db->GetAll($sql); + +$subtitle=T_("Sample list"); +xhtml_head(T_("Sample management"),true,$css,$js_head,false,false,false,$subtitle); +echo ""; +$columns = array("id","description","cnt","status","enabledisable","calls","did","ssearch","delsample"); //"vp","rname", +//$titles = array(T_("ID"),T_("Sample"),T_("Records"), T_("Call History"),T_("Enable/Disable"), T_("Status"), T_("Deidentify"), T_("View"), T_("Rename"), T_("Search"), T_("Delete sample")); +xhtml_table($rs,$columns, false, "table-hover table-condensed "); + +xhtml_foot($js_foot); +?> + diff --git a/admin/samplesearch.php b/admin/samplesearch.php index fee180a3..0946786e 100644 --- a/admin/samplesearch.php +++ b/admin/samplesearch.php @@ -1,205 +1,205 @@ - - * @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"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -global $db; -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/font-awesome-4.3.0/css/font-awesome.css", -/* "../include/bootgrid/jquery.bootgrid.css", */ -"../include/bs-data-table/css/jquery.bdt.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -/* "../include/bootgrid/jquery.bootgrid.min.js", */ - ); -$js_foot = array( - -"../include/bs-data-table/js/vendor/jquery.sortelements.js", -"../include/bs-data-table/js/jquery.bdt.js", -"../js/window.js", -"../js/custom.js" - ); - -$sample_import_id = false; -if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); - -$subtitle = T_("Search within this sample"); - -xhtml_head(T_("Search the sample"),true,$css,$js_head); - -?> - - " . T_("Go back") . ""; - -$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM sample_import"; -$r = $db->GetAll($sql); - -if(!empty($r)) - - print "

" . T_("Select sample ") . " 

"; - display_chooser($r,"sample_import_id","sample_import_id",true,false,true,false); - - print "
"; - -if (isset($_GET['sample_id'])) -{ - //need to remove this sample record from the sample - - $sample_id = bigintval($_GET['sample_id']); - - $db->StartTrans(); - - $sql = "DELETE FROM sample_var - WHERE sample_id = '$sample_id'"; - $db->Execute($sql); - - $sql = "DELETE FROM sample - WHERE sample_id = '$sample_id'"; - $db->Execute($sql); - - $db->CompleteTrans(); - - print ""; -} - -print "
"; - -if ($sample_import_id != false) -{ - $sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN - CONCAT('  ') - ELSE CONCAT('', c.case_id ,'') - END as link - FROM sample_var AS sv - JOIN (sample as s) ON (s.import_id = '$sample_import_id' and sv.sample_id = s.sample_id) - LEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id ) - GROUP BY s.sample_id, c.case_id"; - $r = $db->GetAll($sql); - - if ($r) { - - - $fnames = array("sample_id"); - $fdesc = array(T_("Sample id")); - - $fnames[] = "link"; - $fdesc[] = T_("Case ID"); - - $sql = "SELECT var,var_id - FROM sample_import_var_restrict - WHERE sample_import_id = $sample_import_id - ORDER by var ASC"; - $rs = $db->GetAll($sql); - - foreach($rs as $rsw) - { - $fnames[] = $rsw['var_id']; - $fdesc[] = $rsw['var']; - } - foreach($r as &$rw) - { - $sql = "SELECT var_id,val - FROM sample_var - WHERE sample_id = {$rw['sample_id']}"; - $rs = $db->GetAll($sql); - foreach($rs as $rsw){ - $rw[$rsw['var_id']] = $rsw['val']; - } - } - - print "
"; - xhtml_table($r,$fnames,$fdesc,"tclass",false,false,"bs-table"); - print "
"; - } - else print ""; -} -xhtml_foot($js_foot); -?> - \ No newline at end of file + + * @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"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +global $db; +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +"../include/bootstrap/css/bootstrap-theme.min.css", +"../include/font-awesome/css/font-awesome.css", +/* "../include/bootgrid/jquery.bootgrid.css", */ +"../include/bs-data-table/css/jquery.bdt.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js", +/* "../include/bootgrid/jquery.bootgrid.min.js", */ + ); +$js_foot = array( + +"../include/bs-data-table/js/vendor/jquery.sortelements.js", +"../include/bs-data-table/js/jquery.bdt.js", +"../js/window.js", +"../js/custom.js" + ); + +$sample_import_id = false; +if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']); + +$subtitle = T_("Search within this sample"); + +xhtml_head(T_("Search the sample"),true,$css,$js_head); + +?> + + " . T_("Go back") . ""; + +$sql = "SELECT sample_import_id as value,description, CASE WHEN sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM sample_import"; +$r = $db->GetAll($sql); + +if(!empty($r)) + + print "

" . T_("Select sample ") . " 

"; + display_chooser($r,"sample_import_id","sample_import_id",true,false,true,false); + + print "
"; + +if (isset($_GET['sample_id'])) +{ + //need to remove this sample record from the sample + + $sample_id = bigintval($_GET['sample_id']); + + $db->StartTrans(); + + $sql = "DELETE FROM sample_var + WHERE sample_id = '$sample_id'"; + $db->Execute($sql); + + $sql = "DELETE FROM sample + WHERE sample_id = '$sample_id'"; + $db->Execute($sql); + + $db->CompleteTrans(); + + print ""; +} + +print "
"; + +if ($sample_import_id != false) +{ + $sql = "SELECT sv.sample_id, CASE WHEN c.case_id IS NULL THEN + CONCAT('  ') + ELSE CONCAT('', c.case_id ,'') + END as link + FROM sample_var AS sv + JOIN (sample as s) ON (s.import_id = '$sample_import_id' and sv.sample_id = s.sample_id) + LEFT JOIN (`case` AS c, questionnaire AS q) ON ( c.sample_id = sv.sample_id AND q.questionnaire_id = c.questionnaire_id ) + GROUP BY s.sample_id, c.case_id"; + $r = $db->GetAll($sql); + + if ($r) { + + + $fnames = array("sample_id"); + $fdesc = array(T_("Sample id")); + + $fnames[] = "link"; + $fdesc[] = T_("Case ID"); + + $sql = "SELECT var,var_id + FROM sample_import_var_restrict + WHERE sample_import_id = $sample_import_id + ORDER by var ASC"; + $rs = $db->GetAll($sql); + + foreach($rs as $rsw) + { + $fnames[] = $rsw['var_id']; + $fdesc[] = $rsw['var']; + } + foreach($r as &$rw) + { + $sql = "SELECT var_id,val + FROM sample_var + WHERE sample_id = {$rw['sample_id']}"; + $rs = $db->GetAll($sql); + foreach($rs as $rsw){ + $rw[$rsw['var_id']] = $rsw['val']; + } + } + + print "
"; + xhtml_table($r,$fnames,$fdesc,"tclass",false,false,"bs-table"); + print "
"; + } + else print ""; +} +xhtml_foot($js_foot); +?> + diff --git a/admin/shiftreport.php b/admin/shiftreport.php index 9ef570ea..ba0e9822 100644 --- a/admin/shiftreport.php +++ b/admin/shiftreport.php @@ -1,176 +1,176 @@ - - * @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_once(dirname(__FILE__).'/../config.inc.php'); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -/** - * Operator functions - */ -include("../functions/functions.operator.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -xhtml_head(T_("Shift reports"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); - -$operator_id = get_operator_id(); - -print "

" . T_("Please select a questionnaire") . "

"; -$questionnaire_id = false; -if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); -display_questionnaire_chooser($questionnaire_id ,false,"form-inline clearfix", "form-control"); - -if ($questionnaire_id) -{ - print "

" . T_("Please select a shift") . "

"; - - $shift_id = false; - if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']); - - //get shifts for this questionnaire in operator time - $sql = "SELECT s.shift_id as value, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT ."')) as description, - CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM `shift` as s, operator as o - WHERE s.questionnaire_id = '$questionnaire_id' - AND o.operator_id = '$operator_id' - ORDER BY s.start ASC"; - - $r = $db->GetAll($sql); - - if (!empty($r)) - display_chooser($r,"shift","shift_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"form-inline form-group"); - - if ($shift_id) - { - print "

" . T_("Reports for this shift") . "

"; - - //list current reports with a link to edit - $sql = "SELECT s.report,o.firstName,DATE_FORMAT(CONVERT_TZ(s.datetime,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."') as d, - CONCAT('". TQ_("Edit") . "') as link - FROM shift_report as s, operator as o - WHERE s.operator_id = o.operator_id - AND s.shift_id = '$shift_id'"; - - $r = $db->GetAll($sql); - - if (!empty($r)) - xhtml_table($r,array("firstName", "d", "report","link"),array(T_("Operator"),T_("Date"),T_("Report"),T_("Edit")),"tclass"); - - //link to create a new report - print "

" . T_("Create new report for this shift") . "

"; - - - if (isset($_GET['createnewreport'])) - { - //create a new report - print "

" . T_("Enter report for this shift") . "

"; - print "

"; - print "

"; - print ""; - print ""; - print "

"; - } - else if (isset($_GET['report'])) - { - //add report to database - $report = $db->qstr($_GET['report']); - - $sql = "INSERT INTO shift_report (shift_id,operator_id,datetime,report,shift_report_id) - VALUES ('$shift_id','$operator_id',CONVERT_TZ(NOW(),'System','UTC'),$report,NULL)"; - - $db->Execute($sql); - } - else if (isset($_GET['shift_report_id'])) - { - $shift_report_id = bigintval($_GET['shift_report_id']); - - if (isset($_GET['ereport'])) - { - //edit report - $report = $db->qstr($_GET['ereport']); - - $sql = "UPDATE shift_report - SET operator_id = '$operator_id', datetime = CONVERT_TZ(NOW(),'System','UTC'), report = $report - WHERE shift_report_id = '$shift_report_id'"; - - $db->Execute($sql); - } - - $sql = "SELECT report - FROM shift_report - WHERE shift_report_id = '$shift_report_id'"; - - $r = $db->GetRow($sql); - if (empty($r)) - { - print "

" . T_("This report does not exist in the database") . "

"; - } - else - { - //edit report - print "

" . T_("Edit report for this shift") . "

"; - print "

"; - print "

"; - print ""; - print ""; - print ""; - print "

"; - } - } - - } -} - -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_once(dirname(__FILE__).'/../config.inc.php'); + +/** + * Database file + */ +include ("../db.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +/** + * Operator functions + */ +include("../functions/functions.operator.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +xhtml_head(T_("Shift reports"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); + +$operator_id = get_operator_id(); + +print "

" . T_("Please select a questionnaire") . "

"; +$questionnaire_id = false; +if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']); +display_questionnaire_chooser($questionnaire_id ,false,"form-inline clearfix", "form-control"); + +if ($questionnaire_id) +{ + print "

" . T_("Please select a shift") . "

"; + + $shift_id = false; + if (isset($_GET['shift_id'])) $shift_id = bigintval($_GET['shift_id']); + + //get shifts for this questionnaire in operator time + $sql = "SELECT s.shift_id as value, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . TIME_FORMAT ."')) as description, + CASE WHEN s.shift_id = '$shift_id' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM `shift` as s, operator as o + WHERE s.questionnaire_id = '$questionnaire_id' + AND o.operator_id = '$operator_id' + ORDER BY s.start ASC"; + + $r = $db->GetAll($sql); + + if (!empty($r)) + display_chooser($r,"shift","shift_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"form-inline form-group"); + + if ($shift_id) + { + print "

" . T_("Reports for this shift") . "

"; + + //list current reports with a link to edit + $sql = "SELECT s.report,o.firstName,DATE_FORMAT(CONVERT_TZ(s.datetime,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."') as d, + CONCAT('". TQ_("Edit") . "') as link + FROM shift_report as s, operator as o + WHERE s.operator_id = o.operator_id + AND s.shift_id = '$shift_id'"; + + $r = $db->GetAll($sql); + + if (!empty($r)) + xhtml_table($r,array("firstName", "d", "report","link"),array(T_("Operator"),T_("Date"),T_("Report"),T_("Edit")),"tclass"); + + //link to create a new report + print "

" . T_("Create new report for this shift") . "

"; + + + if (isset($_GET['createnewreport'])) + { + //create a new report + print "

" . T_("Enter report for this shift") . "

"; + print "

"; + print "

"; + print ""; + print ""; + print "

"; + } + else if (isset($_GET['report'])) + { + //add report to database + $report = $db->qstr($_GET['report']); + + $sql = "INSERT INTO shift_report (shift_id,operator_id,datetime,report,shift_report_id) + VALUES ('$shift_id','$operator_id',CONVERT_TZ(NOW(),'System','UTC'),$report,NULL)"; + + $db->Execute($sql); + } + else if (isset($_GET['shift_report_id'])) + { + $shift_report_id = bigintval($_GET['shift_report_id']); + + if (isset($_GET['ereport'])) + { + //edit report + $report = $db->qstr($_GET['ereport']); + + $sql = "UPDATE shift_report + SET operator_id = '$operator_id', datetime = CONVERT_TZ(NOW(),'System','UTC'), report = $report + WHERE shift_report_id = '$shift_report_id'"; + + $db->Execute($sql); + } + + $sql = "SELECT report + FROM shift_report + WHERE shift_report_id = '$shift_report_id'"; + + $r = $db->GetRow($sql); + if (empty($r)) + { + print "

" . T_("This report does not exist in the database") . "

"; + } + else + { + //edit report + print "

" . T_("Edit report for this shift") . "

"; + print "

"; + print "

"; + print ""; + print ""; + print ""; + print "

"; + } + } + + } +} + +xhtml_foot(); + + + +?> + diff --git a/admin/shifttemplate.php b/admin/shifttemplate.php index 6f975c23..58370145 100644 --- a/admin/shifttemplate.php +++ b/admin/shifttemplate.php @@ -1,159 +1,159 @@ - - * @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"); - -$css = array( -"../include/bootstrap-3.3.2/css/bootstrap.min.css", -//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", -"../include/clockpicker/dist/bootstrap-clockpicker.min.css", -"../css/custom.css" - ); -$js_head = array( -"../js/jquery-2.1.3.min.js", -"../include/bootstrap-3.3.2/js/bootstrap.min.js", -"../js/addrow-v2.js", - ); -$js_foot = array( -"../include/clockpicker/dist/bootstrap-clockpicker.js", -"../js/custom.js" - ); - -global $db; - -$year="2008"; -$woy="1"; - -if (isset($_POST['day'])) -{ - $db->StartTrans(); - - $sql = "DELETE FROM shift_template - WHERE 1"; - $db->Execute($sql); - - foreach($_POST['day'] as $key => $val) - { - if (!empty($val)) - { - $val = intval($val); - $key = intval($key); - - $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); - $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); - - $sql = "INSERT INTO shift_template(day_of_week,start,end) - VALUES ($val,$start,$end)"; - $db->Execute($sql); - } - } - $db->CompleteTrans(); -} - -xhtml_head(T_("Set default shift times"),true,$css,$js_head);//T_("Modify shift template"),array("../css/shifts.css"),array("../js/addrow-v2.js") - -$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria' - -$rs = $db->GetRow($sql); - -if (empty($rs) || !$rs || empty($rs['t'])) - print ""; - -/** - * Display warning if timezone data not installed - * - */ - -//print "

" . T_("Set default shift times") . "

"; -print "
" . T_("Enter standard shift start and end times for each day of the week in local time") . "
"; - -/** - * Begin displaying currently loaded shifts - */ - -$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT('$year',' ','$woy',' ',day_of_week -1),'%x %v %w'), '%W') AS dt,day_of_week,start,end - FROM shift_template"; - -$shifts = $db->GetAll($sql); -translate_array($shifts,array("dt")); - -$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year,' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected - FROM day_of_week"; - -$daysofweek = $db->GetAll($sql); -translate_array($daysofweek,array("description")); - -?> -
- -"; - $count = 0; - foreach($shifts as $shift) - { - print " - - "; - $count++; - } - print " - "; - -?> -
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
";// class='row_to_clone' /* these are not the rows to clone...*/ - display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$shift['dt'])); - print "
"; - display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); - print "
-

- "/> -
- - \ No newline at end of file + + * @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"); + +$css = array( +"../include/bootstrap/css/bootstrap.min.css", +//"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", +"../include/clockpicker/dist/bootstrap-clockpicker.min.css", +"../css/custom.css" + ); +$js_head = array( +"../include/jquery/jquery.min.js", +"../include/bootstrap/js/bootstrap.min.js", +"../js/addrow-v2.js", + ); +$js_foot = array( +"../include/clockpicker/dist/bootstrap-clockpicker.js", +"../js/custom.js" + ); + +global $db; + +$year="2008"; +$woy="1"; + +if (isset($_POST['day'])) +{ + $db->StartTrans(); + + $sql = "DELETE FROM shift_template + WHERE 1"; + $db->Execute($sql); + + foreach($_POST['day'] as $key => $val) + { + if (!empty($val)) + { + $val = intval($val); + $key = intval($key); + + $start = $db->qstr($_POST['start'][$key],get_magic_quotes_gpc()); + $end = $db->qstr($_POST['end'][$key],get_magic_quotes_gpc()); + + $sql = "INSERT INTO shift_template(day_of_week,start,end) + VALUES ($val,$start,$end)"; + $db->Execute($sql); + } + } + $db->CompleteTrans(); +} + +xhtml_head(T_("Set default shift times"),true,$css,$js_head);//T_("Modify shift template"),array("../css/shifts.css"),array("../js/addrow-v2.js") + +$sql = "SELECT CONVERT_TZ(NOW(),'" . DEFAULT_TIME_ZONE . "','UTC') as t";//'Australia/Victoria' + +$rs = $db->GetRow($sql); + +if (empty($rs) || !$rs || empty($rs['t'])) + print ""; + +/** + * Display warning if timezone data not installed + * + */ + +//print "

" . T_("Set default shift times") . "

"; +print "
" . T_("Enter standard shift start and end times for each day of the week in local time") . "
"; + +/** + * Begin displaying currently loaded shifts + */ + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT('$year',' ','$woy',' ',day_of_week -1),'%x %v %w'), '%W') AS dt,day_of_week,start,end + FROM shift_template"; + +$shifts = $db->GetAll($sql); +translate_array($shifts,array("dt")); + +$sql = "SELECT DATE_FORMAT(STR_TO_DATE(CONCAT($year,' ',$woy,' ',day_of_week - 1),'%x %v %w'), '%W') as description, day_of_week as value, '' as selected + FROM day_of_week"; + +$daysofweek = $db->GetAll($sql); +translate_array($daysofweek,array("description")); + +?> +
+ +"; + $count = 0; + foreach($shifts as $shift) + { + print " + + "; + $count++; + } + print " + "; + +?> +
" . T_("Day") . "" . T_("Start") . "" . T_("End") . "
";// class='row_to_clone' /* these are not the rows to clone...*/ + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, array("description",$shift['dt'])); + print "
"; + display_chooser($daysofweek, "day[$count]", false, true, false, false, false, false); + print "
+

+ "/> +
+ + diff --git a/admin/supervisor.php b/admin/supervisor.php index 2fa7ec73..2bca6b6a 100644 --- a/admin/supervisor.php +++ b/admin/supervisor.php @@ -1,576 +1,576 @@ -StartTrans(); - - $sql = "SELECT sample_id - FROM `case` - WHERE case_id = $case_id"; - - $sample_id = $db->GetOne($sql); - - $sql = "DELETE FROM sample_var - WHERE sample_id = $sample_id"; - - $db->Execute($sql); - - //clear number from sample table - - $sql = "UPDATE `sample` - SET phone = '' - WHERE sample_id = $sample_id"; - - $db->Execute($sql); - - //clear respondent table (firstName,lastName) - - $sql = "UPDATE `respondent` - SET firstName = '', lastName = '' - WHERE case_id = $case_id"; - - $db->Execute($sql); - - //clear contact phone (phone,description) - - $sql = "UPDATE `contact_phone` - SET phone = '', description = '' - WHERE case_id = $case_id"; - - $db->Execute($sql); - - $db->CompleteTrans(); -} - -if (isset($_GET['case_note_id'])) -{ - $case_note_id = bigintval($_GET['case_note_id']); - - $sql = "DELETE FROM case_note - WHERE case_id = '$case_id' - AND case_note_id = '$case_note_id'"; - - $db->Execute($sql); -} - -xhtml_head(T_("Assign outcomes to cases"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") - -?> - -
-
- -"> - -
-
- -GetAll($sql); - -if (!empty($rs)) -{ - print "
" . T_("or") . ""; - display_chooser($rs,"case","case_id",true,false,true,false); - print "
"; -} -?> - - - - - 0) - { - $sql = "UPDATE `call` - SET outcome_id = '$outcome_id' - WHERE call_id = '$call_id'"; - - $db->Execute($sql); - } - } - else - { - print ""; - } - - //unset($_GET['call_id']); -} -if ($case_id != false) -{ - if (isset($_GET['note'])) - { - $note = $db->qstr($_GET['note']); - - $sql = "INSERT INTO `case_note` (case_note_id,case_id,operator_id,note,datetime) - VALUES (NULL,'$case_id','$operator_id',$note,CONVERT_TZ(NOW(),'System','UTC'))"; - $db->Execute($sql); - } - - if (isset($_GET['outcome_id'])) - { - $outcome_id = bigintval($_GET['outcome_id']); - - if ($outcome_id > 0) - { - $sql = "UPDATE `case` - SET current_outcome_id = $outcome_id - WHERE case_id = '$case_id'"; - - $db->Execute($sql); - } - } - - if (isset($_GET['operator_id'])) - { - $case_operator_id = bigintval($_GET['operator_id']); - - if ($case_operator_id == 0) - { - //clear the next case if set to no operator - $sql = "UPDATE `operator` - SET next_case_id = NULL - WHERE next_case_id = '$case_id'"; - } - else - { - $sql = "UPDATE `operator` - SET next_case_id = '$case_id' - WHERE operator_id = '$case_operator_id'"; - } - - $db->Execute($sql); - } - - if (isset($_GET['submitag'])) - { - $db->StartTrans(); - - $sql = "DELETE FROM case_availability - WHERE case_id = '$case_id'"; - - $db->Execute($sql); - - foreach($_GET as $key => $val) - { - if (substr($key,0,2) == "ag") - { - $sql = "INSERT INTO case_availability (case_id,availability_group_id) - VALUES ($case_id,'$val')"; - $db->Execute($sql); - } - } - $db->CompleteTrans(); - } - - $sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd, s.import_id as sid - FROM `case` as c, `outcome` as o, questionnaire as q, sample as s, sample_import as si - WHERE c.case_id = '$case_id' - AND q.questionnaire_id = c.questionnaire_id - AND s.sample_id = c.sample_id - AND si.sample_import_id = s.import_id - AND c.current_outcome_id = o.outcome_id"; - - $rs = $db->GetRow($sql); - - if (!empty($rs)) - { - print "
-

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

-

 " . T_("Sample") . ": {$rs['sd']} 

-

". T_("Current outcome:") ." " . T_($rs['description']) . "

"; - - $current_outcome_id = $rs['outcome_id']; - $sid = $rs['sid']; - - // view sample details - print "

 " . T_("Sample details")."

"; - - $sql = "SELECT sv.sample_id, c.case_id , s.Time_zone_name, - TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time - FROM sample_var AS sv - LEFT JOIN (`case` AS c , sample as s) ON ( c.sample_id = sv.sample_id AND s.sample_id = c.sample_id ) WHERE c.case_id = '$case_id' - GROUP BY sv.sample_id"; - $r = $db->GetAll($sql); - if ($r){ - $fnames = array("sample_id", "Time_zone_name", "time"); - $fdesc = array(T_("Sample id"),T_("Timezone"),T_("Time NOW")); - $varr= array(); - $sql = "SELECT var,var_id - FROM sample_import_var_restrict - WHERE sample_import_id = $sid AND type IN (2,3,6,7) - ORDER by var DESC"; - $rs = $db->GetAll($sql); - - foreach($rs as $rsw) - { - $fnames[] = $rsw['var_id']; - $fdesc[] = $rsw['var']; - $varr[] = $rsw['var_id']; //array for valid var_id's - } - $varr= implode(",",$varr); - foreach($r as &$rw) - { - $sql = "SELECT var_id,val - FROM sample_var - WHERE sample_id = {$rw['sample_id']} AND var_id IN ($varr)"; - $rs = $db->GetAll($sql); - foreach($rs as $rsw){ - $rw[$rsw['var_id']] = $rsw['val']; - } - } - - xhtml_table($r,$fnames,$fdesc,"tclass"); - }else{ - print "

" . T_("No sample data for this case") . "

"; - } - print "
"; - - //View appointments - print "

 " . T_("Appointments")."

"; - - $sql = "SELECT - 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,'" . T_("Not yet called") . "') as outcome, - CONCAT (oo.firstName,' ', oo.lastName) as makerName, - CONCAT (ooo.firstName,' ', ooo.lastName) as callerName, - 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, 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) - 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) - WHERE c.case_id = '$case_id' - GROUP BY a.appointment_id - ORDER BY a.start ASC"; - - $rs = $db->GetAll($sql); - - if (!empty($rs)) - { - translate_array($rs,array("outcome")); - xhtml_table($rs,array("start","end","edit","makerName","resp","outcome","callerName","link"),array(T_("Start"),T_("End"),"  ",T_("Operator"),T_("Respondent"),T_("Current outcome"),T_("Operator who called"),"  "),"table-hover table-bordered table-condensed col-sm-10"); - } - else - print ""; - -// * disable appointment creation if no sample_id - if ($r[0]['sample_id']){ - $rtz= $r[0]['Time_zone_name']; - print "  " . T_("Create appointment") . ""; } - - print "
"; - - - //view calls and outcomes - $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'".DATE_TIME_FORMAT."') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, CONCAT(op.firstName,' ',op.lastName) as firstName, o.description as des, CONCAT(' ') as link, cp.phone as phone - FROM `call` as c - JOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and cp.contact_phone_id = c.contact_phone_id) - WHERE c.case_id = '$case_id' - ORDER BY c.start DESC"; - $rs = $db->GetAll($sql); - - print "

 " . T_("Call list")."

"; - if (empty($rs)) - print ""; - else - { - translate_array($rs,array("des")); - xhtml_table($rs,array("start","phone","firstName","des","link"),array(T_("Date/Time"),T_("Phone number"),T_("Operator"),T_("Outcome"),"  ")); - } - print "
"; - - //view notes - $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as time, CONCAT(op.firstName,' ',op.lastName) as firstName, c.note as note, CONCAT('') as link - FROM `case_note` as c - JOIN (operator as op) on (c.operator_id = op.operator_id) - WHERE c.case_id = '$case_id' - ORDER BY c.datetime DESC"; - $rs = $db->GetAll($sql); - - print "

 " . T_("Case notes")."

"; - - if (empty($rs)) - print "

" . T_("No notes") . "

"; - else { - xhtml_table($rs,array("time","firstName","note","link"),array(T_("Date/Time"),T_("Operator"),T_("Note"),"  ")); - print "
"; - } - //add a note - ?> -
- -   - -
- "; - - //view timeslots - $sql = "SELECT count(*) - FROM questionnaire_timeslot as q, `case` as c - WHERE c.case_id = $case_id - AND c.questionnaire_id = q.questionnaire_id"; - - if ($db->GetOne($sql) >= 1) - { - $sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca - WHERE ca.case_id = c.case_id - AND a.availability_group_id = ag.availability_group_id - AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name)) - AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start - AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou - FROM availability_group as ag, `case` as c, `questionnaire_timeslot` as qt, sample as s - WHERE c.case_id = '$case_id' - AND s.sample_id = c.sample_id - AND qt.questionnaire_id = c.questionnaire_id AND ag.availability_group_id = qt.availability_group_id"; - if ( array("cou") >=1){ - print "

 " . T_("Call attempts by timeslot") . "

"; - xhtml_table($db->GetAll($sql),array('description','cou'),array(T_("Time slot"),T_("Call attempts")));//,"tclass",false,array("cou") - print "
"; - } - } else { print "" . T_("Time slots NOT defined") . ""; } - - - print "
"; - - if ($r[0]['sample_id']){ //if sample data exists assign this to an operator for their next case - - print "

 " . T_("Assign this case to operator (will appear as next case for them)") . "

"; - ?> -
- GetAll($sql); - display_chooser($rs3, "operator_id", "operator_id",true,false,false,false); - ?> - - -
- "; - if ($id) - print "

 " . T_("Modify responses for this case") . "

"; - else - print ""; - print "
"; - - if ($r[0]['sample_id']){ // if sample data exists view availability - - print "

 " . T_("Availability groups") . "

"; - if (is_using_availability($case_id)) - { - //List all availability group items and whether selected or not (all selected by default unless >= 1 availability group is in use for this case - $sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id - FROM `case` as c - JOIN questionnaire_availability AS qa ON (qa.questionnaire_id = c.questionnaire_id) - JOIN availability_group AS ag ON (ag.availability_group_id = qa.availability_group_id) - LEFT JOIN case_availability AS ca ON (ca.availability_group_id = qa.availability_group_id and ca.case_id = c.case_id) - WHERE c.case_id = '$case_id'"; - - $rs = $db->GetAll($sql); - - //Display all availability groups as checkboxes - print "
"; - print "
" . T_("Select groups to limit availability (Selecting none means always available)") . "
"; - foreach ($rs as $r) - { - $checked = ""; - - //if ($allselected || $r['availability_group_id'] == $r['selected_group_id']) - if ($r['availability_group_id'] == $r['selected_group_id']) - $checked = "checked='checked'"; - - print " 
"; - } - ?>
- - -
-
" . T_("Availability groups not defined for this questionnaire") . "
"; - } - print ""; } - - //set an outcome - print "

 " . T_("Set a case outcome") . "

"; - ?> -
- GetAll($sql); - translate_array($rs2,array("description")); - display_chooser($rs2, "outcome_id", "outcome_id",true,false,false,false); - ?> -

- -
- "; - - if ($r[0]['sample_id']){ // if sample data exists deidentify record - print "

 " . T_("Deidentify") . "

"; - print "
" . T_("Remove all sample details and contact numbers from this case") . "
"; - ?> -
- - -
- " . T_("Case does not exist") . ""; - } -} -xhtml_foot($js_foot);// deidentify data-toggle="modal" type="submit"submitclass -?> - - - - \ No newline at end of file +StartTrans(); + + $sql = "SELECT sample_id + FROM `case` + WHERE case_id = $case_id"; + + $sample_id = $db->GetOne($sql); + + $sql = "DELETE FROM sample_var + WHERE sample_id = $sample_id"; + + $db->Execute($sql); + + //clear number from sample table + + $sql = "UPDATE `sample` + SET phone = '' + WHERE sample_id = $sample_id"; + + $db->Execute($sql); + + //clear respondent table (firstName,lastName) + + $sql = "UPDATE `respondent` + SET firstName = '', lastName = '' + WHERE case_id = $case_id"; + + $db->Execute($sql); + + //clear contact phone (phone,description) + + $sql = "UPDATE `contact_phone` + SET phone = '', description = '' + WHERE case_id = $case_id"; + + $db->Execute($sql); + + $db->CompleteTrans(); +} + +if (isset($_GET['case_note_id'])) +{ + $case_note_id = bigintval($_GET['case_note_id']); + + $sql = "DELETE FROM case_note + WHERE case_id = '$case_id' + AND case_note_id = '$case_note_id'"; + + $db->Execute($sql); +} + +xhtml_head(T_("Assign outcomes to cases"),true,$css,$js_head);//array("../css/table.css"),array("../js/window.js") + +?> + +
+
+ +"> + +
+
+ +GetAll($sql); + +if (!empty($rs)) +{ + print "
" . T_("or") . ""; + display_chooser($rs,"case","case_id",true,false,true,false); + print "
"; +} +?> + + + + + 0) + { + $sql = "UPDATE `call` + SET outcome_id = '$outcome_id' + WHERE call_id = '$call_id'"; + + $db->Execute($sql); + } + } + else + { + print ""; + } + + //unset($_GET['call_id']); +} +if ($case_id != false) +{ + if (isset($_GET['note'])) + { + $note = $db->qstr($_GET['note']); + + $sql = "INSERT INTO `case_note` (case_note_id,case_id,operator_id,note,datetime) + VALUES (NULL,'$case_id','$operator_id',$note,CONVERT_TZ(NOW(),'System','UTC'))"; + $db->Execute($sql); + } + + if (isset($_GET['outcome_id'])) + { + $outcome_id = bigintval($_GET['outcome_id']); + + if ($outcome_id > 0) + { + $sql = "UPDATE `case` + SET current_outcome_id = $outcome_id + WHERE case_id = '$case_id'"; + + $db->Execute($sql); + } + } + + if (isset($_GET['operator_id'])) + { + $case_operator_id = bigintval($_GET['operator_id']); + + if ($case_operator_id == 0) + { + //clear the next case if set to no operator + $sql = "UPDATE `operator` + SET next_case_id = NULL + WHERE next_case_id = '$case_id'"; + } + else + { + $sql = "UPDATE `operator` + SET next_case_id = '$case_id' + WHERE operator_id = '$case_operator_id'"; + } + + $db->Execute($sql); + } + + if (isset($_GET['submitag'])) + { + $db->StartTrans(); + + $sql = "DELETE FROM case_availability + WHERE case_id = '$case_id'"; + + $db->Execute($sql); + + foreach($_GET as $key => $val) + { + if (substr($key,0,2) == "ag") + { + $sql = "INSERT INTO case_availability (case_id,availability_group_id) + VALUES ($case_id,'$val')"; + $db->Execute($sql); + } + } + $db->CompleteTrans(); + } + + $sql = "SELECT o.description,o.outcome_id, q.description as qd, si.description as sd, s.import_id as sid + FROM `case` as c, `outcome` as o, questionnaire as q, sample as s, sample_import as si + WHERE c.case_id = '$case_id' + AND q.questionnaire_id = c.questionnaire_id + AND s.sample_id = c.sample_id + AND si.sample_import_id = s.import_id + AND c.current_outcome_id = o.outcome_id"; + + $rs = $db->GetRow($sql); + + if (!empty($rs)) + { + print "
+

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

+

 " . T_("Sample") . ": {$rs['sd']} 

+

". T_("Current outcome:") ." " . T_($rs['description']) . "

"; + + $current_outcome_id = $rs['outcome_id']; + $sid = $rs['sid']; + + // view sample details + print "

 " . T_("Sample details")."

"; + + $sql = "SELECT sv.sample_id, c.case_id , s.Time_zone_name, + TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,s.Time_zone_name),'". TIME_FORMAT ."') as time + FROM sample_var AS sv + LEFT JOIN (`case` AS c , sample as s) ON ( c.sample_id = sv.sample_id AND s.sample_id = c.sample_id ) WHERE c.case_id = '$case_id' + GROUP BY sv.sample_id"; + $r = $db->GetAll($sql); + if ($r){ + $fnames = array("sample_id", "Time_zone_name", "time"); + $fdesc = array(T_("Sample id"),T_("Timezone"),T_("Time NOW")); + $varr= array(); + $sql = "SELECT var,var_id + FROM sample_import_var_restrict + WHERE sample_import_id = $sid AND type IN (2,3,6,7) + ORDER by var DESC"; + $rs = $db->GetAll($sql); + + foreach($rs as $rsw) + { + $fnames[] = $rsw['var_id']; + $fdesc[] = $rsw['var']; + $varr[] = $rsw['var_id']; //array for valid var_id's + } + $varr= implode(",",$varr); + foreach($r as &$rw) + { + $sql = "SELECT var_id,val + FROM sample_var + WHERE sample_id = {$rw['sample_id']} AND var_id IN ($varr)"; + $rs = $db->GetAll($sql); + foreach($rs as $rsw){ + $rw[$rsw['var_id']] = $rsw['val']; + } + } + + xhtml_table($r,$fnames,$fdesc,"tclass"); + }else{ + print "

" . T_("No sample data for this case") . "

"; + } + print "
"; + + //View appointments + print "

 " . T_("Appointments")."

"; + + $sql = "SELECT + 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,'" . T_("Not yet called") . "') as outcome, + CONCAT (oo.firstName,' ', oo.lastName) as makerName, + CONCAT (ooo.firstName,' ', ooo.lastName) as callerName, + 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, 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) + 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) + WHERE c.case_id = '$case_id' + GROUP BY a.appointment_id + ORDER BY a.start ASC"; + + $rs = $db->GetAll($sql); + + if (!empty($rs)) + { + translate_array($rs,array("outcome")); + xhtml_table($rs,array("start","end","edit","makerName","resp","outcome","callerName","link"),array(T_("Start"),T_("End"),"  ",T_("Operator"),T_("Respondent"),T_("Current outcome"),T_("Operator who called"),"  "),"table-hover table-bordered table-condensed col-sm-10"); + } + else + print ""; + +// * disable appointment creation if no sample_id + if ($r[0]['sample_id']){ + $rtz= $r[0]['Time_zone_name']; + print "  " . T_("Create appointment") . ""; } + + print "
"; + + + //view calls and outcomes + $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'".DATE_TIME_FORMAT."') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, CONCAT(op.firstName,' ',op.lastName) as firstName, o.description as des, CONCAT(' ') as link, cp.phone as phone + FROM `call` as c + JOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and cp.contact_phone_id = c.contact_phone_id) + WHERE c.case_id = '$case_id' + ORDER BY c.start DESC"; + $rs = $db->GetAll($sql); + + print "

 " . T_("Call list")."

"; + if (empty($rs)) + print ""; + else + { + translate_array($rs,array("des")); + xhtml_table($rs,array("start","phone","firstName","des","link"),array(T_("Date/Time"),T_("Phone number"),T_("Operator"),T_("Outcome"),"  ")); + } + print "
"; + + //view notes + $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.datetime,'UTC',op.Time_zone_name),'".DATE_TIME_FORMAT."') as time, CONCAT(op.firstName,' ',op.lastName) as firstName, c.note as note, CONCAT('') as link + FROM `case_note` as c + JOIN (operator as op) on (c.operator_id = op.operator_id) + WHERE c.case_id = '$case_id' + ORDER BY c.datetime DESC"; + $rs = $db->GetAll($sql); + + print "

 " . T_("Case notes")."

"; + + if (empty($rs)) + print "

" . T_("No notes") . "

"; + else { + xhtml_table($rs,array("time","firstName","note","link"),array(T_("Date/Time"),T_("Operator"),T_("Note"),"  ")); + print "
"; + } + //add a note + ?> +
+ +   + +
+ "; + + //view timeslots + $sql = "SELECT count(*) + FROM questionnaire_timeslot as q, `case` as c + WHERE c.case_id = $case_id + AND c.questionnaire_id = q.questionnaire_id"; + + if ($db->GetOne($sql) >= 1) + { + $sql = "SELECT ag.description, (SELECT COUNT(*) FROM availability as a, `call_attempt` as ca + WHERE ca.case_id = c.case_id + AND a.availability_group_id = ag.availability_group_id + AND (a.day_of_week = DAYOFWEEK(CONVERT_TZ(ca.start,'UTC',s.Time_zone_name)) + AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) >= a.start + AND TIME(CONVERT_TZ(ca.start, 'UTC' , s.Time_zone_name)) <= a.end)) as cou + FROM availability_group as ag, `case` as c, `questionnaire_timeslot` as qt, sample as s + WHERE c.case_id = '$case_id' + AND s.sample_id = c.sample_id + AND qt.questionnaire_id = c.questionnaire_id AND ag.availability_group_id = qt.availability_group_id"; + if ( array("cou") >=1){ + print "

 " . T_("Call attempts by timeslot") . "

"; + xhtml_table($db->GetAll($sql),array('description','cou'),array(T_("Time slot"),T_("Call attempts")));//,"tclass",false,array("cou") + print "
"; + } + } else { print "" . T_("Time slots NOT defined") . ""; } + + + print "
"; + + if ($r[0]['sample_id']){ //if sample data exists assign this to an operator for their next case + + print "

 " . T_("Assign this case to operator (will appear as next case for them)") . "

"; + ?> +
+ GetAll($sql); + display_chooser($rs3, "operator_id", "operator_id",true,false,false,false); + ?> + + +
+ "; + if ($id) + print "

 " . T_("Modify responses for this case") . "

"; + else + print ""; + print "
"; + + if ($r[0]['sample_id']){ // if sample data exists view availability + + print "

 " . T_("Availability groups") . "

"; + if (is_using_availability($case_id)) + { + //List all availability group items and whether selected or not (all selected by default unless >= 1 availability group is in use for this case + $sql = "SELECT qa.availability_group_id,ag.description,ca.availability_group_id as selected_group_id + FROM `case` as c + JOIN questionnaire_availability AS qa ON (qa.questionnaire_id = c.questionnaire_id) + JOIN availability_group AS ag ON (ag.availability_group_id = qa.availability_group_id) + LEFT JOIN case_availability AS ca ON (ca.availability_group_id = qa.availability_group_id and ca.case_id = c.case_id) + WHERE c.case_id = '$case_id'"; + + $rs = $db->GetAll($sql); + + //Display all availability groups as checkboxes + print "
"; + print "
" . T_("Select groups to limit availability (Selecting none means always available)") . "
"; + foreach ($rs as $r) + { + $checked = ""; + + //if ($allselected || $r['availability_group_id'] == $r['selected_group_id']) + if ($r['availability_group_id'] == $r['selected_group_id']) + $checked = "checked='checked'"; + + print " 
"; + } + ?>
+ + +
+
" . T_("Availability groups not defined for this questionnaire") . "
"; + } + print "
"; } + + //set an outcome + print "

 " . T_("Set a case outcome") . "

"; + ?> +
+ GetAll($sql); + translate_array($rs2,array("description")); + display_chooser($rs2, "outcome_id", "outcome_id",true,false,false,false); + ?> +

+ +
+ "; + + if ($r[0]['sample_id']){ // if sample data exists deidentify record + print "

 " . T_("Deidentify") . "

"; + print "
" . T_("Remove all sample details and contact numbers from this case") . "
"; + ?> +
+ + +
+ " . T_("Case does not exist") . ""; + } +} +xhtml_foot($js_foot);// deidentify data-toggle="modal" type="submit"submitclass +?> + + + + diff --git a/admin/supervisorchat.php b/admin/supervisorchat.php index 774a952f..eb90efe0 100644 --- a/admin/supervisorchat.php +++ b/admin/supervisorchat.php @@ -1,91 +1,91 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/ queXS was writen for ACSPRI - * @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"); - - -if (isset($_POST['update'])) -{ - set_setting("bosh_service",$_POST['bosh']); - set_setting("supervisor_xmpp",$_POST['supervisor']); - $enable = false; - - if (isset($_POST['enable'])) - $enable = true; - - set_setting("chat_enabled",$enable); -} - -xhtml_head(T_("Supervisor chat"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js", "../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../js/window.js")); - -print "

" . T_("Allow interviewers to chat with the supervisor over XMPP (Jabber). Required is a BOSH enabled XMPP/Jabber server. The operators and the supervisor will need XMPP/Jabber accounts.") . "

"; - - $e = get_setting("chat_enabled"); - $checked = "checked='checked'"; - if (empty($e)) - $checked = ""; -?> -
- -
- - " data-off="" data-width="80" name='enable' val='1' /> -
-
- - -
-
- - -
- - "/> - -
- - \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2013 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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"); + + +if (isset($_POST['update'])) +{ + set_setting("bosh_service",$_POST['bosh']); + set_setting("supervisor_xmpp",$_POST['supervisor']); + $enable = false; + + if (isset($_POST['enable'])) + $enable = true; + + set_setting("chat_enabled",$enable); +} + +xhtml_head(T_("Supervisor chat"),true,array("../include/bootstrap/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../css/custom.css"),array("../include/jquery/jquery.min.js", "../include/bootstrap/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../js/window.js")); + +print "

" . T_("Allow interviewers to chat with the supervisor over XMPP (Jabber). Required is a BOSH enabled XMPP/Jabber server. The operators and the supervisor will need XMPP/Jabber accounts.") . "

"; + + $e = get_setting("chat_enabled"); + $checked = "checked='checked'"; + if (empty($e)) + $checked = ""; +?> +
+ +
+ + " data-off="" data-width="80" name='enable' val='1' /> +
+
+ + +
+
+ + +
+ + "/> + +
+ + diff --git a/admin/systemsort.php b/admin/systemsort.php index b7f68e7b..49c6b960 100644 --- a/admin/systemsort.php +++ b/admin/systemsort.php @@ -1,110 +1,110 @@ - - * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011 - * @package queXS - * @subpackage admin - * @link http://www.acspri.org.au/ queXS was writen for ACSPRI - * @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"); - -/** - * Process - */ -include ("../functions/functions.process.php"); - -/** - * XHTML functions - */ -include("../functions/functions.xhtml.php"); - - - -if (isset($_GET['watch'])) -{ - //start watching process - start_process(realpath(dirname(__FILE__) . "/systemsortprocess.php"),2); -} - -$p = is_process_running(2); - - -if ($p) -{ - if (isset($_GET['kill'])) - { - if ($_GET['kill'] == "force") - end_process($p); - else - kill_process($p); - - set_setting('systemsort',false); - } - - xhtml_head(T_("Monitor system wide case sorting"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),false,false,false,true); - - print "

" . T_("Running process:") . " $p

"; - - if (is_process_killed($p)) - { - print "

" . T_("Kill signal sent: Please wait...") . "

"; - print "

" . T_("Process is already closed (eg. server was rebooted) - click here to confirm") . "

"; - } - else - { - print "

" . T_("Kill the running process") . "

"; - } - - $d = process_get_data($p); - if ($d !== false) - { - xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); - } -} -else -{ - xhtml_head(T_("Monitor system wide case sorting"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css")); - //print "

" . T_("Monitor system wide case sorting") . "

"; - print "

" . T_("Click here to enable and begin system wide case sorting") . "

"; - print "

" . T_("System wide case sorting is periodically (via SYSTEM_SORT_MINUTES configuration directive) sorting cases on a system wide basis instead of finding the most appropriate case each time an operator requests a new case. This may increase performance where there are a large number of cases or complex quotas in place. If you are not experiencing any performance problems, it is not recommended to use this feature.") . "

"; - print "

" . T_("Outcome of last process run (if any)") . "

"; - $d = process_get_last_data(2); - if ($d !== false) - { - xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); - } -} -xhtml_foot(); - -?> \ No newline at end of file + + * @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2011 + * @package queXS + * @subpackage admin + * @link http://www.acspri.org.au/ queXS was writen for ACSPRI + * @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"); + +/** + * Process + */ +include ("../functions/functions.process.php"); + +/** + * XHTML functions + */ +include("../functions/functions.xhtml.php"); + + + +if (isset($_GET['watch'])) +{ + //start watching process + start_process(realpath(dirname(__FILE__) . "/systemsortprocess.php"),2); +} + +$p = is_process_running(2); + + +if ($p) +{ + if (isset($_GET['kill'])) + { + if ($_GET['kill'] == "force") + end_process($p); + else + kill_process($p); + + set_setting('systemsort',false); + } + + xhtml_head(T_("Monitor system wide case sorting"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),false,false,false,true); + + print "

" . T_("Running process:") . " $p

"; + + if (is_process_killed($p)) + { + print "

" . T_("Kill signal sent: Please wait...") . "

"; + print "

" . T_("Process is already closed (eg. server was rebooted) - click here to confirm") . "

"; + } + else + { + print "

" . T_("Kill the running process") . "

"; + } + + $d = process_get_data($p); + if ($d !== false) + { + xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); + } +} +else +{ + xhtml_head(T_("Monitor system wide case sorting"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css")); + //print "

" . T_("Monitor system wide case sorting") . "

"; + print "

" . T_("Click here to enable and begin system wide case sorting") . "

"; + print "

" . T_("System wide case sorting is periodically (via SYSTEM_SORT_MINUTES configuration directive) sorting cases on a system wide basis instead of finding the most appropriate case each time an operator requests a new case. This may increase performance where there are a large number of cases or complex quotas in place. If you are not experiencing any performance problems, it is not recommended to use this feature.") . "

"; + print "

" . T_("Outcome of last process run (if any)") . "

"; + $d = process_get_last_data(2); + if ($d !== false) + { + xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); + } +} +xhtml_foot(); + +?> diff --git a/admin/timezonetemplate.php b/admin/timezonetemplate.php index 7773c2f5..e585e9ea 100644 --- a/admin/timezonetemplate.php +++ b/admin/timezonetemplate.php @@ -1,137 +1,137 @@ - - * @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"); - -/** - * Display functions - */ -include("../functions/functions.display.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -global $db; - -if (isset($_POST['dtime_zone'])) -{ - set_setting('DEFAULT_TIME_ZONE', $_POST['dtime_zone']); - -} - -if (isset($_GET['time_zone'])) -{ - //need to add sample to questionnaire - - $tz = $db->qstr($_GET['time_zone'],get_magic_quotes_gpc()); - - $sql = "INSERT INTO timezone_template(Time_zone_name) - VALUES($tz)"; - - $db->Execute($sql); - -} - -if (isset($_GET['tz'])) -{ - //need to remove rsid from questionnaire - - $tz = $db->qstr($_GET['tz'],get_magic_quotes_gpc()); - - $sql = "DELETE FROM timezone_template - WHERE Time_zone_name = $tz"; - - $db->Execute($sql); -} - - -xhtml_head(T_("Set Timezones"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); //,"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css" - -$dtz = get_setting("DEFAULT_TIME_ZONE"); - -$sql = "SELECT name as value, name as description, - CASE WHEN name LIKE '$dtz' THEN 'selected=\'selected\'' ELSE '' END AS selected - FROM mysql.time_zone_name - WHERE `Name` LIKE 'Europe%' OR `Name` LIKE 'Asia%' "; - -$tzl = $db->GetAll($sql); - -if (empty($tzl) || !$tzl) -{ - print "
" . T_("Your database does not have timezones installed, please see here for details") . " ...
"; -} - -print "

" . T_("Default Timezone: ") . " $dtz

";//
- ?> -
-   - "/> -
- "; - -print "

" . T_("Timezone list") . "

"; - -$sql = "SELECT Time_zone_name, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,Time_zone_name),'". TIME_FORMAT ."') as time, CONCAT('

', TIME_FORMAT(TIMEDIFF( CONVERT_TZ(NOW(),'$dtz','$dtz'),CONVERT_TZ(NOW(), Time_zone_name,'$dtz')),' %H : %i'), '

') AS timediff, -CONCAT('" . T_("Remove") . "') as link - FROM timezone_template ORDER BY time ASC"; - -$qs = $db->GetAll($sql); - xhtml_table($qs, array("Time_zone_name","timediff","time","link"), array(T_("Timezone name"),T_("Time diff to Default Time zone"),T_("Current time"),T_("Remove"))); -print "
"; - -print "

" . T_("Add a Timezone:") . " 

"; - ?> -
-   - "/> -
- "; - -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"); + +/** + * Display functions + */ +include("../functions/functions.display.php"); + +/** + * Input functions + */ +include("../functions/functions.input.php"); + +global $db; + +if (isset($_POST['dtime_zone'])) +{ + set_setting('DEFAULT_TIME_ZONE', $_POST['dtime_zone']); + +} + +if (isset($_GET['time_zone'])) +{ + //need to add sample to questionnaire + + $tz = $db->qstr($_GET['time_zone'],get_magic_quotes_gpc()); + + $sql = "INSERT INTO timezone_template(Time_zone_name) + VALUES($tz)"; + + $db->Execute($sql); + +} + +if (isset($_GET['tz'])) +{ + //need to remove rsid from questionnaire + + $tz = $db->qstr($_GET['tz'],get_magic_quotes_gpc()); + + $sql = "DELETE FROM timezone_template + WHERE Time_zone_name = $tz"; + + $db->Execute($sql); +} + + +xhtml_head(T_("Set Timezones"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js")); //,"../include/bootstrap/css/bootstrap-theme.min.css" + +$dtz = get_setting("DEFAULT_TIME_ZONE"); + +$sql = "SELECT name as value, name as description, + CASE WHEN name LIKE '$dtz' THEN 'selected=\'selected\'' ELSE '' END AS selected + FROM mysql.time_zone_name + WHERE `Name` LIKE 'Europe%' OR `Name` LIKE 'Asia%' "; + +$tzl = $db->GetAll($sql); + +if (empty($tzl) || !$tzl) +{ + print "
" . T_("Your database does not have timezones installed, please see here for details") . " ...
"; +} + +print "

" . T_("Default Timezone: ") . " $dtz

";//
+ ?> +
+   + "/> +
+ "; + +print "

" . T_("Timezone list") . "

"; + +$sql = "SELECT Time_zone_name, TIME_FORMAT(CONVERT_TZ(NOW(),@@session.time_zone,Time_zone_name),'". TIME_FORMAT ."') as time, CONCAT('

', TIME_FORMAT(TIMEDIFF( CONVERT_TZ(NOW(),'$dtz','$dtz'),CONVERT_TZ(NOW(), Time_zone_name,'$dtz')),' %H : %i'), '

') AS timediff, +CONCAT('" . T_("Remove") . "') as link + FROM timezone_template ORDER BY time ASC"; + +$qs = $db->GetAll($sql); + xhtml_table($qs, array("Time_zone_name","timediff","time","link"), array(T_("Timezone name"),T_("Time diff to Default Time zone"),T_("Current time"),T_("Remove"))); +print "
"; + +print "

" . T_("Add a Timezone:") . " 

"; + ?> +
+   + "/> +
+ "; + +xhtml_foot(); +?> diff --git a/admin/voipmonitor.php b/admin/voipmonitor.php index b05768cd..bb5d7155 100644 --- a/admin/voipmonitor.php +++ b/admin/voipmonitor.php @@ -1,107 +1,107 @@ - - * @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"); - -/** - * Process - */ -include ("../functions/functions.process.php"); - -/** - * XHTML functions - */ -include("../functions/functions.xhtml.php"); - - - -if (isset($_GET['watch'])) -{ - //start watching process - start_process(realpath(dirname(__FILE__) . "/process.php")); -} - -$p = is_process_running(); - - -if ($p) -{ - if (isset($_GET['kill'])) - { - if ($_GET['kill'] == "force") - end_process($p); - else - kill_process($p); - } - - xhtml_head(T_("Monitor VoIP Process"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),false,false,false,true); - - print "

" . T_("Running process:") . " $p

"; - - if (is_process_killed($p)) - { - print "

" . T_("Kill signal sent: Please wait...
(Note: Process will be stalled until there is activity on the VoIP Server)") . "

"; - print "

" . T_("Process is already closed (eg. server was rebooted)") . "" . T_("click here to confirm") . "

"; - } - else - { - print "

" . T_("Kill the running process") . " ". T_("(requires activity on the VoIP Server to take effect)") . "

"; - } - - $d = process_get_data($p); - if ($d !== false) - { - xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); - } -} -else -{ - xhtml_head(T_("Monitor VoIP Process"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css")); - //print "

" . T_("Monitor VoIP Process") . "

"; - print "

" . T_("Click here to begin monitoring the VoIP Process") . "

"; - print "

" . T_("Outcome of last process run (if any)") . "

"; - $d = process_get_last_data(); - if ($d !== false) - { - xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); - } -} -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"); + +/** + * Process + */ +include ("../functions/functions.process.php"); + +/** + * XHTML functions + */ +include("../functions/functions.xhtml.php"); + + + +if (isset($_GET['watch'])) +{ + //start watching process + start_process(realpath(dirname(__FILE__) . "/process.php")); +} + +$p = is_process_running(); + + +if ($p) +{ + if (isset($_GET['kill'])) + { + if ($_GET['kill'] == "force") + end_process($p); + else + kill_process($p); + } + + xhtml_head(T_("Monitor VoIP Process"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css"),false,false,false,true); + + print "

" . T_("Running process:") . " $p

"; + + if (is_process_killed($p)) + { + print "

" . T_("Kill signal sent: Please wait...
(Note: Process will be stalled until there is activity on the VoIP Server)") . "

"; + print "

" . T_("Process is already closed (eg. server was rebooted)") . "" . T_("click here to confirm") . "

"; + } + else + { + print "

" . T_("Kill the running process") . " ". T_("(requires activity on the VoIP Server to take effect)") . "

"; + } + + $d = process_get_data($p); + if ($d !== false) + { + xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); + } +} +else +{ + xhtml_head(T_("Monitor VoIP Process"),true,array("../include/bootstrap/css/bootstrap.min.css","../css/custom.css")); + //print "

" . T_("Monitor VoIP Process") . "

"; + print "

" . T_("Click here to begin monitoring the VoIP Process") . "

"; + print "

" . T_("Outcome of last process run (if any)") . "

"; + $d = process_get_last_data(); + if ($d !== false) + { + xhtml_table($d,array('process_log_id','datetime','data'),array(T_("Log id"), T_("Date"), T_("Log entry"))); + } +} +xhtml_foot(); + +?> diff --git a/appointment.php b/appointment.php index 0e775645..6085ce68 100644 --- a/appointment.php +++ b/appointment.php @@ -115,10 +115,10 @@ if(isset($_POST['start']) && isset($_POST['end']) && isset($_POST['day']) && iss $js = array("js/window.js"); if (AUTO_LOGOUT_MINUTES !== false) { - $js[] = "include/jquery-ui/js/jquery-1.4.2.min.js"; + $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } -xhtml_head(T_("Create appointment"),false,array("include/bootstrap-3.3.2/css/bootstrap.min.css", "css/respondent.css"),$js);//"include/clockpicker/dist/bootstrap-clockpicker.min.css", +xhtml_head(T_("Create appointment"),false,array("include/bootstrap/css/bootstrap.min.css", "css/respondent.css"),$js);//"include/clockpicker/dist/bootstrap-clockpicker.min.css", //select a respondent from a list or create a new one print "

" . T_("Respondent") . ":"; diff --git a/appointmentlist.php b/appointmentlist.php index 4e5b04d8..88ce8265 100644 --- a/appointmentlist.php +++ b/appointmentlist.php @@ -51,7 +51,7 @@ include("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Appointment List"),false,array("css/table.css"),$js,false,60); diff --git a/availability.php b/availability.php index 77850123..fd9adb02 100644 --- a/availability.php +++ b/availability.php @@ -51,7 +51,7 @@ include("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Availability"),false,array("css/table.css"),$js); diff --git a/call.php b/call.php index 8c2fe826..c0dc7905 100644 --- a/call.php +++ b/call.php @@ -255,7 +255,7 @@ if (isset($_GET['newstate'])) $js = "js/window.js"; if (browser_ie()) $js = "js/window_ie6.js"; -xhtml_head(T_("Call"),true,array("css/call.css"),array($js,"include/jquery-ui/js/jquery-1.4.2.min.js")); +xhtml_head(T_("Call"),true,array("css/call.css"),array($js,"include/jquery/jquery-1.4.2.min.js")); $state = is_on_call($operator_id); switch($state) diff --git a/call_interface2.php b/call_interface2.php index e5a8489a..a1066d94 100644 --- a/call_interface2.php +++ b/call_interface2.php @@ -303,7 +303,7 @@ if (isset($_GET['newstate'])) if (browser_ie()) $js = "js/window_ie6_interface2.js"; else $js = "js/window_interface2.js"; -xhtml_head(T_("Set outcome"),true,array("include/bootstrap-3.3.2/css/bootstrap.min.css"/* ,"css/call.css" */),array($js,"include/jquery-ui/js/jquery-1.4.2.min.js")); +xhtml_head(T_("Set outcome"),true,array("include/bootstrap/css/bootstrap.min.css"/* ,"css/call.css" */),array($js,"include/jquery/jquery-1.4.2.min.js")); $state = is_on_call($operator_id); switch($state) diff --git a/callhistory.php b/callhistory.php index bcc7f20f..4adf9546 100644 --- a/callhistory.php +++ b/callhistory.php @@ -51,7 +51,7 @@ include("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Case History List"),false,array("css/table.css"),$js,false,60); diff --git a/calllist.php b/calllist.php index deef62ff..45c60c31 100644 --- a/calllist.php +++ b/calllist.php @@ -51,7 +51,7 @@ include("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Call List"),false,array("css/table.css"),$js,false,60); diff --git a/casenote.php b/casenote.php index 220eeb1d..1bb68fd9 100644 --- a/casenote.php +++ b/casenote.php @@ -51,7 +51,7 @@ include("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Case Notes"),false,array("css/table.css","css/casenote.css"),$js, (isset($_GET['add'])) ? "onload=\"document.getElementById('note').focus();\"" : false); diff --git a/contactdetails.php b/contactdetails.php index fbb7c6a6..f5254bd8 100644 --- a/contactdetails.php +++ b/contactdetails.php @@ -63,7 +63,7 @@ $js = array("js/window.js"); if (AUTO_LOGOUT_MINUTES !== false) { - $js[] = "include/jquery-ui/js/jquery-1.4.2.min.js"; + $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } diff --git a/endwork.php b/endwork.php index 15090d86..c3e16290 100644 --- a/endwork.php +++ b/endwork.php @@ -41,7 +41,7 @@ include_once("lang.inc.php"); * XHTML functions */ include_once("functions/functions.xhtml.php"); - +include_once("functions/functions.operator.php"); xhtml_head(T_("End of work")); if (isset($_GET['auto'])) @@ -51,7 +51,7 @@ if (isset($_GET['auto'])) print "

" . T_("Work has ended. That is it") . "

"; -include_once("functions/functions.operator.php"); + if (ALLOW_OPERATOR_EXTENSION_SELECT && VOIP_ENABLED) { //unassign extension diff --git a/index.php b/index.php index 20a70b30..5e6e4f17 100644 --- a/index.php +++ b/index.php @@ -112,7 +112,7 @@ if (isset($_GET['endcase'])) //if ($db->HasFailedTrans()) {print "

FAILED AT ENDCASE

"; exit();} } -$js = array("js/popup.js","js/tabber.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","js/tabber.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); $body = true; $script = ""; if (AUTO_LOGOUT_MINUTES !== false) @@ -142,7 +142,7 @@ else if (HEADER_EXPANDER_MANUAL) $js[] = "js/headerexpandmanual.js"; } -xhtml_head(T_("queXS"), $body, array("css/index.css","css/tabber.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css") , $js); +xhtml_head(T_("queXS"), $body, array("css/index.css","css/tabber.css","include/jquery-ui/jquery-ui.min.css") , $js); print $script; $case_id = get_case_id($operator_id,true); diff --git a/index_interface2.php b/index_interface2.php index 7893036d..b7da752f 100644 --- a/index_interface2.php +++ b/index_interface2.php @@ -159,7 +159,7 @@ if (isset($_GET['endcase'])) } -$js = array("js/popup.js","js/tabber.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","js/tabber.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); $body = true; $script = ""; if (AUTO_LOGOUT_MINUTES !== false) @@ -194,7 +194,7 @@ else if (HEADER_EXPANDER_MANUAL) } -xhtml_head(T_("Case"), $body, array("css/index_interface2.css","css/tabber_interface2.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css") , $js); +xhtml_head(T_("Case"), $body, array("css/index_interface2.css","css/tabber_interface2.css","include/jquery-ui/jquery-ui.min.css") , $js); print $script; $case_id = get_case_id($operator_id,true); diff --git a/info.php b/info.php index 700e0e30..6f5be7f0 100644 --- a/info.php +++ b/info.php @@ -51,7 +51,7 @@ include ("db.inc.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Information"),true,false,$js); diff --git a/nocallavailable.php b/nocallavailable.php index 36ab49fb..ae2b2ffc 100644 --- a/nocallavailable.php +++ b/nocallavailable.php @@ -70,7 +70,7 @@ if (isset($_GET['contact_phone'])) $js = array(); if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); $jsw = "js/window.js"; if (browser_ie()) $jsw = "js/window_ie6.js"; diff --git a/nocaseavailable.php b/nocaseavailable.php index 2dfdbec8..bd9f74dc 100644 --- a/nocaseavailable.php +++ b/nocaseavailable.php @@ -58,7 +58,7 @@ include ("functions/functions.limesurvey.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("No case available"),true,array("css/table.css"),$js); diff --git a/performance.php b/performance.php index 29ae3b66..7675f979 100644 --- a/performance.php +++ b/performance.php @@ -56,7 +56,7 @@ include("functions/functions.performance.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Performance"),true,array("css/table.css"),$js); diff --git a/project_info.php b/project_info.php index 66284935..5fe8ace0 100644 --- a/project_info.php +++ b/project_info.php @@ -56,7 +56,7 @@ include ("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Project information"),true,false,$js); diff --git a/respondent.php b/respondent.php index 35fadc5b..f55c228b 100644 --- a/respondent.php +++ b/respondent.php @@ -63,7 +63,7 @@ $js = array("js/window.js","js/showhide.js"); if (AUTO_LOGOUT_MINUTES !== false) { - $js[] = "include/jquery-ui/js/jquery-1.4.2.min.js"; + $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } diff --git a/rs_answeringmachine.php b/rs_answeringmachine.php index d282fe62..77e93164 100644 --- a/rs_answeringmachine.php +++ b/rs_answeringmachine.php @@ -54,14 +54,14 @@ $case_id = get_case_id($operator_id); $questionnaire_id = get_questionnaire_id($operator_id); $leavemessage = leave_message($case_id); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { $js[] = "js/childnap.js"; } -xhtml_head(T_("Respondent Selection - Answering machine"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"),$js); +xhtml_head(T_("Respondent Selection - Answering machine"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"),$js); if ($leavemessage) { diff --git a/rs_answeringmachine_interface2.php b/rs_answeringmachine_interface2.php index 7ab47cd2..a30d9ff3 100644 --- a/rs_answeringmachine_interface2.php +++ b/rs_answeringmachine_interface2.php @@ -54,14 +54,14 @@ $case_id = get_case_id($operator_id); $questionnaire_id = get_questionnaire_id($operator_id); $leavemessage = leave_message($case_id); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { $js[] = "js/childnap.js"; } -xhtml_head(T_("Respondent Selection - Answering machine"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"),$js); +xhtml_head(T_("Respondent Selection - Answering machine"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"),$js); if ($leavemessage) { diff --git a/rs_business.php b/rs_business.php index 8d226b15..f8e5bcda 100644 --- a/rs_business.php +++ b/rs_business.php @@ -44,7 +44,7 @@ include ("functions/functions.xhtml.php"); */ include ("lang.inc.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -52,7 +52,7 @@ if (AUTO_LOGOUT_MINUTES !== false) } -xhtml_head(T_("Respondent Selection - Business answers"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Business answers"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); ?> diff --git a/rs_business_interface2.php b/rs_business_interface2.php index ad5c7a27..eaa309bb 100644 --- a/rs_business_interface2.php +++ b/rs_business_interface2.php @@ -44,7 +44,7 @@ include ("functions/functions.xhtml.php"); */ include ("lang.inc.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -52,7 +52,7 @@ if (AUTO_LOGOUT_MINUTES !== false) } -xhtml_head(T_("Respondent Selection - Business answers"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Business answers"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); ?> diff --git a/rs_callback.php b/rs_callback.php index 8ae023bf..aa54b1cc 100644 --- a/rs_callback.php +++ b/rs_callback.php @@ -54,7 +54,7 @@ include ("functions/functions.operator.php"); */ include ("functions/functions.limesurvey.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -63,7 +63,7 @@ if (AUTO_LOGOUT_MINUTES !== false) -xhtml_head(T_("Respondent Selection - Call back"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js ); +xhtml_head(T_("Respondent Selection - Call back"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js ); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/rs_callback_interface2.php b/rs_callback_interface2.php index d46b6559..c582af9d 100644 --- a/rs_callback_interface2.php +++ b/rs_callback_interface2.php @@ -54,7 +54,7 @@ include ("functions/functions.operator.php"); */ include ("functions/functions.limesurvey.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -63,7 +63,7 @@ if (AUTO_LOGOUT_MINUTES !== false) -xhtml_head(T_("Respondent Selection - Call back"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js ); +xhtml_head(T_("Respondent Selection - Call back"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js ); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/rs_intro.php b/rs_intro.php index 38a41293..dc0a6f8e 100644 --- a/rs_intro.php +++ b/rs_intro.php @@ -54,7 +54,7 @@ include ("functions/functions.operator.php"); */ include ("functions/functions.limesurvey.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -62,7 +62,7 @@ if (AUTO_LOGOUT_MINUTES !== false) } -xhtml_head(T_("Respondent Selection - Introduction"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Introduction"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); //display introduction text diff --git a/rs_intro_interface2.php b/rs_intro_interface2.php index ac4bd72d..5b0140c7 100644 --- a/rs_intro_interface2.php +++ b/rs_intro_interface2.php @@ -54,7 +54,7 @@ include ("functions/functions.operator.php"); */ include ("functions/functions.limesurvey.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -62,7 +62,7 @@ if (AUTO_LOGOUT_MINUTES !== false) } -xhtml_head(T_("Respondent Selection - Introduction"),false,array("include/bootstrap-3.3.2/css/bootstrap.min.css","css/rs.css","css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Introduction"),false,array("include/bootstrap/css/bootstrap.min.css","css/rs.css","css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/rs_project_end.php b/rs_project_end.php index dc13621f..5bf150fd 100644 --- a/rs_project_end.php +++ b/rs_project_end.php @@ -59,7 +59,7 @@ if (ALTERNATE_INTERFACE && !is_voip_enabled($operator_id)) die(); } -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -68,7 +68,7 @@ if (AUTO_LOGOUT_MINUTES !== false) -xhtml_head(T_("Respondent Selection - Project end"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Project end"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); $case_id = get_case_id($operator_id); $questionnaire_id = get_questionnaire_id($operator_id); diff --git a/rs_project_end_interface2.php b/rs_project_end_interface2.php index 65ec4372..e2e10c72 100644 --- a/rs_project_end_interface2.php +++ b/rs_project_end_interface2.php @@ -50,7 +50,7 @@ include_once ("functions/functions.xhtml.php"); include_once ("functions/functions.operator.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -59,7 +59,7 @@ if (AUTO_LOGOUT_MINUTES !== false) -xhtml_head(T_("Respondent Selection - Project end"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Project end"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/rs_project_intro.php b/rs_project_intro.php index 8b9c3fb5..92600f28 100644 --- a/rs_project_intro.php +++ b/rs_project_intro.php @@ -49,14 +49,14 @@ include ("functions/functions.xhtml.php"); */ include ("functions/functions.operator.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { $js[] = "js/childnap.js"; } -xhtml_head(T_("Respondent Selection - Project Introduction"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Project Introduction"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/rs_project_intro_interface2.php b/rs_project_intro_interface2.php index 246f3be1..2f21a3a3 100644 --- a/rs_project_intro_interface2.php +++ b/rs_project_intro_interface2.php @@ -49,14 +49,14 @@ include ("functions/functions.xhtml.php"); */ include ("functions/functions.operator.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { $js[] = "js/childnap.js"; } -xhtml_head(T_("Respondent Selection - Project Introduction"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Project Introduction"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/rs_quota_end.php b/rs_quota_end.php index b9943598..daf4afcf 100644 --- a/rs_quota_end.php +++ b/rs_quota_end.php @@ -49,7 +49,7 @@ include ("functions/functions.xhtml.php"); */ include ("functions/functions.operator.php"); -$js = array("js/popup.js","include/jquery-ui/js/jquery-1.4.2.min.js","include/jquery-ui/js/jquery-ui-1.8.2.custom.min.js"); +$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); if (AUTO_LOGOUT_MINUTES !== false) { @@ -58,7 +58,7 @@ if (AUTO_LOGOUT_MINUTES !== false) -xhtml_head(T_("Respondent Selection - Project Quota End"),true,array("css/rs.css","include/jquery-ui/css/smoothness/jquery-ui-1.8.2.custom.css"), $js); +xhtml_head(T_("Respondent Selection - Project Quota End"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); diff --git a/shifts.php b/shifts.php index 8bbe6726..0bc76406 100644 --- a/shifts.php +++ b/shifts.php @@ -51,7 +51,7 @@ include("functions/functions.operator.php"); $js = false; if (AUTO_LOGOUT_MINUTES !== false) - $js = array("include/jquery-ui/js/jquery-1.4.2.min.js","js/childnap.js"); + $js = array("include/jquery/jquery-1.4.2.min.js","js/childnap.js"); xhtml_head(T_("Shift List"),false,array("css/table.css"),$js,false,600); diff --git a/status.php b/status.php index 30781bc7..b06b4fb1 100644 --- a/status.php +++ b/status.php @@ -70,7 +70,7 @@ if ($state == 4 && AUTO_POPUP) $js = array("js/popupkeep.js"); if (AUTO_LOGOUT_MINUTES !== false) { - $js[] = "include/jquery-ui/js/jquery-1.4.2.min.js"; + $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } diff --git a/status_interface2.php b/status_interface2.php index ebcd6a02..a8fdf644 100644 --- a/status_interface2.php +++ b/status_interface2.php @@ -63,11 +63,11 @@ else if (AUTO_LOGOUT_MINUTES !== false) { - $js[] = "include/jquery-ui/js/jquery-1.4.2.min.js"; + $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } -xhtml_head(T_("Status"),false,array("include/bootstrap-3.3.2/css/bootstrap.min.css","css/status_interface2.css"),$js); +xhtml_head(T_("Status"),false,array("include/bootstrap/css/bootstrap.min.css","css/status_interface2.css"),$js); $ca = get_call_attempt($operator_id,false); if ($ca) diff --git a/supervisorchat.php b/supervisorchat.php index ff26e583..57467d03 100644 --- a/supervisorchat.php +++ b/supervisorchat.php @@ -49,7 +49,7 @@ include ("functions/functions.xhtml.php"); */ include("functions/functions.operator.php"); -$js = array("include/jquery-ui/js/jquery-1.4.2.min.js","include/strophe/strophe.js","js/supervisorchat.js"); +$js = array("include/jquery/jquery-1.4.2.min.js","include/strophe/strophe.js","js/supervisorchat.js"); if (AUTO_LOGOUT_MINUTES !== false) $js[] = "js/childnap.js"; diff --git a/waitnextcase_interface2.php b/waitnextcase_interface2.php index a7d490c1..3f05625d 100644 --- a/waitnextcase_interface2.php +++ b/waitnextcase_interface2.php @@ -40,7 +40,7 @@ include_once("lang.inc.php"); */ include_once("functions/functions.xhtml.php"); -xhtml_head(T_("Standby"),false,array("include/bootstrap-3.3.2/css/bootstrap.min.css","css/index_interface2.css"), array(), false, 300); +xhtml_head(T_("Standby"),false,array("include/bootstrap/css/bootstrap.min.css","css/index_interface2.css"), array(), false, 300); if (isset($_GET['auto'])) { @@ -197,4 +197,4 @@ else xhtml_foot(); -?> \ No newline at end of file +?>