From e1e5434e2a63050d3dd56bb2319e7f3502933ee9 Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Mon, 11 Aug 2014 13:10:29 +0200 Subject: [PATCH] Stock locations are now shown on receivings and sales receipts Database migration script now defines a default stock location name Rmeove obsolete constraints from migration script --- application/controllers/receivings.php | 4 ++++ application/controllers/sales.php | 4 ++++ application/views/receivings/receipt.php | 14 +++++++------- application/views/sales/receipt.php | 4 +++- database/2.2.2_to_2.3.sql | 4 +--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/application/controllers/receivings.php b/application/controllers/receivings.php index 1f958150d..e710edc9d 100644 --- a/application/controllers/receivings.php +++ b/application/controllers/receivings.php @@ -141,6 +141,8 @@ class Receivings extends Secure_area $data['receipt_title']=$this->lang->line('recvs_receipt'); $data['transaction_time']= date('m/d/Y h:i:s a'); $data['mode']=$this->receiving_lib->get_mode(); + $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array(); + $data['show_stock_locations'] = count($stock_locations) > 1; $supplier_id=$this->receiving_lib->get_supplier(); $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; $comment = $this->input->post('comment'); @@ -203,6 +205,8 @@ class Receivings extends Secure_area $data['mode']=$this->receiving_lib->get_mode(); $data['receipt_title']=$this->lang->line('recvs_receipt'); $data['transaction_time']= date('m/d/Y h:i:s a', strtotime($receiving_info['receiving_time'])); + $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array(); + $data['show_stock_locations'] = count($stock_locations) > 1; $supplier_id=$this->receiving_lib->get_supplier(); $emp_info=$this->Employee->get_info($receiving_info['employee_id']); $data['payment_type']=$receiving_info['payment_type']; diff --git a/application/controllers/sales.php b/application/controllers/sales.php index d60e83da1..ac079d5d9 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -197,6 +197,8 @@ class Sales extends Secure_area $data['total']=$this->sale_lib->get_total(); $data['receipt_title']=$this->lang->line('sales_receipt'); $data['transaction_time']= date('m/d/Y h:i:s a'); + $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array(); + $data['show_stock_locations'] = count($stock_locations) > 1; $customer_id=$this->sale_lib->get_customer(); $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; $comment = $this->sale_lib->get_comment(); @@ -240,6 +242,8 @@ class Sales extends Secure_area { $sale_info = $this->Sale->get_info($sale_id)->row_array(); $this->sale_lib->copy_entire_sale($sale_id); + $stock_locations = $this->Stock_locations->get_undeleted_all()->result_array(); + $data['show_stock_locations'] = count($stock_locations) > 1; $data['cart']=$this->sale_lib->get_cart(); $data['payments']=$this->sale_lib->get_payments(); $data['subtotal']=$this->sale_lib->get_subtotal(); diff --git a/application/views/receivings/receipt.php b/application/views/receivings/receipt.php index ebc6673d6..004f21ef1 100644 --- a/application/views/receivings/receipt.php +++ b/application/views/receivings/receipt.php @@ -41,9 +41,8 @@ if (isset($error_message)) - - @@ -62,16 +61,14 @@ if (isset($error_message)) lang->line('sales_payment'); ?> - + +
diff --git a/application/views/sales/receipt.php b/application/views/sales/receipt.php index 6031cc643..57dc7960d 100644 --- a/application/views/sales/receipt.php +++ b/application/views/sales/receipt.php @@ -43,7 +43,9 @@ if (isset($error_message)) - + diff --git a/database/2.2.2_to_2.3.sql b/database/2.2.2_to_2.3.sql index e5775746e..cb287b0e9 100644 --- a/database/2.2.2_to_2.3.sql +++ b/database/2.2.2_to_2.3.sql @@ -21,7 +21,7 @@ ALTER TABLE ospos_inventory ALTER TABLE ospos_items DROP COLUMN location; -INSERT INTO `ospos_stock_locations` ( `deleted` ) VALUES ('0'); +INSERT INTO `ospos_stock_locations` ( `deleted`, `location_name` ) VALUES ('0', 'stock'); ALTER TABLE ospos_receivings_items ADD COLUMN item_location int(11) NOT NULL, @@ -33,7 +33,6 @@ ALTER TABLE ospos_sales_items ADD COLUMN item_location int(11) NOT NULL, ADD KEY `item_location` (`item_location`), ADD KEY `sale_id` (`sale_id`), - ADD CONSTRAINT `ospos_sales_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales` (`sale_id`), ADD CONSTRAINT `ospos_sales_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`); ALTER TABLE ospos_sales_items_taxes @@ -46,7 +45,6 @@ ALTER TABLE ospos_sales_suspended_items ADD COLUMN item_location int(11) NOT NULL, ADD KEY `item_location` (`item_location`), ADD KEY `sale_id` (`sale_id`), - ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_2` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_suspended` (`sale_id`), ADD CONSTRAINT `ospos_sales_suspended_items_ibfk_3` FOREIGN KEY (`item_location`) REFERENCES `ospos_stock_locations` (`location_id`); ALTER TABLE `ospos_item_quantities`