diff --git a/application/controllers/Receivings.php b/application/controllers/Receivings.php index 7872eff29..972065ffb 100644 --- a/application/controllers/Receivings.php +++ b/application/controllers/Receivings.php @@ -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(); diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index 607f67800..b23399bbc 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -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'], diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index b8f3e15d0..fcbe2b5f3 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -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'); diff --git a/application/helpers/locale_helper.php b/application/helpers/locale_helper.php index fe68a7c3c..983624532 100644 --- a/application/helpers/locale_helper.php +++ b/application/helpers/locale_helper.php @@ -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); } -?> \ No newline at end of file +?> diff --git a/application/helpers/tabular_helper.php b/application/helpers/tabular_helper.php index 2b3569920..37e62a652 100644 --- a/application/helpers/tabular_helper.php +++ b/application/helpers/tabular_helper.php @@ -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 ? '' : '', diff --git a/application/views/cashups/form.php b/application/views/cashups/form.php index ede1c42e8..734afb8b3 100644 --- a/application/views/cashups/form.php +++ b/application/views/cashups/form.php @@ -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))) );?> @@ -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))) );?> diff --git a/application/views/customers/form.php b/application/views/customers/form.php index 3b640688a..5ff8ff6b0 100644 --- a/application/views/customers/form.php +++ b/application/views/customers/form.php @@ -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') ); ?> diff --git a/application/views/expenses/form.php b/application/views/expenses/form.php index a9b294ec4..6340355ba 100644 --- a/application/views/expenses/form.php +++ b/application/views/expenses/form.php @@ -17,7 +17,7 @@ 'date', 'class'=>'form-control input-sm datetime', - 'value'=>to_date(strtotime($expenses_info->date)), + 'value'=>to_datetime(strtotime($expenses_info->date)), 'readonly'=>'readonly') );?> diff --git a/application/views/partial/datepicker_locale.php b/application/views/partial/datepicker_locale.php index 5b706c68f..c35c121de 100644 --- a/application/views/partial/datepicker_locale.php +++ b/application/views/partial/datepicker_locale.php @@ -2,8 +2,8 @@ var pickerconfig = function(config) { return $.extend({ - format: "config->item('dateformat'));?>", - startDate: "", + format: "config->item('dateformat')) . ' ' . dateformat_bootstrap($this->config->item('timeformat'));?>", + startDate: "", config->item('timeformat'); $m = $t[strlen($t)-1]; @@ -110,4 +110,4 @@ $.fn.datetimepicker.dates['config->item("language"); ?>'] = { weekStart: lang->line("datepicker_weekstart"); ?> }; -$(".datetime").datetimepicker(pickerconfig()); \ No newline at end of file +$(".datetime").datetimepicker(pickerconfig()); diff --git a/application/views/sales/form.php b/application/views/sales/form.php index 2e5d607a4..35561e39c 100755 --- a/application/views/sales/form.php +++ b/application/views/sales/form.php @@ -12,7 +12,7 @@