mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-12 02:48:48 -04:00
Fix datetime issues (#2319) and refactor code
This commit is contained in:
@@ -202,7 +202,7 @@ class Receivings extends Secure_Controller
|
||||
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
$data['total'] = $this->receiving_lib->get_total();
|
||||
$data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'));
|
||||
$data['transaction_time'] = to_datetime();
|
||||
$data['mode'] = $this->receiving_lib->get_mode();
|
||||
$data['comment'] = $this->receiving_lib->get_comment();
|
||||
$data['reference'] = $this->receiving_lib->get_reference();
|
||||
@@ -288,7 +288,7 @@ class Receivings extends Secure_Controller
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
$data['total'] = $this->receiving_lib->get_total();
|
||||
$data['mode'] = $this->receiving_lib->get_mode();
|
||||
$data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($receiving_info['receiving_time']));
|
||||
$data['transaction_time'] = to_datetime(strtotime($receiving_info['receiving_time']));
|
||||
$data['show_stock_locations'] = $this->Stock_location->show_locations('receivings');
|
||||
$data['payment_type'] = $receiving_info['payment_type'];
|
||||
$data['reference'] = $this->receiving_lib->get_reference();
|
||||
|
||||
@@ -50,7 +50,7 @@ class Reports extends Secure_Controller
|
||||
foreach($report_data as $row)
|
||||
{
|
||||
$tabular_data[] = $this->xss_clean(array(
|
||||
'sale_date' => date($this->config->item('dateformat'), strtotime($row['sale_date'])),
|
||||
'sale_date' => to_date(strtotime($row['sale_date'])),
|
||||
'quantity' => to_quantity_decimals($row['quantity_purchased']),
|
||||
'subtotal' => to_currency($row['subtotal']),
|
||||
'tax' => to_currency_tax($row['tax']),
|
||||
@@ -551,7 +551,7 @@ class Reports extends Secure_Controller
|
||||
{
|
||||
$row = $this->xss_clean($row);
|
||||
|
||||
$date = date($this->config->item('dateformat'), strtotime($row['sale_date']));
|
||||
$date = to_date(strtotime($row['sale_date']));
|
||||
$labels[] = $date;
|
||||
$series[] = array('meta' => $date, 'value' => $row['total']);
|
||||
}
|
||||
@@ -950,7 +950,7 @@ class Reports extends Secure_Controller
|
||||
$summary_data[] = $this->xss_clean(array(
|
||||
'id' => $row['sale_id'],
|
||||
'type_code' => $row['type_code'],
|
||||
'sale_date' => date($this->config->item('dateformat'), strtotime($row['sale_date'])),
|
||||
'sale_date' => to_date(strtotime($row['sale_date'])),
|
||||
'quantity' => to_quantity_decimals($row['items_purchased']),
|
||||
'employee_name' => $row['employee_name'],
|
||||
'subtotal' => to_currency($row['subtotal']),
|
||||
@@ -1061,7 +1061,7 @@ class Reports extends Secure_Controller
|
||||
$summary_data[] = $this->xss_clean(array(
|
||||
'id' => $row['sale_id'],
|
||||
'type_code' => $row['type_code'],
|
||||
'sale_date' => date($this->config->item('dateformat'), strtotime($row['sale_date'])),
|
||||
'sale_date' => to_date(strtotime($row['sale_date'])),
|
||||
'quantity' => to_quantity_decimals($row['items_purchased']),
|
||||
'customer_name' => $row['customer_name'],
|
||||
'subtotal' => to_currency($row['subtotal']),
|
||||
@@ -1168,7 +1168,7 @@ class Reports extends Secure_Controller
|
||||
$summary_data[] = $this->xss_clean(array(
|
||||
'id' => $row['sale_id'],
|
||||
'type_code' => $row['type_code'],
|
||||
'sale_date' => date($this->config->item('dateformat'), strtotime($row['sale_date'])),
|
||||
'sale_date' => to_date(strtotime($row['sale_date'])),
|
||||
'quantity' => to_quantity_decimals($row['items_purchased']),
|
||||
'employee_name' => $row['employee_name'],
|
||||
'customer_name' => $row['customer_name'],
|
||||
@@ -1245,7 +1245,7 @@ class Reports extends Secure_Controller
|
||||
|
||||
$summary_data = $this->xss_clean(array(
|
||||
'sale_id' => $report_data['sale_id'],
|
||||
'sale_date' => date($this->config->item('dateformat'), strtotime($report_data['sale_date'])),
|
||||
'sale_date' => to_date(strtotime($report_data['sale_date'])),
|
||||
'quantity' => to_quantity_decimals($report_data['items_purchased']),
|
||||
'employee_name' => $report_data['employee_name'],
|
||||
'customer_name' => $report_data['customer_name'],
|
||||
@@ -1321,7 +1321,7 @@ class Reports extends Secure_Controller
|
||||
$summary_data[] = $this->xss_clean(array(
|
||||
'id' => $row['sale_id'],
|
||||
'type_code' => $row['type_code'],
|
||||
'sale_date' => date($this->config->item('dateformat'), strtotime($row['sale_date'])),
|
||||
'sale_date' => to_date(strtotime($row['sale_date'])),
|
||||
'quantity' => to_quantity_decimals($row['items_purchased']),
|
||||
'employee_name' => $row['employee_name'],
|
||||
'customer_name' => $row['customer_name'],
|
||||
@@ -1398,7 +1398,7 @@ class Reports extends Secure_Controller
|
||||
|
||||
$summary_data = $this->xss_clean(array(
|
||||
'receiving_id' => $report_data['receiving_id'],
|
||||
'receiving_date' => date($this->config->item('dateformat'), strtotime($report_data['receiving_date'])),
|
||||
'receiving_date' => to_date(strtotime($report_data['receiving_date'])),
|
||||
'quantity' => to_quantity_decimals($report_data['items_purchased']),
|
||||
'employee_name' => $report_data['employee_name'],
|
||||
'supplier_name' => $report_data['supplier_name'],
|
||||
@@ -1440,7 +1440,7 @@ class Reports extends Secure_Controller
|
||||
{
|
||||
$summary_data[] = $this->xss_clean(array(
|
||||
'id' => $row['receiving_id'],
|
||||
'receiving_date' => date($this->config->item('dateformat'), strtotime($row['receiving_date'])),
|
||||
'receiving_date' => to_date(strtotime($row['receiving_date'])),
|
||||
'quantity' => to_quantity_decimals($row['items_purchased']),
|
||||
'employee_name' => $row['employee_name'],
|
||||
'supplier_name' => $row['supplier_name'],
|
||||
|
||||
@@ -511,8 +511,8 @@ class Sales extends Secure_Controller
|
||||
$data['cart'] = $this->sale_lib->get_cart();
|
||||
|
||||
$data['include_hsn'] = ($this->config->item('include_hsn') == '1');
|
||||
$data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'));
|
||||
$data['transaction_date'] = date($this->config->item('dateformat'));
|
||||
$data['transaction_time'] = to_datetime();
|
||||
$data['transaction_date'] = to_date();
|
||||
$data['show_stock_locations'] = $this->Stock_location->show_locations('sales');
|
||||
$data['comments'] = $this->sale_lib->get_comment();
|
||||
$employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
|
||||
@@ -945,8 +945,8 @@ class Sales extends Secure_Controller
|
||||
$tax_details = $this->tax_lib->get_taxes($data['cart']);
|
||||
$data['taxes'] = $this->Sale->get_sales_taxes($sale_id);
|
||||
$data['discount'] = $this->sale_lib->get_discount();
|
||||
$data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($sale_info['sale_time']));
|
||||
$data['transaction_date'] = date($this->config->item('dateformat'), strtotime($sale_info['sale_time']));
|
||||
$data['transaction_time'] = to_datetime(strtotime($sale_info['sale_time']));
|
||||
$data['transaction_date'] = to_date(strtotime($sale_info['sale_time']));
|
||||
$data['show_stock_locations'] = $this->Stock_location->show_locations('sales');
|
||||
|
||||
$data['include_hsn'] = ($this->config->item('include_hsn') == '1');
|
||||
|
||||
@@ -310,13 +310,20 @@ function tax_decimals()
|
||||
return $config->item('tax_decimals') ? $config->item('tax_decimals') : 0;
|
||||
}
|
||||
|
||||
function to_date($date)
|
||||
function to_date($date = DEFAULT_DATE)
|
||||
{
|
||||
$config = get_instance()->config;
|
||||
|
||||
return date($config->item('dateformat'), $date);
|
||||
}
|
||||
|
||||
function to_datetime($datetime = DEFAULT_DATE)
|
||||
{
|
||||
$config = get_instance()->config;
|
||||
|
||||
return date($config->item('dateformat') . ' ' . $config->item('timeformat'), $datetime);
|
||||
}
|
||||
|
||||
function to_currency($number)
|
||||
{
|
||||
return to_decimals($number, 'currency_decimals', \NumberFormatter::CURRENCY);
|
||||
@@ -547,4 +554,4 @@ function valid_decimal($decimal)
|
||||
return preg_match('/^(\d*\.)?\d+$/', $decimal);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -90,7 +90,7 @@ function get_sale_data_row($sale)
|
||||
|
||||
$row = array (
|
||||
'sale_id' => $sale->sale_id,
|
||||
'sale_time' => to_date(strtotime($sale->sale_time)),
|
||||
'sale_time' => to_datetime(strtotime($sale->sale_time)),
|
||||
'customer_name' => $sale->customer_name,
|
||||
'amount_due' => to_currency($sale->amount_due),
|
||||
'amount_tendered' => to_currency($sale->amount_tendered),
|
||||
@@ -333,7 +333,8 @@ function get_items_manage_table_headers()
|
||||
array('unit_price' => $CI->lang->line('items_unit_price')),
|
||||
array('quantity' => $CI->lang->line('items_quantity'))
|
||||
);
|
||||
if ($CI->config->item('use_destination_based_tax') == '1')
|
||||
|
||||
if($CI->config->item('use_destination_based_tax') == '1')
|
||||
{
|
||||
$headers[] = array('tax_percents' => $CI->lang->line('items_tax_category'), 'sortable' => FALSE);
|
||||
}
|
||||
@@ -363,9 +364,9 @@ function get_item_data_row($item)
|
||||
{
|
||||
$CI =& get_instance();
|
||||
|
||||
if ($CI->config->item('use_destination_based_tax') == '1')
|
||||
if($CI->config->item('use_destination_based_tax') == '1')
|
||||
{
|
||||
if ($item->tax_category_id == NULL)
|
||||
if($item->tax_category_id == NULL)
|
||||
{
|
||||
$tax_percents = '-';
|
||||
}
|
||||
@@ -411,7 +412,7 @@ function get_item_data_row($item)
|
||||
}
|
||||
}
|
||||
|
||||
if ($CI->config->item('multi_pack_enabled') == '1')
|
||||
if($CI->config->item('multi_pack_enabled') == '1')
|
||||
{
|
||||
$item->name .= NAME_SEPARATOR . $item->pack_name;
|
||||
}
|
||||
@@ -531,7 +532,7 @@ function expand_attribute_values($definition_names, $attribute_values)
|
||||
foreach($values as $attribute_value)
|
||||
{
|
||||
$exploded_value = explode('_', $attribute_value);
|
||||
if (sizeof($exploded_value) > 1)
|
||||
if(sizeof($exploded_value) > 1)
|
||||
{
|
||||
$indexed_values[$exploded_value[0]] = $exploded_value[1];
|
||||
}
|
||||
@@ -540,7 +541,7 @@ function expand_attribute_values($definition_names, $attribute_values)
|
||||
$attribute_values = array();
|
||||
foreach($definition_names as $definition_id => $definition_name)
|
||||
{
|
||||
if (isset($indexed_values[$definition_id]))
|
||||
if(isset($indexed_values[$definition_id]))
|
||||
{
|
||||
$attribute_value = $indexed_values[$definition_id];
|
||||
$attribute_values["$definition_id"] = $attribute_value;
|
||||
@@ -570,11 +571,11 @@ function get_attribute_definition_data_row($attribute)
|
||||
$CI =& get_instance();
|
||||
$controller_name=strtolower(get_class($CI));
|
||||
|
||||
if (count($attribute->definition_flags) == 0)
|
||||
if(count($attribute->definition_flags) == 0)
|
||||
{
|
||||
$definition_flags = $CI->lang->line('common_none_selected_text');
|
||||
}
|
||||
else if ($attribute->definition_type == GROUP)
|
||||
else if($attribute->definition_type == GROUP)
|
||||
{
|
||||
$definition_flags = "-";
|
||||
}
|
||||
@@ -659,7 +660,7 @@ function get_expenses_data_row($expense)
|
||||
$controller_name = strtolower(get_class($CI));
|
||||
return array (
|
||||
'expense_id' => $expense->expense_id,
|
||||
'date' => to_date(strtotime($expense->date)),
|
||||
'date' => to_datetime(strtotime($expense->date)),
|
||||
'supplier_name' => $expense->supplier_name,
|
||||
'supplier_tax_code' => $expense->supplier_tax_code,
|
||||
'amount' => to_currency($expense->amount),
|
||||
@@ -750,11 +751,11 @@ function get_cash_up_data_row($cash_up)
|
||||
$controller_name = strtolower(get_class($CI));
|
||||
return array (
|
||||
'cashup_id' => $cash_up->cashup_id,
|
||||
'open_date' => to_date(strtotime($cash_up->open_date)),
|
||||
'open_date' => to_datetime(strtotime($cash_up->open_date)),
|
||||
'open_employee_id' => $cash_up->open_first_name . ' ' . $cash_up->open_last_name,
|
||||
'open_amount_cash' => to_currency($cash_up->open_amount_cash),
|
||||
'transfer_amount_cash' => to_currency($cash_up->transfer_amount_cash),
|
||||
'close_date' => to_date(strtotime($cash_up->close_date)),
|
||||
'close_date' => to_datetime(strtotime($cash_up->close_date)),
|
||||
'close_employee_id' => $cash_up->close_first_name . ' ' . $cash_up->close_last_name,
|
||||
'closed_amount_cash' => to_currency($cash_up->closed_amount_cash),
|
||||
'note' => $cash_up->note ? '<span class="glyphicon glyphicon-ok"></span>' : '<span class="glyphicon glyphicon-remove"></span>',
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
'name'=>'open_date',
|
||||
'id'=>'open_date',
|
||||
'class'=>'form-control input-sm datepicker',
|
||||
'value'=>date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($cash_ups_info->open_date)))
|
||||
'value'=>to_datetime(strtotime($cash_ups_info->open_date)))
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -80,7 +80,7 @@
|
||||
'name'=>'close_date',
|
||||
'id'=>'close_date',
|
||||
'class'=>'form-control input-sm datepicker',
|
||||
'value'=>date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($cash_ups_info->close_date)))
|
||||
'value'=>to_datetime(strtotime($cash_ups_info->close_date)))
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
'name'=>'date',
|
||||
'id'=>'datetime',
|
||||
'class'=>'form-control input-sm',
|
||||
'value'=>to_date(strtotime($person_info->date)),
|
||||
'value'=>to_datetime(strtotime($person_info->date)),
|
||||
'readonly'=>'true')
|
||||
); ?>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<?php echo form_input(array(
|
||||
'name'=>'date',
|
||||
'class'=>'form-control input-sm datetime',
|
||||
'value'=>to_date(strtotime($expenses_info->date)),
|
||||
'value'=>to_datetime(strtotime($expenses_info->date)),
|
||||
'readonly'=>'readonly')
|
||||
);?>
|
||||
</div>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
var pickerconfig = function(config) {
|
||||
return $.extend({
|
||||
format: "<?php echo dateformat_bootstrap($this->config->item('dateformat'));?>",
|
||||
startDate: "<?php echo to_date(DEFAULT_DATE); ?>",
|
||||
format: "<?php echo dateformat_bootstrap($this->config->item('dateformat')) . ' ' . dateformat_bootstrap($this->config->item('timeformat'));?>",
|
||||
startDate: "<?php echo to_date(); ?>",
|
||||
<?php
|
||||
$t = $this->config->item('timeformat');
|
||||
$m = $t[strlen($t)-1];
|
||||
@@ -110,4 +110,4 @@ $.fn.datetimepicker.dates['<?php echo $this->config->item("language"); ?>'] = {
|
||||
weekStart: <?php echo $this->lang->line("datepicker_weekstart"); ?>
|
||||
};
|
||||
|
||||
$(".datetime").datetimepicker(pickerconfig());
|
||||
$(".datetime").datetimepicker(pickerconfig());
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="form-group form-group-sm">
|
||||
<?php echo form_label($this->lang->line('sales_date'), 'date', array('class'=>'control-label col-xs-3')); ?>
|
||||
<div class='col-xs-8'>
|
||||
<?php echo form_input(array('name'=>'date','value'=>to_date(strtotime($sale_info['sale_time'])), 'class'=>'datetime form-control input-sm'));?>
|
||||
<?php echo form_input(array('name'=>'date','value'=>to_datetime(strtotime($sale_info['sale_time'])), 'class'=>'datetime form-control input-sm'));?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user