Files
opensourcepos/app/Libraries/Item_lib.php
objecttothis 48c04417b8 Fixes
- PHP 8.2 deprecates dynamically declared class properties. Adding these declarations removes deprecation warnings and makes the code PHP 8.3 compatible.
- Add Elvis operator to set search string to an empty string when it's value is null to get rid of an error in the search function call.
- Imported class for OSPOS config
- Replaced private with protected in parent controller's property.
- Removed unneeded TODO
- Refactored local variables
- Replaced ternary notation
- Removed unneeded comments
- Removed unneeded class property
- Removed unneeded @property declarations
- Fixed database version
2024-06-15 17:19:15 +02:00

47 lines
933 B
PHP

<?php
namespace app\Libraries;
use CodeIgniter\Model;
use CodeIgniter\Session\Session;
use App\Models\Stock_location;
/**
* Item library
*
* Library with utilities to manage items
**/
class Item_lib
{
private Session $session;
private Stock_location $stock_location;
public function __construct()
{
$this->session = Session();
$this->stock_location = model(Stock_location::class);
}
public function get_item_location(): string
{
if(!$this->session->get('item_location'))
{
$location_id = $this->stock_location->get_default_location_id();
$this->set_item_location($location_id);
}
return $this->session->get('item_location');
}
public function set_item_location(?string $location): void
{
$this->session->set('item_location',$location);
}
public function clear_item_location(): void //TODO: This isn't called from anywhere in the code.
{
$this->session->remove('item_location');
}
}