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 9df7fcb0c..b958fc04c 100644 --- a/application/controllers/Config.php +++ b/application/controllers/Config.php @@ -302,7 +302,8 @@ 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'), + 'filter_datetime_format' => $this->input->post('filter_datetime_format') ); $result = $this->Appconfig->batch_save($batch_save_data); diff --git a/application/controllers/Items.php b/application/controllers/Items.php index e31954b32..8f02aabfe 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/controllers/Login.php b/application/controllers/Login.php index cdf5f928b..8eabd84ab 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -40,6 +40,7 @@ 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 7848280da..51c557815 100644 --- a/application/controllers/Reports.php +++ b/application/controllers/Reports.php @@ -43,7 +43,8 @@ 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)); + $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) @@ -60,10 +61,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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 +76,8 @@ 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)); + $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) @@ -92,10 +94,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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 +109,8 @@ 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)); + $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) @@ -124,10 +127,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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); @@ -139,7 +142,8 @@ 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)); + $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) @@ -156,10 +160,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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); @@ -171,7 +175,8 @@ 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)); + $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) @@ -188,10 +193,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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); @@ -203,7 +208,8 @@ 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)); + $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) @@ -220,10 +226,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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 +241,8 @@ 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)); + $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) @@ -250,10 +257,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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 +272,8 @@ 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)); + $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) @@ -277,10 +285,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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 +300,8 @@ 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)); + $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) @@ -305,10 +314,10 @@ class Reports extends Secure_Controller $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' => $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))) + '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 +363,9 @@ 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)); + + $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(); @@ -370,11 +380,11 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +398,9 @@ 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)); + + $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(); @@ -403,11 +414,11 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +432,10 @@ 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))); + + $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(); @@ -437,7 +449,7 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -453,9 +465,10 @@ 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))); + + $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(); @@ -469,7 +482,7 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -485,9 +498,10 @@ 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))); + + $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(); @@ -501,7 +515,7 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -517,9 +531,10 @@ 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))); + + $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(); @@ -533,7 +548,7 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -549,8 +564,9 @@ 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)); + + $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(); @@ -564,11 +580,11 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +598,9 @@ 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)); + + $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(); @@ -597,11 +614,11 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +632,10 @@ 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))); + + $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(); @@ -631,7 +649,7 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), 'chart_type' => 'reports/graphs/pie', 'labels_1' => $labels, 'series_data_1' => $series, @@ -663,7 +681,8 @@ 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)); + $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 +698,14 @@ 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' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +732,8 @@ 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)); + $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 +749,14 @@ 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' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)), + 'subtitle' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +785,8 @@ 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)); + $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(); @@ -780,11 +803,11 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +847,8 @@ 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)); + $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(); @@ -864,12 +888,12 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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 +930,8 @@ 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)); + $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(); @@ -943,12 +968,12 @@ class Reports extends Secure_Controller $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' => $this->_get_subtitle_report(array($start_date,$end_date),$datetime_filter), '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); @@ -1029,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 514ba99ce..20defe553 100644 --- a/application/controllers/Sales.php +++ b/application/controllers/Sales.php @@ -78,8 +78,10 @@ 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); + + $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..d29bbba2f 100644 --- a/application/language/en/config_lang.php +++ b/application/language/en/config_lang.php @@ -182,3 +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"; +$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..783a847a0 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"; +$lang["config_theme"] = "Tema"; \ No newline at end of file diff --git a/application/models/Item.php b/application/models/Item.php index 1cfc03a79..2bd676f2d 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') + 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'); @@ -69,8 +69,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/models/Receiving.php b/application/models/Receiving.php index c12605efb..ec185109f 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_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..1d7b42466 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,8 +34,11 @@ 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'])); + + 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'])); if(!empty($search)) { @@ -561,7 +564,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_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..9481bff91 100644 --- a/application/models/reports/Detailed_receivings.php +++ b/application/models/reports/Detailed_receivings.php @@ -53,7 +53,11 @@ 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'])); + + 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 +99,11 @@ 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'])); + + 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..5c717aef8 100644 --- a/application/models/reports/Detailed_sales.php +++ b/application/models/reports/Detailed_sales.php @@ -55,7 +55,11 @@ 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'])); + + 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 +97,11 @@ 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'])); + + 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..3d9df04cd 100644 --- a/application/models/reports/Specific_customer.php +++ b/application/models/reports/Specific_customer.php @@ -21,7 +21,13 @@ 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'])); + + 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']); if ($inputs['sale_type'] == 'sales') { @@ -54,7 +60,13 @@ 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'])); + + 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']); if ($inputs['sale_type'] == 'sales') { diff --git a/application/models/reports/Specific_discount.php b/application/models/reports/Specific_discount.php index c7a926633..00f4f777c 100755 --- a/application/models/reports/Specific_discount.php +++ b/application/models/reports/Specific_discount.php @@ -21,8 +21,14 @@ 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'])); + + 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 = '.$inputs['discount']); + if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -55,8 +61,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..50ef7be24 100644 --- a/application/models/reports/Specific_employee.php +++ b/application/models/reports/Specific_employee.php @@ -21,8 +21,14 @@ 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'])); - + + 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']); + if ($inputs['sale_type'] == 'sales') { $this->db->where('quantity_purchased > 0'); @@ -54,7 +60,13 @@ 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'])); + + 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']); if ($inputs['sale_type'] == 'sales') { diff --git a/application/models/reports/Summary_categories.php b/application/models/reports/Summary_categories.php index b8fdf22a9..ba5e4150f 100644 --- a/application/models/reports/Summary_categories.php +++ b/application/models/reports/Summary_categories.php @@ -19,7 +19,11 @@ 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'])); + + 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 +41,6 @@ class Summary_categories extends Report $this->db->group_by('category'); $this->db->order_by('category'); - return $this->db->get()->result_array(); } @@ -45,7 +48,11 @@ 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'])); + + 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..6464de1bd 100644 --- a/application/models/reports/Summary_customers.php +++ b/application/models/reports/Summary_customers.php @@ -19,7 +19,11 @@ 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'])); + + 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 +49,11 @@ 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'])); + + 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..433a4032f 100644 --- a/application/models/reports/Summary_discounts.php +++ b/application/models/reports/Summary_discounts.php @@ -19,7 +19,12 @@ 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'])); + + 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 +51,13 @@ 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'])); + + 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..a182a5c67 100644 --- a/application/models/reports/Summary_employees.php +++ b/application/models/reports/Summary_employees.php @@ -19,7 +19,11 @@ 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'])); + + 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 +49,11 @@ 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'])); + + 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..86a922a67 100644 --- a/application/models/reports/Summary_items.php +++ b/application/models/reports/Summary_items.php @@ -19,7 +19,11 @@ 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'])); + + 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 +49,11 @@ 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'])); + + 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..24c8e6a7c 100644 --- a/application/models/reports/Summary_payments.php +++ b/application/models/reports/Summary_payments.php @@ -20,7 +20,11 @@ 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'])); + + 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 +71,11 @@ 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'])); + + 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..fe8dfdd4b 100644 --- a/application/models/reports/Summary_sales.php +++ b/application/models/reports/Summary_sales.php @@ -19,7 +19,11 @@ 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'])); + + 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 +49,11 @@ 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'])); + + 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..7400cbf12 100644 --- a/application/models/reports/Summary_suppliers.php +++ b/application/models/reports/Summary_suppliers.php @@ -21,7 +21,11 @@ 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'])); + + 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 +53,11 @@ 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'])); + + 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..320799425 100644 --- a/application/models/reports/Summary_taxes.php +++ b/application/models/reports/Summary_taxes.php @@ -47,6 +47,14 @@ 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, @@ -58,7 +66,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 +76,11 @@ 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'])); + + 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..f83e85411 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -262,6 +262,17 @@ +
+ 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 6427e5efa..b3c94f046 100644 --- a/application/views/partial/daterangepicker.php +++ b/application/views/partial/daterangepicker.php @@ -1,57 +1,60 @@ -lang->load("calendar"); $this->lang->load("date"); ?> +lang->load("calendar"); $this->lang->load("date"); -var start_date = ""; -var end_date = ""; + if(empty($this->config->item('filter_datetime_format'))){ +?> +$('#daterangepicker').css("width","200"); +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 +92,118 @@ $('#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 +}); + +$('#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 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("/"); }); }); 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