- Added cash only filter

- Set to 'all' the sale_type so even returns are shown (we might want to add a drop down filter for this too)
This commit is contained in:
FrancescoUK
2015-09-04 19:30:43 +01:00
parent 852f83a8f6
commit d35ef071bb
14 changed files with 44 additions and 11 deletions

View File

@@ -43,6 +43,7 @@ $route['no_access/(:any)'] = "no_access/index/$1";
$route['no_access/(:any)/(:any)'] = "no_access/index/$1/$2";
$route['sales/index/(:any)'] = "sales/manage/$1";
$route['sales/index/(:any)/(:any)'] = "sales/manage/$1/$2";
$route['sales/index/(:any)/(:any)/(:any)'] = "sales/manage/$1/$2/$3";
$route['reports/(summary_:any)/(:any)/(:any)'] = "reports/$1/$2/$3";
$route['reports/summary_:any'] = "reports/date_input_excel_export";
$route['reports/(graphical_:any)/(:any)/(:any)'] = "reports/$1/$2/$3";

View File

@@ -15,7 +15,7 @@ class Sales extends Secure_area
$this->_reload();
}
function manage($only_invoices = FALSE, $limit_from = 0)
function manage($only_invoices = FALSE, $only_cash = FALSE, $limit_from = 0)
{
$data['controller_name'] = strtolower($this->uri->segment(1));
$data['only_invoices'] = array($this->lang->line('sales_no_filter'), $this->lang->line('sales_invoice'));
@@ -26,11 +26,13 @@ class Sales extends Secure_area
$yesterday = date('Y-m-d', mktime(0,0,0,date("m"),date("d")-1,date("Y")));
$start_of_time = date('Y-m-d', 0);
$sale_type = 'sales';
$sale_type = 'all';
$location_id = 'all';
$report_data = $this->Sale->get_data(array('start_date' => $yesterday, 'end_date' => $today, 'sale_type' => $sale_type, 'location_id' => $location_id,
'only_invoices' => $only_invoices, 'lines_per_page' => $lines_per_page, 'limit_from' => $limit_from));
$report_data = $this->Sale->get_data(array('start_date' => $start_of_time, 'end_date' => $today,
'sale_type' => $sale_type, 'location_id' => $location_id,
'only_invoices' => $only_invoices, 'only_cash' => $only_cash,
'lines_per_page' => $lines_per_page, 'limit_from' => $limit_from));
$data['only_invoices'] = $only_invoices;
$data['links'] = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, count($report_data['sales']), 'manage', $only_invoices);
@@ -61,20 +63,23 @@ class Sales extends Secure_area
function search()
{
$only_invoices = $this->input->post('only_invoices', TRUE);
$only_cash = $this->input->post('only_cash', TRUE);
$lines_per_page = $this->Appconfig->get('lines_per_page');
$limit_from = $this->input->post('limit_from', TRUE);
$sale_type = 'sales';
$sale_type = 'all';
$location_id = 'all';
$today = date('Y-m-d');
$yesterday = date('Y-m-d', mktime(0,0,0,date("m"),date("d")-1,date("Y")));
$start_of_time = date('Y-m-d', 0);
$report_data = $this->Sale->get_data(array('sale_type' => $sale_type, 'location_id' => $location_id,
'start_date' => $yesterday, 'end_date' => $today, 'only_invoices' => $only_invoices,
'lines_per_page' => $lines_per_page, 'limit_from' => $limit_from));
$report_data = $this->Sale->get_data(array('start_date' => $start_of_time, 'end_date' => $today,
'sale_type' => $sale_type, 'location_id' => $location_id,
'only_invoices' => $only_invoices, 'only_cash' => $only_cash,
'lines_per_page' => $lines_per_page, 'limit_from' => $limit_from));
$total_rows = count($report_data['sales']);
$links = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, $total_rows, 'search', $only_invoices);
$data_rows=get_sales_manage_table_data_rows($report_data['sales'], $this);
$data_rows = get_sales_manage_table_data_rows($report_data['sales'], $this);
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
$this->_remove_duplicate_cookies();
}

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Invoice #";
$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "tarjeta de Crédito";
$lang["sales_invoice_confirm"] = "Esta factura sera enviada a";
$lang["sales_invoice_enable"] = "Crear factura";
$lang["sales_invoice_filter"] = "Facturas";
$lang["sales_cash_filter"] = "Efectivo";
$lang["sales_invoice_no_email"] = "Este cliente no tiene un email válido";
$lang["sales_invoice_number"] = "Factura #";
$lang["sales_invoice_number_duplicate"] = "Por favor ingrese un número de factura único";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Invoice #";
$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Nomor Nota";
$lang["sales_invoice_number_duplicate"] = "Nomor Nota Double";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Factuur";
$lang["sales_invoice_confirm"] = "Deze factuur zal verstuurd worden naar";
$lang["sales_invoice_enable"] = "Maak Factuur";
$lang["sales_invoice_filter"] = "Facturen";
$lang["sales_cash_filter"] = "Contant";
$lang["sales_invoice_no_email"] = "Er werd geen email adres gevonden voor deze klant";
$lang["sales_invoice_number"] = "Factuur #";
$lang["sales_invoice_number_duplicate"] = "Vul een unieke nummer in";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Invoice #";
$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Invoice #";
$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Invoice #";
$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number";

View File

@@ -47,6 +47,7 @@ $lang["sales_invoice"] = "Invoice";
$lang["sales_invoice_confirm"] = "This invoice will be sent to";
$lang["sales_invoice_enable"] = "Create Invoice";
$lang["sales_invoice_filter"] = "Invoices";
$lang["sales_cash_filter"] = "Cash";
$lang["sales_invoice_no_email"] = "This customer does not have a valid email address";
$lang["sales_invoice_number"] = "Invoice #";
$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number";

View File

@@ -48,6 +48,11 @@ class Sale extends CI_Model
$this->db->where('invoice_number <> ', 'NULL');
}
if ($inputs['only_cash'] != FALSE)
{
$this->db->where('payment_type LIKE ', $this->lang->line('sales_cash') . '%');
}
$this->db->group_by('sale_id');
$this->db->order_by('sale_date', 'desc');
@@ -60,7 +65,7 @@ class Sale extends CI_Model
$data['sales'] = $this->db->get()->result_array();
// get payment summary
$this->db->select('sales_payments.payment_type, count(*) as count, 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_items_temp', 'sales_items_temp.sale_id=sales_payments.sale_id');
$this->db->where('date(sale_time) BETWEEN "'. $inputs['start_date']. '" AND "'. $inputs['end_date'].'"');
@@ -78,6 +83,11 @@ class Sale extends CI_Model
{
$this->db->where('invoice_number <> ', 'NULL');
}
if ($inputs['only_cash'] != FALSE)
{
$this->db->where('sales_payments.payment_type LIKE ', $this->lang->line('sales_cash') . '%');
}
$this->db->group_by("payment_type");

View File

@@ -13,6 +13,11 @@ $(document).ready(function()
$('#search_form').submit();
return false;
});
$("#search_filter_section #only_cash").change(function() {
$('#search_form').submit();
return false;
});
var show_renumber = function() {
var value = $("#only_invoices").val();
@@ -149,8 +154,10 @@ function init_table_sorting()
</div>
<?php echo form_open("$controller_name/search",array('id'=>'search_form')); ?>
<div id="search_filter_section" style="display: <?php echo isset($search_section_state)? ( ($search_section_state)? 'block' : 'none') : 'none';?>;background-color:#EEEEEE;">
<?php echo form_label($this->lang->line('sales_invoice_filter').' '.':', 'invoices_filter');?>
<?php echo form_label($this->lang->line('sales_invoice_filter').' '.':', 'invoices_filter');?>
<?php echo form_checkbox(array('name'=>'only_invoices','id'=>'only_invoices','value'=>1,'checked'=> isset($only_invoices)? ( ($only_invoices)? 1 : 0) : 0));?>
<?php echo form_label($this->lang->line('sales_cash_filter').' '.':', 'cash_filter');?>
<?php echo form_checkbox(array('name'=>'only_cash','id'=>'only_cash','value'=>1,'checked'=> isset($only_cash)? ( ($only_cash)? 1 : 0) : 0));?>
<input type="hidden" name="search_section_state" id="search_section_state" value="<?php echo isset($search_section_state)? ( ($search_section_state)? 'block' : 'none') : 'none';?>" />
</div>
<div id="table_action_header">

View File

@@ -46,6 +46,7 @@ sales_invoice,Factuur,tarjeta de Crédito,Invoice,Invoice,Invoice,Invoice,Invoic
sales_invoice_confirm,Deze factuur zal verstuurd worden naar,Esta factura sera enviada a,This invoice will be sent to,This invoice will be sent to,This invoice will be sent to,This invoice will be sent to,This invoice will be sent to,This invoice will be sent to,This invoice will be sent to
sales_invoice_enable,Maak Factuur,Crear factura,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Create Invoice,Create Invoice
sales_invoice_filter,Facturen,Facturas,Invoices,Invoices,Invoices,Invoices,Invoices,Invoices,Invoices
sales_cash_filter,Contant,Efectivo,Cash,Cash,Cash,Cash,Cash,Cash,Cash
sales_invoice_no_email,Er werd geen email adres gevonden voor deze klant,Este cliente no tiene un email válido,This customer does not have a valid email address,This customer does not have a valid email address,This customer does not have a valid email address,This customer does not have a valid email address,This customer does not have a valid email address,This customer does not have a valid email address,This customer does not have a valid email address
sales_invoice_number,Factuur #,Factura #,Invoice #,Invoice #,Invoice #,Invoice #,Invoice #,Invoice #,Nomor Nota
sales_invoice_number_duplicate,Vul een unieke nummer in,Por favor ingrese un número de factura único,Please enter an unique invoice number,Please enter an unique invoice number,Please enter an unique invoice number,Please enter an unique invoice number,Please enter an unique invoice number,Please enter an unique invoice number,Nomor Nota Double
1 label nl-BE es en fr zh ru th tr id
46 sales_invoice_confirm Deze factuur zal verstuurd worden naar Esta factura sera enviada a This invoice will be sent to This invoice will be sent to This invoice will be sent to This invoice will be sent to This invoice will be sent to This invoice will be sent to This invoice will be sent to
47 sales_invoice_enable Maak Factuur Crear factura Create Invoice Create Invoice Create Invoice Create Invoice Create Invoice Create Invoice Create Invoice
48 sales_invoice_filter Facturen Facturas Invoices Invoices Invoices Invoices Invoices Invoices Invoices
49 sales_cash_filter Contant Efectivo Cash Cash Cash Cash Cash Cash Cash
50 sales_invoice_no_email Er werd geen email adres gevonden voor deze klant Este cliente no tiene un email válido This customer does not have a valid email address This customer does not have a valid email address This customer does not have a valid email address This customer does not have a valid email address This customer does not have a valid email address This customer does not have a valid email address This customer does not have a valid email address
51 sales_invoice_number Factuur # Factura # Invoice # Invoice # Invoice # Invoice # Invoice # Invoice # Nomor Nota
52 sales_invoice_number_duplicate Vul een unieke nummer in Por favor ingrese un número de factura único Please enter an unique invoice number Please enter an unique invoice number Please enter an unique invoice number Please enter an unique invoice number Please enter an unique invoice number Please enter an unique invoice number Nomor Nota Double