Add Customer get_row function in order to refresh the table row correctly (#1369)

This commit is contained in:
FrancescoUK
2017-08-12 22:41:10 +01:00
parent 712414c56e
commit f23f583ced

View File

@@ -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.
*/