Reports minor fixes

This commit is contained in:
FrancescoUK
2020-01-12 18:19:09 +00:00
parent ef661e52e7
commit bdddb945f0
4 changed files with 20 additions and 17 deletions

View File

@@ -48,6 +48,7 @@ class Specific_customer extends Report
{
$this->db->select('sale_id,
MAX(CASE
WHEN sale_type = ' . SALE_TYPE_POS . ' && sale_status = ' . COMPLETED . ' THEN \'' . $this->lang->line('reports_code_pos') . '\'
WHEN sale_type = ' . SALE_TYPE_INVOICE . ' && sale_status = ' . COMPLETED . ' THEN \'' . $this->lang->line('reports_code_invoice') . '\'
WHEN sale_type = ' . SALE_TYPE_WORK_ORDER . ' && sale_status = ' . SUSPENDED . ' THEN \'' . $this->lang->line('reports_code_work_order') . '\'
WHEN sale_type = ' . SALE_TYPE_QUOTE . ' && sale_status = ' . SUSPENDED . ' THEN \'' . $this->lang->line('reports_code_quote') . '\'
@@ -67,25 +68,25 @@ class Specific_customer extends Report
MAX(payment_type) AS payment_type,
MAX(comment) AS comment');
$this->db->from('sales_items_temp');
$this->db->where('customer_id', $inputs['customer_id']);
$this->db->where('customer_id', $inputs['customer_id']);
if($inputs['payment_type'] == 'invoices')
{
$this->db->where('sale_type', SALE_TYPE_INVOICE);
}
elseif ($inputs['payment_type'] != 'all')
}
elseif($inputs['payment_type'] != 'all')
{
$this->db->like('payment_type', $this->lang->line('sales_'.$inputs['payment_type']));
}
}
if($inputs['sale_type'] == 'complete')
{
$this->db->where('sale_status', COMPLETED);
$this->db->group_start();
$this->db->where('sale_type', SALE_TYPE_POS);
$this->db->or_where('sale_type', SALE_TYPE_INVOICE);
$this->db->or_where('sale_type', SALE_TYPE_RETURN);
$this->db->or_where('sale_type', SALE_TYPE_RETURN);
$this->db->group_end();
}
elseif($inputs['sale_type'] == 'sales')
@@ -94,7 +95,6 @@ class Specific_customer extends Report
$this->db->group_start();
$this->db->where('sale_type', SALE_TYPE_POS);
$this->db->or_where('sale_type', SALE_TYPE_INVOICE);
$this->db->group_end();
}
elseif($inputs['sale_type'] == 'quotes')
@@ -144,17 +144,18 @@ class Specific_customer extends Report
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where('customer_id', $inputs['customer_id']);
if($inputs['payment_type'] == 'invoices')
{
$this->db->where('sale_type', SALE_TYPE_INVOICE);
}
elseif ($inputs['payment_type'] != 'all')
}
elseif ($inputs['payment_type'] != 'all')
{
$this->db->like('payment_type', $this->lang->line('sales_'.$inputs['payment_type']));
}
}
if($inputs['sale_type'] == 'complete')
{
$this->db->where('sale_status', COMPLETED);
@@ -190,7 +191,7 @@ class Specific_customer extends Report
{
$this->db->where('sale_status', COMPLETED);
$this->db->where('sale_type', SALE_TYPE_RETURN);
}
}
return $this->db->get()->row_array();
}

View File

@@ -70,7 +70,7 @@ class Specific_discount extends Report
MAX(payment_type) AS payment_type,
MAX(comment) AS comment');
$this->db->from('sales_items_temp');
$this->db->where('discount >=', $inputs['discount']);
$this->db->where('discount_type', $inputs['discount_type']);
@@ -138,7 +138,7 @@ class Specific_discount extends Report
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where('discount >=', $inputs['discount']);
$this->db->where('discount_type', $inputs['discount_type']);

View File

@@ -68,6 +68,7 @@ class Specific_employee extends Report
MAX(payment_type) AS payment_type,
MAX(comment) AS comment');
$this->db->from('sales_items_temp');
$this->db->where('employee_id', $inputs['employee_id']);
if($inputs['sale_type'] == 'complete')
@@ -134,6 +135,7 @@ class Specific_employee extends Report
{
$this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
$this->db->from('sales_items_temp');
$this->db->where('employee_id', $inputs['employee_id']);
if($inputs['sale_type'] == 'complete')

View File

@@ -21,7 +21,7 @@ class Summary_customers extends Summary_report
parent::_select($inputs);
$this->db->select('
CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer,
MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer,
SUM(sales_items.quantity_purchased) AS quantity_purchased
');
}