From 3650b47d8b49c32b215dbb12d38d15fa82426bb5 Mon Sep 17 00:00:00 2001 From: Joshua Fernandes Date: Sat, 4 Mar 2017 17:17:03 +0530 Subject: [PATCH] reports display added for detailed sale and customer --- application/controllers/Reports.php | 17 ++++++++++++++++- application/language/en/reports_lang.php | 2 ++ application/models/reports/Detailed_sales.php | 10 +++++++++- .../models/reports/Specific_customer.php | 9 ++++++++- application/views/reports/tabular_details.php | 8 +++++++- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index 38a006c66..0758a00e6 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -729,6 +729,7 @@ class Reports extends Secure_Controller $summary_data = array(); $details_data = array(); + $details_data_rewards = array(); foreach($report_data['summary'] as $key => $row) { @@ -749,6 +750,12 @@ class Reports extends Secure_Controller { $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%')); } + if(isset($report_data['rewards'][$key])){ + foreach($report_data['rewards'][$key] as $drow) + { + $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['earned'], $drow['used'])); + } + } } $customer_info = $this->Customer->get_info($customer_id); @@ -758,6 +765,7 @@ class Reports extends Secure_Controller 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, + 'details_data_rewards' => $details_data_rewards, 'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs)) ); @@ -940,6 +948,7 @@ class Reports extends Secure_Controller $summary_data = array(); $details_data = array(); + $details_data_rewards = array(); $show_locations = $this->xss_clean($this->Stock_location->multiple_locations()); @@ -972,6 +981,12 @@ class Reports extends Secure_Controller } $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%')); } + if(isset($report_data['rewards'][$key])){ + foreach($report_data['rewards'][$key] as $drow) + { + $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['earned'], $drow['used'])); + } + } } $data = array( @@ -981,9 +996,9 @@ class Reports extends Secure_Controller 'editable' => 'sales', 'summary_data' => $summary_data, 'details_data' => $details_data, + 'details_data_rewards' => $details_data_rewards, 'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs)) ); - $this->load->view('reports/tabular_details', $data); } diff --git a/application/language/en/reports_lang.php b/application/language/en/reports_lang.php index 6a0c6c2bb..b2bc07bd7 100644 --- a/application/language/en/reports_lang.php +++ b/application/language/en/reports_lang.php @@ -95,3 +95,5 @@ $lang["reports_total_inventory_value"] = "Total Inventory Value"; $lang["reports_zero_and_less"] = "Zero and less"; $lang["reports_more_than_zero"] = "More than zero"; $lang["reports_no_reports_to_display"] = "No Items to display"; +$lang["reports_used"] = "Points Used"; +$lang["reports_earned"] = "Points Earned"; diff --git a/application/models/reports/Detailed_sales.php b/application/models/reports/Detailed_sales.php index 540e87eda..7fd900189 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -42,7 +42,10 @@ class Detailed_sales extends Report $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'), - $this->lang->line('reports_discount')) + $this->lang->line('reports_discount')), + 'details_rewards' => array( + $this->lang->line('reports_used'), + $this->lang->line('reports_earned')) ); } @@ -91,6 +94,7 @@ class Detailed_sales extends Report $data = array(); $data['summary'] = $this->db->get()->result_array(); $data['details'] = array(); + $data['rewards'] = array(); foreach($data['summary'] as $key=>$value) { @@ -98,6 +102,10 @@ class Detailed_sales extends Report $this->db->from('sales_items_temp'); $this->db->where('sale_id', $value['sale_id']); $data['details'][$key] = $this->db->get()->result_array(); + $this->db->select('earned, used'); + $this->db->from('sales_reward_points'); + $this->db->where('sale_id', $value['sale_id']); + $data['rewards'][$key] = $this->db->get()->result_array(); } return $data; diff --git a/application/models/reports/Specific_customer.php b/application/models/reports/Specific_customer.php index 7ab99546a..3c53b800f 100644 --- a/application/models/reports/Specific_customer.php +++ b/application/models/reports/Specific_customer.php @@ -41,7 +41,10 @@ class Specific_customer extends Report $this->lang->line('reports_total'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'), - $this->lang->line('reports_discount')) + $this->lang->line('reports_discount')), + 'details_rewards' => array( + $this->lang->line('reports_used'), + $this->lang->line('reports_earned')) ); } @@ -73,6 +76,10 @@ class Specific_customer extends Report $this->db->from('sales_items_temp'); $this->db->where('sale_id', $value['sale_id']); $data['details'][$key] = $this->db->get()->result_array(); + $this->db->select('earned, used'); + $this->db->from('sales_reward_points'); + $this->db->where('sale_id', $value['sale_id']); + $data['rewards'][$key] = $this->db->get()->result_array(); } return $data; diff --git a/application/views/reports/tabular_details.php b/application/views/reports/tabular_details.php index 7ba606272..f49a714cd 100644 --- a/application/views/reports/tabular_details.php +++ b/application/views/reports/tabular_details.php @@ -26,7 +26,7 @@ load->view('partial/bootstrap_tables_locale'); ?> var detail_data = ; - + var details_data_rewards = ; var init_dialog = function() { @@ -60,6 +60,12 @@ columns: , data: detail_data[(!isNaN(row.id) && row.id) || $(row[0] || row.id).text().replace(/(POS|RECV)\s*/g, '')] }); + + $detail.append('
').find("table").bootstrapTable({ + columns: , + data: details_data_rewards[(!isNaN(row.id) && row.id) || $(row[0] || row.id).text().replace(/(POS|RECV)\s*/g, '')] + }); + } });