From 485b6ded38208030d83967e0a012170b00a4ad7d Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 20 May 2015 15:31:27 +0300 Subject: [PATCH] new Appointment window popup - simple, clean and nice day names ready to add to translation .po file swithch to string instead of selector if only 1 respondent for case time selectors switched to 15 min intervals, excluded last value as it will equal possible time limit --- appointment.php | 40 ++++---- functions/functions.calendar.php | 154 ++++++++++++------------------- 2 files changed, 84 insertions(+), 110 deletions(-) diff --git a/appointment.php b/appointment.php index dde5f62a..0e775645 100644 --- a/appointment.php +++ b/appointment.php @@ -115,16 +115,15 @@ 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-ui/js/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } -xhtml_head(T_("Appointment"),true,array("css/respondent.css"),$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", //select a respondent from a list or create a new one -print("

" . T_("Select a respondent") . "

"); - +print "

" . T_("Respondent") . ":"; $sr = display_respondent_list($case_id,isset($_GET['respondent_id'])?bigintval($_GET['respondent_id']):false,true); - +print "

"; if ($sr != false) $_GET['respondent_id'] = $sr; if(isset($_GET['respondent_id']) && $_GET['respondent_id'] == 0) @@ -141,6 +140,11 @@ if(isset($_GET['respondent_id']) && $_GET['respondent_id'] == 0) else if(isset($_GET['respondent_id'])) { $respondent_id = bigintval($_GET['respondent_id']); + + $sql = "SELECT TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name)) as tme, r.Time_zone_name as tzn FROM `respondent` as r WHERE r.respondent_id = $respondent_id"; + $ct = $db->GetRow($sql); + + print "

".T_("Timezone").": ".$ct['tzn']. " ".T_("Current Time").": " . $ct['tme'] . "

"; if (isset($_GET['d']) && isset($_GET['m']) && isset($_GET['y'])) { @@ -156,12 +160,12 @@ else if(isset($_GET['respondent_id'])) { $list = return_contact_phone_list($case_id); - print "

" . T_("Select phone number:") . "

"; + print "
"; if (isset($_GET['contact_phone_id'])) $contact_phone_id = bigintval($_GET['contact_phone_id']); else $contact_phone_id = -1; - print "
"; foreach($list as $l) { $id = $l['contact_phone_id']; @@ -170,27 +174,29 @@ else if(isset($_GET['respondent_id'])) print ""; } - print "
"; + print "
"; if(isset($_GET['contact_phone_id'])) { $contact_phone_id = bigintval($_GET['contact_phone_id']); + + print "
"; if ($contact_phone_id == 0) { //ability to add a new one ?>

-
-

-

"/> + +

+  "/> -

+
-

- " . T_("Accept appointment from ") .convert_time($_GET['start']).T_(" till ").convert_time($_GET['end']).T_(" on ") . "$day/$month/$year? " . T_("on") . " $phonenum

"; ?> -

- + ".T_("Accept appointment from ")."".$_GET['start']."".T_(" till ")."".$_GET['end']."".T_(" on ") . " $day/$month/$year " . T_("on") . " $phonenum ?

"; ?> + @@ -216,10 +220,12 @@ else if(isset($_GET['respondent_id'])) - "/>

+ "/> "; } } diff --git a/functions/functions.calendar.php b/functions/functions.calendar.php index 5c3f3de3..cfa942a1 100644 --- a/functions/functions.calendar.php +++ b/functions/functions.calendar.php @@ -2,9 +2,6 @@ /** * Functions relating to appointment times and calendars * - * - * - * * This file is part of queXS * * queXS is free software; you can redistribute it and/or modify @@ -31,7 +28,6 @@ * */ - /** * Configuration file */ @@ -42,7 +38,6 @@ include_once(dirname(__FILE__).'/../config.inc.php'); */ include_once(dirname(__FILE__).'/../db.inc.php'); - /** * Add a phone number to a case (via the contact_phone table) * @@ -131,7 +126,7 @@ function convert_time($time) //Use the TIME_FORMAT string as defined in mysql http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format $from = array("%H","%h","%I","%i","%S","%s","%p"); - $to = array(substr($time,0,2),$h,$h,$m,$s,$s,$p); + $to = array(substr($time,0,2),$h,$h,$m,$m,$s,$s,$p); return str_replace($from,$to,TIME_FORMAT); } @@ -193,32 +188,34 @@ function display_respondent_list($case_id,$respondent_id = false,$first = false) WHERE case_id = '$case_id'"; $rs = $db->GetAll($sql); - - print "
"; + if (!empty($rs)) { - $rid = $r['respondent_id']; - if ($respondent_id == false && $first == true) + foreach($rs as $r) { - $first = false; - $selected = "selected='selected'"; - $respondent_id = $rid; + $rid = $r['respondent_id']; + if ($respondent_id == false && $first == true) + { + $first = false; + $selected = "selected='selected'"; + $respondent_id = $rid; + } + else $selected = ""; + + if ($rid == $respondent_id) $selected="selected='selected'"; + print ""; } - else - $selected = ""; - if ($rid == $respondent_id) $selected="selected='selected'"; - print ""; } + print "

"; } - print ""; + else { echo " ",$rs[0]['firstName']," ",$rs[0]['lastName'],""; $respondent_id =$rs[0]['respondent_id'];} return $respondent_id; } - - /** * Print an XHTML form for adding or modifying respondent details * @@ -256,13 +253,12 @@ function display_respondent_form($respondent_id = false,$case_id = false) $rs = $db->GetRow($sql); } - $sql = "SELECT Time_zone_name FROM timezone_template"; $rs = $db->Execute($sql); - print "
+ print "
"; /** @@ -272,7 +268,6 @@ function display_respondent_form($respondent_id = false,$case_id = false) } - /** * Print shift details in XHTML based on the given day * Display start time, and if start time selected display end time also @@ -294,16 +289,14 @@ function display_time($questionnaire_id,$respondent_id, $day, $month, $year, $ti { global $db; - $restricted = is_shift_restricted($questionnaire_id); - if ($restricted) { /** * Select shift start and end times for this day */ - $sql = " SELECT s.shift_id, HOUR(TIME(CONVERT_TZ(s.start,'UTC',r.Time_zone_name))) as sh, MINUTE(TIME(CONVERT_TZ(s.start,'UTC',r.Time_zone_name))) as sm, !(DATE(CONVERT_TZ(NOW(),'System',r.Time_zone_name)) = DATE(CONVERT_TZ(s.start,'UTC',r.Time_zone_name))) as today, HOUR(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as eh, MINUTE(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as em, (TIME_TO_SEC( TIMEDIFF( TIME( CONVERT_TZ( s.end, 'UTC', r.Time_zone_name ) ) , TIME( CONVERT_TZ( s.start, 'UTC', r.Time_zone_name ) ) ) ) /300) as intervals, TIME(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) as start, TIME(CONVERT_TZ(s.end,'UTC',r.Time_zone_name)) as end + $sql = "SELECT s.shift_id, HOUR(TIME(CONVERT_TZ(s.start,'UTC',r.Time_zone_name))) as sh, MINUTE(TIME(CONVERT_TZ(s.start,'UTC',r.Time_zone_name))) as sm, !(DATE(CONVERT_TZ(NOW(),'System',r.Time_zone_name)) = DATE(CONVERT_TZ(s.start,'UTC',r.Time_zone_name))) as today, HOUR(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as eh, MINUTE(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as em, (TIME_TO_SEC( TIMEDIFF( s.end, s.start)) / 900) as intervals, TIME(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) as start, TIME(CONVERT_TZ(s.end,'UTC',r.Time_zone_name)) as end FROM shift as s, respondent as r, `case` as c WHERE r.respondent_id = '$respondent_id' AND r.case_id = c.case_id @@ -312,27 +305,21 @@ function display_time($questionnaire_id,$respondent_id, $day, $month, $year, $ti AND MONTH(CONVERT_TZ(s.start,'UTC', r.Time_zone_name)) = '$month' AND YEAR(CONVERT_TZ(s.start,'UTC', r.Time_zone_name)) = '$year' ORDER BY s.start ASC"; - } else - $sql = "SELECT 0 as sh, 0 as sm, !(DATE(CONVERT_TZ(NOW(),'System',r.Time_zone_name)) = DATE(CONVERT_TZ('$year-$month-$day 00:00:00','UTC',r.Time_zone_name))) as today, HOUR(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as eh, MINUTE(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as em, (TIME_TO_SEC( TIMEDIFF( TIME( CONVERT_TZ(DATE_ADD( CURDATE( ) , INTERVAL '23:59:59' HOUR_SECOND ) , 'System', r.Time_zone_name ) ) , TIME( CONVERT_TZ( CURDATE(), 'System', r.Time_zone_name ) ) ) ) /300) as intervals, TIME(CONVERT_TZ(CURDATE(),'System',r.Time_zone_name)) as start, TIME(CONVERT_TZ(DATE_ADD( CURDATE( ) , INTERVAL '23:59:59' HOUR_SECOND ),'System',r.Time_zone_name)) as end + $sql = "SELECT 0 as sh, 0 as sm, !(DATE(CONVERT_TZ(NOW(),'System',r.Time_zone_name)) = DATE(CONVERT_TZ('$year-$month-$day 08:00:00','UTC',r.Time_zone_name))) as today, HOUR(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as eh, MINUTE(TIME(CONVERT_TZ(NOW(),'System',r.Time_zone_name))) as em, (TIME_TO_SEC( TIMEDIFF( TIME( CONVERT_TZ(DATE_ADD( CURDATE( ) , INTERVAL '23:59:59' HOUR_SECOND ) , 'System', r.Time_zone_name ) ) , TIME( CONVERT_TZ( CURDATE(), 'System', r.Time_zone_name ) ) ) ) /900) as intervals, TIME(CONVERT_TZ(CURDATE(),'System',r.Time_zone_name)) as start, TIME(CONVERT_TZ(DATE_ADD( CURDATE( ) , INTERVAL '23:59:59' HOUR_SECOND ),'System',r.Time_zone_name)) as end FROM respondent as r WHERE r.respondent_id = '$respondent_id'"; - $rs = $db->GetAll($sql); - - print "
"; + foreach($rs as $r) { - print "

" . T_("Shift from:") . " ".convert_time($r['start']).T_(" till ")." ".convert_time($r['end'])."

"; + print "

" . T_("Shift from:") . " ".$r['start']." " . T_(" till ")." ".$r['end']."

"; } - print "
"; + - - - print "

"; - print ""; foreach ($rs as $r) { $sh = $r['sh']; @@ -345,12 +332,9 @@ function display_time($questionnaire_id,$respondent_id, $day, $month, $year, $ti //today = 0 if the shift is today otherwise 1 $today = $r['today']; - - /** - * Display only times in the future and within the shift in 5 minute intervals - * - */ - for ($i = 0; $i <= $intervals; $i++) + + // * Display only times in the future and within the shift in 5 minute intervals + for ($i = 0; $i <= $intervals-1; $i++) { $t = str_pad($sh,2,"0",STR_PAD_LEFT).":".str_pad($sm,2,"0",STR_PAD_LEFT).":00"; @@ -359,42 +343,34 @@ function display_time($questionnaire_id,$respondent_id, $day, $month, $year, $ti $selected = ""; if ($t == $time) $selected = "selected=\"selected\""; - print ""; + print ""; } - - - $sm += 5; + $sm += 15; if ($sm >= 60) { $sh++; if ($sh >= 24) $sh -= 24; $sm -= 60; } - } - } - print ""; + print ""; if ($time) { $eh = substr($time,0,2); $em = substr($time,3,2); - print ""; foreach ($rs as $r) { $sh = $r['sh']; $sm = $r['sm']; $intervals = $r['intervals']; - - /** - * Display only times after the start time and within the shift in 5 minute intervals - * - */ - for ($i = 0; $i <= $intervals; $i++) + // * Display only times after the start time and within the shift in 15 minute intervals + for ($i = 0; $i <= $intervals-1; $i++) { $t = str_pad($sh,2,"0",STR_PAD_LEFT).":".str_pad($sm,2,"0",STR_PAD_LEFT).":00"; @@ -403,28 +379,26 @@ function display_time($questionnaire_id,$respondent_id, $day, $month, $year, $ti $selected = ""; if ($t == $timeend) $selected = "selected=\"selected\""; - print ""; + print ""; } - $sm += 5; + $sm += 15; if ($sm >= 60) { $sh++; if ($sh >= 24) $sh -= 24; $sm -= 60; + } - } - } - print ""; + print ""; } print ""; print ""; print ""; print ""; - print "

"; } /** @@ -485,21 +459,19 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon // Build the days in the month $Month->build(); - ?> - - - - - - - - - - - -"; + print " + + + + + + + + + + "; while ( $Day = $Month->fetch() ) { @@ -512,7 +484,6 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon $today = ""; if ($year == $Day->thisYear() && $month == $Day->thisMonth() && $day == $Day->thisDay()) $today = "today"; - // isFirst() to find start of week if ( $Day->isFirst() ) echo ( "\n" ); @@ -525,7 +496,7 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon //if it is in the past -> unavailable if ($Day->getTimeStamp() < $ttoday->getTimeStamp()) { - echo ( "\n" ); + echo ( "\n" ); } //if there are shift restrictions, restrict else if ($restricted) @@ -540,16 +511,16 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon if (!empty($rs) && $rs->RecordCount() == 0) { - echo ( "\n" ); + echo ( "\n" ); } else { - echo ( "\n" ); + echo ( "\n" ); } } else - echo ( "\n" ); + echo ( "\n" ); } // isLast() to find end of week @@ -559,18 +530,15 @@ function display_calendar($respondent_id, $questionnaire_id, $year = false, $mon ?> - +
- getTimeStamp())); ?> -
MTWTFSS
" . T_( date('F Y',$Month->getTimeStamp())) . "
" . T_("Mon") . "" . T_("Tue") . "" . T_("Wed") . "" . T_("Thu") . "" . T_("Fri") . "" . T_("Sat") . "" . T_("Sun") . "
".$Day->thisDay()."".$Day->thisDay()."".$Day->thisDay()."".$Day->thisDay()."".$Day->thisDay()."".$Day->thisDay()."".$Day->thisDay()."".$Day->thisDay()."
- << + <<  " . date('l j F Y',mktime(0,0,0,$month,$day,$year)) . "";?> - >> + >>
" . date('l j F Y',mktime(0,0,0,$month,$day,$year)) . ""; } - - -?> +?> \ No newline at end of file