From 0f95c6c9b52594211b97f16c3610df84062c159a Mon Sep 17 00:00:00 2001 From: Jorge Colmenarez Date: Tue, 1 Nov 2016 22:08:47 -0400 Subject: [PATCH 1/3] Add Support for filter reports with format date/time --- application/controllers/Config.php | 6 +- application/controllers/Login.php | 5 + application/controllers/Reports.php | 514 +++++++++++++++--- application/controllers/Sales.php | 9 +- application/language/en/config_lang.php | 5 + application/language/es/config_lang.php | 5 + application/models/Receiving.php | 4 +- application/models/Sale.php | 17 +- .../models/reports/Detailed_receivings.php | 14 +- application/models/reports/Detailed_sales.php | 14 +- .../models/reports/Specific_customer.php | 18 +- .../models/reports/Specific_discount.php | 22 +- .../models/reports/Specific_employee.php | 20 +- .../models/reports/Summary_categories.php | 15 +- .../models/reports/Summary_customers.php | 14 +- .../models/reports/Summary_discounts.php | 17 +- .../models/reports/Summary_employees.php | 14 +- application/models/reports/Summary_items.php | 14 +- .../models/reports/Summary_payments.php | 14 +- application/models/reports/Summary_sales.php | 14 +- .../models/reports/Summary_suppliers.php | 14 +- application/models/reports/Summary_taxes.php | 19 +- application/views/configs/locale_config.php | 12 + application/views/partial/daterangepicker.php | 175 ++++-- application/views/reports/date_input.php | 2 +- 25 files changed, 822 insertions(+), 155 deletions(-) diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 9df7fcb0c..7fd0552e3 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -302,7 +302,11 @@ class Config extends Secure_Controller 'tax_decimals' => $this->input->post('tax_decimals'), 'quantity_decimals' => $this->input->post('quantity_decimals'), 'country_codes' => $this->input->post('country_codes'), - 'payment_options_order' => $this->input->post('payment_options_order') + 'payment_options_order' => $this->input->post('payment_options_order'), + // Added By Jorge Colmenarez 2016-10-31 16:39 + // Support for filter datetime reports + 'filter_datetime_format' => $this->input->post('filter_datetime_format') + // End Jorge Colmenarez ); $result = $this->Appconfig->batch_save($batch_save_data); diff --git a/application/controllers/Login.php b/application/controllers/Login.php index 1ef48e9a7..321a79c00 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -41,6 +41,11 @@ class Login extends CI_Controller $this->tracking_lib->track_event('Stats', 'Tax Decimals', $this->config->item('tax_decimals')); $this->tracking_lib->track_event('Stats', 'Quantity Decimals', $this->config->item('quantity_decimals')); $this->tracking_lib->track_event('Stats', 'Invoice Enable', $this->config->item('invoice_enable')); + /** + * Jorge Colmenarez 2016-11-01 08:33 + * Set Static Filter DateTime Format Value + */ + $this->tracking_lib->track_event('Stats', 'Filter DateTime Format', $this->config->item('filter_datetime_format')); } redirect('home'); diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index 7848280da..9f7636ac6 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -43,7 +43,12 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_sales'); $model = $this->Summary_sales; - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + /** + * Added by Jorge Colmenarez 2016-11-01 19:00 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -58,12 +63,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 19:01 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_sales_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -75,7 +90,12 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_categories'); $model = $this->Summary_categories; - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + /** + * Added by Jorge Colmenarez 2016-11-01 19:07 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -90,12 +110,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:01 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_categories_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -107,7 +137,12 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_customers'); $model = $this->Summary_customers; - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + /** + * Added by Jorge Colmenarez 2016-11-01 20:13 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -122,12 +157,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:14 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_customers_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -138,8 +183,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_suppliers'); $model = $this->Summary_suppliers; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:16 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -154,12 +204,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:17 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_suppliers_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -170,8 +230,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_items'); $model = $this->Summary_items; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:21 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -186,12 +251,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:22 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_items_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -202,8 +277,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_employees'); $model = $this->Summary_employees; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:24 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -218,12 +298,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:25 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_employees_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -235,7 +325,12 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_taxes'); $model = $this->Summary_taxes; - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + /** + * Added by Jorge Colmenarez 2016-11-01 20:29 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -248,12 +343,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:30 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_taxes_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -265,7 +370,12 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_discounts'); $model = $this->Summary_discounts; - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + /** + * Added by Jorge Colmenarez 2016-11-01 20:44 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -275,12 +385,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:44 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_discounts_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -292,7 +412,12 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_payments'); $model = $this->Summary_payments; - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + /** + * Added by Jorge Colmenarez 2016-11-01 20:47 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $tabular_data = array(); foreach($report_data as $row) @@ -303,12 +428,22 @@ class Reports extends Secure_Controller )); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:48 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_payments_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, - 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular', $data); @@ -354,8 +489,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_sales'); $model = $this->Summary_sales; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:53 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $labels = array(); $series = array(); @@ -368,13 +508,23 @@ class Reports extends Secure_Controller $series[] = array('meta' => $date, 'value' => $row['total']); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:54 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_sales_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/line', 'labels_1' => $labels, 'series_data_1' => $series, - 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))), + 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))), 'yaxis_title' => $this->lang->line('reports_revenue'), 'xaxis_title' => $this->lang->line('reports_date'), 'show_currency' => TRUE @@ -388,8 +538,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_items'); $model = $this->Summary_items; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:54 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $labels = array(); $series = array(); @@ -401,13 +556,23 @@ class Reports extends Secure_Controller $series[] = $row['total']; } + /** + * Added by Jorge Colmenarez 2016-11-01 20:55 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_items_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/hbar', 'labels_1' => $labels, 'series_data_1' => $series, - 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))), + 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))), 'yaxis_title' => $this->lang->line('reports_items'), 'xaxis_title' => $this->lang->line('reports_revenue'), 'show_currency' => TRUE @@ -421,9 +586,14 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_categories'); $model = $this->Summary_categories; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); - $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:56 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); + $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); $labels = array(); $series = array(); @@ -435,9 +605,19 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['category'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:56 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_categories_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -453,9 +633,14 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_suppliers'); $model = $this->Summary_suppliers; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); - $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:57 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); + $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); $labels = array(); $series = array(); @@ -467,9 +652,19 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['supplier'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:57 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_suppliers_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -485,9 +680,14 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_employees'); $model = $this->Summary_employees; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); - $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:59 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); + $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); $labels = array(); $series = array(); @@ -499,9 +699,19 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['employee'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:59 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_employees_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -517,9 +727,14 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_taxes'); $model = $this->Summary_taxes; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); - $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))); + + /** + * Added by Jorge Colmenarez 2016-11-01 20:59 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); + $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); $labels = array(); $series = array(); @@ -531,9 +746,19 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['percent'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } + /** + * Added by Jorge Colmenarez 2016-11-01 20:59 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_taxes_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -549,8 +774,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_customers'); $model = $this->Summary_customers; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:01 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $labels = array(); $series = array(); @@ -562,13 +792,23 @@ class Reports extends Secure_Controller $series[] = $row['total']; } + /** + * Added by Jorge Colmenarez 2016-11-01 21:01 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_customers_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/hbar', 'labels_1' => $labels, 'series_data_1' => $series, - 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))), + 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))), 'yaxis_title' => $this->lang->line('reports_customers'), 'xaxis_title' => $this->lang->line('reports_revenue'), 'show_currency' => TRUE @@ -582,8 +822,13 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_discounts'); $model = $this->Summary_discounts; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:02 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $labels = array(); $series = array(); @@ -595,13 +840,23 @@ class Reports extends Secure_Controller $series[] = $row['count']; } + /** + * Added by Jorge Colmenarez 2016-11-01 21:02 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_discounts_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/bar', 'labels_1' => $labels, 'series_data_1' => $series, - 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))), + 'summary_data_1' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))), 'yaxis_title' => $this->lang->line('reports_count'), 'xaxis_title' => $this->lang->line('reports_discount_percent'), 'show_currency' => FALSE @@ -615,9 +870,14 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_payments'); $model = $this->Summary_payments; - - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); - $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:03 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); + $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); $labels = array(); $series = array(); @@ -629,9 +889,19 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['payment_type'] . ' ' . round($row['payment_amount'] / $summary['total'] * 100, 2) . '%', 'value' => $row['payment_amount']); } + /** + * Added by Jorge Colmenarez 2016-11-01 21:03 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_payments_summary_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -663,7 +933,13 @@ class Reports extends Secure_Controller $model = $this->Specific_customer; $headers = $this->xss_clean($model->getDataColumns()); - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:06 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter)); $summary_data = array(); $details_data = array(); @@ -679,13 +955,24 @@ class Reports extends Secure_Controller } $customer_info = $this->Customer->get_info($customer_id); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:06 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->xss_clean($customer_info->first_name . ' ' . $customer_info->last_name . ' ' . $this->lang->line('reports_report')), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, - 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type))) + 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular_details', $data); @@ -712,7 +999,13 @@ class Reports extends Secure_Controller $model = $this->Specific_employee; $headers = $this->xss_clean($model->getDataColumns()); - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:13 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter)); $summary_data = array(); $details_data = array(); @@ -728,13 +1021,24 @@ class Reports extends Secure_Controller } $employee_info = $this->Employee->get_info($employee_id); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:06 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->xss_clean($employee_info->first_name . ' ' . $employee_info->last_name . ' ' . $this->lang->line('reports_report')), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, - 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'employee_id' => $employee_id, 'sale_type' => $sale_type))) + 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'employee_id' => $employee_id, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular_details', $data); @@ -763,7 +1067,13 @@ class Reports extends Secure_Controller $model = $this->Specific_discount; $headers = $this->xss_clean($model->getDataColumns()); - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:17 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter)); $summary_data = array(); $details_data = array(); @@ -778,13 +1088,23 @@ class Reports extends Secure_Controller } } + /** + * Added by Jorge Colmenarez 2016-11-01 21:17 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $discount . '% ' . $this->lang->line('reports_discount') . ' ' . $this->lang->line('reports_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, - 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'discount' => $discount, 'sale_type' => $sale_type))) + 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'discount' => $discount, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular_details', $data); @@ -824,7 +1144,13 @@ class Reports extends Secure_Controller $model = $this->Detailed_sales; $headers = $this->xss_clean($model->getDataColumns()); - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:28 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary_data = array(); $details_data = array(); @@ -862,14 +1188,24 @@ class Reports extends Secure_Controller } } + /** + * Added by Jorge Colmenarez 2016-11-01 21:28 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_detailed_sales_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $headers, 'editable' => 'sales', 'summary_data' => $summary_data, 'details_data' => $details_data, - 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) + 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular_details', $data); @@ -906,7 +1242,13 @@ class Reports extends Secure_Controller $model = $this->Detailed_receivings; $headers = $this->xss_clean($model->getDataColumns()); - $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id)); + + /** + * Added by Jorge Colmenarez 2016-11-01 21:32 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary_data = array(); $details_data = array(); @@ -941,14 +1283,24 @@ class Reports extends Secure_Controller } } + /** + * Added by Jorge Colmenarez 2016-11-01 21:32 + * Set subtitle with corresponsed format + */ + $subtitle =""; + if(empty($datetime_filter)) + $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); + else + $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); + $data = array( 'title' => $this->lang->line('reports_detailed_receivings_report'), - 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $subtitle, 'headers' => $headers, 'editable' => 'receivings', 'summary_data' => $summary_data, 'details_data' => $details_data, - 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id))) + 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) ); $this->load->view('reports/tabular_details', $data); diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index ab4c858b5..df807093d 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -78,8 +78,13 @@ class Sales extends Secure_Controller // check if any filter is set in the multiselect dropdown $filledup = array_fill_keys($this->input->get('filters'), TRUE); $filters = array_merge($filters, $filledup); - - $sales = $this->Sale->search($search, $filters, $limit, $offset, $sort, $order); + /** + * Added by Jorge Colmenarez 2016-11-01 14:22 + * Support for send flag datetime filter + */ + $datetime_filter = $this->config->item('filter_datetime_format'); + // Modify function search to add parameter datetime filter + $sales = $this->Sale->search($search, $filters, $limit, $offset, $sort, $order,$datetime_filter); $total_rows = $this->Sale->get_found_rows($search, $filters); $payments = $this->Sale->get_payments_summary($search, $filters); $payment_summary = $this->xss_clean(get_sales_manage_payments_summary($payments, $sales, $this)); diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php index 4963c51c0..c6feba41a 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -182,3 +182,8 @@ $lang["config_number_locale_required"] = "Number Locale is a required field"; $lang["config_number_locale_invalid"] = "The entered locale is invalid. Check the link in the tooltip to find a sensible value"; $lang["config_number_locale_tooltip"] = "Find a suitable locale through this link"; $lang["config_theme"] = "Theme"; +/** +* Added by Jorge Colmenarez 2016-10-31 16:30 +* Support for DateTime Reports Filter +*/ +$lang["config_filter_datetime_format"] = "Filter with date/time format in reports"; diff --git a/application/language/es/config_lang.php b/application/language/es/config_lang.php index 84a045f45..a7c8e8aae 100644 --- a/application/language/es/config_lang.php +++ b/application/language/es/config_lang.php @@ -182,3 +182,8 @@ $lang["config_number_locale_required"] = "Numero local es un campo requerido"; $lang["config_number_locale_invalid"] = "El local ingresado es invalido. Revisa el link en el tooltip para encontrar informacion"; $lang["config_number_locale_tooltip"] = "Encontrar un local adecuado en esta liga"; $lang["config_theme"] = "Tema"; +/** +* Added by Jorge Colmenarez 2016-10-31 16:34 +* Support for DateTime Reports Filter +*/ +$lang["config_filter_datetime_format"] = "Filtrar con formato de fecha/hora en los informes"; \ No newline at end of file diff --git a/application/models/Receiving.php b/application/models/Receiving.php index c12605efb..471464950 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -205,8 +205,10 @@ class Receiving extends CI_Model */ public function create_temp_table() { + // Modify by Jorge Colmenarez 2016-11-01 21:45 + // Add Index receiving_time $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') . - ' (INDEX(receiving_date), INDEX(receiving_id)) + ' (INDEX(receiving_date), INDEX(receiving_time), INDEX(receiving_id)) ( SELECT DATE(receiving_time) AS receiving_date, diff --git a/application/models/Sale.php b/application/models/Sale.php index 465440746..03d14709b 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -26,7 +26,7 @@ class Sale extends CI_Model /* Get the sales data for the takings (sales/manage) view */ - public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc') + public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc', $datetime_filter = '') { $this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased, customer_name, customer_company_name AS company_name, @@ -34,9 +34,13 @@ class Sale extends CI_Model 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->where('sale_date BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); - + // Modify by Jorge Colmenarez 2016-11-01 14:25 + // Set DateTime filter field + if(empty($datetime_filter)) + $this->db->where('sale_date BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); + else + $this->db->where('sale_time BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); + // End Jorge Colmenarez if(!empty($search)) { if($filters['is_valid_receipt'] != FALSE) @@ -559,9 +563,10 @@ class Sale extends CI_Model GROUP BY sale_id )' ); - + // Modify by Jorge Colmenarez 2016-11-01 14:29 + // Add Index sale_time $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') . - ' (INDEX(sale_date), INDEX(sale_id)) + ' (INDEX(sale_date), INDEX(sale_time), INDEX(sale_id)) ( SELECT DATE(sales.sale_time) AS sale_date, diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index 7a970dc88..518e483b0 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -53,7 +53,12 @@ class Detailed_receivings extends Report $this->db->from('receivings_items_temp'); $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); - $this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 21:47 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("receiving_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("receiving_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -95,7 +100,12 @@ class Detailed_receivings extends Report { $this->db->select('SUM(total) AS total'); $this->db->from('receivings_items_temp'); - $this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 21:47 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("receiving_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("receiving_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Detailed_sales.php b/application/models/reports/Detailed_sales.php index 6059412e4..39cf15fb9 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -55,7 +55,12 @@ class Detailed_sales extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - $this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 21:29 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -93,7 +98,12 @@ class Detailed_sales extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 21:29 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Specific_customer.php b/application/models/reports/Specific_customer.php index fdb67677f..50eec443b 100644 --- a/application/models/reports/Specific_customer.php +++ b/application/models/reports/Specific_customer.php @@ -21,7 +21,14 @@ class Specific_customer extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND customer_id=" . $this->db->escape($inputs['customer_id'])); + // Modify by Jorge Colmenarez 2016-11-01 21:05 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + // Support for filter by Specific Customer + $this->db->where("customer_id = ".$inputs['customer_id']); if ($inputs['sale_type'] == 'sales') { @@ -54,7 +61,14 @@ class Specific_customer extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND customer_id=" . $this->db->escape($inputs['customer_id'])); + // Modify by Jorge Colmenarez 2016-11-01 21:05 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + // Support for filter by Specific Customer + $this->db->where("customer_id = ".$inputs['customer_id']); if ($inputs['sale_type'] == 'sales') { diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index c7a926633..d76560f07 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -21,8 +21,15 @@ class Specific_discount extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount'])); - + // Modify by Jorge Colmenarez 2016-11-01 21:05 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + // Support for filter by Specific Discount + $this->db->where('discount_percent = '.$inputs['discount']); + if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -55,8 +62,15 @@ class Specific_discount extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount'])); - + // Modify by Jorge Colmenarez 2016-11-01 21:05 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + // Support for filter by Specific Discount + $this->db->where('discount_percent = '.$inputs['discount']); + if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); diff --git a/application/models/reports/Specific_employee.php b/application/models/reports/Specific_employee.php index 977de2103..8fc0d75bd 100644 --- a/application/models/reports/Specific_employee.php +++ b/application/models/reports/Specific_employee.php @@ -21,8 +21,15 @@ class Specific_employee extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND employee_id=" . $this->db->escape($inputs['employee_id'])); - + // Modify by Jorge Colmenarez 2016-11-01 21:05 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + // Support by filter Specific Employee + $this->db->where("employee_id = ".$inputs['employee_id']); + if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -54,7 +61,14 @@ class Specific_employee extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND employee_id=" . $this->db->escape($inputs['employee_id'])); + // Modify by Jorge Colmenarez 2016-11-01 21:05 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + // Support by filter Specific Employee + $this->db->where("employee_id = ".$inputs['employee_id']); if ($inputs['sale_type'] == 'sales') { diff --git a/application/models/reports/Summary_categories.php b/application/models/reports/Summary_categories.php index b8fdf22a9..265f45a16 100644 --- a/application/models/reports/Summary_categories.php +++ b/application/models/reports/Summary_categories.php @@ -19,7 +19,12 @@ class Summary_categories extends Report { $this->db->select('category, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 16:47 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -37,7 +42,6 @@ class Summary_categories extends Report $this->db->group_by('category'); $this->db->order_by('category'); - return $this->db->get()->result_array(); } @@ -45,7 +49,12 @@ class Summary_categories extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 16:47 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_customers.php b/application/models/reports/Summary_customers.php index ebf863c71..8cf646e50 100644 --- a/application/models/reports/Summary_customers.php +++ b/application/models/reports/Summary_customers.php @@ -19,7 +19,12 @@ class Summary_customers extends Report { $this->db->select('customer_name AS customer, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:15 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -45,7 +50,12 @@ class Summary_customers extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:15 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_discounts.php b/application/models/reports/Summary_discounts.php index 29d34a327..b3356f54c 100644 --- a/application/models/reports/Summary_discounts.php +++ b/application/models/reports/Summary_discounts.php @@ -19,7 +19,13 @@ class Summary_discounts extends Report { $this->db->select('CONCAT(discount_percent, "%") AS discount_percent, count(*) AS count'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:45 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + $this->db->where('discount_percent > 0'); if ($inputs['location_id'] != 'all') @@ -46,7 +52,14 @@ class Summary_discounts extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:45 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); + + $this->db->where('discount_percent > 0'); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_employees.php b/application/models/reports/Summary_employees.php index 52c7fc4d1..b6e73b56a 100644 --- a/application/models/reports/Summary_employees.php +++ b/application/models/reports/Summary_employees.php @@ -19,7 +19,12 @@ class Summary_employees extends Report { $this->db->select('employee_name AS employee, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:26 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -45,7 +50,12 @@ class Summary_employees extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:26 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_items.php b/application/models/reports/Summary_items.php index 033a9b870..9d38aae69 100644 --- a/application/models/reports/Summary_items.php +++ b/application/models/reports/Summary_items.php @@ -19,7 +19,12 @@ class Summary_items extends Report { $this->db->select('name, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:23 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -45,7 +50,12 @@ class Summary_items extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:23 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_payments.php b/application/models/reports/Summary_payments.php index b1f316bd8..25639b3b7 100644 --- a/application/models/reports/Summary_payments.php +++ b/application/models/reports/Summary_payments.php @@ -20,7 +20,12 @@ class Summary_payments extends Report $this->db->select('sales_payments.payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount'); $this->db->from('sales_payments'); $this->db->join('sales', 'sales.sale_id=sales_payments.sale_id'); - $this->db->where("date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:49 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -67,7 +72,12 @@ class Summary_payments extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:49 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_sales.php b/application/models/reports/Summary_sales.php index 6d8b08dcf..1178c75d4 100644 --- a/application/models/reports/Summary_sales.php +++ b/application/models/reports/Summary_sales.php @@ -19,7 +19,12 @@ class Summary_sales extends Report { $this->db->select('sale_date, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 19:01 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -45,7 +50,12 @@ class Summary_sales extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 19:01 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_suppliers.php b/application/models/reports/Summary_suppliers.php index 07644a46f..3d2693e1e 100644 --- a/application/models/reports/Summary_suppliers.php +++ b/application/models/reports/Summary_suppliers.php @@ -21,7 +21,12 @@ class Summary_suppliers extends Report $this->db->from('sales_items_temp'); $this->db->join('suppliers', 'suppliers.person_id = sales_items_temp.supplier_id'); $this->db->join('people', 'suppliers.person_id = people.person_id'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:18 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { @@ -49,7 +54,12 @@ class Summary_suppliers extends Report $this->db->from('sales_items_temp'); $this->db->join('suppliers', 'suppliers.person_id = sales_items_temp.supplier_id'); $this->db->join('people', 'suppliers.person_id = people.person_id'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:18 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_taxes.php b/application/models/reports/Summary_taxes.php index c5f0a420f..e8f733f85 100644 --- a/application/models/reports/Summary_taxes.php +++ b/application/models/reports/Summary_taxes.php @@ -47,6 +47,16 @@ class Summary_taxes extends Report $decimals = totals_decimals(); + // Modify by Jorge Colmenarez 2016-11-01 20:31 + // Set WHERE Clause with support for DateTime filter field + $clauseWhere = ""; + if(empty($inputs['datetime_filter'])) + $clauseWhere = "WHERE date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']); + else + $clauseWhere = "WHERE sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date'])); + + $clauseWhere.=" ".$quantity_cond; + $query = $this->db->query("SELECT percent, count(*) AS count, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax FROM (SELECT name, CONCAT(ROUND(percent, $decimals), '%') AS percent, ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $subtotal, $decimals) AS subtotal, @@ -58,7 +68,7 @@ class Summary_taxes extends Report .$this->db->dbprefix('sales_items').'.item_id='.$this->db->dbprefix('sales_items_taxes').'.item_id'." AND " .$this->db->dbprefix('sales_items').'.line='.$this->db->dbprefix('sales_items_taxes').'.line' ." JOIN ".$this->db->dbprefix('sales')." ON ".$this->db->dbprefix('sales_items_taxes').".sale_id=".$this->db->dbprefix('sales').".sale_id - WHERE date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " $quantity_cond) AS temp_taxes + $clauseWhere) AS temp_taxes GROUP BY percent"); return $query->result_array(); @@ -68,7 +78,12 @@ class Summary_taxes extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + // Modify by Jorge Colmenarez 2016-11-01 20:32 + // Set DateTime filter field + if(empty($inputs['datetime_filter'])) + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); + else + $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); if ($inputs['location_id'] != 'all') { diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index e6f335536..e2504c703 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -261,6 +261,18 @@ ?> + +
+ lang->line('config_filter_datetime_format'), 'filter_datetime_format', array('class' => 'control-label col-xs-2')); ?> +
+ 'filter_datetime_format', + 'id' => 'filter_datetime_format', + 'value' => 'filter_datetime_format', + 'checked'=>$this->config->item('filter_datetime_format'))); ?> +
+
+ 'submit_form', diff --git a/application/views/partial/daterangepicker.php b/application/views/partial/daterangepicker.php index 6427e5efa..fa2597e2b 100644 --- a/application/views/partial/daterangepicker.php +++ b/application/views/partial/daterangepicker.php @@ -1,57 +1,64 @@ lang->load("calendar"); $this->lang->load("date"); ?> -var start_date = ""; -var end_date = ""; +/** +* Added By Jorge Colmenarez 2016-11-01 8:52 +* Support for Set Dinamyc DateTime Filter into Object daterangepicker +*/ +config->item('filter_datetime_format'))){ +?> +var start_date = ""; +var end_date = ""; $('#daterangepicker').daterangepicker({ "ranges": { "lang->line("datepicker_today"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d"),date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" ], "lang->line("datepicker_today_last_year"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y")-1));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d"),date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>" ], "lang->line("datepicker_yesterday"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-1,date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d"),date("Y"))-1);?>" ], "lang->line("datepicker_last_7"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-6,date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-6,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" ], "lang->line("datepicker_last_30"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-29,date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-29,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" ], "lang->line("datepicker_this_month"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m")+1,1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m")+1,1,date("Y"))-1);?>" ], "lang->line("datepicker_same_month_to_same_day_last_year"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")-1));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>" ], "lang->line("datepicker_this_month_last_year"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")-1));?>", - "config->item('dateformat'), mktime(0,0,0,date("m")+1,1,date("Y")-1)-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m")+1,1,date("Y")-1)-1);?>" ], "lang->line("datepicker_last_month"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,date("m")-1,1,date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m")-1,1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y"))-1);?>" ], "lang->line("datepicker_this_year"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,1,1,date("Y")));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")+1)-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")+1)-1);?>" ], "lang->line("datepicker_last_year"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,1,1,date("Y")-1));?>", - "config->item('dateformat'), mktime(0,0,0,1,1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y"))-1);?>" ], "lang->line("datepicker_all_time"); ?>": [ - "config->item('dateformat'), mktime(0,0,0,01,01,2010));?>", - "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,01,01,2010));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" ], }, "locale": { @@ -89,11 +96,117 @@ $('#daterangepicker').daterangepicker({ "firstDay": lang->line("datepicker_weekstart"); ?> }, "alwaysShowCalendars": true, - "startDate": "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>", - "endDate": "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>", - "minDate": "config->item('dateformat'), mktime(0,0,0,01,01,2010));?>", - "maxDate": "config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "startDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>", + "endDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>", + "minDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,01,01,2010));?>", + "maxDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" }, function(start, end, label) { start_date = start.format('YYYY-MM-DD'); end_date = end.format('YYYY-MM-DD'); -}); \ No newline at end of file +}); + +var start_date = ""; +var end_date = ""; + +$('#daterangepicker').daterangepicker({ + "ranges": { + "lang->line("datepicker_today"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'), mktime(0,0,0,date("m"),date("d"),date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y"))-1);?>" + ], + "lang->line("datepicker_today_last_year"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d"),date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y")-1)-1);?>" + ], + "lang->line("datepicker_yesterday"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y"))-1);?>" + ], + "lang->line("datepicker_last_7"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-6,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y"))-1);?>" + ], + "lang->line("datepicker_last_30"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-29,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y"))-1);?>" + ], + "lang->line("datepicker_this_month"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m")+1,1,date("Y"))-1);?>" + ], + "lang->line("datepicker_same_month_to_same_day_last_year"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y")-1)-1);?>" + ], + "lang->line("datepicker_this_month_last_year"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m")+1,1,date("Y")-1)-1);?>" + ], + "lang->line("datepicker_last_month"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m")-1,1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),1,date("Y"))-1);?>" + ], + "lang->line("datepicker_this_year"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y")));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),1,date("Y")+1)-1);?>" + ], + "lang->line("datepicker_last_year"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y")-1));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,1,1,date("Y"))-1);?>" + ], + "lang->line("datepicker_all_time"); ?>": [ + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,01,01,2010));?>", + "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y"))-1);?>" + ], + }, + "locale": { + "format": 'config->item("dateformat")." ".$this->config->item('timeformat'))?>', + "separator": " - ", + "applyLabel": "lang->line("datepicker_apply"); ?>", + "cancelLabel": "lang->line("datepicker_cancel"); ?>", + "fromLabel": "lang->line("datepicker_from"); ?>", + "toLabel": "lang->line("datepicker_to"); ?>", + "customRangeLabel": "lang->line("datepicker_custom"); ?>", + "daysOfWeek": [ + "lang->line("cal_su"); ?>", + "lang->line("cal_mo"); ?>", + "lang->line("cal_tu"); ?>", + "lang->line("cal_we"); ?>", + "lang->line("cal_th"); ?>", + "lang->line("cal_fr"); ?>", + "lang->line("cal_sa"); ?>", + "lang->line("cal_su"); ?>" + ], + "monthNames": [ + "lang->line("cal_january"); ?>", + "lang->line("cal_february"); ?>", + "lang->line("cal_march"); ?>", + "lang->line("cal_april"); ?>", + "lang->line("cal_may"); ?>", + "lang->line("cal_june"); ?>", + "lang->line("cal_july"); ?>", + "lang->line("cal_august"); ?>", + "lang->line("cal_september"); ?>", + "lang->line("cal_october"); ?>", + "lang->line("cal_november"); ?>", + "lang->line("cal_december"); ?>" + ], + "firstDay": lang->line("datepicker_weekstart"); ?> + }, + "timePicker": true, + "timePickerSeconds": true, + "alwaysShowCalendars": true, + "startDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>", + "endDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y"))-1);?>", + "minDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,01,01,2010));?>", + "maxDate": "config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")+1,date("Y"))-1);?>" +}, function(start, end, label) { + start_date = start.format('YYYY-MM-DD HH:mm:ss'); + end_date = end.format('YYYY-MM-DD HH:mm:ss'); +}); + \ No newline at end of file diff --git a/application/views/reports/date_input.php b/application/views/reports/date_input.php index 312e39268..acc10eed4 100644 --- a/application/views/reports/date_input.php +++ b/application/views/reports/date_input.php @@ -77,7 +77,7 @@ $(document).ready(function() load->view('partial/daterangepicker'); ?> $("#generate_report").click(function() - { + { window.location = [window.location, start_date, end_date, $("#input_type").val() || 0, $("#location_id").val()].join("/"); }); }); From e326c1dfd4a02ffd77248df47645f31db7e97f6e Mon Sep 17 00:00:00 2001 From: Jorge Colmenarez Date: Fri, 4 Nov 2016 09:32:41 -0400 Subject: [PATCH 2/3] Remove copyright comments and apply suggestions --- LICENSE | 1 + application/controllers/Config.php | 3 - application/controllers/Login.php | 4 - application/controllers/Reports.php | 392 ++---------------- application/controllers/Sales.php | 5 +- application/language/en/config_lang.php | 4 - application/language/es/config_lang.php | 7 +- application/models/Receiving.php | 2 - application/models/Sale.php | 8 +- .../models/reports/Detailed_receivings.php | 6 +- application/models/reports/Detailed_sales.php | 6 +- .../models/reports/Specific_customer.php | 10 +- .../models/reports/Specific_discount.php | 5 +- .../models/reports/Specific_employee.php | 10 +- .../models/reports/Summary_categories.php | 6 +- .../models/reports/Summary_customers.php | 6 +- .../models/reports/Summary_discounts.php | 6 +- .../models/reports/Summary_employees.php | 6 +- application/models/reports/Summary_items.php | 6 +- .../models/reports/Summary_payments.php | 6 +- application/models/reports/Summary_sales.php | 6 +- .../models/reports/Summary_suppliers.php | 6 +- application/models/reports/Summary_taxes.php | 5 +- application/views/configs/locale_config.php | 3 +- application/views/partial/daterangepicker.php | 7 +- database/database.sql | 3 +- public/license/LICENSE | 1 + 27 files changed, 81 insertions(+), 449 deletions(-) diff --git a/LICENSE b/LICENSE index 9eb29b09e..4f37e2cea 100644 --- a/LICENSE +++ b/LICENSE @@ -10,6 +10,7 @@ Copyright (c) 2015-2016 FrancescoUK (aka daN4cat) Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com Copyright (c) 2015 Toni Haryanto (aka yllumi) Copyright (c) 2016 Ramkrishna Mondal (aka RamkrishnaMondal) +Copyright (c) 2016 Jorge Colmenarez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/application/controllers/Config.php b/application/controllers/Config.php index 7fd0552e3..b958fc04c 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -303,10 +303,7 @@ class Config extends Secure_Controller 'quantity_decimals' => $this->input->post('quantity_decimals'), 'country_codes' => $this->input->post('country_codes'), 'payment_options_order' => $this->input->post('payment_options_order'), - // Added By Jorge Colmenarez 2016-10-31 16:39 - // Support for filter datetime reports 'filter_datetime_format' => $this->input->post('filter_datetime_format') - // End Jorge Colmenarez ); $result = $this->Appconfig->batch_save($batch_save_data); diff --git a/application/controllers/Login.php b/application/controllers/Login.php index 321a79c00..2844e3833 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -41,10 +41,6 @@ class Login extends CI_Controller $this->tracking_lib->track_event('Stats', 'Tax Decimals', $this->config->item('tax_decimals')); $this->tracking_lib->track_event('Stats', 'Quantity Decimals', $this->config->item('quantity_decimals')); $this->tracking_lib->track_event('Stats', 'Invoice Enable', $this->config->item('invoice_enable')); - /** - * Jorge Colmenarez 2016-11-01 08:33 - * Set Static Filter DateTime Format Value - */ $this->tracking_lib->track_event('Stats', 'Filter DateTime Format', $this->config->item('filter_datetime_format')); } diff --git a/application/controllers/Reports.php b/application/controllers/Reports.php index 9f7636ac6..51c557815 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -43,10 +43,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_sales'); $model = $this->Summary_sales; - /** - * Added by Jorge Colmenarez 2016-11-01 19:00 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -63,19 +59,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 19:01 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_sales_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -90,10 +76,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_categories'); $model = $this->Summary_categories; - /** - * Added by Jorge Colmenarez 2016-11-01 19:07 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -110,19 +92,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:01 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_categories_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -137,10 +109,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_customers'); $model = $this->Summary_customers; - /** - * Added by Jorge Colmenarez 2016-11-01 20:13 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -157,19 +125,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:14 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_customers_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -183,11 +141,7 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_suppliers'); $model = $this->Summary_suppliers; - - /** - * Added by Jorge Colmenarez 2016-11-01 20:16 - * Support for send flag datetime filter - */ + $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -204,19 +158,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:17 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_suppliers_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -230,11 +174,7 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_items'); $model = $this->Summary_items; - - /** - * Added by Jorge Colmenarez 2016-11-01 20:21 - * Support for send flag datetime filter - */ + $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -251,19 +191,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:22 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_items_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -277,11 +207,7 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_employees'); $model = $this->Summary_employees; - - /** - * Added by Jorge Colmenarez 2016-11-01 20:24 - * Support for send flag datetime filter - */ + $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -298,19 +224,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:25 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_employees_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -325,10 +241,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_taxes'); $model = $this->Summary_taxes; - /** - * Added by Jorge Colmenarez 2016-11-01 20:29 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -343,19 +255,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:30 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_taxes_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -370,10 +272,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_discounts'); $model = $this->Summary_discounts; - /** - * Added by Jorge Colmenarez 2016-11-01 20:44 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -385,19 +283,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:44 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_discounts_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -412,10 +300,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_payments'); $model = $this->Summary_payments; - /** - * Added by Jorge Colmenarez 2016-11-01 20:47 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -428,19 +312,9 @@ class Reports extends Secure_Controller )); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:48 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_payments_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $this->xss_clean($model->getDataColumns()), 'data' => $tabular_data, 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))) @@ -490,10 +364,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_sales'); $model = $this->Summary_sales; - /** - * Added by Jorge Colmenarez 2016-11-01 20:53 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -508,19 +378,9 @@ class Reports extends Secure_Controller $series[] = array('meta' => $date, 'value' => $row['total']); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:54 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_sales_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/line', 'labels_1' => $labels, 'series_data_1' => $series, @@ -539,10 +399,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_items'); $model = $this->Summary_items; - /** - * Added by Jorge Colmenarez 2016-11-01 20:54 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -556,19 +412,9 @@ class Reports extends Secure_Controller $series[] = $row['total']; } - /** - * Added by Jorge Colmenarez 2016-11-01 20:55 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_items_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/hbar', 'labels_1' => $labels, 'series_data_1' => $series, @@ -587,10 +433,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_categories'); $model = $this->Summary_categories; - /** - * Added by Jorge Colmenarez 2016-11-01 20:56 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); @@ -605,19 +447,9 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['category'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:56 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_categories_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -634,10 +466,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_suppliers'); $model = $this->Summary_suppliers; - /** - * Added by Jorge Colmenarez 2016-11-01 20:57 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); @@ -652,19 +480,9 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['supplier'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:57 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_suppliers_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -681,10 +499,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_employees'); $model = $this->Summary_employees; - /** - * Added by Jorge Colmenarez 2016-11-01 20:59 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); @@ -699,19 +513,9 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['employee'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:59 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_employees_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -728,10 +532,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_taxes'); $model = $this->Summary_taxes; - /** - * Added by Jorge Colmenarez 2016-11-01 20:59 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); @@ -746,19 +546,9 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['percent'] . ' ' . round($row['total'] / $summary['total'] * 100, 2) . '%', 'value' => $row['total']); } - /** - * Added by Jorge Colmenarez 2016-11-01 20:59 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_taxes_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -775,10 +565,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_customers'); $model = $this->Summary_customers; - /** - * Added by Jorge Colmenarez 2016-11-01 21:01 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -792,19 +578,9 @@ class Reports extends Secure_Controller $series[] = $row['total']; } - /** - * Added by Jorge Colmenarez 2016-11-01 21:01 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_customers_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/hbar', 'labels_1' => $labels, 'series_data_1' => $series, @@ -823,10 +599,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_discounts'); $model = $this->Summary_discounts; - /** - * Added by Jorge Colmenarez 2016-11-01 21:02 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -840,19 +612,9 @@ class Reports extends Secure_Controller $series[] = $row['count']; } - /** - * Added by Jorge Colmenarez 2016-11-01 21:02 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_discounts_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/bar', 'labels_1' => $labels, 'series_data_1' => $series, @@ -871,10 +633,6 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_payments'); $model = $this->Summary_payments; - /** - * Added by Jorge Colmenarez 2016-11-01 21:03 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); $summary = $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter))); @@ -889,19 +647,9 @@ class Reports extends Secure_Controller $series[] = array('meta' => $row['payment_type'] . ' ' . round($row['payment_amount'] / $summary['total'] * 100, 2) . '%', 'value' => $row['payment_amount']); } - /** - * Added by Jorge Colmenarez 2016-11-01 21:03 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_payments_summary_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -933,11 +681,6 @@ class Reports extends Secure_Controller $model = $this->Specific_customer; $headers = $this->xss_clean($model->getDataColumns()); - - /** - * Added by Jorge Colmenarez 2016-11-01 21:06 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter)); @@ -956,19 +699,9 @@ class Reports extends Secure_Controller $customer_info = $this->Customer->get_info($customer_id); - /** - * Added by Jorge Colmenarez 2016-11-01 21:06 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->xss_clean($customer_info->first_name . ' ' . $customer_info->last_name . ' ' . $this->lang->line('reports_report')), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, @@ -999,11 +732,6 @@ class Reports extends Secure_Controller $model = $this->Specific_employee; $headers = $this->xss_clean($model->getDataColumns()); - - /** - * Added by Jorge Colmenarez 2016-11-01 21:13 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter)); @@ -1022,19 +750,9 @@ class Reports extends Secure_Controller $employee_info = $this->Employee->get_info($employee_id); - /** - * Added by Jorge Colmenarez 2016-11-01 21:06 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->xss_clean($employee_info->first_name . ' ' . $employee_info->last_name . ' ' . $this->lang->line('reports_report')), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, @@ -1067,11 +785,6 @@ class Reports extends Secure_Controller $model = $this->Specific_discount; $headers = $this->xss_clean($model->getDataColumns()); - - /** - * Added by Jorge Colmenarez 2016-11-01 21:17 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type, 'datetime_filter' => $datetime_filter)); @@ -1088,19 +801,9 @@ class Reports extends Secure_Controller } } - /** - * Added by Jorge Colmenarez 2016-11-01 21:17 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $discount . '% ' . $this->lang->line('reports_discount') . ' ' . $this->lang->line('reports_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $headers, 'summary_data' => $summary_data, 'details_data' => $details_data, @@ -1144,11 +847,6 @@ class Reports extends Secure_Controller $model = $this->Detailed_sales; $headers = $this->xss_clean($model->getDataColumns()); - - /** - * Added by Jorge Colmenarez 2016-11-01 21:28 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -1188,19 +886,9 @@ class Reports extends Secure_Controller } } - /** - * Added by Jorge Colmenarez 2016-11-01 21:28 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_detailed_sales_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $headers, 'editable' => 'sales', 'summary_data' => $summary_data, @@ -1242,11 +930,6 @@ class Reports extends Secure_Controller $model = $this->Detailed_receivings; $headers = $this->xss_clean($model->getDataColumns()); - - /** - * Added by Jorge Colmenarez 2016-11-01 21:32 - * Support for send flag datetime filter - */ $datetime_filter = $this->config->item('filter_datetime_format'); $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id, 'datetime_filter' => $datetime_filter)); @@ -1283,19 +966,9 @@ class Reports extends Secure_Controller } } - /** - * Added by Jorge Colmenarez 2016-11-01 21:32 - * Set subtitle with corresponsed format - */ - $subtitle =""; - if(empty($datetime_filter)) - $subtitle = date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)); - else - $subtitle = date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $start_date))) . '-' . date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $end_date))); - $data = array( 'title' => $this->lang->line('reports_detailed_receivings_report'), - 'subtitle' => $subtitle, + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'headers' => $headers, 'editable' => 'receivings', 'summary_data' => $summary_data, @@ -1381,5 +1054,18 @@ class Reports extends Secure_Controller $this->load->view('reports/tabular', $data); } + // Returns subtitle for the reports + private function _get_subtitle_report($value,$datetime_filter){ + $subtitle =""; + if(empty($datetime_filter)) + for($i = 0; $i < count($value); $i++) + $subtitle .= date($this->config->item('dateformat'), strtotime($value[$i])) . ' - '; + else + for($i = 0; $i < count($value); $i++) + $subtitle .= date($this->config->item('dateformat')." ".$this->config->item('timeformat'), strtotime(str_replace("%20", " ", $value[$i]))) . ' - '; + $subtitle = substr($subtitle,0,-2); + + return $subtitle; + } } ?> \ No newline at end of file diff --git a/application/controllers/Sales.php b/application/controllers/Sales.php index df807093d..db8b1a27a 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -78,10 +78,7 @@ class Sales extends Secure_Controller // check if any filter is set in the multiselect dropdown $filledup = array_fill_keys($this->input->get('filters'), TRUE); $filters = array_merge($filters, $filledup); - /** - * Added by Jorge Colmenarez 2016-11-01 14:22 - * Support for send flag datetime filter - */ + $datetime_filter = $this->config->item('filter_datetime_format'); // Modify function search to add parameter datetime filter $sales = $this->Sale->search($search, $filters, $limit, $offset, $sort, $order,$datetime_filter); diff --git a/application/language/en/config_lang.php b/application/language/en/config_lang.php index c6feba41a..d29bbba2f 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -182,8 +182,4 @@ $lang["config_number_locale_required"] = "Number Locale is a required field"; $lang["config_number_locale_invalid"] = "The entered locale is invalid. Check the link in the tooltip to find a sensible value"; $lang["config_number_locale_tooltip"] = "Find a suitable locale through this link"; $lang["config_theme"] = "Theme"; -/** -* Added by Jorge Colmenarez 2016-10-31 16:30 -* Support for DateTime Reports Filter -*/ $lang["config_filter_datetime_format"] = "Filter with date/time format in reports"; diff --git a/application/language/es/config_lang.php b/application/language/es/config_lang.php index a7c8e8aae..783a847a0 100644 --- a/application/language/es/config_lang.php +++ b/application/language/es/config_lang.php @@ -181,9 +181,4 @@ $lang["config_return_policy_required"] = "Política de Devolución es requerida" $lang["config_number_locale_required"] = "Numero local es un campo requerido"; $lang["config_number_locale_invalid"] = "El local ingresado es invalido. Revisa el link en el tooltip para encontrar informacion"; $lang["config_number_locale_tooltip"] = "Encontrar un local adecuado en esta liga"; -$lang["config_theme"] = "Tema"; -/** -* Added by Jorge Colmenarez 2016-10-31 16:34 -* Support for DateTime Reports Filter -*/ -$lang["config_filter_datetime_format"] = "Filtrar con formato de fecha/hora en los informes"; \ No newline at end of file +$lang["config_theme"] = "Tema"; \ No newline at end of file diff --git a/application/models/Receiving.php b/application/models/Receiving.php index 471464950..ec185109f 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -205,8 +205,6 @@ class Receiving extends CI_Model */ public function create_temp_table() { - // Modify by Jorge Colmenarez 2016-11-01 21:45 - // Add Index receiving_time $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') . ' (INDEX(receiving_date), INDEX(receiving_time), INDEX(receiving_id)) ( diff --git a/application/models/Sale.php b/application/models/Sale.php index 03d14709b..1d7b42466 100644 --- a/application/models/Sale.php +++ b/application/models/Sale.php @@ -34,13 +34,12 @@ class Sale extends CI_Model 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'); - // Modify by Jorge Colmenarez 2016-11-01 14:25 - // Set DateTime filter field + if(empty($datetime_filter)) $this->db->where('sale_date BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); else $this->db->where('sale_time BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); - // End Jorge Colmenarez + if(!empty($search)) { if($filters['is_valid_receipt'] != FALSE) @@ -563,8 +562,7 @@ class Sale extends CI_Model GROUP BY sale_id )' ); - // Modify by Jorge Colmenarez 2016-11-01 14:29 - // Add Index sale_time + $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') . ' (INDEX(sale_date), INDEX(sale_time), INDEX(sale_id)) ( diff --git a/application/models/reports/Detailed_receivings.php b/application/models/reports/Detailed_receivings.php index 518e483b0..9481bff91 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -53,8 +53,7 @@ class Detailed_receivings extends Report $this->db->from('receivings_items_temp'); $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id'); $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left'); - // Modify by Jorge Colmenarez 2016-11-01 21:47 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("receiving_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -100,8 +99,7 @@ class Detailed_receivings extends Report { $this->db->select('SUM(total) AS total'); $this->db->from('receivings_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:47 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("receiving_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Detailed_sales.php b/application/models/reports/Detailed_sales.php index 39cf15fb9..5c717aef8 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -55,8 +55,7 @@ class Detailed_sales extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:29 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -98,8 +97,7 @@ class Detailed_sales extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:29 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Specific_customer.php b/application/models/reports/Specific_customer.php index 50eec443b..3d9df04cd 100644 --- a/application/models/reports/Specific_customer.php +++ b/application/models/reports/Specific_customer.php @@ -21,13 +21,12 @@ class Specific_customer extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:05 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); - // Support for filter by Specific Customer + $this->db->where("customer_id = ".$inputs['customer_id']); if ($inputs['sale_type'] == 'sales') @@ -61,13 +60,12 @@ class Specific_customer extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:05 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); - // Support for filter by Specific Customer + $this->db->where("customer_id = ".$inputs['customer_id']); if ($inputs['sale_type'] == 'sales') diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index d76560f07..00f4f777c 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -21,13 +21,12 @@ class Specific_discount extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:05 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); - // Support for filter by Specific Discount + $this->db->where('discount_percent = '.$inputs['discount']); if ($inputs['sale_type'] == 'sales') diff --git a/application/models/reports/Specific_employee.php b/application/models/reports/Specific_employee.php index 8fc0d75bd..50ef7be24 100644 --- a/application/models/reports/Specific_employee.php +++ b/application/models/reports/Specific_employee.php @@ -21,13 +21,12 @@ class Specific_employee extends Report { $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:05 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); - // Support by filter Specific Employee + $this->db->where("employee_id = ".$inputs['employee_id']); if ($inputs['sale_type'] == 'sales') @@ -61,13 +60,12 @@ class Specific_employee extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 21:05 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else $this->db->where("sale_time BETWEEN " . $this->db->escape(str_replace("%20"," ", $inputs['start_date'])) . " AND " . $this->db->escape(str_replace("%20"," ", $inputs['end_date']))); - // Support by filter Specific Employee + $this->db->where("employee_id = ".$inputs['employee_id']); if ($inputs['sale_type'] == 'sales') diff --git a/application/models/reports/Summary_categories.php b/application/models/reports/Summary_categories.php index 265f45a16..ba5e4150f 100644 --- a/application/models/reports/Summary_categories.php +++ b/application/models/reports/Summary_categories.php @@ -19,8 +19,7 @@ class Summary_categories extends Report { $this->db->select('category, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 16:47 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -49,8 +48,7 @@ class Summary_categories extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 16:47 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_customers.php b/application/models/reports/Summary_customers.php index 8cf646e50..6464de1bd 100644 --- a/application/models/reports/Summary_customers.php +++ b/application/models/reports/Summary_customers.php @@ -19,8 +19,7 @@ class Summary_customers extends Report { $this->db->select('customer_name AS customer, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:15 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -50,8 +49,7 @@ class Summary_customers extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:15 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_discounts.php b/application/models/reports/Summary_discounts.php index b3356f54c..433a4032f 100644 --- a/application/models/reports/Summary_discounts.php +++ b/application/models/reports/Summary_discounts.php @@ -19,8 +19,7 @@ class Summary_discounts extends Report { $this->db->select('CONCAT(discount_percent, "%") AS discount_percent, count(*) AS count'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:45 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -52,8 +51,7 @@ class Summary_discounts extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:45 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_employees.php b/application/models/reports/Summary_employees.php index b6e73b56a..a182a5c67 100644 --- a/application/models/reports/Summary_employees.php +++ b/application/models/reports/Summary_employees.php @@ -19,8 +19,7 @@ class Summary_employees extends Report { $this->db->select('employee_name AS employee, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:26 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -50,8 +49,7 @@ class Summary_employees extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:26 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_items.php b/application/models/reports/Summary_items.php index 9d38aae69..86a922a67 100644 --- a/application/models/reports/Summary_items.php +++ b/application/models/reports/Summary_items.php @@ -19,8 +19,7 @@ class Summary_items extends Report { $this->db->select('name, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:23 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -50,8 +49,7 @@ class Summary_items extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:23 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_payments.php b/application/models/reports/Summary_payments.php index 25639b3b7..24c8e6a7c 100644 --- a/application/models/reports/Summary_payments.php +++ b/application/models/reports/Summary_payments.php @@ -20,8 +20,7 @@ class Summary_payments extends Report $this->db->select('sales_payments.payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount'); $this->db->from('sales_payments'); $this->db->join('sales', 'sales.sale_id=sales_payments.sale_id'); - // Modify by Jorge Colmenarez 2016-11-01 20:49 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -72,8 +71,7 @@ class Summary_payments extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:49 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_sales.php b/application/models/reports/Summary_sales.php index 1178c75d4..fe8dfdd4b 100644 --- a/application/models/reports/Summary_sales.php +++ b/application/models/reports/Summary_sales.php @@ -19,8 +19,7 @@ class Summary_sales extends Report { $this->db->select('sale_date, SUM(quantity_purchased) AS quantity_purchased, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 19:01 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -50,8 +49,7 @@ class Summary_sales extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 19:01 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_suppliers.php b/application/models/reports/Summary_suppliers.php index 3d2693e1e..7400cbf12 100644 --- a/application/models/reports/Summary_suppliers.php +++ b/application/models/reports/Summary_suppliers.php @@ -21,8 +21,7 @@ class Summary_suppliers extends Report $this->db->from('sales_items_temp'); $this->db->join('suppliers', 'suppliers.person_id = sales_items_temp.supplier_id'); $this->db->join('people', 'suppliers.person_id = people.person_id'); - // Modify by Jorge Colmenarez 2016-11-01 20:18 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else @@ -54,8 +53,7 @@ class Summary_suppliers extends Report $this->db->from('sales_items_temp'); $this->db->join('suppliers', 'suppliers.person_id = sales_items_temp.supplier_id'); $this->db->join('people', 'suppliers.person_id = people.person_id'); - // Modify by Jorge Colmenarez 2016-11-01 20:18 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/models/reports/Summary_taxes.php b/application/models/reports/Summary_taxes.php index e8f733f85..320799425 100644 --- a/application/models/reports/Summary_taxes.php +++ b/application/models/reports/Summary_taxes.php @@ -47,8 +47,6 @@ class Summary_taxes extends Report $decimals = totals_decimals(); - // Modify by Jorge Colmenarez 2016-11-01 20:31 - // Set WHERE Clause with support for DateTime filter field $clauseWhere = ""; if(empty($inputs['datetime_filter'])) $clauseWhere = "WHERE date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']); @@ -78,8 +76,7 @@ class Summary_taxes extends Report { $this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit'); $this->db->from('sales_items_temp'); - // Modify by Jorge Colmenarez 2016-11-01 20:32 - // Set DateTime filter field + if(empty($inputs['datetime_filter'])) $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); else diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index e2504c703..f83e85411 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -261,7 +261,7 @@ ?> - +
lang->line('config_filter_datetime_format'), 'filter_datetime_format', array('class' => 'control-label col-xs-2')); ?>
@@ -272,7 +272,6 @@ 'checked'=>$this->config->item('filter_datetime_format'))); ?>
- 'submit_form', diff --git a/application/views/partial/daterangepicker.php b/application/views/partial/daterangepicker.php index fa2597e2b..642ffffcf 100644 --- a/application/views/partial/daterangepicker.php +++ b/application/views/partial/daterangepicker.php @@ -1,10 +1,5 @@ -lang->load("calendar"); $this->lang->load("date"); ?> +lang->load("calendar"); $this->lang->load("date"); -/** -* Added By Jorge Colmenarez 2016-11-01 8:52 -* Support for Set Dinamyc DateTime Filter into Object daterangepicker -*/ -config->item('filter_datetime_format'))){ ?> var start_date = ""; diff --git a/database/database.sql b/database/database.sql index 0dfc5dbaf..644741442 100644 --- a/database/database.sql +++ b/database/database.sql @@ -82,7 +82,8 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('theme', 'flatly'), ('statistics', '1'), ('language', 'english'), -('language_code', 'en'); +('language_code', 'en'), +('filter_datetime_format',''); -- -------------------------------------------------------- diff --git a/public/license/LICENSE b/public/license/LICENSE index 9eb29b09e..4f37e2cea 100644 --- a/public/license/LICENSE +++ b/public/license/LICENSE @@ -10,6 +10,7 @@ Copyright (c) 2015-2016 FrancescoUK (aka daN4cat) Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com Copyright (c) 2015 Toni Haryanto (aka yllumi) Copyright (c) 2016 Ramkrishna Mondal (aka RamkrishnaMondal) +Copyright (c) 2016 Jorge Colmenarez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 88219b6aa03583d68a85c2ead11156cf79b0d0ce Mon Sep 17 00:00:00 2001 From: Jorge Colmenarez Date: Sun, 6 Nov 2016 21:18:26 -0400 Subject: [PATCH 3/3] Add Support for filter datetime records into Models Items and modify width of input daterangepicker --- application/controllers/Items.php | 4 +++- application/models/Item.php | 8 +++++--- application/views/partial/daterangepicker.php | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/application/controllers/Items.php b/application/controllers/Items.php index 7b0b21ba7..06b8a1e57 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -56,7 +56,9 @@ class Items extends Secure_Controller $filledup = array_fill_keys($this->input->get('filters'), TRUE); $filters = array_merge($filters, $filledup); - $items = $this->Item->search($search, $filters, $limit, $offset, $sort, $order); + $datetime_filter = $this->config->item('filter_datetime_format'); + // Modify function search to add parameter datetime filter + $items = $this->Item->search($search, $filters, $limit, $offset, $sort, $order, $datetime_filter); $total_rows = $this->Item->get_found_rows($search, $filters); $data_rows = array(); diff --git a/application/models/Item.php b/application/models/Item.php index f726ca13d..cab102aa3 100644 --- a/application/models/Item.php +++ b/application/models/Item.php @@ -53,7 +53,7 @@ class Item extends CI_Model /* Perform a search on items */ - public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc') + public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc', $datetime_filter = '') { $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); @@ -64,8 +64,10 @@ class Item extends CI_Model $this->db->join('item_quantities', 'item_quantities.item_id = items.item_id'); $this->db->where('location_id', $filters['stock_location_id']); } - - $this->db->where('DATE_FORMAT(trans_date, "%Y-%m-%d") BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); + if(empty($datetime_filter)) + $this->db->where('DATE_FORMAT(trans_date, "%Y-%m-%d") BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); + else + $this->db->where('trans_date BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); if(!empty($search)) { diff --git a/application/views/partial/daterangepicker.php b/application/views/partial/daterangepicker.php index 642ffffcf..b3c94f046 100644 --- a/application/views/partial/daterangepicker.php +++ b/application/views/partial/daterangepicker.php @@ -2,6 +2,7 @@ if(empty($this->config->item('filter_datetime_format'))){ ?> +$('#daterangepicker').css("width","200"); var start_date = ""; var end_date = ""; @@ -103,6 +104,7 @@ $('#daterangepicker').daterangepicker({ } else{ ?> +$('#daterangepicker').css("width","300"); var start_date = ""; var end_date = "";