mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-14 18:53:56 -04:00
Fix issue in Sales/Takings and apply same fix to other controller to avoid similar issues in the future (#337)
This commit is contained in:
@@ -24,13 +24,15 @@ class Customers extends Person_controller
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$search = $this->input->post('search');
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$customers = $this->Customer->search($search, $lines_per_page, $limit_from);
|
||||
$total_rows = $this->Customer->get_found_rows($search);
|
||||
$links = $this->_initialize_pagination($this->Customer,$lines_per_page, $limit_from, $total_rows);
|
||||
$data_rows = get_people_manage_table_data_rows($customers, $this);
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,15 @@ class Employees extends Person_controller
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$search = $this->input->post('search');
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$employees = $this->Employee->search($search, $limit_from, $lines_per_page);
|
||||
$total_rows = $this->Employee->get_found_rows($search);
|
||||
$links = $this->_initialize_pagination($this->Employee, $lines_per_page, $limit_from, $total_rows);
|
||||
$data_rows = get_people_manage_table_data_rows($employees, $this);
|
||||
|
||||
echo json_encode(array('rows' => $data_rows, 'pagination' => $links));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,13 +25,15 @@ class Giftcards extends Secure_area implements iData_controller
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$search = $this->input->post('search');
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$giftcards = $this->Giftcard->search($search, $lines_per_page, $limit_from);
|
||||
$total_rows = $this->Giftcard->get_found_rows($search);
|
||||
$links = $this->_initialize_pagination($this->Giftcard, $lines_per_page, $limit_from, $total_rows);
|
||||
$data_rows = get_giftcards_manage_table_data_rows($giftcards, $this);
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,10 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$search = $this->input->post('search');
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$item_kits = $this->Item_kit->search($search, $lines_per_page, $limit_from);
|
||||
$total_rows = $this->Item_kit->get_found_rows($search);
|
||||
$links = $this->_initialize_pagination($this->Item_kit, $lines_per_page, $limit_from, $total_rows, 'search');
|
||||
|
||||
@@ -21,13 +21,13 @@ class Items extends Secure_area implements iData_controller
|
||||
$items = $this->Item->get_all($stock_location, $lines_per_page, $limit_from);
|
||||
$data['links'] = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from);
|
||||
|
||||
// assume year 2010 as starting date for OSPOS
|
||||
// set 01/01/2010 as starting date for OSPOS
|
||||
$start_of_time = date($this->config->item('dateformat'), mktime(0,0,0,1,1,2010));
|
||||
$today = date($this->config->item('dateformat'));
|
||||
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date', TRUE) : $start_of_time;
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date') : $start_of_time;
|
||||
$start_date_formatter = date_create_from_format($this->config->item('dateformat'), $start_date);
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date', TRUE) : $today;
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date') : $today;
|
||||
$end_date_formatter = date_create_from_format($this->config->item('dateformat'), $end_date);
|
||||
|
||||
$data['start_date'] = $start_date_formatter->format($this->config->item('dateformat'));
|
||||
@@ -53,19 +53,18 @@ class Items extends Secure_area implements iData_controller
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$search = $this->input->post('search');
|
||||
$this->item_lib->set_item_location($this->input->post('stock_location'));
|
||||
$data['search_section_state'] = $this->input->post('search_section_state');
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
$this->item_lib->set_item_location($this->input->post('stock_location'));
|
||||
|
||||
// assume year 2010 as starting date for OSPOS
|
||||
// set 01/01/2010 as starting date for OSPOS
|
||||
$start_of_time = date($this->config->item('dateformat'), mktime(0,0,0,1,1,2010));
|
||||
$today = date($this->config->item('dateformat'));
|
||||
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date', TRUE) : $start_of_time;
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date') : $start_of_time;
|
||||
$start_date_formatter = date_create_from_format($this->config->item('dateformat'), $start_date);
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date', TRUE) : $today;
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date') : $today;
|
||||
$end_date_formatter = date_create_from_format($this->config->item('dateformat'), $end_date);
|
||||
|
||||
$filters = array('start_date' => $start_date_formatter->format('Y-m-d'),
|
||||
@@ -83,6 +82,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$total_rows = $this->Item->get_found_rows($search, $filters);
|
||||
$links = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from, $total_rows, 'search');
|
||||
$data_rows = get_items_manage_table_data_rows($items, $this);
|
||||
|
||||
// do not move this line to be after the json_encode otherwise the searhc function won't work!!
|
||||
$this->_remove_duplicate_cookies();
|
||||
|
||||
@@ -470,13 +470,12 @@ class Items extends Secure_area implements iData_controller
|
||||
|
||||
$success &= $this->Inventory->insert($inv_data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($success && $upload_success)
|
||||
}
|
||||
if ($success && $upload_success)
|
||||
{
|
||||
$success_message = $this->lang->line('items_successful_' . ($new_item ? 'adding' : 'updating')) .' '. $item_data['name'];
|
||||
|
||||
echo json_encode(array('success'=>true,'message'=>$success_message,'item_id'=>$item_id));
|
||||
echo json_encode(array('success'=>true, 'message'=>$success_message, 'item_id'=>$item_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -484,16 +483,13 @@ class Items extends Secure_area implements iData_controller
|
||||
$this->lang->line('items_error_adding_updating') .' '. $item_data['name'] :
|
||||
$this->upload->display_errors();
|
||||
|
||||
echo json_encode(array('success'=>false,
|
||||
'message'=>$error_message,'item_id'=>$item_id));
|
||||
echo json_encode(array('success'=>false, 'message'=>$error_message, 'item_id'=>$item_id));
|
||||
}
|
||||
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
echo json_encode(array('success'=>false,
|
||||
'message'=>$this->lang->line('items_error_adding_updating').' '
|
||||
.$item_data['name'],'item_id'=>-1));
|
||||
echo json_encode(array('success'=>false, 'message'=>$this->lang->line('items_error_adding_updating').' '.$item_data['name'], 'item_id'=>-1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,34 +27,34 @@ class Sales extends Secure_area
|
||||
{
|
||||
$this->Sale->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');
|
||||
$data['controller_name'] = $this->get_controller_name();
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$today = date($this->config->item('dateformat'));
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date', TRUE) : $today;
|
||||
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date') : $today;
|
||||
$start_date_formatter = date_create_from_format($this->config->item('dateformat'), $start_date);
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date', TRUE) : $today;
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date') : $today;
|
||||
$end_date_formatter = date_create_from_format($this->config->item('dateformat'), $end_date);
|
||||
|
||||
$sale_type = 'all';
|
||||
$sale_type = 'all';
|
||||
$location_id = 'all';
|
||||
$is_valid_receipt = FALSE;
|
||||
$search = null;
|
||||
|
||||
$filters = array('sale_type' => $sale_type,
|
||||
'location_id' => $location_id,
|
||||
'start_date' => $start_date_formatter->format('Y-m-d'),
|
||||
'end_date' => $end_date_formatter->format('Y-m-d'),
|
||||
'only_invoices' => $only_invoices,
|
||||
'only_cash' => $only_cash,
|
||||
'is_valid_receipt' => $is_valid_receipt);
|
||||
'location_id' => $location_id,
|
||||
'start_date' => $start_date_formatter->format('Y-m-d'),
|
||||
'end_date' => $end_date_formatter->format('Y-m-d'),
|
||||
'only_invoices' => $only_invoices,
|
||||
'only_cash' => $only_cash,
|
||||
'is_valid_receipt' => $is_valid_receipt);
|
||||
|
||||
$sales = $this->Sale->search($search, $filters, $lines_per_page, $limit_from)->result_array();
|
||||
$payments = $this->Sale->get_payments_summary($search, $filters);
|
||||
$total_rows = $this->Sale->get_found_rows($search, $filters);
|
||||
$data['only_invoices'] = $only_invoices;
|
||||
$data['only_cash '] = $only_cash;
|
||||
$data['start_date'] = $start_date_formatter->format($this->config->item('dateformat'));
|
||||
$data['end_date'] = $end_date_formatter->format($this->config->item('dateformat'));
|
||||
$data['links'] = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, $total_rows, 'manage', $only_invoices);
|
||||
@@ -87,27 +87,31 @@ class Sales extends Secure_area
|
||||
{
|
||||
return 400;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Returns Sales table data rows. This will be called with AJAX.
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$this->Sale->create_sales_items_temp_table();
|
||||
|
||||
$only_invoices = $this->input->post('only_invoices', TRUE);
|
||||
$only_cash = $this->input->post('only_cash', TRUE);
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
$limit_from = $this->input->post('limit_from', TRUE);
|
||||
$search = $this->input->post('search', TRUE);
|
||||
|
||||
$today = date($this->config->item('dateformat'));
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date', TRUE) : $today;
|
||||
|
||||
$start_date = $this->input->post('start_date') != null ? $this->input->post('start_date') : $today;
|
||||
$start_date_formatter = date_create_from_format($this->config->item('dateformat'), $start_date);
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date', TRUE) : $today;
|
||||
$end_date = $this->input->post('end_date') != null ? $this->input->post('end_date') : $today;
|
||||
$end_date_formatter = date_create_from_format($this->config->item('dateformat'), $end_date);
|
||||
|
||||
$is_valid_receipt = isset($search) ? $this->sale_lib->is_valid_receipt($search) : FALSE;
|
||||
|
||||
$sale_type = 'all';
|
||||
$location_id = 'all';
|
||||
$only_invoices = $this->input->post('only_invoices') != null;
|
||||
$only_cash = $this->input->post('only_cash') != null;
|
||||
|
||||
$filters = array('sale_type' => $sale_type,
|
||||
'location_id' => $location_id,
|
||||
@@ -123,6 +127,8 @@ class Sales extends Secure_area
|
||||
$links = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, $total_rows, 'search', $only_invoices);
|
||||
$sale_rows = get_sales_manage_table_data_rows($sales, $this);
|
||||
$payment_summary = get_sales_manage_payments_summary($payments, $sales, $this);
|
||||
|
||||
// do not move this line to be after the json_encode otherwise the searhc function won't work!!
|
||||
$this->_remove_duplicate_cookies();
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $sale_rows, 'pagination' => $links, 'payment_summary' => $payment_summary));
|
||||
@@ -151,8 +157,8 @@ class Sales extends Secure_area
|
||||
|
||||
function suggest()
|
||||
{
|
||||
$search = $this->input->post('q', TRUE);
|
||||
$limit = $this->input->post('limit', TRUE);
|
||||
$search = $this->input->post('q');
|
||||
$limit = $this->input->post('limit');
|
||||
$suggestions = $this->Sale->get_search_suggestions($search, $limit);
|
||||
|
||||
echo implode("\n",$suggestions);
|
||||
@@ -303,8 +309,8 @@ class Sales extends Secure_area
|
||||
$this->form_validation->set_rules('quantity', 'lang:items_quantity', 'required|numeric');
|
||||
$this->form_validation->set_rules('discount', 'lang:items_discount', 'required|numeric');
|
||||
|
||||
$description = $this->input->post('description');
|
||||
$serialnumber = $this->input->post('serialnumber');
|
||||
$description = $this->input->post('description');
|
||||
$serialnumber = $this->input->post('serialnumber');
|
||||
$price = $this->input->post('price');
|
||||
$quantity = $this->input->post('quantity');
|
||||
$discount = $this->input->post('discount');
|
||||
@@ -367,7 +373,7 @@ class Sales extends Secure_area
|
||||
$this->config->item('phone'),
|
||||
$this->config->item('account_number')
|
||||
));
|
||||
$cust_info = '';
|
||||
$cust_info = '';
|
||||
if($customer_id!=-1)
|
||||
{
|
||||
$cust_info = $this->Customer->get_info($customer_id);
|
||||
@@ -670,7 +676,7 @@ class Sales extends Secure_area
|
||||
|
||||
function save($sale_id)
|
||||
{
|
||||
$start_date_formatter = date_create_from_format($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), $this->input->post('date', TRUE));
|
||||
$start_date_formatter = date_create_from_format($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), $this->input->post('date'));
|
||||
|
||||
$sale_data = array(
|
||||
'sale_time' => $start_date_formatter->format('Y-m-d H:i:s'),
|
||||
@@ -721,11 +727,11 @@ class Sales extends Secure_area
|
||||
{
|
||||
$person_info = $this->Employee->get_logged_in_employee_info();
|
||||
$data['cart'] = $this->sale_lib->get_cart();
|
||||
$data['modes'] = array('sale'=>$this->lang->line('sales_sale'),'return'=>$this->lang->line('sales_return'));
|
||||
$data['mode'] = $this->sale_lib->get_mode();
|
||||
$data['modes'] = array('sale'=>$this->lang->line('sales_sale'),'return'=>$this->lang->line('sales_return'));
|
||||
$data['mode'] = $this->sale_lib->get_mode();
|
||||
|
||||
$data['stock_locations'] = $this->Stock_location->get_allowed_locations('sales');
|
||||
$data['stock_location'] = $this->sale_lib->get_sale_location();
|
||||
$data['stock_locations'] = $this->Stock_location->get_allowed_locations('sales');
|
||||
$data['stock_location'] = $this->sale_lib->get_sale_location();
|
||||
|
||||
$data['subtotal'] = $this->sale_lib->get_subtotal(TRUE);
|
||||
$data['tax_exclusive_subtotal'] = $this->sale_lib->get_subtotal(TRUE, TRUE);
|
||||
@@ -764,11 +770,11 @@ class Sales extends Secure_area
|
||||
$this->_remove_duplicate_cookies();
|
||||
}
|
||||
|
||||
function cancel_sale()
|
||||
{
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_reload();
|
||||
}
|
||||
function cancel_sale()
|
||||
{
|
||||
$this->sale_lib->clear_all();
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
function suspend()
|
||||
{
|
||||
@@ -835,7 +841,7 @@ class Sales extends Secure_area
|
||||
$this->sale_lib->clear_all();
|
||||
$this->sale_lib->copy_entire_suspended_sale($sale_id);
|
||||
$this->Sale_suspended->delete($sale_id);
|
||||
$this->_reload();
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
function check_invoice_number()
|
||||
@@ -843,6 +849,7 @@ class Sales extends Secure_area
|
||||
$sale_id=$this->input->post('sale_id');
|
||||
$invoice_number=$this->input->post('invoice_number');
|
||||
$exists=!empty($invoice_number) && $this->Sale->invoice_number_exists($invoice_number,$sale_id);
|
||||
|
||||
echo json_encode(array('success'=>!$exists, 'message'=>$this->lang->line('sales_invoice_number_duplicate')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,15 @@ class Suppliers extends Person_controller
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
$search = $this->input->post('search');
|
||||
$search = $this->input->post('search') != '' ? $this->input->post('search') : null;
|
||||
$limit_from = $this->input->post('limit_from');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$suppliers = $this->Supplier->search($search, $lines_per_page, $limit_from);
|
||||
$total_rows = $this->Supplier->get_found_rows($search);
|
||||
$links = $this->_initialize_pagination($this->Supplier, $lines_per_page, $limit_from, $total_rows);
|
||||
$data_rows = get_supplier_manage_table_data_rows($suppliers, $this);
|
||||
|
||||
echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($filters['is_valid_receipt'])
|
||||
if ($filters['is_valid_receipt'] != FALSE)
|
||||
{
|
||||
$pieces = explode(' ', $search);
|
||||
$this->db->where('sales_items_temp.sale_id', $pieces[1]);
|
||||
|
||||
Reference in New Issue
Block a user