mirror of
https://github.com/Karaka-Management/oms-WarehouseManagement.git
synced 2026-02-05 17:48:40 +00:00
new datamapper mostly implemented
This commit is contained in:
parent
012b876923
commit
ec680f81f6
|
|
@ -62,10 +62,10 @@ final class Installer extends InstallerAbstract
|
|||
{
|
||||
$stock = new Stock('Default');
|
||||
$stock->type = 0;
|
||||
StockMapper::create($stock);
|
||||
StockMapper::create()->execute($stock);
|
||||
|
||||
$stockLocation = new StockLocation((string) ($stock->getId() . '-1'));
|
||||
$stockLocation->stock = $stock;
|
||||
StockLocationMapper::create($stockLocation);
|
||||
StockLocationMapper::create()->execute($stockLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,15 +62,15 @@ final class ApiController extends Controller
|
|||
{
|
||||
$stock = new Stock($new->number);
|
||||
$stock->type = 1;
|
||||
StockMapper::create($stock);
|
||||
StockMapper::create()->execute($stock);
|
||||
|
||||
$stockLocation = new StockLocation($stock->name . '-1');
|
||||
$stockLocation->stock = $stock->getId();
|
||||
StockLocationMapper::create($stockLocation);
|
||||
StockLocationMapper::create()->execute($stockLocation);
|
||||
|
||||
$stockShelf = new StockShelf($stockLocation->name . '-1');
|
||||
$stockShelf->location = $stockLocation->getId();
|
||||
StockShelfMapper::create($stockShelf);
|
||||
StockShelfMapper::create()->execute($stockShelf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,18 +53,24 @@ final class BackendController extends Controller
|
|||
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$view->setData('stocks',
|
||||
StockMapper::with('language', $response->getLanguage())
|
||||
::getBeforePivot((int) ($request->getData('id') ?? 0), limit: 25)
|
||||
StockMapper::getAll()
|
||||
->where('id', (int) ($request->getData('id') ?? 0))
|
||||
->limit(25)
|
||||
->execute()
|
||||
);
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$view->setData('stocks',
|
||||
StockMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot((int) ($request->getData('id') ?? 0), limit: 25)
|
||||
StockMapper::getAll()
|
||||
->where('id', (int) ($request->getData('id') ?? 0))
|
||||
->limit(25)
|
||||
->execute()
|
||||
);
|
||||
} else {
|
||||
$view->setData('stocks',
|
||||
StockMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot(0, limit: 25)
|
||||
StockMapper::getAll()
|
||||
->where('id', 0)
|
||||
->limit(25)
|
||||
->execute()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +96,7 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/WarehouseManagement/Theme/Backend/stock');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001302001, $request, $response));
|
||||
|
||||
$view->setData('stock', StockMapper::get((int) $request->getData('id')));
|
||||
$view->setData('stock', StockMapper::get()->where('id', (int) $request->getData('id'))->execute());
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
@ -116,18 +122,24 @@ final class BackendController extends Controller
|
|||
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$view->setData('locations',
|
||||
StockLocationMapper::with('language', $response->getLanguage())
|
||||
::getBeforePivot((int) ($request->getData('id') ?? 0), limit: 25)
|
||||
StockLocationMapper::getAll()
|
||||
->where('id', (int) ($request->getData('id') ?? 0))
|
||||
->limit(25)
|
||||
->execute()
|
||||
);
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$view->setData('locations',
|
||||
StockLocationMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot((int) ($request->getData('id') ?? 0), limit: 25)
|
||||
StockLocationMapper::getAll()
|
||||
->where('id', (int) ($request->getData('id') ?? 0))
|
||||
->limit(25)
|
||||
->execute()
|
||||
);
|
||||
} else {
|
||||
$view->setData('locations',
|
||||
StockLocationMapper::with('language', $response->getLanguage())
|
||||
::getAfterPivot(0, limit: 25)
|
||||
StockLocationMapper::getAll()
|
||||
->where('id', 0)
|
||||
->limit(25)
|
||||
->execute()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +165,7 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/WarehouseManagement/Theme/Backend/stock-location');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1001302001, $request, $response));
|
||||
|
||||
$view->setData('location', StockLocationMapper::get((int) $request->getData('id')));
|
||||
$view->setData('location', StockLocationMapper::get()->where('id', (int) $request->getData('id'))->execute());
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
39
Models/NullStock.php
Normal file
39
Models/NullStock.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\WarehouseManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\WarehouseManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullStock extends Stock
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
39
Models/NullStockLocation.php
Normal file
39
Models/NullStockLocation.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\WarehouseManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\WarehouseManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullStockLocation extends StockLocation
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
39
Models/NullStockShelf.php
Normal file
39
Models/NullStockShelf.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\WarehouseManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\WarehouseManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullStockShelf extends StockShelf
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* WarehouseManagement mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class StockLocationMapper extends DataMapperAbstract
|
||||
final class StockLocationMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class StockLocationMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'warehousemgmt_stocklocation_id' => ['name' => 'warehousemgmt_stocklocation_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'warehousemgmt_stocklocation_name' => ['name' => 'warehousemgmt_stocklocation_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'warehousemgmt_stocklocation_stock' => ['name' => 'warehousemgmt_stocklocation_stock', 'type' => 'int', 'internal' => 'stock'],
|
||||
|
|
@ -47,7 +47,7 @@ final class StockLocationMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, external:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [
|
||||
public const BELONGS_TO = [
|
||||
'stock' => [
|
||||
'mapper' => StockMapper::class,
|
||||
'external' => 'warehousemgmt_stocklocation_stock',
|
||||
|
|
@ -60,7 +60,7 @@ final class StockLocationMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'warehousemgmt_stocklocation';
|
||||
public const TABLE = 'warehousemgmt_stocklocation';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -68,5 +68,5 @@ final class StockLocationMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'warehousemgmt_stocklocation_id';
|
||||
public const PRIMARYFIELD ='warehousemgmt_stocklocation_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* WarehouseManagement mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class StockMapper extends DataMapperAbstract
|
||||
final class StockMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class StockMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'warehousemgmt_stock_id' => ['name' => 'warehousemgmt_stock_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'warehousemgmt_stock_name' => ['name' => 'warehousemgmt_stock_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'warehousemgmt_stock_type' => ['name' => 'warehousemgmt_stock_type', 'type' => 'int', 'internal' => 'type'],
|
||||
|
|
@ -44,7 +44,7 @@ final class StockMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'warehousemgmt_stock';
|
||||
public const TABLE = 'warehousemgmt_stock';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -52,5 +52,5 @@ final class StockMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'warehousemgmt_stock_id';
|
||||
public const PRIMARYFIELD ='warehousemgmt_stock_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* WarehouseManagement mapper class.
|
||||
|
|
@ -24,6 +24,6 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class StockMovementMapper extends DataMapperAbstract
|
||||
final class StockMovementMapper extends DataMapperFactory
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\WarehouseManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* WarehouseManagement mapper class.
|
||||
|
|
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class StockShelfMapper extends DataMapperAbstract
|
||||
final class StockShelfMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -32,7 +32,7 @@ final class StockShelfMapper extends DataMapperAbstract
|
|||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
public const COLUMNS = [
|
||||
'warehousemgmt_stockshelf_id' => ['name' => 'warehousemgmt_stockshelf_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'warehousemgmt_stockshelf_name' => ['name' => 'warehousemgmt_stockshelf_name', 'type' => 'string', 'internal' => 'name'],
|
||||
'warehousemgmt_stockshelf_location' => ['name' => 'warehousemgmt_stockshelf_location', 'type' => 'int', 'internal' => 'location'],
|
||||
|
|
@ -47,7 +47,7 @@ final class StockShelfMapper extends DataMapperAbstract
|
|||
* @var array<string, array{mapper:string, external:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $belongsTo = [
|
||||
public const BELONGS_TO = [
|
||||
'location' => [
|
||||
'mapper' => StockMapper::class,
|
||||
'external' => 'warehousemgmt_stockshelf_location',
|
||||
|
|
@ -60,7 +60,7 @@ final class StockShelfMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'warehousemgmt_stockshelf';
|
||||
public const TABLE = 'warehousemgmt_stockshelf';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
|
|
@ -68,5 +68,5 @@ final class StockShelfMapper extends DataMapperAbstract
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'warehousemgmt_stockshelf_id';
|
||||
public const PRIMARYFIELD ='warehousemgmt_stockshelf_id';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
|
|||
require_once __DIR__ . '/Autoloader.php';
|
||||
|
||||
use phpOMS\DataStorage\Database\DatabasePool;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\DataStorage\Session\HttpSession;
|
||||
|
||||
$CONFIG = [
|
||||
|
|
@ -329,7 +329,7 @@ $GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete'])
|
|||
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
|
||||
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
|
||||
|
||||
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
|
||||
DataMapperFactory::db($GLOBALS['dbpool']->get());
|
||||
|
||||
$GLOBALS['frameworkpath'] = '/phpOMS/';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user