mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 08:20:54 -04:00
Optimise Reports usage of temp database tables (#964)
This commit is contained in:
@@ -40,10 +40,15 @@ class Reports extends Secure_Controller
|
||||
//Summary sales report
|
||||
public function summary_sales($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -63,7 +68,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -72,10 +77,15 @@ class Reports extends Secure_Controller
|
||||
//Summary categories report
|
||||
public function summary_categories($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -95,7 +105,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -104,10 +114,15 @@ class Reports extends Secure_Controller
|
||||
//Summary customers report
|
||||
public function summary_customers($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -127,7 +142,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -136,10 +151,15 @@ class Reports extends Secure_Controller
|
||||
//Summary suppliers report
|
||||
public function summary_suppliers($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -159,7 +179,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -168,10 +188,15 @@ class Reports extends Secure_Controller
|
||||
//Summary items report
|
||||
public function summary_items($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -191,7 +216,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -200,10 +225,15 @@ class Reports extends Secure_Controller
|
||||
//Summary employees report
|
||||
public function summary_employees($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -223,7 +253,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -232,10 +262,15 @@ class Reports extends Secure_Controller
|
||||
//Summary taxes report
|
||||
public function summary_taxes($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -253,7 +288,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -262,10 +297,15 @@ class Reports extends Secure_Controller
|
||||
//Summary discounts report
|
||||
public function summary_discounts($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -280,7 +320,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -289,10 +329,15 @@ class Reports extends Secure_Controller
|
||||
//Summary payments report
|
||||
public function summary_payments($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -308,7 +353,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => date($this->config->item('dateformat'), strtotime($start_date)) . '-' . date($this->config->item('dateformat'), strtotime($end_date)),
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id)))
|
||||
'summary_data' => $summary
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -352,10 +397,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary sales report
|
||||
public function graphical_summary_sales($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -374,7 +424,7 @@ class Reports extends Secure_Controller
|
||||
'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' => $summary,
|
||||
'yaxis_title' => $this->lang->line('reports_revenue'),
|
||||
'xaxis_title' => $this->lang->line('reports_date'),
|
||||
'show_currency' => TRUE
|
||||
@@ -386,10 +436,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary items report
|
||||
public function graphical_summary_items($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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));
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -407,7 +462,7 @@ class Reports extends Secure_Controller
|
||||
'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' => $summary,
|
||||
'yaxis_title' => $this->lang->line('reports_items'),
|
||||
'xaxis_title' => $this->lang->line('reports_revenue'),
|
||||
'show_currency' => TRUE
|
||||
@@ -419,11 +474,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary customers report
|
||||
public function graphical_summary_categories($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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)));
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -451,11 +510,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary suppliers report
|
||||
public function graphical_summary_suppliers($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$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)));
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -483,11 +546,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary employees report
|
||||
public function graphical_summary_employees($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Summary_employees');
|
||||
$model = $this->Summary_employees;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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)));
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -515,11 +582,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary taxes report
|
||||
public function graphical_summary_taxes($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Summary_taxes');
|
||||
$model = $this->Summary_taxes;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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)));
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -547,10 +618,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary customers report
|
||||
public function graphical_summary_customers($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Summary_customers');
|
||||
$model = $this->Summary_customers;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -568,7 +644,7 @@ class Reports extends Secure_Controller
|
||||
'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' => $summary,
|
||||
'yaxis_title' => $this->lang->line('reports_customers'),
|
||||
'xaxis_title' => $this->lang->line('reports_revenue'),
|
||||
'show_currency' => TRUE
|
||||
@@ -580,10 +656,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary discounts report
|
||||
public function graphical_summary_discounts($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Summary_discounts');
|
||||
$model = $this->Summary_discounts;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id));
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -601,7 +682,7 @@ class Reports extends Secure_Controller
|
||||
'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' => $summary,
|
||||
'yaxis_title' => $this->lang->line('reports_count'),
|
||||
'xaxis_title' => $this->lang->line('reports_discount_percent'),
|
||||
'show_currency' => FALSE
|
||||
@@ -613,11 +694,15 @@ class Reports extends Secure_Controller
|
||||
//Graphical summary payments report
|
||||
public function graphical_summary_payments($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Summary_payments');
|
||||
$model = $this->Summary_payments;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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)));
|
||||
$report_data = $model->getData($inputs);
|
||||
$summary = $this->xss_clean($model->getSummaryData($inputs));
|
||||
|
||||
$labels = array();
|
||||
$series = array();
|
||||
@@ -659,11 +744,15 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function specific_customer($start_date, $end_date, $customer_id, $sale_type)
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'customer_id' => $customer_id, 'sale_type' => $sale_type);
|
||||
|
||||
$this->load->model('reports/Specific_customer');
|
||||
$model = $this->Specific_customer;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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));
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
$details_data = array();
|
||||
@@ -685,7 +774,7 @@ class Reports extends Secure_Controller
|
||||
'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($inputs))
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular_details', $data);
|
||||
@@ -708,11 +797,15 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function specific_employee($start_date, $end_date, $employee_id, $sale_type)
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type);
|
||||
|
||||
$this->load->model('reports/Specific_employee');
|
||||
$model = $this->Specific_employee;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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));
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
$details_data = array();
|
||||
@@ -734,7 +827,7 @@ class Reports extends Secure_Controller
|
||||
'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($inputs))
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular_details', $data);
|
||||
@@ -759,11 +852,15 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function specific_discount($start_date, $end_date, $discount, $sale_type)
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type);
|
||||
|
||||
$this->load->model('reports/Specific_discount');
|
||||
$model = $this->Specific_discount;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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));
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
$details_data = array();
|
||||
@@ -784,7 +881,7 @@ class Reports extends Secure_Controller
|
||||
'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($inputs))
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular_details', $data);
|
||||
@@ -792,9 +889,13 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function get_detailed_sales_row($sale_id)
|
||||
{
|
||||
$inputs = array('sale_id' => $sale_id);
|
||||
|
||||
$this->load->model('reports/Detailed_sales');
|
||||
$model = $this->Detailed_sales;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getDataBySaleId($sale_id);
|
||||
|
||||
$summary_data = $this->xss_clean(array(
|
||||
@@ -820,11 +921,15 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function detailed_sales($start_date, $end_date, $sale_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Detailed_sales');
|
||||
$model = $this->Detailed_sales;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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));
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
$details_data = array();
|
||||
@@ -869,7 +974,7 @@ class Reports extends Secure_Controller
|
||||
'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($inputs))
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular_details', $data);
|
||||
@@ -877,8 +982,12 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function get_detailed_receivings_row($receiving_id)
|
||||
{
|
||||
$inputs = array('receiving_id' => $receiving_id);
|
||||
|
||||
$this->load->model('reports/Detailed_receivings');
|
||||
$model = $this->Detailed_receivings;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getDataByReceivingId($receiving_id);
|
||||
|
||||
@@ -902,11 +1011,15 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function detailed_receivings($start_date, $end_date, $receiving_type, $location_id = 'all')
|
||||
{
|
||||
$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id);
|
||||
|
||||
$this->load->model('reports/Detailed_receivings');
|
||||
$model = $this->Detailed_receivings;
|
||||
|
||||
$model->create($inputs);
|
||||
|
||||
$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));
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$summary_data = array();
|
||||
$details_data = array();
|
||||
@@ -948,7 +1061,7 @@ class Reports extends Secure_Controller
|
||||
'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($inputs))
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular_details', $data);
|
||||
@@ -956,10 +1069,14 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function inventory_low()
|
||||
{
|
||||
$inputs = array();
|
||||
|
||||
$this->load->model('reports/Inventory_low');
|
||||
$model = $this->Inventory_low;
|
||||
|
||||
$report_data = $model->getData(array());
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
@@ -977,7 +1094,7 @@ class Reports extends Secure_Controller
|
||||
'subtitle' => '',
|
||||
'headers' => $this->xss_clean($model->getDataColumns()),
|
||||
'data' => $tabular_data,
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData(array()))
|
||||
'summary_data' => $this->xss_clean($model->getSummaryData($inputs))
|
||||
);
|
||||
|
||||
$this->load->view('reports/tabular', $data);
|
||||
@@ -1000,10 +1117,14 @@ class Reports extends Secure_Controller
|
||||
|
||||
public function inventory_summary($location_id = 'all', $item_count = 'all')
|
||||
{
|
||||
$inputs = array('location_id' => $location_id, 'item_count' => $item_count);
|
||||
|
||||
$this->load->model('reports/Inventory_summary');
|
||||
$model = $this->Inventory_summary;
|
||||
|
||||
$report_data = $model->getData(array('location_id' => $location_id, 'item_count' => $item_count));
|
||||
$model->create($inputs);
|
||||
|
||||
$report_data = $model->getData($inputs);
|
||||
|
||||
$tabular_data = array();
|
||||
foreach($report_data as $row)
|
||||
|
||||
@@ -514,7 +514,7 @@ class Item extends CI_Model
|
||||
* $old_price (optional) : the current-cost-price
|
||||
*
|
||||
* used in receiving-process to update cost-price if changed
|
||||
* caution: must be used there before item_quantities gets updated, otherwise average price is wrong!
|
||||
* caution: must be used before item_quantities gets updated, otherwise the average price is wrong!
|
||||
*
|
||||
*/
|
||||
public function change_cost_price($item_id, $items_received, $new_price, $old_price = null)
|
||||
@@ -539,32 +539,5 @@ class Item extends CI_Model
|
||||
|
||||
return $this->save($data, $item_id);
|
||||
}
|
||||
|
||||
//We create a temp table that allows us to do easy report queries
|
||||
public function create_temp_table()
|
||||
{
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('items_temp') .
|
||||
' (INDEX(quantity), INDEX(location_id))
|
||||
(
|
||||
SELECT
|
||||
items.name,
|
||||
items.item_number,
|
||||
items.description,
|
||||
items.reorder_level,
|
||||
item_quantities.quantity,
|
||||
stock_locations.location_name,
|
||||
stock_locations.location_id,
|
||||
items.cost_price,
|
||||
items.unit_price,
|
||||
(items.cost_price * item_quantities.quantity) AS sub_total_value
|
||||
FROM ' . $this->db->dbprefix('items') . ' AS items
|
||||
INNER JOIN ' . $this->db->dbprefix('item_quantities') . ' AS item_quantities
|
||||
ON items.item_id = item_quantities.item_id
|
||||
INNER JOIN ' . $this->db->dbprefix('stock_locations') . ' AS stock_locations
|
||||
ON item_quantities.location_id = stock_locations.location_id
|
||||
WHERE items.deleted = 0 AND stock_locations.deleted = 0
|
||||
)'
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -223,8 +223,17 @@ class Receiving extends CI_Model
|
||||
/*
|
||||
We create a temp table that allows us to do easy report/receiving queries
|
||||
*/
|
||||
public function create_temp_table()
|
||||
public function create_temp_table(array $inputs)
|
||||
{
|
||||
if(empty($input['receiving_id']))
|
||||
{
|
||||
$where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = 'WHERE receivings_items.receiving_id = ' . $this->db->escape($inputs['receiving_id']);
|
||||
}
|
||||
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') .
|
||||
' (INDEX(receiving_date), INDEX(receiving_id))
|
||||
(
|
||||
@@ -256,6 +265,9 @@ class Receiving extends CI_Model
|
||||
ON receivings_items.receiving_id = receivings.receiving_id
|
||||
INNER JOIN ' . $this->db->dbprefix('items') . ' AS items
|
||||
ON receivings_items.item_id = items.item_id
|
||||
' . "
|
||||
$where
|
||||
" . '
|
||||
GROUP BY receivings_items.receiving_id, items.item_id, receivings_items.line
|
||||
)'
|
||||
);
|
||||
|
||||
@@ -31,7 +31,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 sales.sale_id = ' . $sale_id . '
|
||||
WHERE sales.sale_id = ' . $this->db->escape($sale_id) . '
|
||||
GROUP BY sale_id
|
||||
)'
|
||||
);
|
||||
@@ -280,7 +280,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
}
|
||||
|
||||
if( $gift_card_count > 0 )
|
||||
if($gift_card_count > 0)
|
||||
{
|
||||
$payments[] = array('payment_type' => $this->lang->line('sales_giftcard'), 'count' => $gift_card_count, 'payment_amount' => $gift_card_amount);
|
||||
}
|
||||
@@ -674,7 +674,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
//We create a temp table that allows us to do easy report/sales queries
|
||||
public function create_temp_table()
|
||||
public function create_temp_table(array $inputs)
|
||||
{
|
||||
if($this->config->item('tax_included'))
|
||||
{
|
||||
@@ -693,15 +693,30 @@ class Sale extends CI_Model
|
||||
$sale_cost = '(sales_items.item_cost_price * sales_items.quantity_purchased)';
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
if(empty($input['sale_id']))
|
||||
{
|
||||
$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_id = ' . $this->db->escape($inputs['sale_id']);
|
||||
}
|
||||
|
||||
// create a temporary table to contain all the payment types and amount
|
||||
$this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
|
||||
' (PRIMARY KEY(sale_id), INDEX(sale_id))
|
||||
(
|
||||
SELECT sale_id,
|
||||
IFNULL(SUM(payment_amount), 0) AS sale_payment_amount,
|
||||
GROUP_CONCAT(CONCAT(payment_type, " ", payment_amount) SEPARATOR ", ") AS payment_type
|
||||
FROM ' . $this->db->dbprefix('sales_payments') . '
|
||||
GROUP BY sale_id
|
||||
SELECT payments.sale_id AS sale_id,
|
||||
IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
|
||||
GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
|
||||
FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
|
||||
INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
|
||||
ON sales.sale_id = payments.sale_id
|
||||
' . "
|
||||
$where
|
||||
" . '
|
||||
GROUP BY payments.sale_id
|
||||
)'
|
||||
);
|
||||
|
||||
@@ -762,9 +777,15 @@ class Sale extends CI_Model
|
||||
ON sales.employee_id = employee.person_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
|
||||
" . '
|
||||
GROUP BY sales.sale_id, items.item_id, sales_items.line
|
||||
)'
|
||||
);
|
||||
|
||||
// drop the temporary table to contain memory consumption as it's no longer required
|
||||
$this->db->query('DROP TEMPORARY TABLE IF EXISTS ' . $this->db->dbprefix('sales_payments_temp'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -5,9 +5,12 @@ class Detailed_receivings extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Receiving->create_temp_table();
|
||||
$this->Receiving->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -53,21 +56,20 @@ 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 ($inputs['location_id'] != 'all')
|
||||
if($inputs['location_id'] != 'all')
|
||||
{
|
||||
$this->db->where('item_location', $inputs['location_id']);
|
||||
}
|
||||
if ($inputs['receiving_type'] == 'receiving')
|
||||
if($inputs['receiving_type'] == 'receiving')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
}
|
||||
elseif ($inputs['receiving_type'] == 'returns')
|
||||
elseif($inputs['receiving_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
elseif ($inputs['receiving_type'] == 'requisitions')
|
||||
elseif($inputs['receiving_type'] == 'requisitions')
|
||||
{
|
||||
$this->db->having('items_purchased = 0');
|
||||
}
|
||||
@@ -80,8 +82,7 @@ class Detailed_receivings extends Report
|
||||
|
||||
foreach($data['summary'] as $key=>$value)
|
||||
{
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location');
|
||||
$this->db->select($this->db->dbprefix('receivings_items_temp').".receiving_quantity");
|
||||
$this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location, receivings_items_temp.receiving_quantity');
|
||||
$this->db->from('receivings_items_temp');
|
||||
$this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
|
||||
$this->db->where('receiving_id = '.$value['receiving_id']);
|
||||
@@ -95,21 +96,20 @@ 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 ($inputs['location_id'] != 'all')
|
||||
if($inputs['location_id'] != 'all')
|
||||
{
|
||||
$this->db->where('item_location', $inputs['location_id']);
|
||||
}
|
||||
if ($inputs['receiving_type'] == 'receiving')
|
||||
if($inputs['receiving_type'] == 'receiving')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
}
|
||||
elseif ($inputs['receiving_type'] == 'returns')
|
||||
elseif($inputs['receiving_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
elseif ($inputs['receiving_type'] == 'requisitions')
|
||||
elseif($inputs['receiving_type'] == 'requisitions')
|
||||
{
|
||||
$this->db->where('quantity_purchased = 0');
|
||||
}
|
||||
|
||||
@@ -5,9 +5,12 @@ class Detailed_sales extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -27,18 +30,18 @@ class Detailed_sales extends Report
|
||||
'payment_type' => $this->lang->line('sales_amount_tendered'),
|
||||
'comment' => $this->lang->line('reports_comments'),
|
||||
'edit' => ''),
|
||||
'details' => array(
|
||||
$this->lang->line('reports_name'),
|
||||
$this->lang->line('reports_category'),
|
||||
$this->lang->line('reports_serial_number'),
|
||||
$this->lang->line('reports_description'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
'details' => array(
|
||||
$this->lang->line('reports_name'),
|
||||
$this->lang->line('reports_category'),
|
||||
$this->lang->line('reports_serial_number'),
|
||||
$this->lang->line('reports_description'),
|
||||
$this->lang->line('reports_quantity'),
|
||||
$this->lang->line('reports_subtotal'),
|
||||
$this->lang->line('reports_total'),
|
||||
$this->lang->line('reports_tax'),
|
||||
$this->lang->line('reports_cost'),
|
||||
$this->lang->line('reports_profit'),
|
||||
$this->lang->line('reports_discount'))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,18 +58,17 @@ 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 ($inputs['location_id'] != 'all')
|
||||
if($inputs['location_id'] != 'all')
|
||||
{
|
||||
$this->db->where('item_location', $inputs['location_id']);
|
||||
}
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
if($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
}
|
||||
elseif ($inputs['sale_type'] == 'returns')
|
||||
elseif($inputs['sale_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
@@ -93,18 +95,17 @@ 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 ($inputs['location_id'] != 'all')
|
||||
if($inputs['location_id'] != 'all')
|
||||
{
|
||||
$this->db->where('item_location', $inputs['location_id']);
|
||||
}
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
if($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
}
|
||||
elseif ($inputs['sale_type'] == 'returns')
|
||||
elseif($inputs['sale_type'] == 'returns')
|
||||
{
|
||||
$this->db->where('quantity_purchased < 0');
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ class Inventory_low extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Item->create_temp_table();
|
||||
}
|
||||
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array($this->lang->line('reports_item_name'),
|
||||
@@ -21,10 +22,14 @@ class Inventory_low extends Report
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('name, item_number, quantity, reorder_level, location_name');
|
||||
$this->db->from('items_temp');
|
||||
$this->db->where('quantity <= reorder_level');
|
||||
$this->db->order_by('name');
|
||||
$this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name');
|
||||
$this->db->from('items');
|
||||
$this->db->join('item_quantities', 'items.item_id = item_quantities.item_id');
|
||||
$this->db->join('stock_locations', 'item_quantities.location_id = stock_locations.location_id');
|
||||
$this->db->where('items.deleted', 0);
|
||||
$this->db->where('stock_locations.deleted', 0);
|
||||
$this->db->where('item_quantities.quantity <= items.reorder_level');
|
||||
$this->db->order_by('items.name');
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
@@ -5,9 +5,10 @@ class Inventory_summary extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Item->create_temp_table();
|
||||
public function create(array $inputs)
|
||||
{
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -23,26 +24,30 @@ class Inventory_summary extends Report
|
||||
}
|
||||
|
||||
public function getData(array $inputs)
|
||||
{
|
||||
$this->db->select('name, item_number, quantity, reorder_level, location_name, cost_price, unit_price, sub_total_value');
|
||||
$this->db->from('items_temp');
|
||||
{
|
||||
$this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name, items.cost_price, items.unit_price, (items.cost_price * item_quantities.quantity) AS sub_total_value');
|
||||
$this->db->from('items AS items');
|
||||
$this->db->join('item_quantities AS item_quantities', 'items.item_id = item_quantities.item_id');
|
||||
$this->db->join('stock_locations AS stock_locations', 'item_quantities.location_id = stock_locations.location_id');
|
||||
$this->db->where('items.deleted', 0);
|
||||
$this->db->where('stock_locations.deleted', 0);
|
||||
|
||||
// should be corresponding to values Inventory_summary::getItemCountDropdownArray() returns...
|
||||
if($inputs['item_count'] == 'zero_and_less')
|
||||
{
|
||||
$this->db->where('quantity <= 0');
|
||||
$this->db->where('item_quantities.quantity <= 0');
|
||||
}
|
||||
elseif($inputs['item_count'] == 'more_than_zero')
|
||||
{
|
||||
$this->db->where('quantity > 0');
|
||||
$this->db->where('item_quantities.quantity > 0');
|
||||
}
|
||||
|
||||
if($inputs['location_id'] != 'all')
|
||||
{
|
||||
$this->db->where('location_id', $inputs['location_id']);
|
||||
$this->db->where('stock_locations.location_id', $inputs['location_id']);
|
||||
}
|
||||
|
||||
$this->db->order_by('name');
|
||||
$this->db->order_by('items.name');
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,17 @@ abstract class Report extends CI_Model
|
||||
$this->output->set_header('Cache-Control: post-check=0, pre-check=0', FALSE);
|
||||
$this->output->set_header('Pragma: no-cache');
|
||||
}
|
||||
|
||||
//Returns the column names used for the report
|
||||
|
||||
// Create temporary table for fast queries
|
||||
public abstract function create(array $inputs);
|
||||
|
||||
// Returns the column names used for the report
|
||||
public abstract function getDataColumns();
|
||||
|
||||
//Returns all the data to be populated into the report
|
||||
// Returns all the data to be populated into the report
|
||||
public abstract function getData(array $inputs);
|
||||
|
||||
//Returns key=>value pairing of summary data for the report
|
||||
// Returns key=>value pairing of summary data for the report
|
||||
public abstract function getSummaryData(array $inputs);
|
||||
}
|
||||
?>
|
||||
@@ -5,9 +5,12 @@ class Specific_customer extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -21,7 +24,7 @@ class Specific_customer extends Report
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$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']));
|
||||
$this->db->where('customer_id', $inputs['customer_id']);
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
@@ -54,7 +57,7 @@ class Specific_customer extends Report
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$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']));
|
||||
$this->db->where('customer_id', $inputs['customer_id']);
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Specific_discount extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -21,8 +24,8 @@ class Specific_discount extends Report
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, customer_name, SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount']));
|
||||
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
@@ -44,7 +47,6 @@ class Specific_discount extends Report
|
||||
$this->db->select('name, serialnumber, category, description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where('sale_id', $value['sale_id']);
|
||||
$this->db->where('discount_percent >= ', $inputs['discount']);
|
||||
$data['details'][$key] = $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
@@ -55,8 +57,8 @@ class Specific_discount extends Report
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$this->db->where("sale_date BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']) . " AND discount_percent >=" . $this->db->escape($inputs['discount']));
|
||||
|
||||
$this->db->where('discount_percent >=', $inputs['discount']);
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
$this->db->where('quantity_purchased > 0');
|
||||
|
||||
@@ -5,9 +5,12 @@ class Specific_employee extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -21,7 +24,7 @@ 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']));
|
||||
$this->db->where('employee_id', $inputs['employee_id']);
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
@@ -54,7 +57,7 @@ class Specific_employee extends Report
|
||||
{
|
||||
$this->db->select('SUM(subtotal) AS subtotal, SUM(total) AS total, SUM(tax) AS tax, SUM(cost) AS cost, SUM(profit) AS profit');
|
||||
$this->db->from('sales_items_temp');
|
||||
$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']));
|
||||
$this->db->where('employee_id', $inputs['employee_id']);
|
||||
|
||||
if ($inputs['sale_type'] == 'sales')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_categories extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -19,7 +22,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -45,7 +47,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_customers extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -19,7 +22,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -45,7 +47,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_discounts extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -19,7 +22,6 @@ 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']));
|
||||
$this->db->where('discount_percent > 0');
|
||||
|
||||
if ($inputs['location_id'] != 'all')
|
||||
@@ -46,7 +48,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_employees extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -19,7 +22,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -45,7 +47,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,11 +5,14 @@ class Summary_items extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
{
|
||||
return array($this->lang->line('reports_item'), $this->lang->line('reports_quantity'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_cost'), $this->lang->line('reports_profit'));
|
||||
@@ -19,7 +22,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -45,7 +47,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_payments extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -20,7 +23,7 @@ class Summary_payments extends Report
|
||||
$this->db->select('sales_payments.payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount');
|
||||
$this->db->from('sales_payments');
|
||||
$this->db->join('sales', 'sales.sale_id=sales_payments.sale_id');
|
||||
$this->db->where("date(sale_time) BETWEEN " . $this->db->escape($inputs['start_date']) . " AND " . $this->db->escape($inputs['end_date']));
|
||||
$this->db->where('DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
|
||||
|
||||
if ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -67,7 +70,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_sales extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -19,7 +22,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -45,7 +47,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_suppliers extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -21,7 +24,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
@@ -49,7 +51,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ class Summary_taxes extends Report
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
public function create(array $inputs)
|
||||
{
|
||||
//Create our temp tables to work with the data in our report
|
||||
$this->Sale->create_temp_table();
|
||||
$this->Sale->create_temp_table($inputs);
|
||||
}
|
||||
|
||||
public function getDataColumns()
|
||||
@@ -68,7 +71,6 @@ 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 ($inputs['location_id'] != 'all')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user