diff --git a/bootstrap.php b/bootstrap.php index fa13a4c1dfe7f15f99527ca4332d683e6760f0e3..c5a03fe2ab45d9bbe2982b95e4d4b6444caec192 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -43,6 +43,7 @@ class Bootstrap { ini_set('date.timezone', 'America/New_York'); } } + date_default_timezone_set('UTC'); if (!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = ''; diff --git a/css/jquery.multiselect.filter.css b/css/jquery.multiselect.filter.css new file mode 100644 index 0000000000000000000000000000000000000000..f8c323a7d2a49bcaab788fb81756fb1b5d4ab375 --- /dev/null +++ b/css/jquery.multiselect.filter.css @@ -0,0 +1,3 @@ +.ui-multiselect-hasfilter ul { position:relative; top:2px } +.ui-multiselect-filter { float:left; margin-right:10px; font-size:11px } +.ui-multiselect-filter input { width:100px; font-size:10px; margin-left:5px; height:15px; padding:2px; border:1px solid #292929; -webkit-appearance:textfield; -webkit-box-sizing:content-box; } diff --git a/include/ajax.config.php b/include/ajax.config.php index bf8d905e0cc9284db412dec493d3948b30a68c90..c625d75502b7d734ffe4a01a0adcef6e8af5832c 100644 --- a/include/ajax.config.php +++ b/include/ajax.config.php @@ -40,7 +40,7 @@ class ConfigAjaxAPI extends AjaxController { $config=array( 'lock_time' => ($cfg->getLockTime()*3600), 'html_thread' => (bool) $cfg->isHtmlThreadEnabled(), - 'date_format' => ($cfg->getDateFormat()), + 'date_format' => $cfg->getDateFormat(true), 'lang' => $lang, 'short_lang' => $sl, 'has_rtl' => $rtl, diff --git a/include/ajax.content.php b/include/ajax.content.php index 39eda3e6d2921d36386ed42049f125d19db3321a..d4e306e71880d7f5b88226a541c35e20e79a8cb8 100644 --- a/include/ajax.content.php +++ b/include/ajax.content.php @@ -28,7 +28,7 @@ class ContentAjaxAPI extends AjaxController { $log->getTitle(), Format::display(str_replace(',',', ',$log->getText())), __('Log Date'), - Format::db_daydatetime($log->getCreateDate()), + Format::daydatetime($log->getCreateDate()), __('IP Address'), $log->getIP()); }else { diff --git a/include/ajax.kbase.php b/include/ajax.kbase.php index 16e961ad94b8b2afad49e677c38c1af330edbb66..3554c85bbddc6531f97055b16255d7dabd0bfb19 100644 --- a/include/ajax.kbase.php +++ b/include/ajax.kbase.php @@ -50,7 +50,7 @@ class KbaseAjaxAPI extends AjaxController { <a href="faq.php?id=%d">'.__('View').'</a> | <a href="faq.php?id=%d">'.__('Attachments (%d)').'</a>', $faq->getQuestion(), $faq->getAnswerWithImages(), - Format::db_daydatetime($faq->getUpdateDate()), + Format::daydatetime($faq->getUpdateDate()), $faq->getId(), $faq->getId(), $faq->getNumAttachments()); diff --git a/include/class.auth.php b/include/class.auth.php index f67b01237c0ce1a8cb13b935a7e35e68ef177007..ed9a7373167f4b54c2ca8ad48ca3374228a0efc7 100644 --- a/include/class.auth.php +++ b/include/class.auth.php @@ -444,9 +444,6 @@ abstract class StaffAuthenticationBackend extends AuthenticationBackend { $staff->setAuthKey($authkey); $staff->refreshSession(true); //set the hash. - $_SESSION['TZ_OFFSET'] = $staff->getTZoffset(); - $_SESSION['TZ_DST'] = $staff->observeDaylight(); - Signal::send('auth.login.succeeded', $staff); if ($bk->supportsInteractiveAuthentication()) @@ -617,11 +614,6 @@ abstract class UserAuthenticationBackend extends AuthenticationBackend { $user->refreshSession(true); //set the hash. - if (($acct = $user->getAccount()) && ($tid = $acct->get('timezone_id'))) { - $_SESSION['TZ_OFFSET'] = Timezone::getOffsetById($tid); - $_SESSION['TZ_DST'] = $acct->get('dst'); - } - //Log login info... $msg=sprintf(_S('%1$s (%2$s) logged in [%3$s]' /* Tokens are <username>, <id>, and <ip> */), diff --git a/include/class.config.php b/include/class.config.php index 4499b2ef359e2faf9ca045e3e8983197f4173e47..0e29cedcfc677af11be09c7c431af10ca02aa735 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -251,8 +251,27 @@ class OsticketConfig extends Config { return $this->get('db_tz_offset'); } - function getDefaultTimezoneId() { - return $this->get('default_timezone_id'); + function getDefaultTimezone() { + return $this->get('default_timezone'); + } + + function getTimezone() { + global $thisstaff, $thisclient; + + if ($thisstaff) + $zone = $thisstaff->getTimezone(); + #elseif ($thisclient) + # $zone = $thisclient->getTimezone(); + else + $zone = $this->get('default_timezone'); + + if (!$zone) + $zone = ini_get('date.timezone'); + return $zone; + } + + function getDefaultLocale() { + return $this->get('default_locale'); } /* Date & Time Formats */ @@ -260,18 +279,45 @@ class OsticketConfig extends Config { return ($this->get('enable_daylight_saving')); } function getTimeFormat() { - return $this->get('time_format'); - } - function getDateFormat() { - return $this->get('date_format'); + if ($this->get('date_formats') == 'custom') + return $this->get('time_format'); + return ''; + } + function isForce24HourTime() { + return $this->get('date_formats') == '24'; + } + function getDateFormat($propogate=false) { + if ($this->get('date_formats') == 'custom') + return $this->get('date_format'); + if ($propogate) { + if (class_exists('IntlDateFormatter')) { + $formatter = new IntlDateFormatter( + Internationalization::getCurrentLocale(), + IntlDateFormatter::SHORT, + IntlDateFormatter::NONE, + $this->getTimezone(), + IntlDateFormatter::GREGORIAN + ); + return $formatter->getPattern(); + } + else { + // Use a standard + return 'y-M-d'; + } + } + return ''; } function getDateTimeFormat() { - return $this->get('datetime_format'); + if ($this->get('date_formats') == 'custom') + return $this->get('datetime_format'); + return ''; } function getDayDateTimeFormat() { - return $this->get('daydatetime_format'); + if ($this->get('date_formats') == 'custom') + return $this->get('daydatetime_format'); + return ''; } function getConfigInfo() { @@ -871,7 +917,7 @@ class OsticketConfig extends Config { $f['date_format']=array('type'=>'string', 'required'=>1, 'error'=>__('Date format is required')); $f['datetime_format']=array('type'=>'string', 'required'=>1, 'error'=>__('Datetime format is required')); $f['daydatetime_format']=array('type'=>'string', 'required'=>1, 'error'=>__('Day, Datetime format is required')); - $f['default_timezone_id']=array('type'=>'int', 'required'=>1, 'error'=>__('Default Timezone is required')); + $f['default_timezone']=array('type'=>'string', 'required'=>1, 'error'=>__('Default Timezone is required')); $f['system_language']=array('type'=>'string', 'required'=>1, 'error'=>__('A primary system language is required')); if(!Validator::process($f, $vars, $errors) || $errors) @@ -898,8 +944,9 @@ class OsticketConfig extends Config { 'date_format'=>$vars['date_format'], 'datetime_format'=>$vars['datetime_format'], 'daydatetime_format'=>$vars['daydatetime_format'], - 'default_timezone_id'=>$vars['default_timezone_id'], - 'enable_daylight_saving'=>isset($vars['enable_daylight_saving'])?1:0, + 'date_formats'=>$vars['date_formats'], + 'default_timezone'=>$vars['default_timezone'], + 'default_locale'=>$vars['default_locale'], 'system_language'=>$vars['system_language'], 'secondary_langs'=>$secondary_langs, )); diff --git a/include/class.format.php b/include/class.format.php index 2357e45e5583990767b37298d5dd6ced66517fed..186a02d0e4016766d3d94ab3d5b0ff1572f0f85f 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -482,34 +482,149 @@ class Format { return $tstring; } - /* Dates helpers...most of this crap will change once we move to PHP 5*/ - function db_date($time) { + function __formatDate($timestamp, $format, $fromDb, $dayType, $timeType, + $strftimeFallback, $timezone) { global $cfg; - return Format::userdate($cfg->getDateFormat(), Misc::db2gmtime($time)); + + if ($timestamp && $fromDb) { + $timestamp = Misc::db2gmtime($timestamp); + } + elseif (!$timestamp) { + $D = new DateTime(); + $timestamp = $D->getTimestamp(); + } + if (class_exists('IntlDateFormatter')) { + $formatter = new IntlDateFormatter( + Internationalization::getCurrentLocale(), + $dayType, + $timeType, + $timezone, + IntlDateFormatter::GREGORIAN, + $format ?: null + ); + if ($cfg->isForce24HourTime()) { + $format = str_replace(array('a', 'h'), array('', 'H'), + $formatter->getPattern()); + $formatter->setPattern($format); + } + return $formatter->format($timestamp); + } + // Fallback using strftime + $format = self::getStrftimeFormat($format); + // TODO: Properly convert to local time + $time = DateTime::createFromFormat('U', $timestamp, new DateTimeZone('UTC')); + $time->setTimeZone(new DateTimeZone($cfg->getTimeZone())); + $timestamp = $time->getTimestamp(); + return strftime($format ?: $strftimeFallback, $timestamp); } - function db_datetime($time) { + function parseDate($date, $format=false) { global $cfg; - return Format::userdate($cfg->getDateTimeFormat(), Misc::db2gmtime($time)); + + if (class_exists('IntlDateFormatter')) { + $formatter = new IntlDateFormatter( + Internationalization::getCurrentLocale(), + null, + null, + null, + IntlDateFormatter::GREGORIAN, + $format ?: null + ); + if ($cfg->isForce24HourTime()) { + $format = str_replace(array('a', 'h'), array('', 'H'), + $formatter->getPattern()); + $formatter->setPattern($format); + } + return $formatter->parse($date); + } + // Fallback using strtotime + return strtotime($date); } - function db_daydatetime($time) { + function time($timestamp, $fromDb=true, $format=false, $timezone=false) { global $cfg; - return Format::userdate($cfg->getDayDateTimeFormat(), Misc::db2gmtime($time)); + + return self::__formatDate($timestamp, + $format ?: $cfg->getTimeFormat(), $fromDb, + IntlDateFormatter::NONE, IntlDateFormatter::SHORT, + '%x', $timezone ?: $cfg->getTimeZone()); } - function userdate($format, $gmtime) { - return Format::date($format, $gmtime, $_SESSION['TZ_OFFSET'], $_SESSION['TZ_DST']); + function date($timestamp, $fromDb=true, $format=false, $timezone=false) { + global $cfg; + + return self::__formatDate($timestamp, + $format ?: $cfg->getDateFormat(), $fromDb, + IntlDateFormatter::SHORT, IntlDateFormatter::NONE, + '%X', $timezone ?: $cfg->getTimeZone()); } - function date($format, $gmtimestamp, $offset=0, $daylight=false){ + function datetime($timestamp, $fromDb=true, $timezone=false) { + global $cfg; + + return self::__formatDate($timestamp, + $format ?: $cfg->getDateTimeFormat(), $fromDb, + IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, + '%X %x', $timezone ?: $cfg->getTimeZone()); + } - if(!$gmtimestamp || !is_numeric($gmtimestamp)) - return ""; + function daydatetime($timestamp, $fromDb=true, $timezone=false) { + global $cfg; - $offset+=$daylight?date('I', $gmtimestamp):0; //Daylight savings crap. + return self::__formatDate($timestamp, + $format ?: $cfg->getDayDateTimeFormat(), $fromDb, + IntlDateFormatter::FULL, IntlDateFormatter::SHORT, + '%X %x', $timezone ?: $cfg->getTimeZone()); + } + + function getStrftimeFormat($format) { + static $dateToStrftime = array( + '%d' => 'dd', + '%a' => 'EEE', + '%e' => 'd', + '%A' => 'EEEE', + '%w' => 'e', + '%w' => 'c', + '%z' => 'D', + + '%V' => 'w', + + '%B' => 'MMMM', + '%m' => 'MM', + '%b' => 'MMM', + + '%g' => 'Y', + '%G' => 'Y', + '%Y' => 'y', + '%y' => 'yy', + + '%P' => 'a', + '%l' => 'h', + '%k' => 'H', + '%I' => 'hh', + '%H' => 'HH', + '%M' => 'mm', + '%S' => 'ss', + + '%z' => 'ZZZ', + '%Z' => 'z', + ); - return date($format, ($gmtimestamp+ ($offset*3600))); + $flipped = array_flip($dateToStrftime); + krsort($flipped); + // Also establish a list of ids, so we can do a creative replacement + // without clobbering the common letters in the formats + $ids = array_keys($flipped); + $ids = array_flip($ids); + foreach ($flipped as $icu=>$date) { + $format = str_replace($date, chr($ids[$icu]), $format); + } + return preg_replace_callback('`[\x00-\x1f]`', + function($m) use ($ids) { + return $ids[ord($m[0])]; + }, + $format + ); } // Thanks, http://stackoverflow.com/a/2955878/1025836 diff --git a/include/class.forms.php b/include/class.forms.php index dafc403f1ec85d14663607e2ab3b5d44d1b598db..d4041dd47cc6e41dd48f141598b081a490280105 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1047,32 +1047,23 @@ class DatetimeField extends FormField { return (int) $value; } - function parse($value) { - if (!$value) return null; - $config = $this->getConfiguration(); - return ($config['gmt']) ? Misc::db2gmtime($value) : $value; - } - function toString($value) { global $cfg; $config = $this->getConfiguration(); - $format = ($config['time']) - ? $cfg->getDateTimeFormat() : $cfg->getDateFormat(); - if ($config['gmt']) - // Return time local to user's timezone - return Format::userdate($format, $value); + // If GMT is set, convert to local time zone. Otherwise, leave + // unchanged (default TZ is UTC) + if ($config['time']) + return Format::datetime($value, false, !$config['gmt'] ? 'UTC' : false); else - return Format::date($format, $value); + return Format::date($value, false, false, !$config['gmt'] ? 'UTC' : false); } function export($value) { $config = $this->getConfiguration(); if (!$value) return ''; - elseif ($config['gmt']) - return Format::userdate('Y-m-d H:i:s', $value); else - return Format::date('Y-m-d H:i:s', $value); + return Format::date($value, false, 'y-MM-dd HH:mm:ss', !$config['gmt'] ? 'UTC' : false); } function getConfigurationOptions() { @@ -1960,12 +1951,15 @@ class DatetimePickerWidget extends Widget { if ($this->value) { $this->value = is_int($this->value) ? $this->value : strtotime($this->value); - if ($config['gmt']) - $this->value += 3600 * - $_SESSION['TZ_OFFSET']+($_SESSION['TZ_DST']?date('I',$this->value):0); + if ($config['gmt']) { + // Convert to GMT time + $tz = new DateTimeZone($cfg->getTimezone()); + $D = DateTime::createFromFormat('U', $this->value); + $this->value += $tz->getOffset($D); + } list($hr, $min) = explode(':', date('H:i', $this->value)); - $this->value = Format::date($cfg->getDateFormat(), $this->value); + $this->value = Format::date($this->value, false, false, 'UTC'); } ?> <input type="text" name="<?php echo $this->name; ?>" @@ -1987,7 +1981,7 @@ class DatetimePickerWidget extends Widget { showButtonPanel: true, buttonImage: './images/cal.png', showOn:'both', - dateFormat: $.translate_format('<?php echo $cfg->getDateFormat(); ?>') + dateFormat: $.translate_format('<?php echo $cfg->getDateFormat(true); ?>') }); }); </script> @@ -2015,9 +2009,12 @@ class DatetimePickerWidget extends Widget { list($hr, $min) = explode(':', $data[$this->name . ':time']); $datetime += $hr * 3600 + $min * 60; } - if ($datetime && $config['gmt']) - $datetime -= (int) (3600 * $_SESSION['TZ_OFFSET'] + - ($_SESSION['TZ_DST'] ? date('I',$datetime) : 0)); + if ($datetime && $config['gmt']) { + // Convert to GMT time + $tz = new DateTimeZone($cfg->getTimezone()); + $D = DateTime::createFromFormat('U', $datetime); + $datetime -= $tz->getOffset($D); + } } return $datetime; } diff --git a/include/class.i18n.php b/include/class.i18n.php index 054e0bfbff4e5c7ee4ecb4c5b773e288d3527723..2aff09521ee3bd8ea61f717459bbe0f93d2da485 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -379,6 +379,23 @@ class Internationalization { return self::getDefaultLanguage(); } + static function getCurrentLocale() { + global $thisstaff, $cfg; + + if ($thisstaff) { + return $thisstaff->getLocale() + ?: self::getCurrentLanguage(); + } + if (!$locale) + $locale = $cfg->getDefaultLocale(); + + if (!$locale) + $locale = self::getCurrentLanguage(); + + return $locale; + } + + static function getTtfFonts() { if (!class_exists('Phar')) return; @@ -410,6 +427,25 @@ class Internationalization { return true; } + static function allLocales() { + $locales = array(); + if (class_exists('ResourceBundle')) { + $current_lang = self::getCurrentLanguage(); + $langs = array(); + foreach (self::getConfiguredSystemLanguages() as $code=>$info) { + list($lang,) = explode('_', $code, 2); + $langs[$lang] = true; + } + foreach (ResourceBundle::getLocales('') as $code) { + list($lang,) = explode('_', $code, 2); + if (isset($langs[$lang])) { + $locales[$code] = Locale::getDisplayName($code, $current_lang); + } + } + } + return $locales; + } + static function bootstrap() { require_once INCLUDE_DIR . 'class.translation.php'; diff --git a/include/class.misc.php b/include/class.misc.php index 84871c5397e2311cc344e2b636f2fa0bbd006d9f..b515507c8610a30448ff10cb7246128360d672c9 100644 --- a/include/class.misc.php +++ b/include/class.misc.php @@ -57,15 +57,18 @@ class Misc { function dbtime($var=null){ global $cfg; - if(is_null($var) || !$var) - $time=Misc::gmtime(); //gm time. - else{ //user time to GM. - $time=is_int($var)?$var:strtotime($var); - $offset=$_SESSION['TZ_OFFSET']+($_SESSION['TZ_DST']?date('I',$time):0); - $time=$time-($offset*3600); + if (is_null($var) || !$var) { + // Default timezone is set to UTC + $time = time(); } - //gm to db time - return $time+($cfg->getDBTZoffset()*3600); + else { //user time to UTC + $tz = new DateTimeZone($cfg->getTimezone()); + $time = is_int($var) ? $var : strtotime($var); + $D = DateTime::createFromFormat('U', $time); + $time -= $tz->getOffset($D); + } + // UTC to db time + return $time + ($cfg->getDBTZoffset()*3600); } /*Helper get GM time based on timezone offset*/ @@ -127,13 +130,12 @@ class Misc { ob_start(); echo sprintf('<select name="%s" id="%s">',$name,$name); echo '<option value="" selected>'.__('Time').'</option>'; - $format = $cfg->getTimeFormat(); for($i=23; $i>=0; $i--) { for($minute=45; $minute>=0; $minute-=15) { $sel=($hr==$i && $min==$minute)?'selected="selected"':''; $_minute=str_pad($minute, 2, '0',STR_PAD_LEFT); $_hour=str_pad($i, 2, '0',STR_PAD_LEFT); - $disp = gmdate($format, $i*3600 + $minute*60); + $disp = Format::time($i*3600 + $minute*60 + 1, false, false, 'UTC'); echo sprintf('<option value="%s:%s" %s>%s</option>',$_hour,$_minute,$sel,$disp); } } diff --git a/include/class.note.php b/include/class.note.php index d16112d4ee2926b8a01b1d94cfd6d49e23a229c7..4b354944e72821618bdd4e699269786aa13c69d1 100644 --- a/include/class.note.php +++ b/include/class.note.php @@ -44,7 +44,7 @@ class QuickNote extends QuickNoteModel { } function getFormattedTime() { - return Format::db_datetime(strpos($this->updated, '0000-') !== 0 + return Format::datetime(strpos($this->updated, '0000-') !== 0 ? $this->updated : $this->created); } diff --git a/include/class.osticket.php b/include/class.osticket.php index d7e8f3d98a4386762d0071294f6dfb982f4a070e..15500c232ddbc3920fb0c5b73848d4c9e6ebebbc 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -432,10 +432,6 @@ class osTicket { if(!($ost = new osTicket())) return null; - //Set default time zone... user/staff settting will override it (on login). - $_SESSION['TZ_OFFSET'] = $ost->getConfig()->getTZoffset(); - $_SESSION['TZ_DST'] = $ost->getConfig()->observeDaylightSaving(); - // Bootstrap installed plugins $ost->plugins->bootstrap(); diff --git a/include/class.pdf.php b/include/class.pdf.php index f0422b47bc5e242b89c56c52266b35948f066eda..34973391ffa8e288ee3d5e20473f2d28313349c4 100644 --- a/include/class.pdf.php +++ b/include/class.pdf.php @@ -84,9 +84,7 @@ class Ticket2PDF extends mPDF $this->SetFont('Arial', 'B',10); $this->WriteCell(0, 5, $cfg->getTitle(), 0, 0, 'L'); $this->SetFont('Arial', 'I',10); - $this->WriteCell(0, 5, Format::date($cfg->getDateTimeFormat(), Misc::gmtime(), - $_SESSION['TZ_OFFSET'], $_SESSION['TZ_DST']) - .' GMT '.$_SESSION['TZ_OFFSET'], 0, 1, 'R'); + $this->WriteCell(0, 5, Format::daydatetime(null, false), 0, 1, 'R'); $this->Ln(5); } @@ -184,7 +182,7 @@ class Ticket2PDF extends mPDF $this->SetFont('Arial', 'B', 11); $this->WriteCell($l, 7, __('Create Date'), 1, 0, 'L', true); $this->SetFont(''); - $this->WriteCell($c, 7, Format::db_datetime($ticket->getCreateDate()), 1, 0, 'L', true); + $this->WriteCell($c, 7, Format::datetime($ticket->getCreateDate()), 1, 0, 'L', true); $this->SetFont('Arial', 'B', 11); $this->WriteCell($l, 7, __('Source'), 1, 0, 'L', true); $this->SetFont(''); @@ -222,22 +220,22 @@ class Ticket2PDF extends mPDF $this->SetFont('Arial', 'B', 11); $this->WriteCell($l, 7, __('Last Response'), 1, 0, 'L', true); $this->SetFont(''); - $this->WriteCell($c, 7, Format::db_datetime($ticket->getLastRespDate()), 1, 1, 'L', true); + $this->WriteCell($c, 7, Format::datetime($ticket->getLastRespDate()), 1, 1, 'L', true); $this->SetFont('Arial', 'B', 11); if($ticket->isOpen()) { $this->WriteCell($l, 7, __('Due Date'), 1, 0, 'L', true); $this->SetFont(''); - $this->WriteCell($c, 7, Format::db_datetime($ticket->getEstDueDate()), 1, 0, 'L', true); + $this->WriteCell($c, 7, Format::datetime($ticket->getEstDueDate()), 1, 0, 'L', true); } else { $this->WriteCell($l, 7, __('Close Date'), 1, 0, 'L', true); $this->SetFont(''); - $this->WriteCell($c, 7, Format::db_datetime($ticket->getCloseDate()), 1, 0, 'L', true); + $this->WriteCell($c, 7, Format::datetime($ticket->getCloseDate()), 1, 0, 'L', true); } $this->SetFont('Arial', 'B', 11); $this->WriteCell($l, 7, __('Last Message'), 1, 0, 'L', true); $this->SetFont(''); - $this->WriteCell($c, 7, Format::db_datetime($ticket->getLastMsgDate()), 1, 1, 'L', true); + $this->WriteCell($c, 7, Format::datetime($ticket->getLastMsgDate()), 1, 1, 'L', true); $this->SetFillColor(255, 255, 255); foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) { @@ -289,7 +287,7 @@ class Ticket2PDF extends mPDF $this->SetFillColor($color[0], $color[1], $color[2]); $this->SetFont('Arial', 'B', 11); - $this->WriteCell($w/2, 7, Format::db_datetime($entry['created']), 'LTB', 0, 'L', true); + $this->WriteCell($w/2, 7, Format::datetime($entry['created']), 'LTB', 0, 'L', true); $this->SetFont('Arial', '', 10); $this->WriteCell($w, 7, Format::truncate($entry['title'], 50), 'TB', 0, 'L', true); $this->WriteCell($w/2, 7, $entry['name'] ?: $entry['poster'], 'TBR', 1, 'L', true); diff --git a/include/class.staff.php b/include/class.staff.php index dd3444bea22dba5f4019101e92eaa7d90f44c7a2..e78c88dfd143c931dfe1c817d0c411b6d65e13f3 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -72,11 +72,6 @@ class Staff extends AuthenticatedUser { if(($time=strtotime($this->ht['passwdreset']?$this->ht['passwdreset']:$this->ht['added']))) $this->ht['passwd_change'] = time()-$time; //XXX: check timezone issues. - if($this->ht['timezone_id']) - $this->ht['tz_offset'] = Timezone::getOffsetById($this->ht['timezone_id']); - elseif($this->ht['timezone_offset']) - $this->ht['tz_offset'] = $this->ht['timezone_offset']; - return ($this->id); } @@ -155,10 +150,6 @@ class Staff extends AuthenticatedUser { return $this->isPasswdResetDue(); } - function getTZoffset() { - return $this->ht['tz_offset']; - } - function observeDaylight() { return $this->ht['daylight_saving']?true:false; } @@ -280,6 +271,14 @@ class Staff extends AuthenticatedUser { return $this->ht['lang']; } + function getTimezone() { + return $this->ht['timezone']; + } + + function getLocale() { + return $this->ht['locale']; + } + function isManager() { return (($dept=$this->getDept()) && $dept->getManagerId()==$this->getId()); } @@ -514,9 +513,6 @@ class Staff extends AuthenticatedUser { $errors['passwd1']=__('New password MUST be different from the current password!'); } - if(!$vars['timezone_id']) - $errors['timezone_id']=__('Time zone selection is required'); - if($vars['default_signature_type']=='mine' && !$vars['signature']) $errors['default_signature_type'] = __("You don't have a signature"); @@ -533,8 +529,8 @@ class Staff extends AuthenticatedUser { .' ,phone_ext='.db_input($vars['phone_ext']) .' ,mobile="'.db_input(Format::phone($vars['mobile']),false).'"' .' ,signature='.db_input(Format::sanitize($vars['signature'])) - .' ,timezone_id='.db_input($vars['timezone_id']) - .' ,daylight_saving='.db_input(isset($vars['daylight_saving'])?1:0) + .' ,timezone='.db_input($vars['timezone']) + .' ,locale='.db_input($vars['locale']) .' ,show_assigned_tickets='.db_input(isset($vars['show_assigned_tickets'])?1:0) .' ,max_page_size='.db_input($vars['max_page_size']) .' ,auto_refresh_rate='.db_input($vars['auto_refresh_rate']) @@ -792,9 +788,6 @@ class Staff extends AuthenticatedUser { if(!$vars['group_id']) $errors['group_id']=__('Group is required'); - if(!$vars['timezone_id']) - $errors['timezone_id']=__('Time zone selection is required'); - if($errors) return false; @@ -806,8 +799,7 @@ class Staff extends AuthenticatedUser { .' ,assigned_only='.db_input(isset($vars['assigned_only'])?1:0) .' ,dept_id='.db_input($vars['dept_id']) .' ,group_id='.db_input($vars['group_id']) - .' ,timezone_id='.db_input($vars['timezone_id']) - .' ,daylight_saving='.db_input(isset($vars['daylight_saving'])?1:0) + .' ,timezone='.db_input($vars['timezone']) .' ,username='.db_input($vars['username']) .' ,firstname='.db_input($vars['firstname']) .' ,lastname='.db_input($vars['lastname']) diff --git a/include/class.thread.php b/include/class.thread.php index b57da97133ac53e51f11bb8fd87a3ed6370ef1a6..7a95ebd3da025a6cd0e08e66aaa35a0fb2a4a748 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -800,19 +800,10 @@ Class ThreadEntry { switch(strtolower($tag)) { case 'create_date': - return Format::date( - $cfg->getDateTimeFormat(), - Misc::db2gmtime($this->getCreateDate()), - $cfg->getTZOffset(), - $cfg->observeDaylightSaving()); - break; + // XXX: Consider preferences of receiving user + return Format::datetime($this->getCreateDate(), true, 'UTC'); case 'update_date': - return Format::date( - $cfg->getDateTimeFormat(), - Misc::db2gmtime($this->getUpdateDate()), - $cfg->getTZOffset(), - $cfg->observeDaylightSaving()); - break; + return Format::datetime($this->getUpdateDate(), true, 'UTC'); } return false; diff --git a/include/class.ticket.php b/include/class.ticket.php index e65347a03663ef74276f52e78f054a175856d7bc..5a837b56a78d6578282fa12f4224cb80638c8f4c 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -384,10 +384,9 @@ class Ticket { 'slaId' => $this->getSLAId(), 'user_id' => $this->getOwnerId(), 'duedate' => $this->getDueDate() - ? Format::userdate($cfg->getDateFormat(), - Misc::db2gmtime($this->getDueDate())) + ? Format::date($this->getDueDate()) :'', - 'time' => $this->getDueDate()?(Format::userdate('G:i', Misc::db2gmtime($this->getDueDate()))):'', + 'time' => $this->getDueDate()?(Format::date($this->getDueDate(), true, 'HH:mm')):'', ); return $info; @@ -1339,31 +1338,19 @@ class Ticket { return sprintf('%s/scp/tickets.php?id=%d', $cfg->getBaseUrl(), $this->getId()); break; case 'create_date': - return Format::date( - $cfg->getDateTimeFormat(), - Misc::db2gmtime($this->getCreateDate()), - $cfg->getTZOffset(), - $cfg->observeDaylightSaving()); + return Format::datetime($this->getCreateDate(), true, 'UTC'); break; case 'due_date': $duedate =''; if($this->getEstDueDate()) - $duedate = Format::date( - $cfg->getDateTimeFormat(), - Misc::db2gmtime($this->getEstDueDate()), - $cfg->getTZOffset(), - $cfg->observeDaylightSaving()); + $duedate = Format::datetime($this->getEstDueDate(), true, 'UTC'); return $duedate; break; case 'close_date': $closedate =''; if($this->isClosed()) - $closedate = Format::date( - $cfg->getDateTimeFormat(), - Misc::db2gmtime($this->getCloseDate()), - $cfg->getTZOffset(), - $cfg->observeDaylightSaving()); + $closedate = Format::datetime($this->getCloseDate(), true, 'UTC'); return $closedate; break; diff --git a/include/client/faq.inc.php b/include/client/faq.inc.php index b43db1431ec4d15d6e5433efd4b8c63b2a5126fe..b879645c8f54d92ccc6b6ab99538d344d80564b5 100644 --- a/include/client/faq.inc.php +++ b/include/client/faq.inc.php @@ -17,7 +17,7 @@ $category=$faq->getCategory(); <div class="article-title flush-left"> <?php echo $faq->getLocalQuestion() ?> </div> -<div class="faded"><?php echo __('Last updated').' '.Format::db_daydatetime($category->getUpdateDate()); ?></div> +<div class="faded"><?php echo __('Last updated').' '.Format::daydatetime($category->getUpdateDate()); ?></div> <br/> <div class="thread-body bleed"> <?php echo Format::safe_html($faq->getLocalAnswerWithImages()); ?> diff --git a/include/client/profile.inc.php b/include/client/profile.inc.php index bcc5aa439b8bcb27cc1563ff46c1d7ab65b9c6fd..6326d44b0296ec01fcc5bee8d814447455e7ca42 100644 --- a/include/client/profile.inc.php +++ b/include/client/profile.inc.php @@ -36,17 +36,6 @@ if ($acct = $thisclient->getAccount()) { </select> <span class="error"><?php echo $errors['timezone_id']; ?></span> </td> -</tr> -<tr> - <td width="180"> - <?php echo __('Daylight Saving') ?>: - </td> - <td> - <input type="checkbox" name="dst" value="1" <?php echo $info['dst']?'checked="checked"':''; ?>> - <?php echo __('Observe daylight saving'); ?> - <em>(<?php __('Current Time'); ?>: - <strong><?php echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['dst']); ?></strong>)</em> - </td> </tr> <tr> <td width="180"> diff --git a/include/client/register.inc.php b/include/client/register.inc.php index 78b42ac9474fc251c3e937f5989677cbc2a70a3e..1280dcce9d8d481f6dbaf0f74e12b0f52eb591ad 100644 --- a/include/client/register.inc.php +++ b/include/client/register.inc.php @@ -2,8 +2,7 @@ $info = $_POST; if (!isset($info['timezone_id'])) $info += array( - 'timezone_id' => $cfg->getDefaultTimezoneId(), - 'dst' => $cfg->observeDaylightSaving(), + 'timezone' => $cfg->getDefaultTimezone(), 'backend' => null, ); if (isset($user) && $user instanceof ClientCreateRequest) { @@ -53,17 +52,6 @@ $info = Format::htmlchars(($errors && $_POST)?$_POST:$info); <span class="error"><?php echo $errors['timezone_id']; ?></span> </td> </tr> -<tr> - <td width="180"> - <?php echo __('Daylight Saving'); ?>: - </td> - <td> - <input type="checkbox" name="dst" value="1" <?php echo $info['dst']?'checked="checked"':''; ?>> - <?php echo __('Observe daylight saving'); ?> - <em>(<?php echo __('Current Time'); ?>: - <strong><?php echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['dst']); ?></strong>)</em> - </td> -</tr> <tr> <td colspan=2"> <div><hr><h3><?php echo __('Access Credentials'); ?></h3></div> diff --git a/include/client/tickets.inc.php b/include/client/tickets.inc.php index 6b8e9df1af38ee40b56dcc831ad260c156d5e235..58ac63af651345554c0f0ab120727179ad80af0c 100644 --- a/include/client/tickets.inc.php +++ b/include/client/tickets.inc.php @@ -179,7 +179,7 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting <a class="Icon <?php echo strtolower($row['source']); ?>Ticket" title="<?php echo $row['email']; ?>" href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $ticketNumber; ?></a> </td> - <td> <?php echo Format::db_date($row['created']); ?></td> + <td> <?php echo Format::date($row['created']); ?></td> <td> <?php echo $row['status']; ?></td> <td> <a href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $subject; ?></a> diff --git a/include/client/view.inc.php b/include/client/view.inc.php index efebfe775a2945433fe1c06bf5665d9171f4bc19..cd0b2ccd3dd859e1de52acc8df6cf4249c08e57b 100644 --- a/include/client/view.inc.php +++ b/include/client/view.inc.php @@ -55,7 +55,7 @@ if ($thisclient && $thisclient->isGuest() </tr> <tr> <th><?php echo __('Create Date');?>:</th> - <td><?php echo Format::db_datetime($ticket->getCreateDate()); ?></td> + <td><?php echo Format::datetime($ticket->getCreateDate()); ?></td> </tr> </table> </td> @@ -117,7 +117,7 @@ if($ticket->getThreadCount() && ($thread=$ticket->getClientThread())) { ?> <table class="thread-entry <?php echo $threadType[$entry['thread_type']]; ?>" cellspacing="0" cellpadding="1" width="800" border="0"> <tr><th><div> -<?php echo Format::db_datetime($entry['created']); ?> +<?php echo Format::datetime($entry['created']); ?> <span class="textra"></span> <span><?php echo $poster; ?></span> </div> diff --git a/include/staff/apikeys.inc.php b/include/staff/apikeys.inc.php index ba45adccef44860eec3ec52136b60950971b9289..e5430c14d1fc3e200a44a7b9116d6826c3202bf9 100644 --- a/include/staff/apikeys.inc.php +++ b/include/staff/apikeys.inc.php @@ -78,8 +78,8 @@ else <td> <a href="apikeys.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($row['apikey']); ?></a></td> <td><?php echo $row['ipaddr']; ?></td> <td><?php echo $row['isactive']?__('Active'):'<b>'.__('Disabled').'</b>'; ?></td> - <td> <?php echo Format::db_date($row['created']); ?></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::date($row['created']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/banlist.inc.php b/include/staff/banlist.inc.php index 26e1d074d2fb070cedbc4242e03ad082cf023c71..7c83e9b1370c149f367cdb955a5ae7612600ae89 100644 --- a/include/staff/banlist.inc.php +++ b/include/staff/banlist.inc.php @@ -101,8 +101,8 @@ if($search) </td> <td> <a href="banlist.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($row['val']); ?></a></td> <td> <?php echo $row['isactive']?__('Active'):'<b>'.__('Disabled').'</b>'; ?></td> - <td><?php echo Format::db_date($row['created']); ?></td> - <td><?php echo Format::db_datetime($row['updated']); ?> </td> + <td><?php echo Format::date($row['created']); ?></td> + <td><?php echo Format::datetime($row['updated']); ?> </td> </tr> <?php } //end of while. diff --git a/include/staff/cannedresponses.inc.php b/include/staff/cannedresponses.inc.php index 70645010559a65e2aadf5469715945d6498b63c3..fe63868ba71655d7f596961a52abcf2e33593c66 100644 --- a/include/staff/cannedresponses.inc.php +++ b/include/staff/cannedresponses.inc.php @@ -90,7 +90,7 @@ else </td> <td><?php echo $row['isenabled']?__('Active'):'<b>'.__('Disabled').'</b>'; ?></td> <td><?php echo $row['department']?$row['department']:'— '.__('All Departments').' —'; ?></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/categories.inc.php b/include/staff/categories.inc.php index 1cb927395517c996325a8d2b1863014f88d2482c..c88237571ff1f37e786e78b475049d4ddff1a76a 100644 --- a/include/staff/categories.inc.php +++ b/include/staff/categories.inc.php @@ -79,7 +79,7 @@ else echo $C->getLocalName(); ?></a></td> <td><?php echo $C->getVisibilityDescription(); ?></td> <td style="text-align:right;padding-right:25px;"><?php echo $faqs; ?></td> - <td> <?php echo Format::db_datetime($C->updated); ?></td> + <td> <?php echo Format::datetime($C->updated); ?></td> </tr><?php } // end of foreach ?> <tfoot> diff --git a/include/staff/emails.inc.php b/include/staff/emails.inc.php index 62900ab33f615399d02c50a1a92df8115f05fe7c..6eb1faf3cf23a978e9e8f7ca975a76d9753e7cf8 100644 --- a/include/staff/emails.inc.php +++ b/include/staff/emails.inc.php @@ -92,8 +92,8 @@ $def_priority = $cfg->getDefaultPriority()->getDesc(); <td><?php echo $row['priority'] ?: $def_priority; ?></td> <td><a href="departments.php?id=<?php $row['dept_id'] ?: $def_dept_id; ?>"><?php echo $row['department'] ?: $def_dept_name; ?></a></td> - <td> <?php echo Format::db_date($row['created']); ?></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::date($row['created']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/faq-category.inc.php b/include/staff/faq-category.inc.php index 8622a44abb8d6b9e7559f049d74a246fd2ba6c11..8ff80af13b9a0be313d561ea17af13a4bf14cd65 100644 --- a/include/staff/faq-category.inc.php +++ b/include/staff/faq-category.inc.php @@ -11,7 +11,7 @@ if(!defined('OSTSTAFFINC') || !$category || !$thisstaff) die('Access Denied'); <div> <strong><?php echo $category->getName() ?></strong> <span>(<?php echo $category->isPublic()?__('Public'):__('Internal'); ?>)</span> - <time> <?php echo __('Last updated').' '. Format::db_daydatetime($category->getUpdateDate()); ?></time> + <time> <?php echo __('Last updated').' '. Format::daydatetime($category->getUpdateDate()); ?></time> </div> <div class="cat-desc"> <?php echo Format::display($category->getDescription()); ?> diff --git a/include/staff/faq-view.inc.php b/include/staff/faq-view.inc.php index 0b5533ff8c5a8e1564a3bd11fc103ec916eaed7b..7b120f0d21aab98d411e024015ec1892ad26de40 100644 --- a/include/staff/faq-view.inc.php +++ b/include/staff/faq-view.inc.php @@ -92,7 +92,7 @@ if ($thisstaff->canManageFAQ()) { ?> </div> <div class="faded"><?php echo __('Last updated');?> - <?php echo Format::db_daydatetime($category->getUpdateDate()); ?> + <?php echo Format::daydatetime($category->getUpdateDate()); ?> </div> <br/> <div class="thread-body bleed"> diff --git a/include/staff/filters.inc.php b/include/staff/filters.inc.php index 76a62a107b0a868d1dcadf1131cae562c8110561..6b4c98647a20910f1a3f5688a58674ef1e5f55e4 100644 --- a/include/staff/filters.inc.php +++ b/include/staff/filters.inc.php @@ -88,8 +88,8 @@ else <td style="text-align:right;padding-right:25px;"><?php echo $row['execorder']; ?> </td> <td style="text-align:right;padding-right:25px;"><?php echo $row['rules']; ?> </td> <td> <?php echo Format::htmlchars($targets[$row['target']]); ?></td> - <td> <?php echo Format::db_date($row['created']); ?></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::date($row['created']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/groups.inc.php b/include/staff/groups.inc.php index 4b47dba87554fceda68666db180f1d2a4fbc30d1..326400daa0ba12932943c96934a7783ffb13af92 100644 --- a/include/staff/groups.inc.php +++ b/include/staff/groups.inc.php @@ -90,8 +90,8 @@ else <td style="text-align:right;padding-right:30px"> <?php echo $row['depts']; ?> </td> - <td><?php echo Format::db_date($row['created']); ?> </td> - <td><?php echo Format::db_datetime($row['updated']); ?> </td> + <td><?php echo Format::date($row['created']); ?> </td> + <td><?php echo Format::datetime($row['updated']); ?> </td> </tr> <?php } //end of while. diff --git a/include/staff/helptopics.inc.php b/include/staff/helptopics.inc.php index a161409e18943a850617525ffc0385c8b0789fdc..1c9d3fd649344453cd9d32282f39ca257a60d2d2 100644 --- a/include/staff/helptopics.inc.php +++ b/include/staff/helptopics.inc.php @@ -104,7 +104,7 @@ foreach ($topics as &$t) <td><?php echo $row['ispublic']?__('Public'):'<b>'.__('Private').'</b>'; ?></td> <td><?php echo $row['priority']; ?></td> <td><a href="departments.php?id=<?php echo $row['dept_id']; ?>"><?php echo $row['department']; ?></a></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/org-view.inc.php b/include/staff/org-view.inc.php index 5bc9d328196b1b295e05a4843071151b6005e5d6..06119767db764a3110a46a224aa3cf136186d811 100644 --- a/include/staff/org-view.inc.php +++ b/include/staff/org-view.inc.php @@ -51,11 +51,11 @@ if(!defined('OSTSCPINC') || !$thisstaff || !is_object($org)) die('Invalid path') <table border="0" cellspacing="" cellpadding="4" width="100%"> <tr> <th width="150"><?php echo __('Created'); ?>:</th> - <td><?php echo Format::db_datetime($org->getCreateDate()); ?></td> + <td><?php echo Format::datetime($org->getCreateDate()); ?></td> </tr> <tr> <th><?php echo __('Last Updated'); ?>:</th> - <td><?php echo Format::db_datetime($org->getUpdateDate()); ?></td> + <td><?php echo Format::datetime($org->getUpdateDate()); ?></td> </tr> </table> </td> diff --git a/include/staff/orgs.inc.php b/include/staff/orgs.inc.php index 862da34be7722441fb1b6f1c447edf3ec8b0d868..d85d42d1d087dcd16268336c79e3f2165a3f7892 100644 --- a/include/staff/orgs.inc.php +++ b/include/staff/orgs.inc.php @@ -124,8 +124,8 @@ else <tr id="<?php echo $row['id']; ?>"> <td> <a href="orgs.php?id=<?php echo $row['id']; ?>"><?php echo $row['name']; ?></a> </td> <td> <?php echo $row['users']; ?></td> - <td><?php echo Format::db_date($row['created']); ?></td> - <td><?php echo Format::db_datetime($row['updated']); ?> </td> + <td><?php echo Format::date($row['created']); ?></td> + <td><?php echo Format::datetime($row['updated']); ?> </td> </tr> <?php } //end of while. diff --git a/include/staff/pages.inc.php b/include/staff/pages.inc.php index a2c8e70ee3b317394b3a275e0d5f77b2dca566f1..2dfc48676682923a9bb006c78d596787b4b32026 100644 --- a/include/staff/pages.inc.php +++ b/include/staff/pages.inc.php @@ -84,8 +84,8 @@ print $pages->count(); <?php echo $page->isActive()?__('Active'):'<b>'.__('Disabled').'</b>'; ?> <?php echo $inuse?'<em>'.__('(in-use)').'</em>':''; ?> </td> - <td> <?php echo Format::db_date($page->created); ?></td> - <td> <?php echo Format::db_datetime($page->updated); ?></td> + <td> <?php echo Format::date($page->created); ?></td> + <td> <?php echo Format::datetime($page->updated); ?></td> </tr> <?php } //end of foreach. ?> diff --git a/include/staff/plugins.inc.php b/include/staff/plugins.inc.php index cd3282e4b030ad9ff728ccc916231c9083cb0d0b..9ec8ff7bd01c9185e8540ff6f48cd3a1e6c117fd 100644 --- a/include/staff/plugins.inc.php +++ b/include/staff/plugins.inc.php @@ -38,7 +38,7 @@ foreach ($ost->plugins->allInstalled() as $p) { ><?php echo $p->getName(); ?></a></td> <td><?php echo ($p->isActive()) ? 'Enabled' : '<strong>Disabled</strong>'; ?></td> - <td><?php echo Format::db_datetime($p->getInstallDate()); ?></td> + <td><?php echo Format::datetime($p->getInstallDate()); ?></td> </tr> <?php } else {} ?> <?php } ?> diff --git a/include/staff/profile.inc.php b/include/staff/profile.inc.php index e47784fc4eee6a13949e89a5b28979e0aeb53584..c4c3972b3679c97bfa9243f9ec750e0066d4ecb8 100644 --- a/include/staff/profile.inc.php +++ b/include/staff/profile.inc.php @@ -81,23 +81,20 @@ $info['id']=$staff->getId(); </th> </tr> <tr> - <td width="180" class="required"> + <td width="180"> <?php echo __('Time Zone');?>: </td> <td> - <select name="timezone_id" id="timezone_id"> - <option value="0">— <?php echo __('Select Time Zone');?> —</option> - <?php - $sql='SELECT id, offset,timezone FROM '.TIMEZONE_TABLE.' ORDER BY id'; - if(($res=db_query($sql)) && db_num_rows($res)){ - while(list($id,$offset, $tz)=db_fetch_row($res)){ - $sel=($info['timezone_id']==$id)?'selected="selected"':''; - echo sprintf('<option value="%d" %s>GMT %s - %s</option>',$id,$sel,$offset,$tz); - } - } - ?> + <select name="timezone" multiple="multiple" id="timezone-dropdown"> + <option value=""><?php echo __('System Default'); ?></option> +<?php foreach (DateTimeZone::listIdentifiers() as $zone) { ?> + <option value="<?php echo $zone; ?>" <?php + if ($info['timezone'] == $zone) + echo 'selected="selected"'; + ?>><?php echo $zone; ?></option> +<?php } ?> </select> - <span class="error">* <?php echo $errors['timezone_id']; ?></span> + <span class="error"><?php echo $errors['timezone']; ?></span> </td> </tr> <tr> @@ -118,14 +115,17 @@ $info['id']=$staff->getId(); <span class="error"> <?php echo $errors['lang']; ?></span> </td> </tr> - <tr> - <td width="180"> - <?php echo __('Daylight Saving');?>: - </td> + <tr><td width="220"><?php echo __('Preferred Locale');?>:</td> <td> - <input type="checkbox" name="daylight_saving" value="1" <?php echo $info['daylight_saving']?'checked="checked"':''; ?>> - <?php echo __('Observe daylight saving');?> - <em>(<?php echo __('Current Time');?>: <strong><?php echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['daylight_saving']); ?></strong>)</em> + <select name="locale"> + <option value=""><?php echo __('Use Language Preference'); ?></option> +<?php foreach (Internationalization::allLocales() as $code=>$name) { ?> + <option value="<?php echo $code; ?>" <?php + if ($code == $info['locale']) + echo 'selected="selected"'; + ?>><?php echo $name; ?></option> +<?php } ?> + </select> </td> </tr> <tr> @@ -260,3 +260,17 @@ $info['id']=$staff->getId(); <input type="button" name="cancel" value="<?php echo __('Cancel Changes');?>" onclick='window.location.href="index.php"'> </p> </form> +<link rel="stylesheet" href="<?php echo ROOT_PATH; ?>/css/jquery.multiselect.css"/> +<link rel="stylesheet" href="<?php echo ROOT_PATH; ?>/css/jquery.multiselect.filter.css"/> +<script type="text/javascript" src="<?php echo ROOT_PATH; ?>/js/jquery.multiselect.filter.min.js"></script> +<script type="text/javascript"> +$('#timezone-dropdown').multiselect({ + multiple: false, + header: <?php echo JsonDataEncoder::encode(__('Time Zones')); ?>, + noneSelectedText: <?php echo JsonDataEncoder::encode(__('System Default')); ?>, + selectedList: 1, + minWidth: 400 +}).multiselectfilter({ + placeholder: <?php echo JsonDataEncoder::encode(__('Search')); ?> +}); +</script> diff --git a/include/staff/settings-access.inc.php b/include/staff/settings-access.inc.php index fa6fc607e77d84f5383723785966311a5a8c3005..505caf52d2810a7a0fd0aa82f147c23ef5942174 100644 --- a/include/staff/settings-access.inc.php +++ b/include/staff/settings-access.inc.php @@ -176,7 +176,7 @@ $manage_content = function($title, $content) use ($contents) { echo Format::htmlchars($title); ?></a><br/> <span class="faded" style="display:inline-block;width:90%"><?php echo Format::display($notes); ?> - <em>(<?php echo sprintf(__('Last Updated %s'), Format::db_datetime($upd)); + <em>(<?php echo sprintf(__('Last Updated %s'), Format::datetime($upd)); ?>)</em></span></td></tr><?php }; ?> <tr> diff --git a/include/staff/settings-system.inc.php b/include/staff/settings-system.inc.php index 3a87722b58b442d37b45a1a2f4a1d8dbddec9fbb..3964997aa340442e5aac3fa248056bb07789b54b 100644 --- a/include/staff/settings-system.inc.php +++ b/include/staff/settings-system.inc.php @@ -127,54 +127,80 @@ $gmtime = Misc::gmtime(); </em> </th> </tr> - <tr><td width="220" class="required"><?php echo __('Time Format');?>:</td> + <tr><td width="220" class="required"><?php echo __('Default Locale');?>:</td> + <td> + <select name="default_locale"> + <option value=""><?php echo __('Use Language Preference'); ?></option> +<?php foreach (Internationalization::allLocales() as $code=>$name) { ?> + <option value="<?php echo $code; ?>" <?php + if ($code == $config['default_locale']) + echo 'selected="selected"'; + ?>><?php echo $name; ?></option> +<?php } ?> + </select> + </td> + </tr> + <tr><td width="220" class="required"><?php echo __('Default Time Zone');?>:</td> + <td> + <select name="default_timezone" multiple="multiple" id="timezone-dropdown"> +<?php foreach (DateTimeZone::listIdentifiers() as $zone) { ?> + <option value="<?php echo $zone; ?>" <?php + if ($config['default_timezone'] == $zone) + echo 'selected="selected"'; + ?>><?php echo $zone; ?></option> +<?php } ?> + </select> + </td> + </tr> + <tr><td width="220" class="required"><?php echo __('Date and Time Format');?>:</td> + <td> + <select name="date_formats" onchange="javascript: + $('#advanced-time').toggle($(this).find(':selected').val() == 'custom'); +"> +<?php foreach (array( + '' => __('Locale Defaults'), + '24' => __('Locale Defaults, 24-hour Time'), + 'custom' => '— '.__("Advanced").' —', +) as $v=>$name) { ?> + <option value="<?php echo $v; ?>" <?php + if ($v == $config['date_formats']) + echo 'selected="selected"'; + ?>><?php echo $name; ?></option> +<?php } ?> + </select> + </td> + </tr> + + </tbody> + <tbody id="advanced-time" <?php if ($config['date_formats'] != 'custom') + echo 'style="display:none;"'; ?>> + <tr> + <td width="220" class="indented required"><?php echo __('Time Format');?>:</td> <td> <input type="text" name="time_format" value="<?php echo $config['time_format']; ?>"> <font class="error">* <?php echo $errors['time_format']; ?></font> - <em><?php echo Format::date($config['time_format'], $gmtime, $config['tz_offset'], $config['enable_daylight_saving']); ?></em></td> + <em><?php echo Format::time(null, false); ?></em></td> </tr> - <tr><td width="220" class="required"><?php echo __('Date Format');?>:</td> + <tr><td width="220" class="indented required"><?php echo __('Date Format');?>:</td> <td><input type="text" name="date_format" value="<?php echo $config['date_format']; ?>"> <font class="error">* <?php echo $errors['date_format']; ?></font> - <em><?php echo Format::date($config['date_format'], $gmtime, $config['tz_offset'], $config['enable_daylight_saving']); ?></em> + <em><?php echo Format::date(null, false); ?></em> </td> </tr> - <tr><td width="220" class="required"><?php echo __('Date and Time Format');?>:</td> + <tr><td width="220" class="indented required"><?php echo __('Date and Time Format');?>:</td> <td><input type="text" name="datetime_format" value="<?php echo $config['datetime_format']; ?>"> <font class="error">* <?php echo $errors['datetime_format']; ?></font> - <em><?php echo Format::date($config['datetime_format'], $gmtime, $config['tz_offset'], $config['enable_daylight_saving']); ?></em> + <em><?php echo Format::datetime(null, false); ?></em> </td> </tr> - <tr><td width="220" class="required"><?php echo __('Day, Date and Time Format');?>:</td> + <tr><td width="220" class="indented required"><?php echo __('Day, Date and Time Format');?>:</td> <td><input type="text" name="daydatetime_format" value="<?php echo $config['daydatetime_format']; ?>"> <font class="error">* <?php echo $errors['daydatetime_format']; ?></font> - <em><?php echo Format::date($config['daydatetime_format'], $gmtime, $config['tz_offset'], $config['enable_daylight_saving']); ?></em> - </td> - </tr> - <tr><td width="220" class="required"><?php echo __('Default Time Zone');?>:</td> - <td> - <select name="default_timezone_id"> - <option value="">— <?php echo __('Select Default Time Zone');?> —</option> - <?php - $sql='SELECT id, offset,timezone FROM '.TIMEZONE_TABLE.' ORDER BY id'; - if(($res=db_query($sql)) && db_num_rows($res)){ - while(list($id, $offset, $tz)=db_fetch_row($res)){ - $sel=($config['default_timezone_id']==$id)?'selected="selected"':''; - echo sprintf('<option value="%d" %s>GMT %s - %s</option>', $id, $sel, $offset, $tz); - } - } - ?> - </select> - <font class="error">* <?php echo $errors['default_timezone_id']; ?></font> + <em><?php echo Format::daydatetime(null, false); ?></em> </td> </tr> - <tr> - <td width="220"><?php echo __('Daylight Saving');?>:</td> - <td> - <input type="checkbox" name="enable_daylight_saving" <?php echo $config['enable_daylight_saving'] ? 'checked="checked"': ''; ?>><?php echo __('Observe daylight savings');?> - </td> - </tr> - + </tbody> + <tbody> <tr> <th colspan="2"> <em><b><?php echo __('System Languages'); ?></b> @@ -246,3 +272,17 @@ $gmtime = Misc::gmtime(); <input class="button" type="reset" name="reset" value="<?php echo __('Reset Changes');?>"> </p> </form> +<link rel="stylesheet" href="<?php echo ROOT_PATH; ?>/css/jquery.multiselect.css"/> +<link rel="stylesheet" href="<?php echo ROOT_PATH; ?>/css/jquery.multiselect.filter.css"/> +<script type="text/javascript" src="<?php echo ROOT_PATH; ?>/js/jquery.multiselect.filter.min.js"></script> +<script type="text/javascript"> +$('#timezone-dropdown').multiselect({ + multiple: false, + header: <?php echo JsonDataEncoder::encode(__('Time Zones')); ?>, + noneSelectedText: <?php echo JsonDataEncoder::encode(__('Select Default Time Zone')); ?>, + selectedList: 1, + minWidth: 400 +}).multiselectfilter({ + placeholder: <?php echo JsonDataEncoder::encode(__('Search')); ?> +}); +</script> diff --git a/include/staff/slaplans.inc.php b/include/staff/slaplans.inc.php index 4acf6763ce198faa5d051e784f32aef46c7c6ecd..1eaf4b24e1d0150a869455c23e2c19d160fc4d7a 100644 --- a/include/staff/slaplans.inc.php +++ b/include/staff/slaplans.inc.php @@ -88,8 +88,8 @@ else ?></a> <?php echo $default; ?></td> <td><?php echo $row['isactive']?__('Active'):'<b>'.__('Disabled').'</b>'; ?></td> <td style="text-align:right;padding-right:35px;"><?php echo $row['grace_period']; ?> </td> - <td> <?php echo Format::db_date($row['created']); ?></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::date($row['created']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/staff.inc.php b/include/staff/staff.inc.php index fe2ba3f3f0657513b926b33136a02d6b10503afe..32d44e94a21eb13e36aa66447716a183835132d3 100644 --- a/include/staff/staff.inc.php +++ b/include/staff/staff.inc.php @@ -25,8 +25,6 @@ if($staff && $_REQUEST['a']!='add'){ $info['isactive']=1; $info['isvisible']=1; $info['isadmin']=0; - $info['timezone_id'] = $cfg->getDefaultTimezoneId(); - $info['daylight_saving'] = $cfg->observeDaylightSaving(); $qstr.='&a=add'; } $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); @@ -263,38 +261,21 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <span class="error">* <?php echo $errors['dept_id']; ?></span> <i class="help-tip icon-question-sign" href="#primary_department"></i> </td> </tr> - <tr> - <td width="180" class="required"> - <?php echo __("Agent's Time Zone");?>: - </td> - <td> - <select name="timezone_id" id="timezone_id"> - <option value="0">— <?php echo __('Select Time Zone');?> —</option> - <?php - $sql='SELECT id, offset,timezone FROM '.TIMEZONE_TABLE.' ORDER BY id'; - if(($res=db_query($sql)) && db_num_rows($res)){ - while(list($id,$offset, $tz)=db_fetch_row($res)){ - $sel=($info['timezone_id']==$id)?'selected="selected"':''; - echo sprintf('<option value="%d" %s>GMT %s - %s</option>',$id,$sel,$offset,$tz); - } - } - ?> - </select> - <span class="error">* <?php echo $errors['timezone_id']; ?></span> - </td> - </tr> <tr> <td width="180"> - <?php echo __('Daylight Saving');?>: + <?php echo __('Time Zone');?>: </td> <td> - <input type="checkbox" name="daylight_saving" value="1" <?php echo $info['daylight_saving']?'checked="checked"':''; ?>> - <?php echo __('Observe daylight saving');?> - <em>(<?php echo __('Current Time');?>: <strong><?php - echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['daylight_saving']); - ?></strong>) - <i class="help-tip icon-question-sign" href="#daylight_saving"></i> - </em> + <select name="timezone" multiple="multiple" id="timezone-dropdown"> + <option value=""><?php echo __('System Default'); ?></option> +<?php foreach (DateTimeZone::listIdentifiers() as $zone) { ?> + <option value="<?php echo $zone; ?>" <?php + if ($info['timezone'] == $zone) + echo 'selected="selected"'; + ?>><?php echo $zone; ?></option> +<?php } ?> + </select> + <span class="error">* <?php echo $errors['timezone']; ?></span> </td> </tr> <tr> @@ -362,3 +343,17 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <input type="button" name="cancel" value="<?php echo __('Cancel');?>" onclick='window.location.href="staff.php"'> </p> </form> +<link rel="stylesheet" href="<?php echo ROOT_PATH; ?>/css/jquery.multiselect.css"/> +<link rel="stylesheet" href="<?php echo ROOT_PATH; ?>/css/jquery.multiselect.filter.css"/> +<script type="text/javascript" src="<?php echo ROOT_PATH; ?>/js/jquery.multiselect.filter.min.js"></script> +<script type="text/javascript"> +$('#timezone-dropdown').multiselect({ + multiple: false, + header: <?php echo JsonDataEncoder::encode(__('Time Zones')); ?>, + noneSelectedText: <?php echo JsonDataEncoder::encode(__('System Default')); ?>, + selectedList: 1, + minWidth: 400 +}).multiselectfilter({ + placeholder: <?php echo JsonDataEncoder::encode(__('Search')); ?> +}); +</script> diff --git a/include/staff/staffmembers.inc.php b/include/staff/staffmembers.inc.php index f440ea3965badfe2218106765adfa496e6dfc514..9ea2607a6db6099cdef1d28ae85ce8ac321eefe9 100644 --- a/include/staff/staffmembers.inc.php +++ b/include/staff/staffmembers.inc.php @@ -150,8 +150,8 @@ else <td><?php echo $row['isactive']?__('Active'):'<b>'.__('Locked').'</b>'; ?> <?php echo $row['onvacation']?'<small>(<i>'.__('vacation').'</i>)</small>':''; ?></td> <td><a href="groups.php?id=<?php echo $row['group_id']; ?>"><?php echo Format::htmlchars($row['group_name']); ?></a></td> <td><a href="departments.php?id=<?php echo $row['dept_id']; ?>"><?php echo Format::htmlchars($row['dept']); ?></a></td> - <td><?php echo Format::db_date($row['created']); ?></td> - <td><?php echo Format::db_datetime($row['lastlogin']); ?> </td> + <td><?php echo Format::date($row['created']); ?></td> + <td><?php echo Format::datetime($row['lastlogin']); ?> </td> </tr> <?php } //end of while. diff --git a/include/staff/syslogs.inc.php b/include/staff/syslogs.inc.php index b264ffa05386b762926f28c26270f1634c580ae8..8b610d0f60dd4d87ec61351ce4313753a6c47acd 100644 --- a/include/staff/syslogs.inc.php +++ b/include/staff/syslogs.inc.php @@ -137,7 +137,7 @@ else <?php echo $sel?'checked="checked"':''; ?>> </td> <td> <a class="tip" href="#log/<?php echo $row['log_id']; ?>"><?php echo Format::htmlchars($row['title']); ?></a></td> <td><?php echo $row['log_type']; ?></td> - <td> <?php echo Format::db_daydatetime($row['created']); ?></td> + <td> <?php echo Format::daydatetime($row['created']); ?></td> <td><?php echo $row['ip_address']; ?></td> </tr> <?php diff --git a/include/staff/teams.inc.php b/include/staff/teams.inc.php index de08d25e88911eadac668e7c6f25e56610f42d2d..d05c371d7a3e20ad36543d6a21e072b20b8273f9 100644 --- a/include/staff/teams.inc.php +++ b/include/staff/teams.inc.php @@ -87,8 +87,8 @@ else </td> <td><a href="staff.php?id=<?php echo $row['lead_id']; ?>"><?php echo $row['team_lead']; ?> </a></td> - <td><?php echo Format::db_date($row['created']); ?> </td> - <td><?php echo Format::db_datetime($row['updated']); ?> </td> + <td><?php echo Format::date($row['created']); ?> </td> + <td><?php echo Format::datetime($row['updated']); ?> </td> </tr> <?php } //end of while. diff --git a/include/staff/template.inc.php b/include/staff/template.inc.php index 325a7423f60eaf50edfb685a8007dfd5537d6141..e0e3727474bed4873cd7fdfb16945083973438f0 100644 --- a/include/staff/template.inc.php +++ b/include/staff/template.inc.php @@ -92,7 +92,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); if (isset($impl[$cn])) { echo sprintf('<tr><td colspan="2"> <strong><a href="templates.php?id=%d&a=manage">%s</a></strong>, <span class="faded">%s</span><br/> %s</td></tr>', $impl[$cn]->getId(), Format::htmlchars(__($info['name'])), - sprintf(__('Updated %s'), Format::db_datetime($impl[$cn]->getLastUpdated())), + sprintf(__('Updated %s'), Format::datetime($impl[$cn]->getLastUpdated())), Format::htmlchars(__($info['desc']))); } else { echo sprintf('<tr><td colspan=2> <strong><a diff --git a/include/staff/templates.inc.php b/include/staff/templates.inc.php index 3fb2c49b5fab00a2953940c18e248e1e68e6c17c..c7bcafafb76e9567817432ce0cfb0af0f039626b 100644 --- a/include/staff/templates.inc.php +++ b/include/staff/templates.inc.php @@ -87,8 +87,8 @@ else <?php echo $default; ?></td> <td> <?php echo $row['isactive']?__('Active'):'<b>'.__('Disabled').'</b>'; ?></td> <td> <?php echo ($inuse)?'<b>'.__('Yes').'</b>':__('No'); ?></td> - <td> <?php echo Format::db_date($row['created']); ?></td> - <td> <?php echo Format::db_datetime($row['updated']); ?></td> + <td> <?php echo Format::date($row['created']); ?></td> + <td> <?php echo Format::datetime($row['updated']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/templates/org.tmpl.php b/include/staff/templates/org.tmpl.php index 06f82255c7736dc9db02d58f65ed5e51073f2b18..561cba8f678fe5b77efbcc53ddfc070059fe9c5f 100644 --- a/include/staff/templates/org.tmpl.php +++ b/include/staff/templates/org.tmpl.php @@ -40,7 +40,7 @@ if ($info['error']) { </table> <div class="clear"></div> <hr> - <div class="faded">Last updated <b><?php echo Format::db_datetime($org->getUpdateDate()); ?> </b></div> + <div class="faded">Last updated <b><?php echo Format::datetime($org->getUpdateDate()); ?> </b></div> </div> <div id="org-form" style="display:<?php echo $forms ? 'block' : 'none'; ?>;"> <div><p id="msg_info"><i class="icon-info-sign"></i> <?php echo __( diff --git a/include/staff/templates/ticket-preview.tmpl.php b/include/staff/templates/ticket-preview.tmpl.php index e045ed4f6625f5bcc5d9c67962513bcd719728c1..4d6e301961aa4bdccc56b78e01577ad91eb94759 100644 --- a/include/staff/templates/ticket-preview.tmpl.php +++ b/include/staff/templates/ticket-preview.tmpl.php @@ -62,14 +62,14 @@ echo sprintf(' <th>'.__('Created').':</th> <td>%s</td> </tr>',$ticket_state, - Format::db_datetime($ticket->getCreateDate())); + Format::datetime($ticket->getCreateDate())); if($ticket->isClosed()) { echo sprintf(' <tr> <th>'.__('Closed').':</th> <td>%s <span class="faded">by %s</span></td> </tr>', - Format::db_datetime($ticket->getCloseDate()), + Format::datetime($ticket->getCloseDate()), ($staff?$staff->getName():'staff') ); } elseif($ticket->getEstDueDate()) { @@ -78,7 +78,7 @@ if($ticket->isClosed()) { <th>'.__('Due Date').':</th> <td>%s</td> </tr>', - Format::db_datetime($ticket->getEstDueDate())); + Format::datetime($ticket->getEstDueDate())); } echo '</table>'; diff --git a/include/staff/templates/tickets.tmpl.php b/include/staff/templates/tickets.tmpl.php index ea0aae0b7e3b28be02252f2d245100b4b73cbddc..67f59864dd13692813ea64850ae5a87842397bed 100644 --- a/include/staff/templates/tickets.tmpl.php +++ b/include/staff/templates/tickets.tmpl.php @@ -140,7 +140,7 @@ if ($results) { ?> <a class="Icon <?php echo strtolower($row['source']); ?>Ticket ticketPreview" title="<?php echo __('Preview Ticket'); ?>" href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $tid; ?></a></td> - <td align="center" nowrap><?php echo Format::db_datetime($row['effective_date']); ?></td> + <td align="center" nowrap><?php echo Format::datetime($row['effective_date']); ?></td> <td><?php echo $status; ?></td> <td><a <?php if ($flag) { ?> class="Icon <?php echo $flag; ?>Ticket" title="<?php echo ucfirst($flag); ?> Ticket" <?php } ?> href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $subject; ?></a> diff --git a/include/staff/templates/users.tmpl.php b/include/staff/templates/users.tmpl.php index 40a2d4952e1c2043917b961b9601cf3a0f0d6c81..47358580bf66bb48be0d9d9ec8f8b22385827b3e 100644 --- a/include/staff/templates/users.tmpl.php +++ b/include/staff/templates/users.tmpl.php @@ -111,7 +111,7 @@ if ($num) { ?> </td> <td><?php echo Format::htmlchars($row['email']); ?></td> <td><?php echo $status; ?></td> - <td><?php echo Format::db_date($row['created']); ?></td> + <td><?php echo Format::date($row['created']); ?></td> </tr> <?php } //end of while. diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index 2001e28505a525d15f0244f8d809c0e88d33bb8a..ca63955bbf3970a0cfb6bf2b5e82613f3c5ff48e 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -3,8 +3,9 @@ if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->canEditTickets() || !$ti $info=Format::htmlchars(($errors && $_POST)?$_POST:$ticket->getUpdateInfo()); if ($_POST) - $info['duedate'] = Format::date($cfg->getDateFormat(), - strtotime($info['duedate'])); + // Reformat duedate to the display standard (but don't convert to local + // timezone) + $info['duedate'] = Format::date(strtotime($info['duedate']), false, false, 'UTC'); ?> <form action="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit" method="post" id="save" enctype="multipart/form-data"> <?php csrf_token(); ?> @@ -125,7 +126,7 @@ if ($_POST) echo Misc::timeDropdown($hr, $min, 'time'); ?> <font class="error"> <?php echo $errors['duedate']; ?> <?php echo $errors['time']; ?></font> - <em><?php echo __('Time is based on your time zone');?> (GMT <?php echo $thisstaff->getTZoffset(); ?>)</em> + <em><?php echo __('Time is based on your time zone');?> (GMT <?php echo Format::date(false, false, 'ZZZ'); ?>)</em> </td> </tr> </tbody> diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 4956c74287c2ad2df7986f6f8f7958388a0b0cff..0c0c6dfe2b61199b0ac658ef82cc2588910ec0a5 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -16,8 +16,7 @@ if ($info['topicId'] && ($topic=Topic::lookup($info['topicId']))) { } if ($_POST) - $info['duedate'] = Format::date($cfg->getDateFormat(), - strtotime($info['duedate'])); + $info['duedate'] = Format::date(strtotime($info['duedate']), false, false, 'UTC'); ?> <form action="tickets.php?a=open" method="post" id="save" enctype="multipart/form-data"> <?php csrf_token(); ?> @@ -219,7 +218,7 @@ if ($_POST) echo Misc::timeDropdown($hr, $min, 'time'); ?> <font class="error"> <?php echo $errors['duedate']; ?> <?php echo $errors['time']; ?></font> - <em><?php echo __('Time is based on your time zone');?> (GMT <?php echo $thisstaff->getTZoffset(); ?>)</em> + <em><?php echo __('Time is based on your time zone');?> (GMT <?php echo Format::date(false, false, 'ZZZ'); ?>)</em> </td> </tr> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index bab1d22e57fcbe449601cf1e8be44d03d3ab80d7..74f819e0d70663c78b1c3d74d4d09e3ae03b1730 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -180,7 +180,7 @@ if($ticket->isOverdue()) </tr> <tr> <th><?php echo __('Create Date');?>:</th> - <td><?php echo Format::db_datetime($ticket->getCreateDate()); ?></td> + <td><?php echo Format::datetime($ticket->getCreateDate()); ?></td> </tr> </table> </td> @@ -301,13 +301,13 @@ if($ticket->isOverdue()) if($ticket->isOpen()){ ?> <tr> <th><?php echo __('Due Date');?>:</th> - <td><?php echo Format::db_datetime($ticket->getEstDueDate()); ?></td> + <td><?php echo Format::datetime($ticket->getEstDueDate()); ?></td> </tr> <?php }else { ?> <tr> <th><?php echo __('Close Date');?>:</th> - <td><?php echo Format::db_datetime($ticket->getCloseDate()); ?></td> + <td><?php echo Format::datetime($ticket->getCloseDate()); ?></td> </tr> <?php } @@ -322,11 +322,11 @@ if($ticket->isOverdue()) </tr> <tr> <th nowrap><?php echo __('Last Message');?>:</th> - <td><?php echo Format::db_datetime($ticket->getLastMsgDate()); ?></td> + <td><?php echo Format::datetime($ticket->getLastMsgDate()); ?></td> </tr> <tr> <th nowrap><?php echo __('Last Response');?>:</th> - <td><?php echo Format::db_datetime($ticket->getLastRespDate()); ?></td> + <td><?php echo Format::datetime($ticket->getLastRespDate()); ?></td> </tr> </table> </td> @@ -391,7 +391,7 @@ $tcount+= $ticket->getNumNotes(); <div> <span class="pull-left"> <span style="display:inline-block"><?php - echo Format::db_datetime($entry['created']);?></span> + echo Format::datetime($entry['created']);?></span> <span style="display:inline-block;padding:0 1em" class="faded title"><?php echo Format::truncate($entry['title'], 100); ?></span> </span> diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index 70acec9195642decac3530a7be2267fb00a176b2..1c5b5f003c453e4c131517c908d8efb91836a15f 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -456,7 +456,7 @@ if ($results) { <td title="<?php echo $row['email']; ?>" nowrap> <a class="Icon <?php echo strtolower($row['source']); ?>Ticket ticketPreview" title="Preview Ticket" href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $tid; ?></a></td> - <td align="center" nowrap><?php echo Format::db_datetime($row['effective_date']); ?></td> + <td align="center" nowrap><?php echo Format::datetime($row['effective_date']); ?></td> <td><a <?php if ($flag) { ?> class="Icon <?php echo $flag; ?>Ticket" title="<?php echo ucfirst($flag); ?> Ticket" <?php } ?> href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $subject; ?></a> <?php diff --git a/include/staff/user-view.inc.php b/include/staff/user-view.inc.php index 2e563ae0cb791fbea4173d031b7df83a31cf8102..edc9464c97907a108e1a5bc2f7803b2f33e392ad 100644 --- a/include/staff/user-view.inc.php +++ b/include/staff/user-view.inc.php @@ -112,11 +112,11 @@ $org = $user->getOrganization(); </tr> <tr> <th><?php echo __('Created'); ?>:</th> - <td><?php echo Format::db_datetime($user->getCreateDate()); ?></td> + <td><?php echo Format::datetime($user->getCreateDate()); ?></td> </tr> <tr> <th><?php echo __('Updated'); ?>:</th> - <td><?php echo Format::db_datetime($user->getUpdateDate()); ?></td> + <td><?php echo Format::datetime($user->getUpdateDate()); ?></td> </tr> </table> </td> diff --git a/include/staff/users.inc.php b/include/staff/users.inc.php index ec35f2205af0052a6cf6eab62716870e59f82a06..b085496395f501aa5c7b17fb6cecd35bad0e957b 100644 --- a/include/staff/users.inc.php +++ b/include/staff/users.inc.php @@ -155,8 +155,8 @@ else ?> </td> <td><?php echo $status; ?></td> - <td><?php echo Format::db_date($row['created']); ?></td> - <td><?php echo Format::db_datetime($row['updated']); ?> </td> + <td><?php echo Format::date($row['created']); ?></td> + <td><?php echo Format::datetime($row['updated']); ?> </td> </tr> <?php } //end of while. diff --git a/js/jquery.multiselect.filter.min.js b/js/jquery.multiselect.filter.min.js new file mode 100644 index 0000000000000000000000000000000000000000..db828899af7fec5044190a002a777654ec33c514 --- /dev/null +++ b/js/jquery.multiselect.filter.min.js @@ -0,0 +1,15 @@ +/* + * jQuery MultiSelect UI Widget Filtering Plugin 1.4 + * Copyright (c) 2011 Eric Hynds + * + * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ + * + * Depends: + * - jQuery UI MultiSelect widget + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * +*/ +(function(a){var f=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;a.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:!1},_create:function(){var e;var b=this,c=this.options,d=this.instance=a(this.element).data("echMultiselect");this.header=d.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");e=this.wrapper=a('<div class="ui-multiselect-filter">'+(c.label.length?c.label:"")+'<input placeholder="'+c.placeholder+'" type="search"'+(/\d/.test(c.width)? 'style="width:'+c.width+'px"':"")+" /></div>").prependTo(this.header),c=e;this.inputs=d.menu.find('input[type="checkbox"], input[type="radio"]');this.input=c.find("input").bind({keydown:function(a){13===a.which&&a.preventDefault()},keyup:a.proxy(b._handler,b),click:a.proxy(b._handler,b)});this.updateCache();d._toggleChecked=function(c,d){var e=d&&d.length?d:this.labels.find("input"),i=this,e=e.not(b.instance._isOpen?":disabled, :hidden":":disabled").each(this._toggleState("checked",c));this.update(); var j=e.map(function(){return this.value}).get();this.element.find("option").filter(function(){!this.disabled&&-1<a.inArray(this.value,j)&&i._toggleState("selected",c).call(this)})};d=a(document).bind("multiselectrefresh",function(){b.updateCache();b._handler()});this.options.autoReset&&d.bind("multiselectclose",a.proxy(this._reset,this))},_handler:function(b){var c=a.trim(this.input[0].value.toLowerCase()),d=this.rows,g=this.inputs,h=this.cache;if(c){d.hide();var e=RegExp(c.replace(f,"\\$&"),"gi"); this._trigger("filter",b,a.map(h,function(a,b){return-1!==a.search(e)?(d.eq(b).show(),g.get(b)):null}))}else d.show();this.instance.menu.find(".ui-multiselect-optgroup-label").each(function(){var b=a(this),c=b.nextUntil(".ui-multiselect-optgroup-label").filter(function(){return"none"!==a.css(this,"display")}).length;b[c?"show":"hide"]()})},_reset:function(){this.input.val("").trigger("keyup")},updateCache:function(){this.rows=this.instance.menu.find(".ui-multiselect-checkboxes li:not(.ui-multiselect-optgroup-label)");this.cache=this.element.children().map(function(){var b=a(this);"optgroup"===this.tagName.toLowerCase()&&(b=b.children());return b.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){a.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery); diff --git a/scp/js/scp.js b/scp/js/scp.js index d55684d93ab041df42a2df6ebf91f11e8ecf9a6e..74061b615bf10aca5cc6a603bd196e7a20d77bd1 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -501,13 +501,20 @@ jQuery.fn.exists = function() { return this.length>0; }; $.translate_format = function(str) { var translation = { - 'd':'dd', - 'j':'d', - 'z':'o', - 'm':'mm', - 'F':'MM', - 'n':'m', - 'Y':'yy' + 'DD': 'oo', + 'D': 'o', + 'EEEE': 'DD', + 'EEE': 'D', + 'MMMM': '||', // Double replace necessary + 'MMM': '|', + 'MM': 'mm', + 'M': 'm', + '||': 'MM', + '|': 'M', + 'yyyy': '`', + 'yyy': '`', + 'yy': 'y', + '`': 'yy' }; // Change PHP formats to datepicker ones $.each(translation, function(php, jqdp) { diff --git a/scp/js/ticket.js b/scp/js/ticket.js index 26ab20c7571897ba5feed2b2674e5b6d18e241a5..8a1bbc6ecae18dd2001b22b6b682461a367c6227 100644 --- a/scp/js/ticket.js +++ b/scp/js/ticket.js @@ -320,7 +320,6 @@ $.refreshTicketView = function() { var ticket_onload = function($) { if (!location.hash || !$('#response_options .tab_content' + location.hash).length) { - console.log('ajshdasdhfasd'); $('#response_options ul.tabs li:first a').trigger('click'); } diff --git a/scp/profile.php b/scp/profile.php index d25d545d45f374211756f638ba7ff8203b19bb56..827ae7869efe454d90e9730fea481ea0c97c86a8 100644 --- a/scp/profile.php +++ b/scp/profile.php @@ -29,8 +29,6 @@ if($_POST && $_POST['id']!=$thisstaff->getId()) { //Check dummy ID used on the f $msg=__('Profile updated successfully'); $thisstaff->reload(); $staff->reload(); - $_SESSION['TZ_OFFSET']=$thisstaff->getTZoffset(); - $_SESSION['TZ_DST']=$thisstaff->observeDaylight(); }elseif(!$errors['err']) $errors['err']=__('Profile update error. Try correcting the errors below and try again!'); } diff --git a/scp/staff.inc.php b/scp/staff.inc.php index d4399c74b8fa94f9e049c84bf4be855c1d44df66..2ec1221e7f984044a7612302bcc1ed2c604c2378 100644 --- a/scp/staff.inc.php +++ b/scp/staff.inc.php @@ -104,10 +104,6 @@ if ($_POST && !$ost->checkCSRFToken()) { $ost->addExtraHeader('<meta name="csrf_token" content="'.$ost->getCSRFToken().'" />'); /******* SET STAFF DEFAULTS **********/ -//Set staff's timezone offset. -$_SESSION['TZ_OFFSET']=$thisstaff->getTZoffset(); -$_SESSION['TZ_DST']=$thisstaff->observeDaylight(); - define('PAGE_LIMIT', $thisstaff->getPageLimit()?$thisstaff->getPageLimit():DEFAULT_PAGE_LIMIT); $tabs=array(); diff --git a/setup/inc/streams/core/install-mysql.sql b/setup/inc/streams/core/install-mysql.sql index 762812bffd2cf8890db4d6dd9c3089e4bc44665b..aa5e22199d44d6063374b4895b90cb169d9b3575 100644 --- a/setup/inc/streams/core/install-mysql.sql +++ b/setup/inc/streams/core/install-mysql.sql @@ -512,7 +512,6 @@ CREATE TABLE `%TABLE_PREFIX%staff` ( `staff_id` int(11) unsigned NOT NULL auto_increment, `group_id` int(10) unsigned NOT NULL default '0', `dept_id` int(10) unsigned NOT NULL default '0', - `timezone_id` int(10) unsigned NOT NULL default '0', `username` varchar(32) NOT NULL default '', `firstname` varchar(32) default NULL, `lastname` varchar(32) default NULL, @@ -524,6 +523,8 @@ CREATE TABLE `%TABLE_PREFIX%staff` ( `mobile` varchar(24) NOT NULL default '', `signature` text NOT NULL, `lang` varchar(16) DEFAULT NULL, + `timezone` varchar(64) default NULL, + `locale` varchar(16) DEFAULT NULL, `notes` text, `isactive` tinyint(1) NOT NULL default '1', `isadmin` tinyint(1) NOT NULL default '0', @@ -531,7 +532,6 @@ CREATE TABLE `%TABLE_PREFIX%staff` ( `onvacation` tinyint(1) unsigned NOT NULL default '0', `assigned_only` tinyint(1) unsigned NOT NULL default '0', `show_assigned_tickets` tinyint(1) unsigned NOT NULL default '0', - `daylight_saving` tinyint(1) unsigned NOT NULL default '0', `change_passwd` tinyint(1) unsigned NOT NULL default '0', `max_page_size` int(11) unsigned NOT NULL default '0', `auto_refresh_rate` int(10) unsigned NOT NULL default '0', @@ -742,48 +742,6 @@ CREATE TABLE `%TABLE_PREFIX%ticket_collaborator` ( UNIQUE KEY `collab` (`ticket_id`,`user_id`) ) DEFAULT CHARSET=utf8; - - -DROP TABLE IF EXISTS `%TABLE_PREFIX%timezone`; -CREATE TABLE `%TABLE_PREFIX%timezone` ( - `id` int(11) unsigned NOT NULL auto_increment, - `offset` float(3,1) NOT NULL default '0.0', - `timezone` varchar(255) NOT NULL default '', - PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8; - -INSERT INTO `%TABLE_PREFIX%timezone` (`id`, `offset`, `timezone`) VALUES - (1, -12.0, 'Eniwetok, Kwajalein'), - (2, -11.0, 'Midway Island, Samoa'), - (3, -10.0, 'Hawaii'), - (4, -9.0, 'Alaska'), - (5, -8.0, 'Pacific Time (US & Canada)'), - (6, -7.0, 'Mountain Time (US & Canada)'), - (7, -6.0, 'Central Time (US & Canada), Mexico City'), - (8, -5.0, 'Eastern Time (US & Canada), Bogota, Lima'), - (9, -4.0, 'Atlantic Time (Canada), Caracas, La Paz'), - (10, -3.5, 'Newfoundland'), - (11, -3.0, 'Brazil, Buenos Aires, Georgetown'), - (12, -2.0, 'Mid-Atlantic'), - (13, -1.0, 'Azores, Cape Verde Islands'), - (14, 0.0, 'Western Europe Time, London, Lisbon, Casablanca'), - (15, 1.0, 'Brussels, Copenhagen, Madrid, Paris'), - (16, 2.0, 'Kaliningrad, South Africa'), - (17, 3.0, 'Baghdad, Riyadh, Moscow, St. Petersburg'), - (18, 3.5, 'Tehran'), - (19, 4.0, 'Abu Dhabi, Muscat, Baku, Tbilisi'), - (20, 4.5, 'Kabul'), - (21, 5.0, 'Ekaterinburg, Islamabad, Karachi, Tashkent'), - (22, 5.5, 'Bombay, Calcutta, Madras, New Delhi'), - (23, 6.0, 'Almaty, Dhaka, Colombo'), - (24, 7.0, 'Bangkok, Hanoi, Jakarta'), - (25, 8.0, 'Beijing, Perth, Singapore, Hong Kong'), - (26, 9.0, 'Tokyo, Seoul, Osaka, Sapporo, Yakutsk'), - (27, 9.5, 'Adelaide, Darwin'), - (28, 10.0, 'Eastern Australia, Guam, Vladivostok'), - (29, 11.0, 'Magadan, Solomon Islands, New Caledonia'), - (30, 12.0, 'Auckland, Wellington, Fiji, Kamchatka'); - -- pages CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%content` ( `id` int(10) unsigned NOT NULL auto_increment, @@ -858,8 +816,7 @@ CREATE TABLE `%TABLE_PREFIX%user_account` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL, `status` int(11) unsigned NOT NULL DEFAULT '0', - `timezone_id` int(11) NOT NULL DEFAULT '0', - `dst` tinyint(1) NOT NULL DEFAULT '1', + `timezone` varchar(24) DEFAULT NULL, `lang` varchar(16) DEFAULT NULL, `username` varchar(64) DEFAULT NULL, `passwd` varchar(128) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,