From f23f583ceddf81049dc61276b5ad0c47b09526d1 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sat, 12 Aug 2017 22:41:10 +0100 Subject: [PATCH] Add Customer get_row function in order to refresh the table row correctly (#1369) --- application/controllers/Customers.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index a3ff0fa07..7198aac34 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -24,6 +24,32 @@ class Customers extends Persons $this->load->view('people/manage', $data); } + /* + Gets one row for a customer manage table. This is called using AJAX to update one row. + */ + public function get_row($row_id) + { + $person = $this->Customer->get_info($row_id); + + // retrieve the total amount the customer spent so far together with min, max and average values + $stats = $this->Customer->get_stats($person->person_id); + if(empty($stats)) + { + //create object with empty properties. + $stats = new stdClass; + $stats->total = 0; + $stats->min = 0; + $stats->max = 0; + $stats->average = 0; + $stats->avg_discount = 0; + $stats->quantity = 0; + } + + $data_row = $this->xss_clean(get_customer_data_row($person, $stats, $this)); + + echo json_encode($data_row); + } + /* Returns customer table data rows. This will be called with AJAX. */