From 4b0badfb30eadc70268dea9e304f47ebcfd1a695 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 15 Jun 2016 08:44:24 +0200 Subject: [PATCH] Fix customer search in takings (#654) Replace payment type label with amount tendered (#513) --- application/models/Sale.php | 7 ++++--- application/models/reports/Detailed_sales.php | 2 +- application/models/reports/Summary_payments.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/application/models/Sale.php b/application/models/Sale.php index 3e7d005f7..85c35f497 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -31,12 +31,13 @@ class Sale extends CI_Model public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc') { $this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased, - CONCAT(customer.first_name, " ", customer.last_name) AS customer_name, + CONCAT(person.first_name, " ", person.last_name) AS customer_name, customer.company_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, sale_payment_amount AS amount_tendered, SUM(total) AS amount_due, (sale_payment_amount - SUM(total)) AS change_due, payment_type, invoice_number'); $this->db->from('sales_items_temp'); - $this->db->join('people AS customer', 'sales_items_temp.customer_id = customer.person_id', 'left'); + $this->db->join('people AS person', 'sales_items_temp.customer_id = person.person_id', 'left'); + $this->db->join('customers AS customer', 'sales_items_temp.customer_id = customer.person_id', 'left'); if(empty($search)) { @@ -55,7 +56,7 @@ class Sale extends CI_Model $this->db->group_start(); $this->db->like('last_name', $search); $this->db->or_like('first_name', $search); - $this->db->or_like('CONCAT(customer.first_name, " ", last_name)', $search); + $this->db->or_like('CONCAT(first_name, " ", last_name)', $search); $this->db->or_like('company_name', $search); $this->db->group_end(); } diff --git a/application/models/reports/Detailed_sales.php b/application/models/reports/Detailed_sales.php index 79513c5d1..2cdffdd9f 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -21,7 +21,7 @@ class Detailed_sales extends Report 'tax' => $this->lang->line('reports_tax'), 'cost' => $this->lang->line('reports_cost'), 'profit' => $this->lang->line('reports_profit'), - 'payment_type' => $this->lang->line('reports_payment_type'), + 'payment_type' => $this->lang->line('sales_amount_tendered'), 'comment' => $this->lang->line('reports_comments'), 'edit' => ''), 'details' => array( diff --git a/application/models/reports/Summary_payments.php b/application/models/reports/Summary_payments.php index 76eed64eb..088d72602 100644 --- a/application/models/reports/Summary_payments.php +++ b/application/models/reports/Summary_payments.php @@ -9,7 +9,7 @@ class Summary_payments extends Report public function getDataColumns() { - return array($this->lang->line('reports_payment_type'), $this->lang->line('reports_count'), $this->lang->line('reports_total')); + return array($this->lang->line('reports_payment_type'), $this->lang->line('reports_count'), $this->lang->line('sales_amount_tendered')); } public function getData(array $inputs)