From 1666a3e689f94366a81dacc01e944fbffc648999 Mon Sep 17 00:00:00 2001 From: jekkos Date: Fri, 25 Nov 2016 20:57:39 +0100 Subject: [PATCH] Fix detailed sale + receiving report row update + currency sorting (#1003) --- application/helpers/table_helper.php | 12 ++++++--- application/models/Receiving.php | 2 +- application/models/Sale.php | 2 +- .../models/reports/Detailed_receivings.php | 19 +++++++------ application/models/reports/Detailed_sales.php | 27 +++++++++---------- application/views/reports/tabular_details.php | 2 +- 6 files changed, 34 insertions(+), 30 deletions(-) diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 93dd86221..2c2dc2855 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -121,11 +121,17 @@ function transform_headers_readonly($array) return json_encode($result); } -function transform_headers($array) +function transform_headers($array, $readonly = FALSE) { $result = array(); - $array = array_merge(array(array('checkbox' => 'select', 'sortable' => FALSE)), - $array, array(array('edit' => ''))); + + if (!readonly) + { + $array = array_merge(array(array('checkbox' => 'select', 'sortable' => FALSE)), $array); + } + + $array[] = array('edit' => ''); + foreach($array as $element) { $result[] = array('field' => key($element), diff --git a/application/models/Receiving.php b/application/models/Receiving.php index 01365ea95..4b8b9145e 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -225,7 +225,7 @@ class Receiving extends CI_Model */ public function create_temp_table(array $inputs) { - if(empty($input['receiving_id'])) + if(empty($inputs['receiving_id'])) { $where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']); } diff --git a/application/models/Sale.php b/application/models/Sale.php index 59046c946..581941ecd 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -733,7 +733,7 @@ class Sale extends CI_Model $decimals = totals_decimals(); - if(empty($input['sale_id'])) + if(empty($inputs['sale_id'])) { $where = 'WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']); } diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index a1d4e7064..e5d434a7e 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -19,16 +19,15 @@ class Detailed_receivings extends Report { $columns = array( 'summary' => array( - 'id' => $this->lang->line('reports_receiving_id'), - 'receiving_date' => $this->lang->line('reports_date'), - 'quantity' => $this->lang->line('reports_quantity'), - 'employee' => $this->lang->line('reports_received_by'), - 'supplier' => $this->lang->line('reports_supplied_by'), - 'total' => $this->lang->line('reports_total'), - 'payment_type' => $this->lang->line('reports_payment_type'), - 'reference' => $this->lang->line('receivings_reference'), - 'comment' => $this->lang->line('reports_comments'), - 'edit' => ''), + array('id' => $this->lang->line('reports_receiving_id')), + array('receiving_date' => $this->lang->line('reports_date')), + array('quantity' => $this->lang->line('reports_quantity')), + array('employee' => $this->lang->line('reports_received_by')), + array('supplier' => $this->lang->line('reports_supplied_by')), + array('total' => $this->lang->line('reports_total')), + array('payment_type' => $this->lang->line('reports_payment_type')), + array('reference' => $this->lang->line('receivings_reference')), + array('comment' => $this->lang->line('reports_comments'))), 'details' => array( $this->lang->line('reports_item_number'), $this->lang->line('reports_name'), diff --git a/application/models/reports/Detailed_sales.php b/application/models/reports/Detailed_sales.php index f4a75963f..f31171522 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -19,19 +19,18 @@ class Detailed_sales extends Report { return array( 'summary' => array( - 'id' => $this->lang->line('reports_sale_id'), - 'sale_date' => $this->lang->line('reports_date'), - 'quantity' => $this->lang->line('reports_quantity'), - 'employee' => $this->lang->line('reports_sold_by'), - 'customer' => $this->lang->line('reports_sold_to'), - 'subtotal' => $this->lang->line('reports_subtotal'), - 'tax' => $this->lang->line('reports_tax'), - 'total' => $this->lang->line('reports_total'), - 'cost' => $this->lang->line('reports_cost'), - 'profit' => $this->lang->line('reports_profit'), - 'payment_type' => $this->lang->line('sales_amount_tendered'), - 'comment' => $this->lang->line('reports_comments'), - 'edit' => ''), + array('id' => $this->lang->line('reports_sale_id')), + array('sale_date' => $this->lang->line('reports_date')), + array('quantity' => $this->lang->line('reports_quantity')), + array('employee' => $this->lang->line('reports_sold_by')), + array('customer' => $this->lang->line('reports_sold_to')), + array('subtotal' => $this->lang->line('reports_subtotal')), + array('total' => $this->lang->line('reports_total')), + array('tax' => $this->lang->line('reports_tax')), + array('cost' => $this->lang->line('reports_cost')), + array('profit' => $this->lang->line('reports_profit')), + array('payment_type' => $this->lang->line('sales_amount_tendered')), + array('comment' => $this->lang->line('reports_comments'))), 'details' => array( $this->lang->line('reports_name'), $this->lang->line('reports_category'), @@ -100,7 +99,7 @@ class Detailed_sales extends Report if($inputs['location_id'] != 'all') { - $this->db->where('item_location', $inputs['location_id']); + $this->db->where('item_location', $inputs['location_id']); } if($inputs['sale_type'] == 'sales') diff --git a/application/views/reports/tabular_details.php b/application/views/reports/tabular_details.php index fbd1cb677..0caf7687b 100644 --- a/application/views/reports/tabular_details.php +++ b/application/views/reports/tabular_details.php @@ -35,7 +35,7 @@ }; $('#table').bootstrapTable({ - columns: , + columns: , pageSize: config->item('lines_per_page'); ?>, striped: true, pagination: true,