Support for Date or Time Format

This commit is contained in:
root
2016-11-30 14:32:25 -04:00
parent 9a9dc9bf1e
commit 305d9dd55e
10 changed files with 347 additions and 137 deletions

View File

@@ -304,7 +304,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'),
'date_or_time_format' => $this->input->post('date_or_time_format')
);
$result = $this->Appconfig->batch_save($batch_save_data);

View File

@@ -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', 'Date or Time Format', $this->config->item('date_or_time_format'));
}
redirect('home');

View File

@@ -64,7 +64,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -100,7 +100,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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -136,7 +136,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -172,7 +172,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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -208,7 +208,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -244,7 +244,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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -278,7 +278,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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -309,7 +309,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -341,7 +341,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' => $start_date, 'end_date' => $end_date)),
'headers' => $this->xss_clean($model->getDataColumns()),
'data' => $tabular_data,
'summary_data' => $summary
@@ -409,7 +409,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/line',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -445,7 +445,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/hbar',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -481,7 +481,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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/pie',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -515,7 +515,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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/pie',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -549,7 +549,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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/pie',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -583,7 +583,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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/pie',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -617,7 +617,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/hbar',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -653,7 +653,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/bar',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -689,7 +689,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' => $start_date, 'end_date' => $end_date)),
'chart_type' => 'reports/graphs/pie',
'labels_1' => $labels,
'series_data_1' => $series,
@@ -754,7 +754,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $headers,
'summary_data' => $summary_data,
'details_data' => $details_data,
@@ -818,7 +818,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $headers,
'summary_data' => $summary_data,
'details_data' => $details_data,
@@ -883,7 +883,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $headers,
'summary_data' => $summary_data,
'details_data' => $details_data,
@@ -975,7 +975,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $headers,
'editable' => 'sales',
'summary_data' => $summary_data,
@@ -1062,7 +1062,7 @@ 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' => $start_date, 'end_date' => $end_date)),
'headers' => $headers,
'editable' => 'receivings',
'summary_data' => $summary_data,
@@ -1154,5 +1154,21 @@ class Reports extends Secure_Controller
$this->load->view('reports/tabular', $data);
}
// Returns subtitle for the reports
private function _get_subtitle_report($inputs)
{
$subtitle = '';
if(empty($this->config->item('filter_datetime_format')))
{
$subtitle .= date($this->config->item('dateformat'), strtotime($inputs['start_date'])) . ' - ' .date($this->config->item('dateformat'), strtotime($inputs['end_date']));
}
else
{
$subtitle .= date($this->config->item('dateformat').' '.$this->config->item('timeformat'), strtotime(rawurldecode($inputs['start_date']))) . ' - ' . date($this->config->item('dateformat').' '.$this->config->item('timeformat'), strtotime(rawurldecode($inputs['end_date'])));
}
return $subtitle;
}
}
?>

View File

@@ -70,7 +70,14 @@ class Item extends CI_Model
$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($this->config->item('date_or_time_format')))
{
$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(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
}
if(!empty($search))
{

View File

@@ -227,7 +227,14 @@ class Receiving extends CI_Model
{
if(empty($inputs['receiving_id']))
{
$where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
if(empty($this->config->item('date_or_time_format')))
{
$where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where = 'WHERE receiving_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
}
}
else
{
@@ -235,7 +242,7 @@ class Receiving extends CI_Model
}
$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,

View File

@@ -98,6 +98,15 @@ class Sale extends CI_Model
*/
public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc')
{
$where = '';
if (empty($this->config->item('date_or_time_format')))
{
$where .= 'WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']) . ' ';
}
else
{
$where .= 'WHERE sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])) . ' ';
}
// NOTE: temporary tables are created to speed up searches due to the fact that are ortogonal to the main query
// create a temporary table to contain all the payments per sale item
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
@@ -109,7 +118,7 @@ class Sale extends CI_Model
FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
ON sales.sale_id = payments.sale_id
WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']) . '
' . $where . '
GROUP BY sale_id
)'
);
@@ -126,7 +135,7 @@ class Sale extends CI_Model
ON sales.sale_id = sales_items_taxes.sale_id
INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']) . '
' . $where . '
GROUP BY sales_items_taxes.sale_id, sales_items_taxes.item_id
)'
);
@@ -176,7 +185,14 @@ class Sale extends CI_Model
$this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
$this->db->join('sales_items_taxes_temp AS sales_items_taxes', 'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id', 'left outer');
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
if (empty($this->config->item('date_or_time_format')))
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
}
else
{
$this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
}
if(!empty($search))
{
@@ -250,7 +266,14 @@ class Sale extends CI_Model
$this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
$this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
$this->db->where('DATE(sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
if (empty($this->config->item('date_or_time_format')))
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
}
else
{
$this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
}
if(!empty($search))
{
@@ -735,7 +758,14 @@ class Sale extends CI_Model
if(empty($inputs['sale_id']))
{
$where = 'WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
if(empty($this->config->item('date_or_time_format')))
{
$where = 'WHERE DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where = 'WHERE sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
}
}
else
{
@@ -760,7 +790,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,

View File

@@ -17,6 +17,16 @@ abstract class Summary_report extends Report
private function _common_select(array $inputs)
{
$where = '';
if(empty($this->config->item('date_or_time_format')))
{
$where .= 'WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where .= 'WHERE sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
}
// create a temporary table to contain all the sum of taxes per sale item
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
' (INDEX(sale_id), INDEX(item_id))
@@ -29,7 +39,7 @@ abstract class Summary_report extends Report
ON sales.sale_id = sales_items_taxes.sale_id
INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']) . '
' . $where . '
GROUP BY sales_items_taxes.sale_id, sales_items_taxes.item_id
)'
);
@@ -69,7 +79,14 @@ abstract class Summary_report extends Report
private function _common_where(array $inputs)
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
if(empty($this->config->item('date_or_time_format')))
{
$this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
}
else
{
$this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
}
if($inputs['location_id'] != 'all')
{

View File

@@ -21,20 +21,29 @@ class Summary_taxes extends Summary_report
public function getData(array $inputs)
{
$quantity_cond = '';
$where = '';
if(empty($this->config->item('date_or_time_format')))
{
$where .= 'WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
}
else
{
$where .= 'WHERE sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
}
if($inputs['sale_type'] == 'sales')
{
$quantity_cond = 'AND quantity_purchased > 0';
$where = 'AND quantity_purchased > 0';
}
elseif($inputs['sale_type'] == 'returns')
{
$quantity_cond = 'AND quantity_purchased < 0';
$where = 'AND quantity_purchased < 0';
}
if($inputs['location_id'] != 'all')
{
$quantity_cond .= 'AND item_location = '. $this->db->escape($inputs['location_id']);
$where .= 'AND item_location = '. $this->db->escape($inputs['location_id']);
}
if($this->config->item('tax_included'))
@@ -64,7 +73,7 @@ class Summary_taxes extends Summary_report
ON sales_items.sale_id = sales.sale_id
LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line
WHERE DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']) . " $quantity_cond
' . " $where
) AS temp_taxes
GROUP BY percent"
);

View File

@@ -262,6 +262,17 @@
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_date_or_time_format'), 'date_or_time_format', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<?php echo form_checkbox(array(
'name' => 'date_or_time_format',
'id' => 'date_or_time_format',
'value' => 'date_or_time_format',
'checked'=>$this->config->item('date_or_time_format'))); ?>
</div>
</div>
<?php echo form_submit(array(
'name' => 'submit_form',
'id' => 'submit_form',

View File

@@ -1,99 +1,210 @@
<?php $this->lang->load("calendar"); $this->lang->load("date"); ?>
<?php $this->lang->load("calendar"); $this->lang->load("date");
if(empty($this->config->item('date_or_time_format')))
{
?>
$('#daterangepicker').css("width","180");
var start_date = "<?php echo date('Y-m-d') ?>";
var end_date = "<?php echo date('Y-m-d') ?>";
var start_date = "<?php echo date('Y-m-d') ?>";
var end_date = "<?php echo date('Y-m-d') ?>";
$('#daterangepicker').daterangepicker({
"ranges": {
"<?php echo $this->lang->line("datepicker_today"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_today_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_yesterday"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_7"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-6,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_30"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-29,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_month"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m")+1,1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_same_month_to_same_day_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_month_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m")+1,1,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_month"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m")-1,1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,1,1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")+1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,1,1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,1,1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_all_time"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,01,01,2010));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
},
"locale": {
"format": '<?php echo dateformat_momentjs($this->config->item("dateformat"))?>',
"separator": " - ",
"applyLabel": "<?php echo $this->lang->line("datepicker_apply"); ?>",
"cancelLabel": "<?php echo $this->lang->line("datepicker_cancel"); ?>",
"fromLabel": "<?php echo $this->lang->line("datepicker_from"); ?>",
"toLabel": "<?php echo $this->lang->line("datepicker_to"); ?>",
"customRangeLabel": "<?php echo $this->lang->line("datepicker_custom"); ?>",
"daysOfWeek": [
"<?php echo $this->lang->line("cal_su"); ?>",
"<?php echo $this->lang->line("cal_mo"); ?>",
"<?php echo $this->lang->line("cal_tu"); ?>",
"<?php echo $this->lang->line("cal_we"); ?>",
"<?php echo $this->lang->line("cal_th"); ?>",
"<?php echo $this->lang->line("cal_fr"); ?>",
"<?php echo $this->lang->line("cal_sa"); ?>",
"<?php echo $this->lang->line("cal_su"); ?>"
],
"monthNames": [
"<?php echo $this->lang->line("cal_january"); ?>",
"<?php echo $this->lang->line("cal_february"); ?>",
"<?php echo $this->lang->line("cal_march"); ?>",
"<?php echo $this->lang->line("cal_april"); ?>",
"<?php echo $this->lang->line("cal_may"); ?>",
"<?php echo $this->lang->line("cal_june"); ?>",
"<?php echo $this->lang->line("cal_july"); ?>",
"<?php echo $this->lang->line("cal_august"); ?>",
"<?php echo $this->lang->line("cal_september"); ?>",
"<?php echo $this->lang->line("cal_october"); ?>",
"<?php echo $this->lang->line("cal_november"); ?>",
"<?php echo $this->lang->line("cal_december"); ?>"
],
"firstDay": <?php echo $this->lang->line("datepicker_weekstart"); ?>
},
"alwaysShowCalendars": true,
"startDate": "<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>",
"endDate": "<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>",
"minDate": "<?php echo date($this->config->item('dateformat'), mktime(0,0,0,01,01,2010));?>",
"maxDate": "<?php echo date($this->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');
});
<?php
}
else
{
?>
$('#daterangepicker').css("width","305");
var start_date = "<?php echo date('Y-m-d H:i:s')?>";
var end_date = "<?php echo date('Y-m-d H:i:s')?>";
$('#daterangepicker').daterangepicker({
"ranges": {
"<?php echo $this->lang->line("datepicker_today"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_today_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_yesterday"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d"),date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_7"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-6,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_30"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")-29,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_month"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m")+1,1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_same_month_to_same_day_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_month_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m")+1,1,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_month"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m")-1,1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,1,1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),1,date("Y")+1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,1,1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,1,1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_all_time"); ?>": [
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,01,01,2010));?>",
"<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>"
],
},
"locale": {
"format": '<?php echo dateformat_momentjs($this->config->item("dateformat"))?>',
"separator": " - ",
"applyLabel": "<?php echo $this->lang->line("datepicker_apply"); ?>",
"cancelLabel": "<?php echo $this->lang->line("datepicker_cancel"); ?>",
"fromLabel": "<?php echo $this->lang->line("datepicker_from"); ?>",
"toLabel": "<?php echo $this->lang->line("datepicker_to"); ?>",
"customRangeLabel": "<?php echo $this->lang->line("datepicker_custom"); ?>",
"daysOfWeek": [
"<?php echo $this->lang->line("cal_su"); ?>",
"<?php echo $this->lang->line("cal_mo"); ?>",
"<?php echo $this->lang->line("cal_tu"); ?>",
"<?php echo $this->lang->line("cal_we"); ?>",
"<?php echo $this->lang->line("cal_th"); ?>",
"<?php echo $this->lang->line("cal_fr"); ?>",
"<?php echo $this->lang->line("cal_sa"); ?>",
"<?php echo $this->lang->line("cal_su"); ?>"
],
"monthNames": [
"<?php echo $this->lang->line("cal_january"); ?>",
"<?php echo $this->lang->line("cal_february"); ?>",
"<?php echo $this->lang->line("cal_march"); ?>",
"<?php echo $this->lang->line("cal_april"); ?>",
"<?php echo $this->lang->line("cal_may"); ?>",
"<?php echo $this->lang->line("cal_june"); ?>",
"<?php echo $this->lang->line("cal_july"); ?>",
"<?php echo $this->lang->line("cal_august"); ?>",
"<?php echo $this->lang->line("cal_september"); ?>",
"<?php echo $this->lang->line("cal_october"); ?>",
"<?php echo $this->lang->line("cal_november"); ?>",
"<?php echo $this->lang->line("cal_december"); ?>"
],
"firstDay": <?php echo $this->lang->line("datepicker_weekstart"); ?>
},
"alwaysShowCalendars": true,
"startDate": "<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>",
"endDate": "<?php echo date($this->config->item('dateformat'), mktime(0,0,0,date("m"),date("d")+1,date("Y"))-1);?>",
"minDate": "<?php echo date($this->config->item('dateformat'), mktime(0,0,0,01,01,2010));?>",
"maxDate": "<?php echo date($this->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').daterangepicker({
"ranges": {
"<?php echo $this->lang->line("datepicker_today"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'), mktime(0,0,0,date("m"),date("d"),date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_today_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d"),date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_yesterday"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d")-1,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_7"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-6,date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_30"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d")-29,date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_month"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m")+1,0,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_same_month_to_same_day_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_month_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m")+1,0,date("Y")-1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_month"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m")-1,1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),0,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_this_year"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y")));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),1,date("Y")+1)-1);?>"
],
"<?php echo $this->lang->line("datepicker_last_year"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,1,1,date("Y")-1));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,1,0,date("Y"))-1);?>"
],
"<?php echo $this->lang->line("datepicker_all_time"); ?>": [
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,01,01,2010));?>",
"<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y"))-1);?>"
],
},
"locale": {
"format": '<?php echo dateformat_momentjs($this->config->item("dateformat")." ".$this->config->item('timeformat'))?>',
"separator": " - ",
"applyLabel": "<?php echo $this->lang->line("datepicker_apply"); ?>",
"cancelLabel": "<?php echo $this->lang->line("datepicker_cancel"); ?>",
"fromLabel": "<?php echo $this->lang->line("datepicker_from"); ?>",
"toLabel": "<?php echo $this->lang->line("datepicker_to"); ?>",
"customRangeLabel": "<?php echo $this->lang->line("datepicker_custom"); ?>",
"daysOfWeek": [
"<?php echo $this->lang->line("cal_su"); ?>",
"<?php echo $this->lang->line("cal_mo"); ?>",
"<?php echo $this->lang->line("cal_tu"); ?>",
"<?php echo $this->lang->line("cal_we"); ?>",
"<?php echo $this->lang->line("cal_th"); ?>",
"<?php echo $this->lang->line("cal_fr"); ?>",
"<?php echo $this->lang->line("cal_sa"); ?>",
"<?php echo $this->lang->line("cal_su"); ?>"
],
"monthNames": [
"<?php echo $this->lang->line("cal_january"); ?>",
"<?php echo $this->lang->line("cal_february"); ?>",
"<?php echo $this->lang->line("cal_march"); ?>",
"<?php echo $this->lang->line("cal_april"); ?>",
"<?php echo $this->lang->line("cal_may"); ?>",
"<?php echo $this->lang->line("cal_june"); ?>",
"<?php echo $this->lang->line("cal_july"); ?>",
"<?php echo $this->lang->line("cal_august"); ?>",
"<?php echo $this->lang->line("cal_september"); ?>",
"<?php echo $this->lang->line("cal_october"); ?>",
"<?php echo $this->lang->line("cal_november"); ?>",
"<?php echo $this->lang->line("cal_december"); ?>"
],
"firstDay": <?php echo $this->lang->line("datepicker_weekstart"); ?>
},
"timePicker": true,
"timePickerSeconds": true,
"alwaysShowCalendars": true,
"startDate": "<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,date("m"),date("d"),date("Y")));?>",
"endDate": "<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),date("Y"))-1);?>",
"minDate": "<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(0,0,0,01,01,2010));?>",
"maxDate": "<?php echo date($this->config->item('dateformat')." ".$this->config->item('timeformat'),mktime(23,59,59,date("m"),date("d"),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');
});
<?php
}
?>