diff --git a/application/config/routes.php b/application/config/routes.php index ef981724e..891f9de81 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -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"; diff --git a/application/controllers/sales.php b/application/controllers/sales.php index fbb3b0842..16f5cf706 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -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(); } diff --git a/application/language/en/sales_lang.php b/application/language/en/sales_lang.php index e671d76c0..7c1b2a204 100644 --- a/application/language/en/sales_lang.php +++ b/application/language/en/sales_lang.php @@ -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"; diff --git a/application/language/es/sales_lang.php b/application/language/es/sales_lang.php index 794d4f4e6..763cf2ac9 100644 --- a/application/language/es/sales_lang.php +++ b/application/language/es/sales_lang.php @@ -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"; diff --git a/application/language/fr/sales_lang.php b/application/language/fr/sales_lang.php index 0ce6d0fd4..7e595bb15 100644 --- a/application/language/fr/sales_lang.php +++ b/application/language/fr/sales_lang.php @@ -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"; diff --git a/application/language/id/sales_lang.php b/application/language/id/sales_lang.php index 83281907d..0fc0d4fae 100644 --- a/application/language/id/sales_lang.php +++ b/application/language/id/sales_lang.php @@ -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"; diff --git a/application/language/nl-BE/sales_lang.php b/application/language/nl-BE/sales_lang.php index fbd744a9b..4c007ab8a 100755 --- a/application/language/nl-BE/sales_lang.php +++ b/application/language/nl-BE/sales_lang.php @@ -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"; diff --git a/application/language/ru/sales_lang.php b/application/language/ru/sales_lang.php index ee9b05149..96ca96ee8 100644 --- a/application/language/ru/sales_lang.php +++ b/application/language/ru/sales_lang.php @@ -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"; diff --git a/application/language/th/sales_lang.php b/application/language/th/sales_lang.php index edaa0016e..da10da222 100644 --- a/application/language/th/sales_lang.php +++ b/application/language/th/sales_lang.php @@ -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"; diff --git a/application/language/tr/sales_lang.php b/application/language/tr/sales_lang.php index 5010f20c8..8bf0403a4 100644 --- a/application/language/tr/sales_lang.php +++ b/application/language/tr/sales_lang.php @@ -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"; diff --git a/application/language/zh/sales_lang.php b/application/language/zh/sales_lang.php index 856515e5b..028babfb0 100755 --- a/application/language/zh/sales_lang.php +++ b/application/language/zh/sales_lang.php @@ -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"; diff --git a/application/models/sale.php b/application/models/sale.php index 458d498b1..4ac080adc 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -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"); diff --git a/application/views/sales/manage.php b/application/views/sales/manage.php index 8e231de2c..ab48b52b8 100755 --- a/application/views/sales/manage.php +++ b/application/views/sales/manage.php @@ -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() 'search_form')); ?>
- lang->line('sales_invoice_filter').' '.':', 'invoices_filter');?> + lang->line('sales_invoice_filter').' '.':', 'invoices_filter');?> 'only_invoices','id'=>'only_invoices','value'=>1,'checked'=> isset($only_invoices)? ( ($only_invoices)? 1 : 0) : 0));?> + lang->line('sales_cash_filter').' '.':', 'cash_filter');?> + 'only_cash','id'=>'only_cash','value'=>1,'checked'=> isset($only_cash)? ( ($only_cash)? 1 : 0) : 0));?>
diff --git a/translations/sales_lang.csv b/translations/sales_lang.csv index 89152612a..941f7d6b3 100644 --- a/translations/sales_lang.csv +++ b/translations/sales_lang.csv @@ -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