mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-18 21:40:52 -04:00
Sales MVC
- Added todo to Stock_location.php - make library function return nullable - Added missing model instantiation - Commented out Sale model instantiation in library because it's causing infinite loop - Changed function name prepending get and post required by CI4 autorouting
This commit is contained in:
@@ -56,6 +56,9 @@ class Sales extends Secure_Controller
|
||||
$this->tax_lib = new Tax_lib();
|
||||
$this->token_lib = new Token_lib();
|
||||
$this->config = config('OSPOS')->settings;
|
||||
|
||||
$this->customer = model('Customer');
|
||||
$this->sale = model('Sale');
|
||||
$this->stock_location = model('Stock_location');
|
||||
}
|
||||
|
||||
@@ -65,7 +68,7 @@ class Sales extends Secure_Controller
|
||||
$this->_reload(); //TODO: Hungarian Notation
|
||||
}
|
||||
|
||||
public function manage(): void
|
||||
public function getManage(): void
|
||||
{
|
||||
$person_id = $this->session->get('person_id');
|
||||
|
||||
@@ -169,9 +172,9 @@ class Sales extends Secure_Controller
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
public function select_customer(): void
|
||||
public function postSelect_customer(): void
|
||||
{
|
||||
$customer_id = $this->request->getPost('customer', FILTER_SANITIZE_NUMBER_INT);
|
||||
$customer_id = (int)$this->request->getPost('customer', FILTER_SANITIZE_NUMBER_INT);
|
||||
if($this->customer->exists($customer_id))
|
||||
{
|
||||
$this->sale_lib->set_customer($customer_id);
|
||||
@@ -188,7 +191,7 @@ class Sales extends Secure_Controller
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
public function change_mode(): void
|
||||
public function postChange_mode(): void
|
||||
{
|
||||
$mode = $this->request->getPost('mode', FILTER_SANITIZE_STRING);
|
||||
$this->sale_lib->set_mode($mode);
|
||||
@@ -451,7 +454,7 @@ class Sales extends Secure_Controller
|
||||
$this->_reload(); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
public function add(): void
|
||||
public function postAdd(): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Sale_lib
|
||||
$this->item_quantity = model('Item_quantity');
|
||||
$this->item_taxes = model('Item_taxes');
|
||||
$this->rounding_mode = model('enums/Rounding_mode');
|
||||
$this->sale = model('Sale');
|
||||
// $this->sale = model('Sale'); //TODO: This is causing an infinite loop because the constructor calls the sale library
|
||||
$this->stock_location = model('Stock_location');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
}
|
||||
@@ -219,17 +219,17 @@ class Sale_lib
|
||||
$this->session->remove('sales_comment');
|
||||
}
|
||||
|
||||
public function get_invoice_number(): string
|
||||
public function get_invoice_number(): ?string
|
||||
{
|
||||
return $this->session->get('sales_invoice_number');
|
||||
}
|
||||
|
||||
public function get_quote_number(): string
|
||||
public function get_quote_number(): ?string
|
||||
{
|
||||
return $this->session->get('sales_quote_number');
|
||||
}
|
||||
|
||||
public function get_work_order_number(): string
|
||||
public function get_work_order_number(): ?string
|
||||
{
|
||||
return $this->session->get('sales_work_order_number');
|
||||
}
|
||||
@@ -759,7 +759,7 @@ class Sale_lib
|
||||
$this->session->set('payment_type', $payment_type);
|
||||
}
|
||||
|
||||
public function get_payment_type(): string
|
||||
public function get_payment_type(): ?string
|
||||
{
|
||||
return $this->session->get('payment_type');
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class Sale extends Model
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// $this->sale_lib = new Sale_lib(); //TODO: This is causing an infinite loop because the sale lib is invoking the sale model and the model invokes the sale_lib
|
||||
$this->sale_lib = new Sale_lib();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,7 +107,7 @@ class Stock_location extends Model
|
||||
$builder->where('deleted', 0);
|
||||
$builder->limit(1);
|
||||
|
||||
return $builder->get()->getRow()->location_id;
|
||||
return $builder->get()->getRow()->location_id; //TODO: this is puking. Trying to get property 'location_id' of non-object
|
||||
}
|
||||
|
||||
public function get_location_name(int $location_id): string
|
||||
|
||||
Reference in New Issue
Block a user