From 88db2af11b19fefdd1d01cf409972305329483ab Mon Sep 17 00:00:00 2001 From: Jorge Colmenarez Date: Fri, 18 Nov 2016 12:19:42 -0400 Subject: [PATCH] Revert "Feature/datetime reports" --- LICENSE | 1 - application/controllers/Config.php | 3 +- application/controllers/Items.php | 4 +- application/controllers/Login.php | 1 - application/controllers/Reports.php | 194 +++++++----------- application/controllers/Sales.php | 6 +- application/language/en/config_lang.php | 1 - application/language/es/config_lang.php | 2 +- application/models/Item.php | 8 +- application/models/Receiving.php | 2 +- application/models/Sale.php | 11 +- .../models/reports/Detailed_receivings.php | 12 +- application/models/reports/Detailed_sales.php | 12 +- .../models/reports/Specific_customer.php | 16 +- .../models/reports/Specific_discount.php | 19 +- .../models/reports/Specific_employee.php | 18 +- .../models/reports/Summary_categories.php | 13 +- .../models/reports/Summary_customers.php | 12 +- .../models/reports/Summary_discounts.php | 15 +- .../models/reports/Summary_employees.php | 12 +- application/models/reports/Summary_items.php | 12 +- .../models/reports/Summary_payments.php | 12 +- application/models/reports/Summary_sales.php | 12 +- .../models/reports/Summary_suppliers.php | 12 +- application/models/reports/Summary_taxes.php | 16 +- application/views/configs/locale_config.php | 11 - application/views/partial/daterangepicker.php | 174 +++------------- application/views/reports/date_input.php | 2 +- database/database.sql | 3 +- public/license/LICENSE | 1 - 30 files changed, 156 insertions(+), 461 deletions(-) diff --git a/LICENSE b/LICENSE index 4f37e2cea..9eb29b09e 100644 --- a/LICENSE +++ b/LICENSE @@ -10,7 +10,6 @@ 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 b958fc04c..9df7fcb0c 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -302,8 +302,7 @@ 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'), - 'filter_datetime_format' => $this->input->post('filter_datetime_format') + 'payment_options_order' => $this->input->post('payment_options_order') ); $result = $this->Appconfig->batch_save($batch_save_data); diff --git a/application/controllers/Items.php b/application/controllers/Items.php index 8f02aabfe..e31954b32 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -56,9 +56,7 @@ class Items extends Secure_Controller $filledup = array_fill_keys($this->input->get('filters'), TRUE); $filters = array_merge($filters, $filledup); - $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); + $items = $this->Item->search($search, $filters, $limit, $offset, $sort, $order); $total_rows = $this->Item->get_found_rows($search, $filters); $data_rows = array(); diff --git a/application/controllers/Login.php b/application/controllers/Login.php index 8eabd84ab..cdf5f928b 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -40,7 +40,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')); - $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 51c557815..7848280da 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -43,8 +43,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_sales'); $model = $this->Summary_sales; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -61,10 +60,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_sales_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -76,8 +75,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_categories'); $model = $this->Summary_categories; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -94,10 +92,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_categories_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -109,8 +107,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_customers'); $model = $this->Summary_customers; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -127,10 +124,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_customers_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -142,8 +139,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_suppliers'); $model = $this->Summary_suppliers; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -160,10 +156,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_suppliers_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -175,8 +171,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_items'); $model = $this->Summary_items; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -193,10 +188,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_items_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -208,8 +203,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_employees'); $model = $this->Summary_employees; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -226,10 +220,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_employees_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -241,8 +235,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_taxes'); $model = $this->Summary_taxes; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -257,10 +250,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_taxes_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -272,8 +265,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_discounts'); $model = $this->Summary_discounts; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -285,10 +277,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_discounts_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -300,8 +292,7 @@ class Reports extends Secure_Controller $this->load->model('reports/Summary_payments'); $model = $this->Summary_payments; - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $tabular_data = array(); foreach($report_data as $row) @@ -314,10 +305,10 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_payments_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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))) + 'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id))) ); $this->load->view('reports/tabular', $data); @@ -363,9 +354,8 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_sales'); $model = $this->Summary_sales; - - $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)); + + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $labels = array(); $series = array(); @@ -380,11 +370,11 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_sales_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))), + '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))), 'yaxis_title' => $this->lang->line('reports_revenue'), 'xaxis_title' => $this->lang->line('reports_date'), 'show_currency' => TRUE @@ -398,9 +388,8 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_items'); $model = $this->Summary_items; - - $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)); + + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $labels = array(); $series = array(); @@ -414,11 +403,11 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_items_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))), + '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))), 'yaxis_title' => $this->lang->line('reports_items'), 'xaxis_title' => $this->lang->line('reports_revenue'), 'show_currency' => TRUE @@ -432,10 +421,9 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_categories'); $model = $this->Summary_categories; - - $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))); + + $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))); $labels = array(); $series = array(); @@ -449,7 +437,7 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_categories_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -465,10 +453,9 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_suppliers'); $model = $this->Summary_suppliers; - - $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))); + + $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))); $labels = array(); $series = array(); @@ -482,7 +469,7 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_suppliers_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -498,10 +485,9 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_employees'); $model = $this->Summary_employees; - - $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))); + + $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))); $labels = array(); $series = array(); @@ -515,7 +501,7 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_employees_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -531,10 +517,9 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_taxes'); $model = $this->Summary_taxes; - - $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))); + + $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))); $labels = array(); $series = array(); @@ -548,7 +533,7 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_taxes_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -564,9 +549,8 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_customers'); $model = $this->Summary_customers; - - $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)); + + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $labels = array(); $series = array(); @@ -580,11 +564,11 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_customers_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))), + '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))), 'yaxis_title' => $this->lang->line('reports_customers'), 'xaxis_title' => $this->lang->line('reports_revenue'), 'show_currency' => TRUE @@ -598,9 +582,8 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_discounts'); $model = $this->Summary_discounts; - - $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)); + + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $labels = array(); $series = array(); @@ -614,11 +597,11 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_discounts_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))), + '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))), 'yaxis_title' => $this->lang->line('reports_count'), 'xaxis_title' => $this->lang->line('reports_discount_percent'), 'show_currency' => FALSE @@ -632,10 +615,9 @@ class Reports extends Secure_Controller { $this->load->model('reports/Summary_payments'); $model = $this->Summary_payments; - - $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))); + + $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))); $labels = array(); $series = array(); @@ -649,7 +631,7 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_payments_summary_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -681,8 +663,7 @@ class Reports extends Secure_Controller $model = $this->Specific_customer; $headers = $this->xss_clean($model->getDataColumns()); - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type)); $summary_data = array(); $details_data = array(); @@ -698,14 +679,13 @@ class Reports extends Secure_Controller } $customer_info = $this->Customer->get_info($customer_id); - $data = array( 'title' => $this->xss_clean($customer_info->first_name . ' ' . $customer_info->last_name . ' ' . $this->lang->line('reports_report')), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))) + '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))) ); $this->load->view('reports/tabular_details', $data); @@ -732,8 +712,7 @@ class Reports extends Secure_Controller $model = $this->Specific_employee; $headers = $this->xss_clean($model->getDataColumns()); - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type)); $summary_data = array(); $details_data = array(); @@ -749,14 +728,13 @@ class Reports extends Secure_Controller } $employee_info = $this->Employee->get_info($employee_id); - $data = array( 'title' => $this->xss_clean($employee_info->first_name . ' ' . $employee_info->last_name . ' ' . $this->lang->line('reports_report')), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))) + '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))) ); $this->load->view('reports/tabular_details', $data); @@ -785,8 +763,7 @@ class Reports extends Secure_Controller $model = $this->Specific_discount; $headers = $this->xss_clean($model->getDataColumns()); - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type)); $summary_data = array(); $details_data = array(); @@ -803,11 +780,11 @@ class Reports extends Secure_Controller $data = array( 'title' => $discount . '% ' . $this->lang->line('reports_discount') . ' ' . $this->lang->line('reports_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))) + 'overall_summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date,'discount' => $discount, 'sale_type' => $sale_type))) ); $this->load->view('reports/tabular_details', $data); @@ -847,8 +824,7 @@ class Reports extends Secure_Controller $model = $this->Detailed_sales; $headers = $this->xss_clean($model->getDataColumns()); - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)); $summary_data = array(); $details_data = array(); @@ -888,12 +864,12 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_detailed_sales_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))) + '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))) ); $this->load->view('reports/tabular_details', $data); @@ -930,8 +906,7 @@ class Reports extends Secure_Controller $model = $this->Detailed_receivings; $headers = $this->xss_clean($model->getDataColumns()); - $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)); + $report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id)); $summary_data = array(); $details_data = array(); @@ -968,12 +943,12 @@ class Reports extends Secure_Controller $data = array( 'title' => $this->lang->line('reports_detailed_receivings_report'), - 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), + 'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), '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, 'datetime_filter' => $datetime_filter))) + '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))) ); $this->load->view('reports/tabular_details', $data); @@ -1054,18 +1029,5 @@ 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 20defe553..514ba99ce 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -78,10 +78,8 @@ 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); - - $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); + + $sales = $this->Sale->search($search, $filters, $limit, $offset, $sort, $order); $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 d29bbba2f..4963c51c0 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -182,4 +182,3 @@ $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"; -$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 783a847a0..84a045f45 100644 --- a/application/language/es/config_lang.php +++ b/application/language/es/config_lang.php @@ -181,4 +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"; \ No newline at end of file +$lang["config_theme"] = "Tema"; diff --git a/application/models/Item.php b/application/models/Item.php index 2bd676f2d..1cfc03a79 100644 --- a/application/models/Item.php +++ b/application/models/Item.php @@ -58,7 +58,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', $datetime_filter = '') + public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc') { $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); @@ -69,10 +69,8 @@ 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']); } - 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'])); + + $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($search)) { diff --git a/application/models/Receiving.php b/application/models/Receiving.php index ec185109f..c12605efb 100644 --- a/application/models/Receiving.php +++ b/application/models/Receiving.php @@ -206,7 +206,7 @@ class Receiving extends CI_Model public function create_temp_table() { $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') . - ' (INDEX(receiving_date), INDEX(receiving_time), INDEX(receiving_id)) + ' (INDEX(receiving_date), INDEX(receiving_id)) ( SELECT DATE(receiving_time) AS receiving_date, diff --git a/application/models/Sale.php b/application/models/Sale.php index 1d7b42466..465440746 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', $datetime_filter = '') + public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc') { $this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased, customer_name, customer_company_name AS company_name, @@ -34,11 +34,8 @@ 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'); - - 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'])); + + $this->db->where('sale_date BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date'])); if(!empty($search)) { @@ -564,7 +561,7 @@ class Sale extends CI_Model ); $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') . - ' (INDEX(sale_date), INDEX(sale_time), INDEX(sale_id)) + ' (INDEX(sale_date), 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 9481bff91..7a970dc88 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -53,11 +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'); - - 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']))); + $this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -99,11 +95,7 @@ class Detailed_receivings extends Report { $this->db->select('SUM(total) AS total'); $this->db->from('receivings_items_temp'); - - 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']))); + $this->db->where('receiving_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($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 5c717aef8..6059412e4 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -55,11 +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'); - - 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('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -97,11 +93,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'); - - 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('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($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 3d9df04cd..fdb67677f 100644 --- a/application/models/reports/Specific_customer.php +++ b/application/models/reports/Specific_customer.php @@ -21,13 +21,7 @@ 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'); - - 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("customer_id = ".$inputs['customer_id']); + $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'])); if ($inputs['sale_type'] == 'sales') { @@ -60,13 +54,7 @@ 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'); - - 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("customer_id = ".$inputs['customer_id']); + $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'])); if ($inputs['sale_type'] == 'sales') { diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index 00f4f777c..c7a926633 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -21,14 +21,8 @@ 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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount'])); - $this->db->where('discount_percent = '.$inputs['discount']); - if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -61,15 +55,8 @@ 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'); - // 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']); - + $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'])); + 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 50ef7be24..977de2103 100644 --- a/application/models/reports/Specific_employee.php +++ b/application/models/reports/Specific_employee.php @@ -21,14 +21,8 @@ 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'); - - 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("employee_id = ".$inputs['employee_id']); - + $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'])); + if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -60,13 +54,7 @@ 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'); - - 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("employee_id = ".$inputs['employee_id']); + $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'])); if ($inputs['sale_type'] == 'sales') { diff --git a/application/models/reports/Summary_categories.php b/application/models/reports/Summary_categories.php index ba5e4150f..b8fdf22a9 100644 --- a/application/models/reports/Summary_categories.php +++ b/application/models/reports/Summary_categories.php @@ -19,11 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -41,6 +37,7 @@ class Summary_categories extends Report $this->db->group_by('category'); $this->db->order_by('category'); + return $this->db->get()->result_array(); } @@ -48,11 +45,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 6464de1bd..ebf863c71 100644 --- a/application/models/reports/Summary_customers.php +++ b/application/models/reports/Summary_customers.php @@ -19,11 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -49,11 +45,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 433a4032f..29d34a327 100644 --- a/application/models/reports/Summary_discounts.php +++ b/application/models/reports/Summary_discounts.php @@ -19,12 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); $this->db->where('discount_percent > 0'); if ($inputs['location_id'] != 'all') @@ -51,13 +46,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'); - - 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'); + $this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { diff --git a/application/models/reports/Summary_employees.php b/application/models/reports/Summary_employees.php index a182a5c67..52c7fc4d1 100644 --- a/application/models/reports/Summary_employees.php +++ b/application/models/reports/Summary_employees.php @@ -19,11 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -49,11 +45,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 86a922a67..033a9b870 100644 --- a/application/models/reports/Summary_items.php +++ b/application/models/reports/Summary_items.php @@ -19,11 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -49,11 +45,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 24c8e6a7c..b1f316bd8 100644 --- a/application/models/reports/Summary_payments.php +++ b/application/models/reports/Summary_payments.php @@ -20,11 +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'); - - 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']))); + $this->db->where("date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -71,11 +67,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 fe8dfdd4b..6d8b08dcf 100644 --- a/application/models/reports/Summary_sales.php +++ b/application/models/reports/Summary_sales.php @@ -19,11 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -49,11 +45,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 7400cbf12..07644a46f 100644 --- a/application/models/reports/Summary_suppliers.php +++ b/application/models/reports/Summary_suppliers.php @@ -21,11 +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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date'])); if ($inputs['location_id'] != 'all') { @@ -53,11 +49,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 320799425..c5f0a420f 100644 --- a/application/models/reports/Summary_taxes.php +++ b/application/models/reports/Summary_taxes.php @@ -47,14 +47,6 @@ class Summary_taxes extends Report $decimals = totals_decimals(); - $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, @@ -66,7 +58,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 - $clauseWhere) AS temp_taxes + WHERE date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " $quantity_cond) AS temp_taxes GROUP BY percent"); return $query->result_array(); @@ -76,11 +68,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'); - - 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("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($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 f83e85411..e6f335536 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -262,17 +262,6 @@ -
- 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', 'id' => 'submit_form', diff --git a/application/views/partial/daterangepicker.php b/application/views/partial/daterangepicker.php index b3c94f046..6427e5efa 100644 --- a/application/views/partial/daterangepicker.php +++ b/application/views/partial/daterangepicker.php @@ -1,60 +1,57 @@ -lang->load("calendar"); $this->lang->load("date"); +lang->load("calendar"); $this->lang->load("date"); ?> - if(empty($this->config->item('filter_datetime_format'))){ -?> -$('#daterangepicker').css("width","200"); -var start_date = ""; -var end_date = ""; +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(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "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);?>" ], "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(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>" + "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);?>" ], "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(0,0,0,date("m"),date("d"),date("Y"))-1);?>" + "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);?>" ], "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(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "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);?>" ], "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(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "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);?>" ], "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(0,0,0,date("m")+1,1,date("Y"))-1);?>" + "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);?>" ], "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(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>" + "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);?>" ], "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(0,0,0,date("m")+1,1,date("Y")-1)-1);?>" + "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);?>" ], "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(0,0,0,date("m"),1,date("Y"))-1);?>" + "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);?>" ], "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(0,0,0,date("m"),1,date("Y")+1)-1);?>" + "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);?>" ], "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(0,0,0,1,1,date("Y"))-1);?>" + "config->item('dateformat'), mktime(0,0,0,1,1,date("Y")-1));?>", + "config->item('dateformat'), mktime(0,0,0,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(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>" + "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);?>" ], }, "locale": { @@ -92,118 +89,11 @@ $('#daterangepicker').daterangepicker({ "firstDay": lang->line("datepicker_weekstart"); ?> }, "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(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);?>" + "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);?>" }, function(start, end, label) { start_date = start.format('YYYY-MM-DD'); end_date = end.format('YYYY-MM-DD'); -}); - -$('#daterangepicker').css("width","300"); -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 +}); \ No newline at end of file diff --git a/application/views/reports/date_input.php b/application/views/reports/date_input.php index acc10eed4..312e39268 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("/"); }); }); diff --git a/database/database.sql b/database/database.sql index 644741442..0dfc5dbaf 100644 --- a/database/database.sql +++ b/database/database.sql @@ -82,8 +82,7 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES ('theme', 'flatly'), ('statistics', '1'), ('language', 'english'), -('language_code', 'en'), -('filter_datetime_format',''); +('language_code', 'en'); -- -------------------------------------------------------- diff --git a/public/license/LICENSE b/public/license/LICENSE index 4f37e2cea..9eb29b09e 100644 --- a/public/license/LICENSE +++ b/public/license/LICENSE @@ -10,7 +10,6 @@ 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