complete datetimepicker change with proper date and time formats support (#116)

This commit is contained in:
FrancescoUK
2016-02-17 22:47:59 +00:00
parent 66a5a159d8
commit f19e7142cd
5 changed files with 75 additions and 17 deletions

View File

@@ -94,7 +94,7 @@ function dateformat_bootstrap($php_format)
'y' => 'yy',
// Time
'a' => 'p',
'A' => 'PP',
'A' => 'P',
'B' => '',
'g' => 'H',
'G' => 'h',

View File

@@ -174,12 +174,12 @@
<div class='form_field'>
<?php echo form_dropdown('dateformat', array(
'd/m/Y' => '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'));
?>
</div>
@@ -187,8 +187,7 @@
<?php echo form_dropdown('timeformat', array(
'H:i:s' => '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'));
?>
</div>

View File

@@ -102,7 +102,6 @@ $(document).ready(function()
"<?php echo $this->lang->line("common_monthsshort_november"); ?>",
"<?php echo $this->lang->line("common_monthsshort_december"); ?>"],
today: "<?php echo $this->lang->line("common_today"); ?>",
suffix: [],
meridiem: [],
weekStart: <?php echo $this->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: "<?php echo dateformat_bootstrap($this->config->item('dateformat')); ?>",
startDate: '01/01/2010',
startDate: "<?php echo date($this->config->item('dateformat'), mktime(0, 0, 0, 1, 1, 2010));?>",
minView: 2,
autoclose: true,
todayBtn: true,

View File

@@ -158,14 +158,44 @@ $(document).ready(function()
"<?php echo $this->lang->line("common_monthsshort_november"); ?>",
"<?php echo $this->lang->line("common_monthsshort_december"); ?>"],
today: "<?php echo $this->lang->line("common_today"); ?>",
suffix: [],
meridiem: [],
<?php
$t = $this->config->item('timeformat');
$m = $t[strlen($t)-1];
if( $m == 'a')
{
?>
meridiem: ["am", "pm"],
<?php
}
else
{
?>
meridiem: ["AM", "PM"],
<?php
}
?>
weekStart: <?php echo $this->lang->line("common_weekstart"); ?>,
};
$('#datetime').datetimepicker({
format: "<?php echo dateformat_bootstrap($this->config->item("dateformat")) . ' ' . dateformat_bootstrap($this->config->item("timeformat"));?>",
startDate: '01/01/2010 00:00:00',
startDate: "<?php echo date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), mktime(0, 0, 0, 1, 1, 2010));?>",
<?php
$t = $this->config->item('timeformat');
$m = $t[strlen($t)-1];
if( $m == 'a' || $m == 'A' )
{
?>
showMeridian: true,
<?php
}
else
{
?>
showMeridian: false,
<?php
}
?>
minuteStep: 1,
autoclose: true,
todayBtn: true,

View File

@@ -101,15 +101,45 @@ $(document).ready(function()
"<?php echo $this->lang->line("common_monthsshort_november"); ?>",
"<?php echo $this->lang->line("common_monthsshort_december"); ?>"],
today: "<?php echo $this->lang->line("common_today"); ?>",
suffix: [],
meridiem: [],
weekStart: <?php echo $this->lang->line("common_weekstart"); ?>,
<?php
$t = $this->config->item('timeformat');
$m = $t[strlen($t)-1];
if( $m == 'a')
{
?>
meridiem: ["am", "pm"],
<?php
}
else
{
?>
meridiem: ["AM", "PM"],
<?php
}
?>
weekStart: <?php echo $this->lang->line("common_weekstart"); ?>
};
// initialise the datetime picker and trigger a search on any change of date
$(".date_filter").datetimepicker({
format: "<?php echo dateformat_bootstrap($this->config->item("dateformat")) . ' ' . dateformat_bootstrap($this->config->item("timeformat"));?>",
startDate: '01/01/2010 00:00:00',
startDate: "<?php echo date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), mktime(0, 0, 0, 1, 1, 2010));?>",
<?php
$t = $this->config->item('timeformat');
$m = $t[strlen($t)-1];
if( $m == 'a' || $m == 'A' )
{
?>
showMeridian: true,
<?php
}
else
{
?>
showMeridian: false,
<?php
}
?>
autoclose: true,
todayBtn: true,
todayHighlight: true,
@@ -254,9 +284,9 @@ function init_table_sorting()
<?php echo form_checkbox(array('name'=>'only_cash','id'=>'only_cash','value'=>1,'checked'=> isset($only_cash)? ( ($only_cash)? 1 : 0) : 0)) . ' | ';?>
<?php echo form_label($this->lang->line('sales_date_range').' :', 'start_date');?>
<?php echo form_input(array('name'=>'start_date', 'value'=>$start_date, 'class'=>'date_filter', 'size' => '18'));?>
<?php echo form_input(array('name'=>'start_date', 'value'=>$start_date, 'class'=>'date_filter', 'size' => '22'));?>
<?php echo form_label(' - ', 'end_date');?>
<?php echo form_input(array('name'=>'end_date', 'value'=>$end_date, 'class'=>'date_filter', 'size' => '18'));?>
<?php echo form_input(array('name'=>'end_date', 'value'=>$end_date, 'class'=>'date_filter', 'size' => '22'));?>
</div>
<div id="table_action_header">