From c96c2a69a663989263e59854e7065e00a6bc45fa Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Tue, 12 Dec 2017 20:58:36 +0000 Subject: [PATCH] Fix Reports and few other minor things --- application/controllers/Reports.php | 57 ++- application/language/en-GB/reports_lang.php | 2 +- application/language/en-US/reports_lang.php | 4 +- application/models/Item.php | 6 +- application/models/Sale.php | 1 + application/models/reports/Detailed_sales.php | 8 +- .../models/reports/Specific_customer.php | 1 + .../models/reports/Specific_discount.php | 4 + .../models/reports/Specific_employee.php | 1 + application/views/items/form.php | 335 +++++++++--------- application/views/items/form_bulk.php | 29 +- .../views/items/form_count_details.php | 22 +- application/views/items/form_inventory.php | 9 +- application/views/partial/header.php | 2 +- composer.lock | 4 +- 15 files changed, 269 insertions(+), 216 deletions(-) diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index cb4ecd8dd..1ff8d2f0f 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -811,6 +811,17 @@ class Reports extends Secure_Controller foreach($report_data['summary'] as $key => $row) { + if($row['sale_status'] == CANCELED) + { + $button_key = 'data-btn-restore'; + $button_label = $this->lang->line('common_restore'); + } + else + { + $button_key = 'data-btn-delete'; + $button_label = $this->lang->line('common_delete'); + } + $summary_data[] = $this->xss_clean(array( 'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), 'type_code' => $row['type_code'], @@ -823,7 +834,10 @@ class Reports extends Secure_Controller 'cost' => to_currency($row['cost']), 'profit' => to_currency($row['profit']), 'payment_type' => $row['payment_type'], - 'comment' => $row['comment'])); + 'comment' => $row['comment'], + 'edit' => anchor('sales/edit/'. $row['sale_id'], '', + array('class'=>'modal-dlg print_hide', $button_key => $button_label, 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))) + )); foreach($report_data['details'][$key] as $drow) { @@ -898,6 +912,17 @@ class Reports extends Secure_Controller foreach($report_data['summary'] as $key => $row) { + if($row['sale_status'] == CANCELED) + { + $button_key = 'data-btn-restore'; + $button_label = $this->lang->line('common_restore'); + } + else + { + $button_key = 'data-btn-delete'; + $button_label = $this->lang->line('common_delete'); + } + $summary_data[] = $this->xss_clean(array( 'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), 'type_code' => $row['type_code'], @@ -910,7 +935,10 @@ class Reports extends Secure_Controller 'cost' => to_currency($row['cost']), 'profit' => to_currency($row['profit']), 'payment_type' => $row['payment_type'], - 'comment' => $row['comment'])); + 'comment' => $row['comment'], + 'edit' => anchor('sales/edit/'. $row['sale_id'], '', + array('class'=>'modal-dlg print_hide', $button_key => $button_label, 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))) + )); foreach($report_data['details'][$key] as $drow) { @@ -987,18 +1015,33 @@ class Reports extends Secure_Controller foreach($report_data['summary'] as $key => $row) { + if($row['sale_status'] == CANCELED) + { + $button_key = 'data-btn-restore'; + $button_label = $this->lang->line('common_restore'); + } + else + { + $button_key = 'data-btn-delete'; + $button_label = $this->lang->line('common_delete'); + } + $summary_data[] = $this->xss_clean(array( 'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')), 'type_code' => $row['type_code'], 'sale_date' => $row['sale_date'], 'quantity' => to_quantity_decimals($row['items_purchased']), + 'employee_name' => $row['employee_name'], 'customer_name' => $row['customer_name'], 'subtotal' => to_currency($row['subtotal']), 'tax' => to_currency_tax($row['tax']), 'total' => to_currency($row['total']), + 'cost' => to_currency($row['cost']), 'profit' => to_currency($row['profit']), 'payment_type' => $row['payment_type'], - 'comment' => $row['comment'] + 'comment' => $row['comment'], + 'edit' => anchor('sales/edit/'. $row['sale_id'], '', + array('class'=>'modal-dlg print_hide', $button_key => $button_label, 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))) )); foreach($report_data['details'][$key] as $drow) @@ -1262,7 +1305,13 @@ class Reports extends Secure_Controller { $quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']'; } - $details_data[$row['receiving_id']][] = $this->xss_clean(array($drow['item_number'], $drow['name'], $drow['category'], $quantity_purchased, to_currency($drow['total']), $drow['discount_percent'].'%')); + $details_data[$row['receiving_id']][] = $this->xss_clean(array( + $drow['item_number'], + $drow['name'], + $drow['category'], + $quantity_purchased, + to_currency($drow['total']), + $drow['discount_percent'].'%')); } } diff --git a/application/language/en-GB/reports_lang.php b/application/language/en-GB/reports_lang.php index b61e624c1..358d08ba8 100644 --- a/application/language/en-GB/reports_lang.php +++ b/application/language/en-GB/reports_lang.php @@ -52,7 +52,7 @@ $lang["reports_inventory_summary_report"] = "Inventory Summary Report"; $lang["reports_item"] = "Item"; $lang["reports_item_count"] = "Filter Item Count"; $lang["reports_item_name"] = "Item Name"; -$lang["reports_item_number"] = "Item Number"; +$lang["reports_item_number"] = "Barcode"; $lang["reports_items"] = "Items"; $lang["reports_items_purchased"] = "Items Purchased"; $lang["reports_items_received"] = "Items Received"; diff --git a/application/language/en-US/reports_lang.php b/application/language/en-US/reports_lang.php index 8d7931e76..8160bfefc 100644 --- a/application/language/en-US/reports_lang.php +++ b/application/language/en-US/reports_lang.php @@ -39,7 +39,9 @@ $lang["reports_expenses_categories"] = "Expenses"; $lang["reports_expenses_categories_summary_report"] = "Expense Categories Summary Report"; $lang["reports_expenses_category"] = "Category"; $lang["reports_expenses_amount"] = "Amount"; +$lang["reports_expenses_tax_amount"] = "Tax"; $lang["reports_expenses_total_amount"] = "Total Amount"; +$lang["reports_expenses_total_tax_amount"] = "Total Tax"; $lang["reports_graphical_reports"] = "Graphical Reports"; $lang["reports_inventory"] = "Inventory"; $lang["reports_inventory_low"] = "Low Inventory"; @@ -50,7 +52,7 @@ $lang["reports_inventory_summary_report"] = "Inventory Summary Report"; $lang["reports_item"] = "Item"; $lang["reports_item_count"] = "Filter Item Count"; $lang["reports_item_name"] = "Item Name"; -$lang["reports_item_number"] = "Item Number"; +$lang["reports_item_number"] = "Barcode"; $lang["reports_items"] = "Items"; $lang["reports_items_purchased"] = "Items Purchased"; $lang["reports_items_received"] = "Items Received"; diff --git a/application/models/Item.php b/application/models/Item.php index d8dac58d4..d876d5d87 100644 --- a/application/models/Item.php +++ b/application/models/Item.php @@ -484,7 +484,7 @@ class Item extends CI_Model { $suggestions = array(); - $this->db->select($this->get_search_suggestion_format('item_id,name')); + $this->db->select($this->get_search_suggestion_format('item_id, name')); $this->db->from('items'); $this->db->where('deleted', $filters['is_deleted']); $this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later @@ -495,7 +495,7 @@ class Item extends CI_Model $suggestions[] = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row)); } - $this->db->select($this->get_search_suggestion_format('item_id,item_number')); + $this->db->select($this->get_search_suggestion_format('item_id, item_number')); $this->db->from('items'); $this->db->where('deleted', $filters['is_deleted']); $this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later @@ -576,7 +576,6 @@ class Item extends CI_Model } } - //only return $limit suggestions if(count($suggestions > $limit)) { @@ -687,7 +686,6 @@ class Item extends CI_Model } } - //only return $limit suggestions if(count($suggestions > $limit)) { diff --git a/application/models/Sale.php b/application/models/Sale.php index 4330065a0..443fa9ec0 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -1183,6 +1183,7 @@ class Sale extends CI_Model MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name, items.item_id AS item_id, MAX(items.name) AS name, + MAX(items.item_number) AS item_number, MAX(items.category) AS category, MAX(items.supplier_id) AS supplier_id, MAX(sales_items.quantity_purchased) AS quantity_purchased, diff --git a/application/models/reports/Detailed_sales.php b/application/models/reports/Detailed_sales.php index e247ae9c1..562c9ab93 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -25,7 +25,7 @@ class Detailed_sales extends Report array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'), - array('payment_type' => $this->lang->line('sales_amount_tendered')), + array('payment_type' => $this->lang->line('reports_payment_type')), array('comment' => $this->lang->line('reports_comments'))), 'details' => array( $this->lang->line('reports_name'), @@ -50,14 +50,14 @@ class Detailed_sales extends Report $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, - employee_name, - customer_name, + MAX(employee_name) AS employee_name, + MAX(customer_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, - payment_type, + MAX(payment_type) AS payment_type, comment'); $this->db->from('sales_items_temp'); $this->db->where('sale_id', $sale_id); diff --git a/application/models/reports/Specific_customer.php b/application/models/reports/Specific_customer.php index ba33c3933..7ec5ab0df 100644 --- a/application/models/reports/Specific_customer.php +++ b/application/models/reports/Specific_customer.php @@ -55,6 +55,7 @@ class Specific_customer extends Report WHEN sale_status = ' . CANCELED . ' THEN \'' . $this->lang->line('reports_code_canceled') . '\' ELSE \'\' END) AS type_code, + MAX(sale_status) as sale_status, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, MAX(employee_name) AS employee_name, diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index c2291ebb5..233500168 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -18,10 +18,12 @@ class Specific_discount extends Report array('type_code' => $this->lang->line('reports_code_type')), array('sale_date' => $this->lang->line('reports_date')), array('quantity' => $this->lang->line('reports_quantity')), + array('employee_name' => $this->lang->line('reports_sold_by')), array('customer_name' => $this->lang->line('reports_sold_to')), array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'), array('payment_type' => $this->lang->line('reports_payment_type')), array('comment' => $this->lang->line('reports_comments'))), @@ -53,8 +55,10 @@ class Specific_discount extends Report WHEN sale_status = ' . CANCELED . ' THEN \'' . $this->lang->line('reports_code_canceled') . '\' ELSE \'\' END) AS type_code, + MAX(sale_status) as sale_status, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, + MAX(employee_name) AS employee_name, MAX(customer_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, diff --git a/application/models/reports/Specific_employee.php b/application/models/reports/Specific_employee.php index f0e83f80f..4d8f0a3ce 100644 --- a/application/models/reports/Specific_employee.php +++ b/application/models/reports/Specific_employee.php @@ -55,6 +55,7 @@ class Specific_employee extends Report WHEN sale_status = ' . CANCELED . ' THEN \'' . $this->lang->line('reports_code_canceled') . '\' ELSE \'\' END) AS type_code, + MAX(sale_status) as sale_status, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, MAX(customer_name) AS customer_name, diff --git a/application/views/items/form.php b/application/views/items/form.php index a44309a8c..54f0e4e49 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -252,7 +252,7 @@ );?> - +
lang->line('items_image'), 'items_image', array('class'=>'control-label col-xs-3')); ?>
@@ -339,183 +339,182 @@ + ?> + receiving_quantity: + { + required: true, + remote: "" + }, + reorder_level: + { + required: true, + remote: "" + }, + tax_percent: + { + required: true, + remote: "" + } + }, + messages: + { + name: "lang->line('items_name_required'); ?>", + item_number: "lang->line('items_item_number_duplicate'); ?>", + category: "lang->line('items_category_required'); ?>", + cost_price: + { + required: "lang->line('items_cost_price_required'); ?>", + number: "lang->line('items_cost_price_number'); ?>" + }, + unit_price: + { + required: "lang->line('items_unit_price_required'); ?>", + number: "lang->line('items_unit_price_number'); ?>" + }, + $location_detail) + { + ?> + : + { + required: "lang->line('items_quantity_required'); ?>", + number: "lang->line('items_quantity_number'); ?>" + }, + + receiving_quantity: + { + required: "lang->line('items_quantity_required'); ?>", + number: "lang->line('items_quantity_number'); ?>" + }, + reorder_level: + { + required: "lang->line('items_reorder_level_required'); ?>", + number: "lang->line('items_reorder_level_number'); ?>" + }, + tax_percent: + { + required: "lang->line('items_tax_percent_required'); ?>", + number: "lang->line('items_tax_percent_number'); ?>" + } + } + }, form_support.error)); +}); + diff --git a/application/views/items/form_bulk.php b/application/views/items/form_bulk.php index 8a02b2aa7..228eeeade 100644 --- a/application/views/items/form_bulk.php +++ b/application/views/items/form_bulk.php @@ -4,7 +4,7 @@ 'item_form', 'class'=>'form-horizontal')); ?>
-
+
lang->line('items_name'), 'name', array('class'=>'control-label col-xs-3')); ?>
-
+
lang->line('items_category'), 'category', array('class'=>'control-label col-xs-3')); ?>
@@ -29,7 +29,7 @@
-
+
lang->line('items_supplier'), 'supplier', array('class'=>'control-label col-xs-3')); ?>
'form-control'));?> @@ -120,7 +120,7 @@
-
+
lang->line('items_reorder_level'), 'reorder_level', array('class'=>'control-label col-xs-3')); ?>
-
+
lang->line('items_description'), 'description', array('class'=>'control-label col-xs-3')); ?>
//validation and submit handling $(document).ready(function() -{ - $("#category").autocomplete({source: "",appendTo:'.modal-content',delay:10}); +{ + $("#category").autocomplete({source: "", appendTo:'.modal-content', delay:10}); var confirm_message = false; $("#tax_percent_name_2, #tax_name_2").prop('disabled', true), @@ -179,7 +179,7 @@ $(document).ready(function() { $(form).ajaxSubmit({ beforeSubmit: function(arr, $form, options) { - arr.push({name: 'item_ids', value: table_support.selected_ids().join(":")}); + arr.push({name: 'item_ids', value: table_support.selected_ids().join(": ")}); }, success:function(response) { @@ -208,26 +208,25 @@ $(document).ready(function() { number:true } - }, - messages: + }, + messages: { unit_price: { - number:"lang->line('items_unit_price_number'); ?>" + number: "lang->line('items_unit_price_number'); ?>" }, tax_percent: { - number:"lang->line('items_tax_percent_number'); ?>" + number: "lang->line('items_tax_percent_number'); ?>" }, quantity: { - number:"lang->line('items_quantity_number'); ?>" + number: "lang->line('items_quantity_number'); ?>" }, reorder_level: { - number:"lang->line('items_reorder_level_number'); ?>" + number: "lang->line('items_reorder_level_number'); ?>" } - } }, form_support.error)); }); diff --git a/application/views/items/form_count_details.php b/application/views/items/form_count_details.php index 2b78138d6..741f55584 100644 --- a/application/views/items/form_count_details.php +++ b/application/views/items/form_count_details.php @@ -91,7 +91,7 @@ foreach($inventory_array as $row) { $employee = $this->Employee->get_info($row['trans_user']); - array_push($employee_name, $employee->first_name . ' ' . $employee->last_name); + array_push($employee_name, $employee->first_name . ' ' . $employee->last_name); } ?> @@ -107,22 +107,22 @@ function display_stock(location_id) { var item_quantities = ; document.getElementById("quantity").value = parseFloat(item_quantities[location_id]).toFixed(); - + var inventory_data = ; var employee_data = ; - + var table = document.getElementById("inventory_result"); // Remove old query from tbody var rowCount = table.rows.length; for (var index = rowCount; index > 0; index--) { - table.deleteRow(index-1); + table.deleteRow(index-1); } - + // Add new query to tbody - for (var index = 0; index < inventory_data.length; index++) - { + for (var index = 0; index < inventory_data.length; index++) + { var data = inventory_data[index]; if(data['trans_location'] == location_id) { @@ -131,17 +131,17 @@ function display_stock(location_id) var td = document.createElement('td'); td.appendChild(document.createTextNode(data['trans_date'])); tr.appendChild(td); - + td = document.createElement('td'); td.appendChild(document.createTextNode(employee_data[index])); tr.appendChild(td); - + td = document.createElement('td'); td.appendChild(document.createTextNode(parseFloat(data['trans_inventory']).toFixed())); td.setAttribute("style", "text-align:center"); tr.appendChild(td); - - td = document.createElement('td'); + + td = document.createElement('td'); td.appendChild(document.createTextNode(data['trans_comment'])); tr.appendChild(td); diff --git a/application/views/items/form_inventory.php b/application/views/items/form_inventory.php index aeb29c50c..61172bc16 100644 --- a/application/views/items/form_inventory.php +++ b/application/views/items/form_inventory.php @@ -106,7 +106,7 @@ $(document).ready(function() dialog_support.hide(); table_support.handle_submit('', response); }, - dataType:'json' + dataType: 'json' }); }, @@ -122,11 +122,10 @@ $(document).ready(function() }, messages: { - newquantity: { - required:"lang->line('items_quantity_required'); ?>", - number:"lang->line('items_quantity_number'); ?>" + required: "lang->line('items_quantity_required'); ?>", + number: "lang->line('items_quantity_number'); ?>" } } }); @@ -137,4 +136,4 @@ function fill_quantity(val) var item_quantities = ; document.getElementById("quantity").value = parseFloat(item_quantities[val]).toFixed(); } - \ No newline at end of file + diff --git a/application/views/partial/header.php b/application/views/partial/header.php index 0ec683ac9..ae3bbf43f 100644 --- a/application/views/partial/header.php +++ b/application/views/partial/header.php @@ -76,7 +76,7 @@ - + diff --git a/composer.lock b/composer.lock index 31f74e000..835fa55d3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "35a55acb9ed53dbac86383781fa12b13", - "content-hash": "df567f98466ce2053faf0a1d0475afa8", + "hash": "70caa9e28d94e2435477700cdba628a5", + "content-hash": "2e34a0c173a47d5f39d714465612eff9", "packages": [ { "name": "codeigniter/framework",