From 9a2cafc1b11ed2cd91f10605b75b9985d781c231 Mon Sep 17 00:00:00 2001 From: jekkos Date: Thu, 3 Sep 2015 23:35:57 +0200 Subject: [PATCH] Review payment type overview Add some padding to bottom of content area Fix invoice only searching Make start and end dates optional --- application/controllers/sales.php | 26 +++++++++++++++++--------- application/helpers/table_helper.php | 23 +++++------------------ application/models/sale.php | 10 ++++++++-- application/views/sales/manage.php | 6 +++--- css/ospos.css | 2 +- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/application/controllers/sales.php b/application/controllers/sales.php index f5de1147f..7dda7bc43 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -7,6 +7,7 @@ class Sales extends Secure_area parent::__construct('sales'); $this->load->library('sale_lib'); $this->load->library('barcode_lib'); + $this->Sale->create_sales_items_temp_table(); } function index() @@ -16,11 +17,6 @@ class Sales extends Secure_area function manage($only_invoices = FALSE, $limit_from = 0) { - $model = $this->Sale; - - // Create the temp tables to work with the data - $model->create_sales_items_temp_table(); - $data['controller_name'] = strtolower($this->uri->segment(1)); $data['only_invoices'] = array($this->lang->line('sales_no_filter'), $this->lang->line('sales_invoice')); $data['search_section_state'] = $this->input->post('search_section_state'); @@ -35,11 +31,11 @@ class Sales extends Secure_area $sale_type = 'sales'; $location_id = 'all'; - $report_data = $model->get_data(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, + $report_data = $this->Sale->get_data(array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id, 'only_invoices' => $only_invoices, 'lines_per_page' => $lines_per_page, 'limit_from' => $limit_from)); $data['only_invoices'] = $only_invoices; - $data['links'] = $this->_initialize_pagination($model, $lines_per_page, $limit_from, -1, 'manage', $only_invoices); + $data['links'] = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, -1, 'manage', $only_invoices); $data['manage_table'] = get_sales_manage_table($report_data['sales'], $this); $data['payments_summary'] = get_sales_manage_payments_summary($report_data['payments'], $report_data['sales'], $this); $this->load->view($data['controller_name'] . '/manage', $data); @@ -50,7 +46,7 @@ class Sales extends Secure_area { $sale_id = $this->input->post('row_id'); $sale_info = $this->Sale->get_info($sale_id)->result_array(); - $data_row=get_sale_data_row($sale_info[0],$this); + $data_row=get_sales_manage_sale_data_row($sale_info[0],$this); echo $data_row; } @@ -66,7 +62,19 @@ class Sales extends Secure_area function search() { - $this->manage($this->input->post('only_invoices', TRUE)); + $only_invoices = $this->input->post('only_invoices', TRUE); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $limit_from = $this->input->post('limit_from', TRUE); + $sale_type = 'sales'; + $location_id = 'all'; + + $report_data = $this->Sale->get_data(array('sale_type' => $sale_type, 'location_id' => $location_id, + 'only_invoices' => $only_invoices, '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); + echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); + $this->_remove_duplicate_cookies(); } function item_search() diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index d02771243..d2da41deb 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -54,10 +54,7 @@ function get_sales_manage_table_data_rows($sales, $controller) } else { - // empty line - //$table_data_rows .= "          "; - // show a line in bold with the totals - $table_data_rows .= " ".$CI->lang->line('sales_total')."  ".to_currency($sum_amount_tendered)."".to_currency($sum_amount_due)."".to_currency($sum_change_due).""; + $table_data_rows .= " ".$CI->lang->line('sales_total')."  ".to_currency($sum_amount_tendered)."".to_currency($sum_amount_due)."".to_currency($sum_change_due).""; } return $table_data_rows; @@ -97,20 +94,12 @@ Get the sales payments summary function get_sales_manage_payments_summary($payments_summary, $sales, $controller) { $CI =& get_instance(); - $table=''; + $table='
'; - $table.='
'; - $table.=''; - foreach($payments_summary as $key=>$summary) - { - $table.=''; - } - $table.=''; - $table.=''; foreach($payments_summary as $key=>$summary) { $amount = $summary['payment_amount']; - + // WARNING: the strong assumption here is that if a change is due it was a cash transaction always // therefore we remove from the total cash amount any change due if( $summary['payment_type'] == $CI->lang->line('sales_cash') ) @@ -120,10 +109,8 @@ function get_sales_manage_payments_summary($payments_summary, $sales, $controlle $amount -= $sale['change_due']; } } - - $table.=''; - } - $table.='
 '.$summary['payment_type'].'
'.$CI->lang->line('sales_total').''.to_currency( $amount ).'
'; + $table.='
'.$summary['payment_type'].': '.to_currency( $amount );'
'; + } return $table; } diff --git a/application/models/sale.php b/application/models/sale.php index f3fc87ebb..df55e7969 100644 --- a/application/models/sale.php +++ b/application/models/sale.php @@ -31,7 +31,10 @@ class Sale extends CI_Model $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 (isset($inputs['start_date']) && isset($inputs['end_date']) ) + { + $this->db->where('sale_date BETWEEN '. $this->db->escape($inputs['start_date']). ' AND '. $this->db->escape($inputs['end_date'])); + } if ($inputs['location_id'] != 'all') { @@ -67,7 +70,10 @@ class Sale extends CI_Model $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'].'"'); + if (isset($inputs['start_date']) && isset($inputs['end_date']) ) + { + $this->db->where('date(sale_time) BETWEEN "'. $inputs['start_date']. '" AND "'. $inputs['end_date'].'"'); + } if ($inputs['sale_type'] == 'sales') { diff --git a/application/views/sales/manage.php b/application/views/sales/manage.php index 48f8f17ed..27adb5120 100755 --- a/application/views/sales/manage.php +++ b/application/views/sales/manage.php @@ -9,8 +9,8 @@ $(document).ready(function() enable_search('','lang->line("common_confirm_search")?>'); enable_delete('lang->line($controller_name."_confirm_delete")?>','lang->line($controller_name."_none_selected")?>'); - $("#search_filter_section select").change(function() { - do_search(true); + $("#search_filter_section #only_invoices").change(function() { + $('#search_form').submit(); return false; }); @@ -150,7 +150,7 @@ function init_table_sorting() 'search_form')); ?>
lang->line('sales_invoice_filter').' '.':', 'invoices_filter');?> - 'only_invoices','id'=>'only_invoices','value'=>1,'checked'=> isset($only_invoices)? ( ($only_invoices)? 1 : 0) : 0));?> + 'only_invoices','id'=>'only_invoices','value'=>1,'checked'=> isset($only_invoices)? ( ($only_invoices)? 1 : 0) : 0));?>
diff --git a/css/ospos.css b/css/ospos.css index 16dd67bf9..c3266d434 100644 --- a/css/ospos.css +++ b/css/ospos.css @@ -31,7 +31,7 @@ a.none width:100%; background-color:#FFFFFF; margin:0px; - padding:0px; + padding-bottom: 10px; border-bottom:1px solid #CCCCCC; text-align:center;