mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Review payment type overview
Add some padding to bottom of content area Fix invoice only searching Make start and end dates optional
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -54,10 +54,7 @@ function get_sales_manage_table_data_rows($sales, $controller)
|
||||
}
|
||||
else
|
||||
{
|
||||
// empty line
|
||||
//$table_data_rows .= "<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>";
|
||||
// show a line in bold with the totals
|
||||
$table_data_rows .= "<tr><th> </th><th>".$CI->lang->line('sales_total')."</th><th> </th><th> </th><th>".to_currency($sum_amount_tendered)."</th><th>".to_currency($sum_amount_due)."</th><th>".to_currency($sum_change_due)."</th></tr>";
|
||||
$table_data_rows .= "<tr><td> </td><td>".$CI->lang->line('sales_total')."</td><td> </td><td> </td><td>".to_currency($sum_amount_tendered)."</td><td>".to_currency($sum_amount_due)."</td><td>".to_currency($sum_change_due)."</td><td colspan=\"3\"></td></tr>";
|
||||
}
|
||||
|
||||
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 class="tablesorter" id="sortable_table">';
|
||||
$table='<div id="report_summary">';
|
||||
|
||||
$table.='<thead><tr>';
|
||||
$table.='<th> </th>';
|
||||
foreach($payments_summary as $key=>$summary)
|
||||
{
|
||||
$table.='<th>'.$summary['payment_type'].'</th>';
|
||||
}
|
||||
$table.='</tr></thead><tbody><tr>';
|
||||
$table.='<th>'.$CI->lang->line('sales_total').'</th>';
|
||||
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.='<td>'.to_currency( $amount ).'</td>';
|
||||
}
|
||||
$table.='</tr></tbody></table>';
|
||||
$table.='<div class="summary_row">'.$summary['payment_type'].': '.to_currency( $amount );'</div>';
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
{
|
||||
|
||||
@@ -9,8 +9,8 @@ $(document).ready(function()
|
||||
enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
|
||||
enable_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>','<?php echo $this->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()
|
||||
<?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_checkbox(array('name'=>'only_invoices','id'=>'only_invoices','value'=>1,'checked'=> isset($only_invoices)? ( ($only_invoices)? 1 : 0) : 0));?>
|
||||
<?php echo form_checkbox(array('name'=>'only_invoices','id'=>'only_invoices','value'=>1,'checked'=> isset($only_invoices)? ( ($only_invoices)? 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">
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user