From 2dab5e0fe72082d655deb338f4024675a77aca32 Mon Sep 17 00:00:00 2001 From: jekkos Date: Mon, 25 Apr 2016 08:58:32 +0200 Subject: [PATCH] Bootstrap-tables integration for sales module (WIP) (#293) Refactor manage_tables, remove public function identifiers --- application/controllers/Sales.php | 6 +++--- application/helpers/table_helper.php | 2 +- application/models/Sale.php | 2 +- application/views/giftcards/manage.php | 5 +++-- application/views/item_kits/manage.php | 5 +++-- application/views/people/manage.php | 13 ++++-------- application/views/sales/form.php | 17 ++++++--------- application/views/sales/manage.php | 29 +++++++++++++------------- dist/opensourcepos.js | 27 +++++++++++++----------- js/manage_tables.js | 27 +++++++++++++----------- 10 files changed, 66 insertions(+), 67 deletions(-) diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index 4571515c2..bd613c0c4 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -47,10 +47,10 @@ class Sales extends Secure_area { $this->Sale->create_sales_items_temp_table(); - $sale_info = $this->Sale->get_info($row_id)->result_array(); - $data_row = get_sales_manage_sale_data_row($sale_info[0], $this); + $sale_info = $this->Sale->get_info($row_id)->row(); + $data_row = get_sale_data_row($sale_info, $this); - echo $data_row; + echo json_encode($data_row); } /* diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 133e1e113..71ddeb7e9 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -66,7 +66,7 @@ function get_sale_data_row($sale, $controller) 'customer' => character_limiter( $sale->customer_name, 25), 'amount_tendered' => to_currency( $sale->amount_tendered ), 'amount_due' => to_currency($sale->amount_due), - 'change_due' => to_currency($sale->chang_due), + 'change_due' => to_currency($sale->change_due), 'payment_type' => $sale->payment_type, 'invoice_number' => $sale->invoice_number, 'receipt' => anchor($controller_name."/receipt/$sale->sale_id", '', diff --git a/application/models/Sale.php b/application/models/Sale.php index 1304d0f5c..96de34226 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -106,7 +106,7 @@ class Sale extends CI_Model if (empty($search)) { - $this->db->where('sale_time BETWEEN '. $this->db->escape($filters['start_date']). ' AND '. $this->db->escape($filters['end_date'])); + //$this->db->where('sale_time BETWEEN '. $this->db->escape($filters['start_date']). ' AND '. $this->db->escape($filters['end_date'])); } else { diff --git a/application/views/giftcards/manage.php b/application/views/giftcards/manage.php index 6e35f20ac..2529b3de9 100644 --- a/application/views/giftcards/manage.php +++ b/application/views/giftcards/manage.php @@ -2,8 +2,9 @@ diff --git a/application/views/item_kits/manage.php b/application/views/item_kits/manage.php index 800ef40bf..cc37297d7 100644 --- a/application/views/item_kits/manage.php +++ b/application/views/item_kits/manage.php @@ -3,8 +3,9 @@ diff --git a/application/views/sales/form.php b/application/views/sales/form.php index d463c1a6c..a33411f64 100755 --- a/application/views/sales/form.php +++ b/application/views/sales/form.php @@ -106,7 +106,7 @@ $(document).ready(function() $.get('', function(response) { dialog_support.hide(); - post_form_submit(response); + table_support.handle_submit('', response); }, "json" ); } @@ -166,11 +166,11 @@ $(document).ready(function() success: function(response) { dialog_support.hide(); - post_form_submit(response); + table_support.handle_submit('', response); }, error: function(jqXHR, textStatus, errorThrown) { - post_form_submit({message: errorThrown}); + table_support.handle_submit('', { message : errorThrown, success: false });; }, dataType: 'json' }); @@ -217,14 +217,9 @@ $(document).ready(function() { dialog_support.hide(); set_feedback(response.message, 'alert alert-dismissible alert-success', false); - var $element = get_table_row(id).parent().parent(); - $element.find("td").animate({backgroundColor:"green"},1200,"linear") - .end().animate({opacity:0},1200,"linear",function() - { - $element.next().remove(); - $(this).remove(); - //Re-init sortable table as we removed a row - update_sortable_table(); + table().remove({ + field: 'id', + values: [id] }); }, error: function(jqXHR, textStatus, errorThrown) { diff --git a/application/views/sales/manage.php b/application/views/sales/manage.php index 0b783a893..22e707e19 100755 --- a/application/views/sales/manage.php +++ b/application/views/sales/manage.php @@ -3,12 +3,6 @@