Added Cost & Count to reports, improved Items suggest, added copyrights and some fixes

Added cost and count to reports

- Added cost in temp table, reports at bottom of page and in each
summary and detailed report
- Added count in all the reports
- Renamed some report fields name to make it generic and consistent
across views
- Fixed few issues here and there
- Adjusted some code indentation

NOTE: Proper translation of word Cost is required in all the languages
but English

Improved Items suggestion

- Added select to restrict results fields
- Added distinct in suppliers instead of the array match
- Added $is_deleted in model part but is not still effective

Add copyright statements in COPYING license file

- Added jekkos and FrancescoUK / daN4cat

Other people that contributed should add their statements.
This commit is contained in:
FrancescoUK
2015-08-17 11:13:04 +01:00
parent 0336fe6298
commit 9f1485cfe5
32 changed files with 196 additions and 126 deletions

View File

@@ -1,6 +1,8 @@
The MIT License (MIT)
Copyright (c) 2014 pappastech
Copyright (c) 2014-2015 jekkos
Copyright (c) 2015 FrancescoUK aka daN4cat
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@@ -88,13 +88,13 @@ class Items extends Secure_area implements iData_controller
*/
function suggest()
{
$suggestions = $this->Item->get_search_suggestions($this->input->post('q'),$this->input->post('limit'));
$suggestions = $this->Item->get_search_suggestions($this->input->post('q'), $this->input->post('limit')/*, $this->input->post('is_deleted')*/); // TODO: is_deleted doesn't seem to be effective...
echo implode("\n",$suggestions);
}
function item_search()
{
$suggestions = $this->Item->get_item_search_suggestions($this->input->post('q'),$this->input->post('limit'),'warehouse');
$suggestions = $this->Item->get_item_search_suggestions($this->input->post('q'), $this->input->post('limit'));
echo implode("\n",$suggestions);
}

View File

@@ -69,6 +69,7 @@ class Reports extends Secure_area
to_currency($report_data['subtotal']),
to_currency($report_data['total']),
to_currency($report_data['tax']),
to_currency($report_data['cost']),
to_currency($report_data['profit']),
$report_data['payment_type'],
$report_data['comment']);
@@ -118,7 +119,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['sale_date'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']));
$tabular_data[] = array($row['sale_date'], $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -143,7 +144,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['category'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']));
$tabular_data[] = array($row['category'], $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -168,7 +169,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['customer'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']));
$tabular_data[] = array($row['customer'], $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -193,7 +194,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['supplier'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']));
$tabular_data[] = array($row['supplier'], $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -218,7 +219,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array(character_limiter($row['name'], 16), $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']));
$tabular_data[] = array(character_limiter($row['name'], 40), $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -243,7 +244,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['employee'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']));
$tabular_data[] = array($row['employee'], $row['quantity_purchased'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']));
}
$data = array(
@@ -268,7 +269,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['percent'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']));
$tabular_data[] = array($row['percent'], $row['count'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']));
}
$data = array(
@@ -293,7 +294,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['discount_percent'],$row['count']);
$tabular_data[] = array($row['discount_percent'], $row['count']);
}
$data = array(
@@ -308,6 +309,7 @@ class Reports extends Secure_area
$this->load->view("reports/tabular",$data);
}
//Summary payments report
function summary_payments($start_date, $end_date, $sale_type, $export_excel=0)
{
$this->load->model('reports/Summary_payments');
@@ -317,7 +319,7 @@ class Reports extends Secure_area
foreach($report_data as $row)
{
$tabular_data[] = array($row['payment_type'],to_currency($row['payment_amount']));
$tabular_data[] = array($row['payment_type'], $row['count'], to_currency($row['payment_amount']));
}
$data = array(
@@ -477,6 +479,7 @@ class Reports extends Secure_area
$this->load->view("reports/graphs/pie",$data);
}
//Graphical summary suppliers report
function graphical_summary_suppliers($start_date, $end_date, $sale_type)
{
$this->load->model('reports/Summary_suppliers');
@@ -513,6 +516,7 @@ class Reports extends Secure_area
$this->load->view("reports/graphs/pie",$data);
}
//Graphical summary employees report
function graphical_summary_employees($start_date, $end_date, $sale_type)
{
$this->load->model('reports/Summary_employees');
@@ -549,6 +553,7 @@ class Reports extends Secure_area
$this->load->view("reports/graphs/pie",$data);
}
//Graphical summary taxes report
function graphical_summary_taxes($start_date, $end_date, $sale_type)
{
$this->load->model('reports/Summary_taxes');
@@ -663,6 +668,7 @@ class Reports extends Secure_area
$this->load->view("reports/graphs/bar",$data);
}
//Graphical summary payments report
function graphical_summary_payments($start_date, $end_date, $sale_type)
{
$this->load->model('reports/Summary_payments');
@@ -700,6 +706,7 @@ class Reports extends Secure_area
$this->load->view("reports/graphs/pie",$data);
}
function specific_customer_input()
{
$data = $this->_get_common_report_data();
@@ -727,11 +734,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
$summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']);
$summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']);
foreach($report_data['details'][$key] as $drow)
{
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),to_currency($drow['profit']), $drow['discount_percent'].'%');
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%');
}
}
@@ -777,11 +784,11 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
$summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']);
$summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']);
foreach($report_data['details'][$key] as $drow)
{
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),to_currency($drow['profit']), $drow['discount_percent'].'%');
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%');
}
}
@@ -831,7 +838,7 @@ class Reports extends Secure_area
foreach($report_data['details'][$key] as $drow)
{
$details_data[$key][] = array($drow['name'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),/*to_currency($drow['profit']),*/ $drow['discount_percent'].'%');
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $drow['quantity_purchased'], to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),/*to_currency($drow['profit']),*/ $drow['discount_percent'].'%');
}
}
@@ -865,7 +872,7 @@ class Reports extends Secure_area
foreach($report_data['summary'] as $key=>$row)
{
$summary_data[] = array(anchor('sales/edit/'.$row['sale_id'] . '/width:'.FORM_WIDTH, 'POS '.$row['sale_id'], array('class' => 'thickbox')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']);
$summary_data[] = array(anchor('sales/edit/'.$row['sale_id'] . '/width:'.FORM_WIDTH, 'POS '.$row['sale_id'], array('class' => 'thickbox')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']), to_currency($row['cost']), to_currency($row['profit']), $row['payment_type'], $row['comment']);
foreach($report_data['details'][$key] as $drow)
{
@@ -874,7 +881,7 @@ class Reports extends Secure_area
{
$quantity_purchased .= ' [' . $this->Stock_locations->get_location_name($drow['item_location']) . ']';
}
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']),to_currency($drow['profit']), $drow['discount_percent'].'%');
$details_data[$key][] = array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['total']), to_currency($drow['tax']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%');
}
}

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Payment Type";
$lang["reports_payments"] = "Payments";
$lang["reports_payments_summary_report"] = "Payments Summary Report";
$lang["reports_profit"] = "Profit";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "Quantity Purchased";
$lang["reports_received_by"] = "Received By";
$lang["reports_receiving_id"] = "Receiving ID";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Tipo de Pago";
$lang["reports_payments"] = "Pagos";
$lang["reports_payments_summary_report"] = "Reporte de Resumen de Pagos";
$lang["reports_profit"] = "Ganancia";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "Cantidad Comprada";
$lang["reports_received_by"] = "Recibido por";
$lang["reports_receiving_id"] = "ID de Recepción";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Type Paiement";
$lang["reports_payments"] = "Paiements";
$lang["reports_payments_summary_report"] = "Rapport: Résumé des Paiements";
$lang["reports_profit"] = "Bénéfice";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "Quantité Achetée";
$lang["reports_received_by"] = "Recu par";
$lang["reports_receiving_id"] = "";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Tipe Pembayaran";
$lang["reports_payments"] = "Pembayaran";
$lang["reports_payments_summary_report"] = "Laporan Ringkasan Pembayaran";
$lang["reports_profit"] = "Keuntungan/Laba";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "Jumlah Dibeli";
$lang["reports_received_by"] = "Diterima Oleh";
$lang["reports_receiving_id"] = "Id Penerima";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Betaald";
$lang["reports_payments"] = "Betalingen";
$lang["reports_payments_summary_report"] = "Overzicht Betalingen";
$lang["reports_profit"] = "Winst";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "Aangekochte Hoeveelheid";
$lang["reports_received_by"] = "Ontvangen door";
$lang["reports_receiving_id"] = "";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Вид оплаты";
$lang["reports_payments"] = "Оплаты";
$lang["reports_payments_summary_report"] = "Платежей Сводный отчет";
$lang["reports_profit"] = "прибыль";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "купенный количество";
$lang["reports_received_by"] = "получило за";
$lang["reports_receiving_id"] = "";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "ชนิดของการจ่าย";
$lang["reports_payments"] = "รายจ่าย";
$lang["reports_payments_summary_report"] = "รายงานสรุปการจ่าย";
$lang["reports_profit"] = "กำไร";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "จำนวนการช์้อ";
$lang["reports_received_by"] = "รับโดย";
$lang["reports_receiving_id"] = "IDรับสินค้า";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "Ödeme Türü";
$lang["reports_payments"] = "Ödemeler";
$lang["reports_payments_summary_report"] = "Ödeme Özet Raporu";
$lang["reports_profit"] = "Kâr";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "Satın Alınan Adet";
$lang["reports_received_by"] = "Alım Yapan";
$lang["reports_receiving_id"] = "Alım No";

View File

@@ -48,6 +48,7 @@ $lang["reports_payment_type"] = "付款方式";
$lang["reports_payments"] = "付款";
$lang["reports_payments_summary_report"] = "收入報告摘要";
$lang["reports_profit"] = "利潤";
$lang["reports_cost"] = "Cost";
$lang["reports_quantity_purchased"] = "銷售金額";
$lang["reports_received_by"] = "收款人";
$lang["reports_receiving_id"] = "";

View File

@@ -141,7 +141,7 @@ class Item extends CI_Model
$this->db->from('items');
$this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
$this->db->where('item_number',$item_number);
$this->db->where('items.deleted',0); // Parq 131226
$this->db->where('items.deleted',0); // Parq 131226
$query = $this->db->get();
@@ -214,13 +214,14 @@ class Item extends CI_Model
/*
Get search suggestions to find items
*/
function get_search_suggestions($search,$limit=25)
function get_search_suggestions($search, $limit=25, $is_deleted=0)
{
$suggestions = array();
$this->db->select('name');
$this->db->from('items');
$this->db->like('name', $search);
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->order_by("name", "asc");
$by_name = $this->db->get();
foreach($by_name->result() as $row)
@@ -230,7 +231,7 @@ class Item extends CI_Model
$this->db->select('category');
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->distinct();
$this->db->like('category', $search);
$this->db->order_by("category", "asc");
@@ -240,9 +241,10 @@ class Item extends CI_Model
$suggestions[]=$row->category;
}
$this->db->select('item_number');
$this->db->from('items');
$this->db->like('item_number', $search);
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->order_by("item_number", "asc");
$by_item_number = $this->db->get();
foreach($by_item_number->result() as $row)
@@ -250,9 +252,11 @@ class Item extends CI_Model
$suggestions[]=$row->item_number;
}
$this->db->select('company_name');
$this->db->from('suppliers');
$this->db->like('company_name', $search);
$this->db->where('deleted', 0);
$this->db->where('deleted', $is_deleted);
$this->db->distinct();
$this->db->order_by("company_name", "asc");
$by_company_name = $this->db->get();
foreach($by_company_name->result() as $row)
@@ -264,9 +268,10 @@ class Item extends CI_Model
/** GARRISON ADDED 4/21/2013 **/
//Search by description
$this->db->select('name, description');
$this->db->from('items');
$this->db->like('description', $search);
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->order_by("description", "asc");
$by_name = $this->db->get();
foreach($by_name->result() as $row)
@@ -291,7 +296,7 @@ class Item extends CI_Model
$this->db->or_like('custom8', $search);
$this->db->or_like('custom9', $search);
$this->db->or_like('custom10', $search);
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->order_by("name", "asc");
$by_name = $this->db->get();
foreach($by_name->result() as $row)
@@ -303,18 +308,19 @@ class Item extends CI_Model
//only return $limit suggestions
if(count($suggestions > $limit))
{
$suggestions = array_slice($suggestions, 0,$limit);
$suggestions = array_slice($suggestions, 0, $limit);
}
return $suggestions;
return $suggestions;
}
function get_item_search_suggestions($search,$limit=25)
function get_item_search_suggestions($search, $limit=25, $is_deleted=0)
{
$suggestions = array();
$this->db->select('item_id, name');
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->like('name', $search);
$this->db->order_by("name", "asc");
$by_name = $this->db->get();
@@ -323,8 +329,9 @@ class Item extends CI_Model
$suggestions[]=$row->item_id.'|'.$row->name;
}
$this->db->select('item_id, item_number');
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->like('item_number', $search);
$this->db->order_by("item_number", "asc");
$by_item_number = $this->db->get();
@@ -334,8 +341,9 @@ class Item extends CI_Model
}
/** GARRISON ADDED 4/21/2013 **/
//Search by description
$this->db->select('item_id, name, description');
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->like('description', $search);
$this->db->order_by("description", "asc");
$by_description = $this->db->get();
@@ -352,7 +360,7 @@ class Item extends CI_Model
/** GARRISON ADDED 4/22/2013 **/
//Search by custom fields
/* $this->db->from('items');
$this->db->where('deleted',0);
$this->db->where('deleted', $is_deleted);
$this->db->like('custom1', $search);
$this->db->or_like('custom2', $search);
$this->db->or_like('custom3', $search);
@@ -376,6 +384,7 @@ class Item extends CI_Model
{
$suggestions = array_slice($suggestions, 0,$limit);
}
return $suggestions;
}

View File

@@ -219,7 +219,8 @@ class Receiving extends CI_Model
item_cost_price, item_unit_price, discount_percent, (item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as subtotal,
".$this->db->dbprefix('receivings_items').".line as line, serialnumber, ".$this->db->dbprefix('receivings_items').".description as description,
(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) as total,
(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) - (item_cost_price*quantity_purchased) as profit
(item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100) - (item_cost_price*quantity_purchased) as profit,
(item_cost_price*quantity_purchased) as cost
FROM ".$this->db->dbprefix('receivings_items')."
INNER JOIN ".$this->db->dbprefix('receivings')." ON ".$this->db->dbprefix('receivings_items').'.receiving_id='.$this->db->dbprefix('receivings').'.receiving_id'."
INNER JOIN ".$this->db->dbprefix('items')." ON ".$this->db->dbprefix('receivings_items').'.item_id='.$this->db->dbprefix('items').'.item_id'."

View File

@@ -9,18 +9,19 @@ class Detailed_receivings extends Report
public function getDataColumns()
{
return array('summary' => array($this->lang->line('reports_receiving_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_received'), $this->lang->line('reports_received_by'), $this->lang->line('reports_supplied_by'), $this->lang->line('reports_total'), $this->lang->line('reports_payment_type'), $this->lang->line('recvs_invoice_number'), $this->lang->line('reports_comments')),
'details' => array($this->lang->line('reports_item_number'), $this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_quantity_purchased'), $this->lang->line('reports_total'), $this->lang->line('reports_discount'))
return array('summary' => array($this->lang->line('reports_receiving_id'), $this->lang->line('reports_date'), $this->lang->line('reports_count'), $this->lang->line('reports_received_by'), $this->lang->line('reports_supplied_by'), $this->lang->line('reports_total'), $this->lang->line('reports_payment_type'), $this->lang->line('recvs_invoice_number'), $this->lang->line('reports_comments')),
'details' => array($this->lang->line('reports_item_number'), $this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_count'), $this->lang->line('reports_total'), $this->lang->line('reports_discount'))
);
}
public function getDataByReceivingId($receiving_id)
{
$this->db->select('receiving_id, DATE_FORMAT(receiving_date, "%d-%m-%Y") AS receiving_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name," ",employee.last_name) as employee_name, suppliers.company_name as supplier_name, sum(subtotal) as subtotal, sum(total) as total, sum(profit) as profit, payment_type, comment, invoice_number', false);
$this->db->select('receiving_id, DATE_FORMAT(receiving_date, "%d-%m-%Y") AS receiving_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name, " ", employee.last_name) as employee_name, suppliers.company_name as supplier_name, sum(subtotal) as subtotal, sum(total) as total, sum(profit) as profit, payment_type, comment, invoice_number', false);
$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 suppliers', 'receivings_items_temp.supplier_id = suppliers.person_id', 'left');
$this->db->where('receiving_id', $receiving_id);
return $this->db->get()->row_array();
}
@@ -72,6 +73,7 @@ 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')
{
$this->db->where('item_location', $inputs['location_id']);

View File

@@ -9,32 +9,35 @@ class Detailed_sales extends Report
public function getDataColumns()
{
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_purchased'), $this->lang->line('reports_sold_by'), $this->lang->line('reports_sold_to'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'), $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
'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_purchased'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'),$this->lang->line('reports_discount'))
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_count'), $this->lang->line('reports_sold_by'), $this->lang->line('reports_sold_to'), $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_payment_type'), $this->lang->line('reports_comments')),
'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_count'), $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'))
);
}
public function getDataBySaleId($sale_id)
{
$this->db->select('sale_id, DATE_FORMAT(sale_time, "%d-%m-%Y") AS sale_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name," ",employee.last_name) as employee_name, CONCAT(customer.first_name," ",customer.last_name) as customer_name, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit, payment_type, comment', false);
$this->db->select('sale_id, DATE_FORMAT(sale_time, "%d-%m-%Y") AS sale_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name, " ", employee.last_name) as employee_name, CONCAT(customer.first_name," ",customer.last_name) as 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', false);
$this->db->from('sales_items_temp');
$this->db->join('people as employee', 'sales_items_temp.employee_id = employee.person_id');
$this->db->join('people as customer', 'sales_items_temp.customer_id = customer.person_id', 'left');
$this->db->where('sale_id', $sale_id);
return $this->db->get()->row_array();
}
public function getData(array $inputs)
{
$this->db->select('sale_id, sale_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name," ",employee.last_name) as employee_name, CONCAT(customer.first_name," ",customer.last_name) as customer_name, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit, payment_type, comment', false);
$this->db->select('sale_id, sale_date, sum(quantity_purchased) as items_purchased, CONCAT(employee.first_name," ",employee.last_name) as employee_name, CONCAT(customer.first_name," ",customer.last_name) as 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', false);
$this->db->from('sales_items_temp');
$this->db->join('people as employee', 'sales_items_temp.employee_id = employee.person_id');
$this->db->join('people as customer', 'sales_items_temp.customer_id = customer.person_id', 'left');
$this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' and '. $this->db->escape($inputs['end_date']));
if ($inputs['location_id'] != 'all')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -42,7 +45,8 @@ class Detailed_sales extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('sale_id');
$this->db->order_by('sale_date');
@@ -52,7 +56,7 @@ class Detailed_sales extends Report
foreach($data['summary'] as $key=>$value)
{
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, sales_items_temp.description, subtotal,total, tax, profit, discount_percent');
$this->db->select('name, category, quantity_purchased, item_location, serialnumber, sales_items_temp.description, subtotal, total, tax, cost, profit, discount_percent');
$this->db->from('sales_items_temp');
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_id', $value['sale_id']);
@@ -64,13 +68,15 @@ class Detailed_sales extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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')
{
$this->db->where('item_location', $inputs['location_id']);
}
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -78,8 +84,8 @@ class Detailed_sales extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -17,16 +17,12 @@ class Inventory_low extends Report
$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->select('name, item_number, reorder_level, item_quantities.quantity,description,location_name');
$this->db->select('name, item_number, reorder_level, item_quantities.quantity, description, location_name');
$this->db->where('item_quantities.quantity <= reorder_level');
$this->db->where('items.deleted = 0');
$this->db->where('items.deleted', 0);
$this->db->order_by('name');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)

View File

@@ -9,21 +9,19 @@ class Inventory_summary extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'),$this->lang->line('reports_stock_location'));
return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'), $this->lang->line('reports_stock_location'));
}
public function getData(array $inputs)
{
$this->db->from('items');
$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->select('name, item_number, reorder_level, item_quantities.quantity, description,location_name');
$this->db->where('items.deleted', 0);
$this->db->order_by('items.name');
return $this->db->get()->result_array();
$this->db->select('name, item_number, reorder_level, item_quantities.quantity, description, location_name');
$this->db->where('items.deleted', 0);
$this->db->order_by('name');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)

View File

@@ -9,17 +9,18 @@ class Specific_customer extends Report
public function getDataColumns()
{
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_purchased'), $this->lang->line('reports_sold_by'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'), $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
'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_purchased'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'),$this->lang->line('reports_discount'))
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_count'), $this->lang->line('reports_sold_by'), $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_payment_type'), $this->lang->line('reports_comments')),
'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_count'), $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'))
);
}
public function getData(array $inputs)
{
$this->db->select('sale_id, sale_date, sum(quantity_purchased) as items_purchased, CONCAT(first_name," ",last_name) as employee_name, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit, payment_type, comment', false);
$this->db->select('sale_id, sale_date, sum(quantity_purchased) as items_purchased, CONCAT(first_name, " ", last_name) as 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', false);
$this->db->from('sales_items_temp');
$this->db->join('people', 'sales_items_temp.employee_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -27,7 +28,8 @@ class Specific_customer extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('sale_id');
$this->db->order_by('sale_date');
@@ -37,21 +39,22 @@ class Specific_customer extends Report
foreach($data['summary'] as $key=>$value)
{
$this->db->select('name, category, serialnumber, sales_items_temp.description, quantity_purchased, subtotal,total, tax, profit, discount_percent');
$this->db->select('name, category, serialnumber, sales_items_temp.description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
$this->db->from('sales_items_temp');
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_id = '.$value['sale_id']);
$data['details'][$key] = $this->db->get()->result_array();
}
return $data;
}
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and customer_id='.$inputs['customer_id']);
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -59,7 +62,8 @@ class Specific_customer extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,14 +9,14 @@ class Specific_discount extends Report
public function getDataColumns()
{
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_purchased'), $this->lang->line('reports_customer'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), /*$this->lang->line('reports_profit'),*/ $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
'details' => array($this->lang->line('reports_name'), $this->lang->line('reports_category'), $this->lang->line('reports_description'), $this->lang->line('reports_quantity_purchased'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), /*$this->lang->line('reports_profit'),*/$this->lang->line('reports_discount'))
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_count'), $this->lang->line('reports_sold_to'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), /*$this->lang->line('reports_profit'),*/ $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
'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_count'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), /*$this->lang->line('reports_profit'),*/ $this->lang->line('reports_discount'))
);
}
public function getData(array $inputs)
{
$this->db->select('sale_id, DATE_FORMAT(sale_time, "%d-%m-%Y") AS sale_date, sum(quantity_purchased) as items_purchased, CONCAT(first_name," ",last_name) as customer_name, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit, payment_type, comment', false);
$this->db->select('sale_id, DATE_FORMAT(sale_time, "%d-%m-%Y") AS sale_date, sum(quantity_purchased) as items_purchased, CONCAT(first_name, " ", last_name) as 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', false);
$this->db->from('sales_items_temp');
$this->db->join('people as customer', 'sales_items_temp.customer_id = customer.person_id', 'left');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and discount_percent >='.$inputs['discount']);
@@ -39,19 +39,19 @@ class Specific_discount extends Report
foreach($data['summary'] as $key=>$value)
{
$this->db->select('name, serialnumber, category, sales_items_temp.description, quantity_purchased, subtotal,total, tax, profit, discount_percent');
$this->db->select('name, serialnumber, category, sales_items_temp.description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
$this->db->from('sales_items_temp');
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_id = '.$value['sale_id'] . " AND discount_percent >= " . $inputs['discount']);
$data['details'][$key] = $this->db->get()->result_array();
}
return $data;
}
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and discount_percent >= '.$inputs['discount']);
@@ -63,7 +63,7 @@ class Specific_discount extends Report
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,14 +9,14 @@ class Specific_employee extends Report
public function getDataColumns()
{
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_items_purchased'), $this->lang->line('reports_sold_to'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'), $this->lang->line('reports_payment_type'), $this->lang->line('reports_comments')),
'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_purchased'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'),$this->lang->line('reports_discount'))
return array('summary' => array($this->lang->line('reports_sale_id'), $this->lang->line('reports_date'), $this->lang->line('reports_count'), $this->lang->line('reports_sold_to'), $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_payment_type'), $this->lang->line('reports_comments')),
'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_count'), $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'))
);
}
public function getData(array $inputs)
{
$this->db->select('sale_id, sale_date, sum(quantity_purchased) as items_purchased, CONCAT(first_name," ",last_name) as customer_name, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit, payment_type, comment', false);
$this->db->select('sale_id, sale_date, sum(quantity_purchased) as items_purchased, CONCAT(first_name, " ", last_name) as 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', false);
$this->db->from('sales_items_temp');
$this->db->join('people', 'sales_items_temp.customer_id = people.person_id', 'left');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and employee_id='.$inputs['employee_id']);
@@ -39,7 +39,7 @@ class Specific_employee extends Report
foreach($data['summary'] as $key=>$value)
{
$this->db->select('name, category, serialnumber, sales_items_temp.description, quantity_purchased, subtotal,total, tax, profit, discount_percent');
$this->db->select('name, category, serialnumber, sales_items_temp.description, quantity_purchased, subtotal, total, tax, cost, profit, discount_percent');
$this->db->from('sales_items_temp');
$this->db->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_id = '.$value['sale_id']);
@@ -51,9 +51,10 @@ class Specific_employee extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and employee_id='.$inputs['employee_id']);
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -61,7 +62,8 @@ class Specific_employee extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,15 +9,16 @@ class Summary_categories extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_category'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'));
return array($this->lang->line('reports_category'), $this->lang->line('reports_count'), $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'));
}
public function getData(array $inputs)
{
$this->db->select('category, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -25,7 +26,8 @@ class Summary_categories extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('category');
$this->db->order_by('category');
@@ -34,10 +36,11 @@ class Summary_categories extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');

View File

@@ -9,16 +9,17 @@ class Summary_customers extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_customer'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'));
return array($this->lang->line('reports_customer'), $this->lang->line('reports_count'), $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'));
}
public function getData(array $inputs)
{
$this->db->select('CONCAT(first_name, " ",last_name) as customer, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax,sum(profit) as profit', false);
$this->db->select('CONCAT(first_name, " ",last_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', false);
$this->db->from('sales_items_temp');
$this->db->join('customers', 'customers.person_id = sales_items_temp.customer_id');
$this->db->join('people', 'customers.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -26,7 +27,8 @@ class Summary_customers extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('customer_id');
$this->db->order_by('last_name');
@@ -35,11 +37,12 @@ class Summary_customers extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('customers', 'customers.person_id = sales_items_temp.customer_id');
$this->db->join('people', 'customers.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -47,7 +50,8 @@ class Summary_customers extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,7 +9,7 @@ class Summary_discounts extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_discount_percent'),$this->lang->line('reports_count'));
return array($this->lang->line('reports_discount_percent'), $this->lang->line('reports_count'));
}
public function getData(array $inputs)
@@ -17,6 +17,7 @@ class Summary_discounts extends Report
$this->db->select('CONCAT(discount_percent, "%") as discount_percent, count(*) as count', false);
$this->db->from('sales_items_temp');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'" and discount_percent > 0');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -24,17 +25,20 @@ class Summary_discounts extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('sales_items_temp.discount_percent');
$this->db->order_by('discount_percent');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax,sum(profit) as profit');
$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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -42,7 +46,8 @@ class Summary_discounts extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,16 +9,17 @@ class Summary_employees extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_employee'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'));
return array($this->lang->line('reports_employee'), $this->lang->line('reports_count'), $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'));
}
public function getData(array $inputs)
{
$this->db->select('CONCAT(first_name, " ",last_name) as employee, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit', false);
$this->db->select('CONCAT(first_name, " ", last_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', false);
$this->db->from('sales_items_temp');
$this->db->join('employees', 'employees.person_id = sales_items_temp.employee_id');
$this->db->join('people', 'employees.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -26,7 +27,8 @@ class Summary_employees extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('employee_id');
$this->db->order_by('last_name');
@@ -35,11 +37,12 @@ class Summary_employees extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('employees', 'employees.person_id = sales_items_temp.employee_id');
$this->db->join('people', 'employees.person_id = people.person_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');

View File

@@ -9,15 +9,16 @@ class Summary_items extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_item'),$this->lang->line('reports_quantity_purchased'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'),$this->lang->line('reports_profit'));
return array($this->lang->line('reports_item'), $this->lang->line('reports_count'), $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'));
}
public function getData(array $inputs)
{
$this->db->select('name, sum(quantity_purchased) as quantity_purchased, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -25,7 +26,8 @@ class Summary_items extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('items.item_id');
$this->db->order_by('name');
@@ -34,10 +36,11 @@ class Summary_items extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -45,7 +48,8 @@ class Summary_items extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,15 +9,16 @@ class Summary_payments extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_payment_type'), $this->lang->line('reports_total'));
return array($this->lang->line('reports_payment_type'), $this->lang->line('reports_count'), $this->lang->line('reports_total'));
}
public function getData(array $inputs)
{
$this->db->select('sales_payments.payment_type, SUM(payment_amount) as payment_amount', false);
$this->db->select('sales_payments.payment_type, count(*) as count, sum(payment_amount) as payment_amount', false);
$this->db->from('sales_payments');
$this->db->join('sales', 'sales.sale_id=sales_payments.sale_id');
$this->db->where('date(sale_time) BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('payment_amount > 0');
@@ -25,17 +26,20 @@ class Summary_payments extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('payment_amount < 0');
}
}
$this->db->group_by("payment_type");
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -43,7 +47,8 @@ class Summary_payments extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,13 +9,14 @@ class Summary_sales extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_date'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'));
return array($this->lang->line('reports_date'), $this->lang->line('reports_count'), $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'));
}
public function getData(array $inputs)
{
$this->db->select('sale_date, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax,sum(profit) as profit');
$this->db->select('sale_date, sum(quantity_purchased) as quantity_purchased, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(cost) as cost, sum(profit) as profit');
$this->db->from('sales_items_temp');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -28,14 +29,16 @@ class Summary_sales extends Report
$this->db->group_by('sale_date');
$this->db->having('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
$this->db->order_by('sale_date');
return $this->db->get()->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax,sum(profit) as profit');
$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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -43,7 +46,8 @@ class Summary_sales extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}

View File

@@ -9,16 +9,17 @@ class Summary_suppliers extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_supplier'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'), $this->lang->line('reports_profit'));
return array($this->lang->line('reports_supplier'), $this->lang->line('reports_count'), $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'));
}
public function getData(array $inputs)
{
$this->db->select('CONCAT(company_name, " (", first_name, " ",last_name, ")") as supplier, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax,sum(profit) as profit', false);
$this->db->select('CONCAT(company_name, " (", first_name, " ",last_name, ")") as supplier, 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', false);
$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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -26,7 +27,8 @@ class Summary_suppliers extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
$this->db->group_by('supplier_id');
$this->db->order_by('last_name');
@@ -35,11 +37,12 @@ class Summary_suppliers extends Report
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->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 "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
if ($inputs['sale_type'] == 'sales')
{
$this->db->where('quantity_purchased > 0');
@@ -47,7 +50,8 @@ class Summary_suppliers extends Report
elseif ($inputs['sale_type'] == 'returns')
{
$this->db->where('quantity_purchased < 0');
}
}
return $this->db->get()->row_array();
}
}

View File

@@ -9,12 +9,11 @@ class Summary_taxes extends Report
public function getDataColumns()
{
return array($this->lang->line('reports_tax_percent'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'));
return array($this->lang->line('reports_tax_percent'), $this->lang->line('reports_count'), $this->lang->line('reports_subtotal'), $this->lang->line('reports_total'), $this->lang->line('reports_tax'));
}
public function getData(array $inputs)
{
$quantity_cond = '';
if ($inputs['sale_type'] == 'sales')
{
@@ -38,7 +37,7 @@ class Summary_taxes extends Report
$subtotal = "1";
}
$query = $this->db->query("SELECT percent, SUM(subtotal) as subtotal, sum(total) as total, sum(tax) as tax
$query = $this->db->query("SELECT percent, count(*) as count, sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax
FROM (SELECT name, CONCAT( percent, '%' ) AS percent,
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $subtotal, 2) AS subtotal,
ROUND((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent /100) * $total, 2) AS total,
@@ -51,12 +50,13 @@ class Summary_taxes extends Report
." JOIN ".$this->db->dbprefix('sales')." ON ".$this->db->dbprefix('sales_items_taxes').".sale_id=".$this->db->dbprefix('sales').".sale_id
WHERE date(sale_time) BETWEEN '".$inputs['start_date']."' and '".$inputs['end_date']."' $quantity_cond) as temp_taxes
GROUP BY percent");
return $query->result_array();
}
public function getSummaryData(array $inputs)
{
$this->db->select('sum(subtotal) as subtotal, sum(total) as total, sum(tax) as tax, sum(profit) as profit');
$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->join('items', 'sales_items_temp.item_id = items.item_id');
$this->db->where('sale_date BETWEEN "'. $inputs['start_date']. '" and "'. $inputs['end_date'].'"');
@@ -69,8 +69,7 @@ class Summary_taxes extends Report
{
$this->db->where('quantity_purchased < 0');
}
return $this->db->get()->row_array();
}
}

View File

@@ -402,7 +402,8 @@ class Sale extends CI_Model
".$this->db->dbprefix('sales_items').".line as line, serialnumber, ".$this->db->dbprefix('sales_items').".description as description,
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$total, 2) as total,
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)*$tax, 2) as tax,
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)- (item_cost_price*quantity_purchased), 2) as profit
ROUND((item_unit_price*quantity_purchased-item_unit_price*quantity_purchased*discount_percent/100)- (item_cost_price*quantity_purchased), 2) as profit,
(item_cost_price*quantity_purchased) as cost
FROM ".$this->db->dbprefix('sales_items')."
INNER JOIN ".$this->db->dbprefix('sales')." ON ".$this->db->dbprefix('sales_items').'.sale_id='.$this->db->dbprefix('sales').'.sale_id'."
INNER JOIN ".$this->db->dbprefix('items')." ON ".$this->db->dbprefix('sales_items').'.item_id='.$this->db->dbprefix('items').'.item_id'."
@@ -416,7 +417,8 @@ class Sale extends CI_Model
.$this->db->dbprefix('sales_items').'.line='.$this->db->dbprefix('sales_items_taxes').'.line'."
GROUP BY sale_id, item_id, line)");
//Update null item_tax_percents to be 0 instead of null$this->db->where('item_tax_percent IS NULL');
//Update null item_tax_percents to be 0 instead of null
$this->db->where('item_tax_percent IS NULL');
$this->db->update('sales_items_temp', array('item_tax_percent' => 0));
//Update null tax to be 0 instead of null

View File

@@ -47,6 +47,7 @@ reports_payment_type,Betaald,Tipo de Pago,Payment Type,Type Paiement,付款方
reports_payments,Betalingen,Pagos,Payments,Paiements,付款,Оплаты,รายจ่าย,Ödemeler,Pembayaran
reports_payments_summary_report,Overzicht Betalingen,Reporte de Resumen de Pagos,Payments Summary Report,Rapport: Résumé des Paiements,收入報告摘要,Платежей Сводный отчет,รายงานสรุปการจ่าย,Ödeme Özet Raporu,Laporan Ringkasan Pembayaran
reports_profit,Winst,Ganancia,Profit,Bénéfice,利潤,прибыль,กำไร,Kâr,Keuntungan/Laba
reports_cost,Cost,Cost,Cost,Cost,Cost,Cost,Cost
reports_quantity_purchased,Aangekochte Hoeveelheid,Cantidad Comprada,Quantity Purchased,Quantité Achetée,銷售金額,купенный количество,จำนวนการช์้อ,Satın Alınan Adet,Jumlah Dibeli
reports_received_by,Ontvangen door,Recibido por,Received By,Recu par,收款人,получило за,รับโดย,Alım Yapan,Diterima Oleh
reports_receiving_id,,ID de Recepción,Receiving ID,,,,IDรับสินค้า,Alım No,Id Penerima
1 label nl-BE es en fr zh ru th tr id
47 reports_payments Betalingen Pagos Payments Paiements 付款 Оплаты รายจ่าย Ödemeler Pembayaran
48 reports_payments_summary_report Overzicht Betalingen Reporte de Resumen de Pagos Payments Summary Report Rapport: Résumé des Paiements 收入報告摘要 Платежей Сводный отчет รายงานสรุปการจ่าย Ödeme Özet Raporu Laporan Ringkasan Pembayaran
49 reports_profit Winst Ganancia Profit Bénéfice 利潤 прибыль กำไร Kâr Keuntungan/Laba
50 reports_cost Cost Cost Cost Cost Cost Cost Cost
51 reports_quantity_purchased Aangekochte Hoeveelheid Cantidad Comprada Quantity Purchased Quantité Achetée 銷售金額 купенный количество จำนวนการช์้อ Satın Alınan Adet Jumlah Dibeli
52 reports_received_by Ontvangen door Recibido por Received By Recu par 收款人 получило за รับโดย Alım Yapan Diterima Oleh
53 reports_receiving_id ID de Recepción Receiving ID IDรับสินค้า Alım No Id Penerima