From f19e7142cd0a344f581f2e01b0bd1531a028863f Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Wed, 17 Feb 2016 22:47:59 +0000 Subject: [PATCH] complete datetimepicker change with proper date and time formats support (#116) --- application/helpers/dateformat_helper.php | 2 +- application/views/configs/locale_config.php | 7 ++-- application/views/items/manage.php | 3 +- application/views/sales/form.php | 36 +++++++++++++++-- application/views/sales/manage.php | 44 +++++++++++++++++---- 5 files changed, 75 insertions(+), 17 deletions(-) diff --git a/application/helpers/dateformat_helper.php b/application/helpers/dateformat_helper.php index cc91ea323..5e802dc63 100644 --- a/application/helpers/dateformat_helper.php +++ b/application/helpers/dateformat_helper.php @@ -94,7 +94,7 @@ function dateformat_bootstrap($php_format) 'y' => 'yy', // Time 'a' => 'p', - 'A' => 'PP', + 'A' => 'P', 'B' => '', 'g' => 'H', 'G' => 'h', diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index e746ee527..eb5a004c2 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -174,12 +174,12 @@
'dd/mm/yyyy', + 'd.m.Y' => 'dd.mm.yyyy', 'm/d/Y' => 'mm/dd/yyyy', 'Y/m/d' => 'yyyy/mm/dd', 'd/m/y' => 'dd/mm/yy', 'm/d/y' => 'mm/dd/yy', - 'y/m/d' => 'yy/mm/dd', - 'd.m.Y' => 'dd.mm.yyyy',), + 'y/m/d' => 'yy/mm/dd'), $this->config->item('dateformat')); ?>
@@ -187,8 +187,7 @@ 'hh:mm:ss (24h)', 'h:i:s a' => 'hh:mm:ss am/pm', - 'h:i:s A' => 'hh:mm:ss AM/PM', - 'h:i:s' => 'hh:mm:ss (12h)'), + 'h:i:s A' => 'hh:mm:ss AM/PM'), $this->config->item('timeformat')); ?> diff --git a/application/views/items/manage.php b/application/views/items/manage.php index 48785a79a..ebc8a649c 100644 --- a/application/views/items/manage.php +++ b/application/views/items/manage.php @@ -102,7 +102,6 @@ $(document).ready(function() "lang->line("common_monthsshort_november"); ?>", "lang->line("common_monthsshort_december"); ?>"], today: "lang->line("common_today"); ?>", - suffix: [], meridiem: [], weekStart: lang->line("common_weekstart"); ?>, }; @@ -110,7 +109,7 @@ $(document).ready(function() // initialise the datetime picker and trigger a search on any change date $(".date_filter").datetimepicker({ format: "config->item('dateformat')); ?>", - startDate: '01/01/2010', + startDate: "config->item('dateformat'), mktime(0, 0, 0, 1, 1, 2010));?>", minView: 2, autoclose: true, todayBtn: true, diff --git a/application/views/sales/form.php b/application/views/sales/form.php index 3e3dd6cb7..9f3b29e3f 100755 --- a/application/views/sales/form.php +++ b/application/views/sales/form.php @@ -158,14 +158,44 @@ $(document).ready(function() "lang->line("common_monthsshort_november"); ?>", "lang->line("common_monthsshort_december"); ?>"], today: "lang->line("common_today"); ?>", - suffix: [], - meridiem: [], + config->item('timeformat'); + $m = $t[strlen($t)-1]; + if( $m == 'a') + { + ?> + meridiem: ["am", "pm"], + + meridiem: ["AM", "PM"], + weekStart: lang->line("common_weekstart"); ?>, }; $('#datetime').datetimepicker({ format: "config->item("dateformat")) . ' ' . dateformat_bootstrap($this->config->item("timeformat"));?>", - startDate: '01/01/2010 00:00:00', + startDate: "config->item('dateformat') . ' ' . $this->config->item('timeformat'), mktime(0, 0, 0, 1, 1, 2010));?>", + config->item('timeformat'); + $m = $t[strlen($t)-1]; + if( $m == 'a' || $m == 'A' ) + { + ?> + showMeridian: true, + + showMeridian: false, + minuteStep: 1, autoclose: true, todayBtn: true, diff --git a/application/views/sales/manage.php b/application/views/sales/manage.php index 1f7907aee..5872c5bb1 100755 --- a/application/views/sales/manage.php +++ b/application/views/sales/manage.php @@ -101,15 +101,45 @@ $(document).ready(function() "lang->line("common_monthsshort_november"); ?>", "lang->line("common_monthsshort_december"); ?>"], today: "lang->line("common_today"); ?>", - suffix: [], - meridiem: [], - weekStart: lang->line("common_weekstart"); ?>, + config->item('timeformat'); + $m = $t[strlen($t)-1]; + if( $m == 'a') + { + ?> + meridiem: ["am", "pm"], + + meridiem: ["AM", "PM"], + + weekStart: lang->line("common_weekstart"); ?> }; - + // initialise the datetime picker and trigger a search on any change of date $(".date_filter").datetimepicker({ format: "config->item("dateformat")) . ' ' . dateformat_bootstrap($this->config->item("timeformat"));?>", - startDate: '01/01/2010 00:00:00', + startDate: "config->item('dateformat') . ' ' . $this->config->item('timeformat'), mktime(0, 0, 0, 1, 1, 2010));?>", + config->item('timeformat'); + $m = $t[strlen($t)-1]; + if( $m == 'a' || $m == 'A' ) + { + ?> + showMeridian: true, + + showMeridian: false, + autoclose: true, todayBtn: true, todayHighlight: true, @@ -254,9 +284,9 @@ function init_table_sorting() 'only_cash','id'=>'only_cash','value'=>1,'checked'=> isset($only_cash)? ( ($only_cash)? 1 : 0) : 0)) . ' | ';?> lang->line('sales_date_range').' :', 'start_date');?> - 'start_date', 'value'=>$start_date, 'class'=>'date_filter', 'size' => '18'));?> + 'start_date', 'value'=>$start_date, 'class'=>'date_filter', 'size' => '22'));?> - 'end_date', 'value'=>$end_date, 'class'=>'date_filter', 'size' => '18'));?> + 'end_date', 'value'=>$end_date, 'class'=>'date_filter', 'size' => '22'));?>