From cd18f753ca5edb0ed54b596f388ee46e88986112 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 26 Jan 2024 22:54:00 +0000 Subject: [PATCH] auto fixes + some impl. --- Admin/Install/ClientManagement.php | 43 +++++ Admin/Install/SupplierManagement.php | 43 +++++ Admin/Install/db.json | 42 ++++- Admin/Installer.php | 62 ++++--- Admin/Routes/Web/Backend.php | 6 +- Controller/ApiAttributeController.php | 33 ++-- Controller/ApiController.php | 167 ++++++++++-------- Controller/ApiStockTypeController.php | 15 +- Controller/BackendController.php | 2 +- Models/Attribute/LotAttributeTypeMapper.php | 14 +- .../Attribute/LotAttributeValueL11nMapper.php | 8 +- Models/Attribute/LotAttributeValueMapper.php | 18 +- Models/Stock.php | 20 +-- Models/StockDistribution.php | 2 +- Models/StockDistributionMapper.php | 12 +- Models/StockLocation.php | 12 -- Models/StockLocationMapper.php | 18 +- Models/StockMapper.php | 30 +++- Models/StockShelf.php | 12 -- Models/StockShelfMapper.php | 18 +- Models/StockTransaction.php | 28 ++- Models/StockTransactionMapper.php | 22 +-- Models/StockType.php | 14 +- Models/StockTypeL11nMapper.php | 8 +- Models/StockTypeMapper.php | 14 +- ...rofile.tpl.php => stock-type-view.tpl.php} | 2 +- tests/Autoloader.php | 4 +- tests/Bootstrap.php | 71 ++++---- 28 files changed, 444 insertions(+), 296 deletions(-) create mode 100644 Admin/Install/ClientManagement.php create mode 100644 Admin/Install/SupplierManagement.php rename Theme/Backend/{stock-type-profile.tpl.php => stock-type-view.tpl.php} (98%) diff --git a/Admin/Install/ClientManagement.php b/Admin/Install/ClientManagement.php new file mode 100644 index 0000000..f0c4743 --- /dev/null +++ b/Admin/Install/ClientManagement.php @@ -0,0 +1,43 @@ +moduleManager->getModuleInstance('WarehouseManagement', 'Api'); $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', 'Default'); $request->setData('unit', 1); + $request->setData('inventory', true); $module->apiStockCreate($request, $response); - - $responseData = $response->getData(''); - if (!\is_array($responseData)) { - return; - } - - $id = $responseData['response']->id; - - $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); - - $request->header->account = 1; - $request->setData('name', $id . '-1'); - $request->setData('stock', $id); - $module->apiStockLocationCreate($request, $response); - - $responseData = $response->getData(''); - if (!\is_array($responseData)) { - return; - } } /** @@ -131,7 +107,7 @@ final class Installer extends InstallerAbstract foreach ($types as $type) { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', $type['name'] ?? ''); @@ -159,7 +135,7 @@ final class Installer extends InstallerAbstract } $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('title', $l11n); @@ -172,4 +148,34 @@ final class Installer extends InstallerAbstract return $stockTypes; } + + /** + * Import accounts + * + * @param ApplicationAbstract $app Application + * @param string $type Personal account type + * + * @return void + * + * @since 1.0.0 + */ + public static function personalStock(ApplicationAbstract $app, string $type) : void + { + /** @var \Modules\WarehouseManagement\Controller\ApiController $module */ + $module = $app->moduleManager->getModuleInstance('WarehouseManagement', 'Api'); + + $mapper = $type === 'client' + ? \Modules\ClientManagement\Models\ClientMapper::class + : \Modules\SupplierManagement\Models\SupplierMapper::class; + + foreach ($mapper::yield()->execute() as $person) { + $response = new HttpResponse(); + $request = new HttpRequest(); + + $request->header->account = 1; + $request->setData('name', $person->number); + $request->setData($type, $person->id); + $module->apiStockCreate($request, $response); + } + } } diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index a9cff5b..fe7986c 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^.*/warehouse/stock/list.*$' => [ + '^.*/warehouse/stock/list(\?.*$|$)' => [ [ 'dest' => '\Modules\WarehouseManagement\Controller\BackendController:viewStockList', 'verb' => RouteVerb::GET, @@ -40,7 +40,7 @@ return [ ], ], ], - '^.*/warehouse/stock/type/list.*$' => [ + '^.*/warehouse/stock/type/list(\?.*$|$)' => [ [ 'dest' => '\Modules\WarehouseManagement\Controller\BackendController:viewStockTypeList', 'verb' => RouteVerb::GET, @@ -62,7 +62,7 @@ return [ ], ], ], - '^.*/warehouse/stock/location/list.*$' => [ + '^.*/warehouse/stock/location/list(\?.*$|$)' => [ [ 'dest' => '\Modules\WarehouseManagement\Controller\BackendController:viewStockLocationList', 'verb' => RouteVerb::GET, diff --git a/Controller/ApiAttributeController.php b/Controller/ApiAttributeController.php index 0d4d477..aab1ba2 100644 --- a/Controller/ApiAttributeController.php +++ b/Controller/ApiAttributeController.php @@ -17,6 +17,7 @@ namespace Modules\WarehouseManagement\Controller; use Modules\Attribute\Models\Attribute; use Modules\Attribute\Models\AttributeType; use Modules\Attribute\Models\AttributeValue; +use Modules\Attribute\Models\AttributeValueType; use Modules\Attribute\Models\NullAttributeType; use Modules\Attribute\Models\NullAttributeValue; use Modules\WarehouseManagement\Models\Attribute\LotAttributeMapper; @@ -156,12 +157,10 @@ final class ApiAttributeController extends Controller */ private function createLotAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $attrL11n = new BaseStringL11n(); - $attrL11n->ref = $request->getDataInt('type') ?? 0; - $attrL11n->setLanguage( - $request->getDataString('language') ?? $request->header->l11n->language - ); - $attrL11n->content = $request->getDataString('title') ?? ''; + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = $request->getDataInt('type') ?? 0; + $attrL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language; + $attrL11n->content = $request->getDataString('title') ?? ''; return $attrL11n; } @@ -226,11 +225,14 @@ final class ApiAttributeController extends Controller private function createLotAttributeTypeFromRequest(RequestAbstract $request) : AttributeType { $attrType = new AttributeType($request->getDataString('name') ?? ''); - $attrType->datatype = $request->getDataInt('datatype') ?? 0; + $attrType->datatype = AttributeValueType::tryFromValue($request->getDataInt('datatype')) ?? AttributeValueType::_STRING; $attrType->custom = $request->getDataBool('custom') ?? false; $attrType->isRequired = $request->getDataBool('is_required') ?? false; $attrType->validationPattern = $request->getDataString('validation_pattern') ?? ''; - $attrType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $attrType->setL11n( + $request->getDataString('title') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); $attrType->setFields($request->getDataInt('fields') ?? 0); return $attrType; @@ -315,7 +317,10 @@ final class ApiAttributeController extends Controller $attrValue->setValue($request->getDataString('value'), $type->datatype); if ($request->hasData('title')) { - $attrValue->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $attrValue->setL11n( + $request->getDataString('title') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); } return $attrValue; @@ -380,12 +385,10 @@ final class ApiAttributeController extends Controller */ private function createLotAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $attrL11n = new BaseStringL11n(); - $attrL11n->ref = $request->getDataInt('value') ?? 0; - $attrL11n->setLanguage( - $request->getDataString('language') ?? $request->header->l11n->language - ); - $attrL11n->content = $request->getDataString('title') ?? ''; + $attrL11n = new BaseStringL11n(); + $attrL11n->ref = $request->getDataInt('value') ?? 0; + $attrL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language; + $attrL11n->content = $request->getDataString('title') ?? ''; return $attrL11n; } diff --git a/Controller/ApiController.php b/Controller/ApiController.php index f4c38d8..2ab2929 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -18,19 +18,21 @@ use Modules\Billing\Models\BillElement; use Modules\Billing\Models\BillMapper; use Modules\Billing\Models\BillStatus; use Modules\Billing\Models\BillTransferType; +use Modules\ClientManagement\Models\NullClient; use Modules\ItemManagement\Models\StockIdentifierType; +use Modules\SupplierManagement\Models\NullSupplier; use Modules\WarehouseManagement\Models\Stock; use Modules\WarehouseManagement\Models\StockDistribution; use Modules\WarehouseManagement\Models\StockDistributionMapper; use Modules\WarehouseManagement\Models\StockLocation; use Modules\WarehouseManagement\Models\StockLocationMapper; use Modules\WarehouseManagement\Models\StockMapper; +use Modules\WarehouseManagement\Models\StockShelf; +use Modules\WarehouseManagement\Models\StockShelfMapper; use Modules\WarehouseManagement\Models\StockTransaction; use Modules\WarehouseManagement\Models\StockTransactionMapper; use Modules\WarehouseManagement\Models\StockTransactionState; use Modules\WarehouseManagement\Models\StockTransactionType; -use Modules\WarehouseManagement\Models\StockShelf; -use Modules\WarehouseManagement\Models\StockShelfMapper; use phpOMS\Message\Http\RequestStatusCode; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; @@ -69,6 +71,13 @@ final class ApiController extends Controller $stock = $this->createStockFromRequest($request); $this->createModel($request->header->account, $stock, StockMapper::class, 'stock', $request->getOrigin()); + + $request->setData('name', $request->getDataString('name') . '-1', true); + $request->setData('stock', $stock->id, true); + + $stock = $this->createStockLocationFromRequest($request); + $this->createModel($request->header->account, $stock, StockLocationMapper::class, 'stocklocation', $request->getOrigin()); + $this->createStandardCreateResponse($request, $response, $stock); } @@ -103,9 +112,13 @@ final class ApiController extends Controller */ private function createStockFromRequest(RequestAbstract $request) : Stock { - $stock = new Stock(); - $stock->name = $request->getDataString('name') ?? ''; - $stock->unit = $request->getDataInt('unit') ?? 1; + $stock = new Stock(); + $stock->name = $request->getDataString('name') ?? ''; + $stock->unit = $request->getDataInt('unit') ?? 1; + $stock->inventory = $request->getDataBool('inventory') ?? false; + + $stock->client = $request->hasData('client') ? new NullClient($request->getDataInt('client')) : null; + $stock->supplier = $request->hasData('supplier') ? new NullSupplier($request->getDataInt('supplier')) : null; return $stock; } @@ -169,8 +182,8 @@ final class ApiController extends Controller */ private function createStockLocationFromRequest(RequestAbstract $request) : StockLocation { - $location = new StockLocation(); - $location->name = $request->getDataString('name') ?? ''; + $location = new StockLocation(); + $location->name = $request->getDataString('name') ?? ''; $location->stock = $request->getDataInt('stock') ?? 1; return $location; @@ -197,12 +210,12 @@ final class ApiController extends Controller int $account, mixed $old, mixed $new, - int $type = null, + ?int $type = null, string $trigger = '', - string $module = null, - string $ref = null, - string $content = null, - string $ip = null + ?string $module = null, + ?string $ref = null, + ?string $content = null, + ?string $ip = null ) : void { /** @var \Modules\ClientManagement\Models\Client|\Modules\SupplierManagement\Models\Supplier $new */ @@ -234,17 +247,20 @@ final class ApiController extends Controller * @return void * * @since 1.0.0 + * + * @todo Cleanup/restructure so this function works with database transactions and exceptions. This function is very critical! + * Maybe do the transaction outside wherever the updateModel/createModel/... functions are called. */ public function eventBillUpdateInternal( int $account, mixed $old, mixed $new, - int $type = null, + ?int $type = null, string $trigger = '', - string $module = null, - string $ref = null, - string $content = null, - string $ip = null + ?string $module = null, + ?string $ref = null, + ?string $content = null, + ?string $ip = null ) : void { // Directly/manually creating a transaction is handled in the API Create/Update functions. @@ -255,18 +271,34 @@ final class ApiController extends Controller $bill = BillMapper::get() ->with('type') ->with('elements') + ->with('elements/container') ->with('elements/item') ->with('supplier') ->with('client') ->where('id', $isBillElement ? $new->bill->id : $new->id) + ->where('type/transferStock', true) ->execute(); // Has stock movement? - if (!$bill->type->transferStock) { + if ($bill->id === 0 || !$bill->type->transferStock) { return; } - $billElements = $isBillElement ? [$new] : $bill->elements; + /* + Only necessary if actual client/supplier stock + $externalStock = 1; + if ($bill->client !== null) { + $externalStock = StockMapper::get() + ->where('client', $bill->client->id) + ->limit(1) + ->execute(); + } elseif ($bill->supplier !== null) { + $externalStock = StockMapper::get() + ->where('supplier', $bill->supplier->id) + ->limit(1) + ->execute(); + } + */ // @todo check if old element existed -> removed/changed item // @todo we cannot have transaction->to and transaction->from be the id of client/supplier because the IDs can overlap @@ -276,7 +308,7 @@ final class ApiController extends Controller // invoice with partly delivery note(s), // invoice with no delivery note // @todo Handle bill drafts (now only finalization moves stock, how do we reserve stock?) - foreach ($billElements as $element) { + foreach ($bill->elements as $element) { if ($element->item === 0 || $element->item === null || $element->item->stockIdentifier === StockIdentifierType::NONE ) { @@ -288,15 +320,14 @@ final class ApiController extends Controller ->where('stock', 1) // @todo fix ->where('stockType', 1) // @todo fix ->where('lot', $element->item->stockIdentifier === StockIdentifierType::NUMBER ? null : '') + ->limit(1) ->execute(); - $transaction = new StockTransaction(); - // @todo how to handle only reserving items for drafted bills (not yet shipped) - if ($trigger === 'POST:Module:Billing-bill_element-create') { + if ($trigger === 'Billing-bill_element-create') { // Check stock availability - if ($bill->type->sign < 0 && $dist->quantity < $element->quantity) { + if ($bill->type->sign > 0 && $dist->quantity < $element->quantity->getInt()) { continue; } @@ -306,31 +337,30 @@ final class ApiController extends Controller ///////////////////////////////////////////////////////////////// // @todo handle stock returns!!! - if ($bill->type->sign < 0) { - $dist->quantity -= $element->quantity; + if ($bill->type->sign > 0) { + $dist->quantity -= $element->quantity->getInt(); StockDistributionMapper::update()->execute($dist); + } elseif ($dist->id === 0) { + $dist = new StockDistribution(); + $dist->item = $element->item->id; + $dist->quantity = $element->quantity->getInt(); + + $dist->lot = null; // @todo handle correct + $dist->stock = 1; // @todo handle correct + $dist->stockType = 1; // @todo handle correct + + StockDistributionMapper::create()->execute($dist); } else { - if ($dist->id === 0) { - $dist = new StockDistribution(); - $dist->item = $element->item->id; - $dist->quantity = $element->quantity; + $dist->quantity += $element->quantity->getInt(); - $dist->lot = null; // @todo handle correct - $dist->stock = 1; // @todo handle correct - $dist->stockType = 1; // @todo handle correct - - StockDistributionMapper::create()->execute($dist); - } else { - $dist->quantity += $element->quantity; - - StockDistributionMapper::update()->execute($dist); - } + StockDistributionMapper::update()->execute($dist); } // Handle transfer protocol ///////////////////////////////////////////////////////////////// + $transaction = new StockTransaction(); $transaction->billElement = $new->id; $transaction->state = StockTransactionState::DRAFT; @@ -338,7 +368,8 @@ final class ApiController extends Controller // @todo find stock candidates $transaction->type = StockTransactionType::TRANSFER; // @todo depends on bill type - $transaction->quantity = $new->getQuantity(); // @todo may require split quantity if not sufficient available from one lost + $transaction->quantity = $new->quantity->getInt(); // @todo may require split quantity if not sufficient available from one lost + $transaction->item = $element->item->id; // @todo allow consignment bills // @todo allow to pass stocklocation for entire bill to avoid re-defining it @@ -347,8 +378,13 @@ final class ApiController extends Controller if ($bill->type->sign > 0) { // Handle from // @todo find possible candidate based on defined default stock for bill type/org/location + $transaction->fromStock = 1; // @todo requires update + $transaction->fromStockType = 1; // @todo requires update // Handle to + $transaction->toStock = null; // @todo requires update + $transaction->toStockType = null; // @todo requires update + if (($bill->client?->id ?? 0) !== 0) { // @todo remove phpstan this is just a bug fix until phpstan fixes this bug /** @phpstan-ignore-next-line */ @@ -362,10 +398,13 @@ final class ApiController extends Controller if ($bill->type->transferType === BillTransferType::SALES) { $transaction->subtype = StockTransactionType::SALE; } elseif ($bill->type->transferType === BillTransferType::PURCHASE) { - $transaction->subtype = StockTransactionType::PURCHASE; + $transaction->subtype = StockTransactionType::RETURN; } } else { // Handle from + $transaction->fromStock = null; // @todo requires update + $transaction->fromStockType = null; // @todo requires update + if (($bill->client?->id ?? 0) !== 0) { // @todo remove phpstan this is just a bug fix until phpstan fixes this bug /** @phpstan-ignore-next-line */ @@ -378,16 +417,18 @@ final class ApiController extends Controller // Handle to // @todo find possible candidate based on defined default stock for bill type/org/location + $transaction->toStock = 1; // @todo requires update + $transaction->toStockType = 1; // @todo requires update - if ($bill->type->transferType === BillTransferType::SALES - || $bill->type->transferType === BillTransferType::PURCHASE - ) { + if ($bill->type->transferType === BillTransferType::SALES) { $transaction->subtype = StockTransactionType::RETURN; + } elseif ($bill->type->transferType === BillTransferType::PURCHASE) { + $transaction->subtype = StockTransactionType::PURCHASE; } } StockTransactionMapper::create()->execute($transaction); - } elseif ($trigger === 'POST:Module:Billing-bill_element-update') { + } elseif ($trigger === 'Billing-bill_element-update') { /** @var \Modules\Billing\Models\BillElement $new */ /** @var \Modules\Billing\Models\BillElement $old */ /** @var \Modules\WarehouseManagement\Models\StockTransaction[] $transactions */ @@ -406,15 +447,18 @@ final class ApiController extends Controller // and then do normal algorithm like for a new element } */ - if ($new->item !== $old->item) { + if ($new->item->id !== $old->item->id) { + // @todo: also undo stock amount in stock distribution StockTransactionMapper::delete()->execute($transactions); $this->eventBillUpdateInternal( $account, $old, $new, - $type, 'POST:Module:Billing-bill_element-create', $module, $ref, $content, $ip + $type, 'Billing-bill_element-create', $module, $ref, $content, $ip ); } - } elseif ($trigger === 'POST:Module:Billing-bill_element-delete') { + + // @todo handle same item but quantity update + } elseif ($trigger === 'Billing-bill_element-delete') { /** @var \Modules\Billing\Models\BillElement $new */ /** @var \Modules\WarehouseManagement\Models\StockTransaction[] $transactions */ $transactions = StockTransactionMapper::getAll() @@ -422,17 +466,7 @@ final class ApiController extends Controller ->execute(); StockTransactionMapper::delete()->execute($transactions); - } elseif ($trigger === 'POST:Module:Billing-bill-delete') { - /** @var \Modules\Billing\Models\Bill $new */ - /** @var \Modules\Billing\Models\Bill $bill */ - $bill = BillMapper::get() - ->with('type') - ->with('elements') - ->with('supplier') - ->with('client') - ->where('id', $new->id) - ->execute(); - + } elseif ($trigger === 'Billing-bill-delete') { foreach ($bill->elements as $element) { /** @var \Modules\WarehouseManagement\Models\StockTransaction[] $transactions */ $transactions = StockTransactionMapper::getAll() @@ -442,7 +476,7 @@ final class ApiController extends Controller StockTransactionMapper::delete()->execute($transactions); // @todo consider not to delete but mark as deleted? } - } elseif ($trigger === 'POST:Module:Billing-bill-update') { + } elseif ($trigger === 'Billing-bill-update') { // is receiver update -> change all movements // is status update -> change all movements (delete = delete) @@ -450,18 +484,9 @@ final class ApiController extends Controller if ($new->status === BillStatus::DELETED) { $this->eventBillUpdateInternal( $account, $old, $new, - $type, 'POST:Module:Billing-bill-delete', $module, $ref, $content, $ip + $type, 'Billing-bill-delete', $module, $ref, $content, $ip ); } elseif ($new->status === BillStatus::ARCHIVED) { - /** @var \Modules\Billing\Models\Bill $bill */ - $bill = BillMapper::get() - ->with('type') - ->with('elements') - ->with('supplier') - ->with('client') - ->where('id', $new->id) - ->execute(); - foreach ($bill->elements as $element) { /** @var \Modules\WarehouseManagement\Models\StockTransaction[] $transactions */ $transactions = StockTransactionMapper::getAll() diff --git a/Controller/ApiStockTypeController.php b/Controller/ApiStockTypeController.php index 2a32593..b7b9202 100644 --- a/Controller/ApiStockTypeController.php +++ b/Controller/ApiStockTypeController.php @@ -74,7 +74,10 @@ final class ApiStockTypeController extends Controller { $stockType = new StockType(); $stockType->name = $request->getDataString('name') ?? ''; - $stockType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $stockType->setL11n( + $request->getDataString('title') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); return $stockType; } @@ -138,12 +141,10 @@ final class ApiStockTypeController extends Controller */ private function createStockTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $stockTypeL11n = new BaseStringL11n(); - $stockTypeL11n->ref = $request->getDataInt('type') ?? 0; - $stockTypeL11n->setLanguage( - $request->getDataString('language') ?? $request->header->l11n->language - ); - $stockTypeL11n->content = $request->getDataString('title') ?? ''; + $stockTypeL11n = new BaseStringL11n(); + $stockTypeL11n->ref = $request->getDataInt('type') ?? 0; + $stockTypeL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language; + $stockTypeL11n->content = $request->getDataString('title') ?? ''; return $stockTypeL11n; } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 56e87f5..efbc585 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -152,7 +152,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/WarehouseManagement/Theme/Backend/stock-type-profile'); + $view->setTemplate('/Modules/WarehouseManagement/Theme/Backend/stock-type-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1001302001, $request, $response); $view->data['type'] = StockMapper::get()->where('id', (int) $request->getData('id'))->execute(); diff --git a/Models/Attribute/LotAttributeTypeMapper.php b/Models/Attribute/LotAttributeTypeMapper.php index 3d07f08..ec2122d 100644 --- a/Models/Attribute/LotAttributeTypeMapper.php +++ b/Models/Attribute/LotAttributeTypeMapper.php @@ -37,13 +37,13 @@ final class LotAttributeTypeMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_attr_type_id' => ['name' => 'warehousemgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_attr_type_name' => ['name' => 'warehousemgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], - 'warehousemgmt_attr_type_datatype' => ['name' => 'warehousemgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], - 'warehousemgmt_attr_type_fields' => ['name' => 'warehousemgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], - 'warehousemgmt_attr_type_custom' => ['name' => 'warehousemgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], - 'warehousemgmt_attr_type_pattern' => ['name' => 'warehousemgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], - 'warehousemgmt_attr_type_required' => ['name' => 'warehousemgmt_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], + 'warehousemgmt_attr_type_id' => ['name' => 'warehousemgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_attr_type_name' => ['name' => 'warehousemgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'warehousemgmt_attr_type_datatype' => ['name' => 'warehousemgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'], + 'warehousemgmt_attr_type_fields' => ['name' => 'warehousemgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'], + 'warehousemgmt_attr_type_custom' => ['name' => 'warehousemgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'], + 'warehousemgmt_attr_type_pattern' => ['name' => 'warehousemgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'], + 'warehousemgmt_attr_type_required' => ['name' => 'warehousemgmt_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'], ]; /** diff --git a/Models/Attribute/LotAttributeValueL11nMapper.php b/Models/Attribute/LotAttributeValueL11nMapper.php index ed11ab2..f8c52a9 100644 --- a/Models/Attribute/LotAttributeValueL11nMapper.php +++ b/Models/Attribute/LotAttributeValueL11nMapper.php @@ -37,10 +37,10 @@ final class LotAttributeValueL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_attr_value_l11n_id' => ['name' => 'warehousemgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_attr_value_l11n_title' => ['name' => 'warehousemgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], - 'warehousemgmt_attr_value_l11n_value' => ['name' => 'warehousemgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'], - 'warehousemgmt_attr_value_l11n_lang' => ['name' => 'warehousemgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'], + 'warehousemgmt_attr_value_l11n_id' => ['name' => 'warehousemgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_attr_value_l11n_title' => ['name' => 'warehousemgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'warehousemgmt_attr_value_l11n_value' => ['name' => 'warehousemgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'], + 'warehousemgmt_attr_value_l11n_lang' => ['name' => 'warehousemgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/Attribute/LotAttributeValueMapper.php b/Models/Attribute/LotAttributeValueMapper.php index ab26e7e..6298a10 100644 --- a/Models/Attribute/LotAttributeValueMapper.php +++ b/Models/Attribute/LotAttributeValueMapper.php @@ -37,15 +37,15 @@ final class LotAttributeValueMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_attr_value_id' => ['name' => 'warehousemgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_attr_value_default' => ['name' => 'warehousemgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], - 'warehousemgmt_attr_value_valueStr' => ['name' => 'warehousemgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], - 'warehousemgmt_attr_value_valueInt' => ['name' => 'warehousemgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], - 'warehousemgmt_attr_value_valueDec' => ['name' => 'warehousemgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], - 'warehousemgmt_attr_value_valueDat' => ['name' => 'warehousemgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], - 'warehousemgmt_attr_value_unit' => ['name' => 'warehousemgmt_attr_value_unit', 'type' => 'string', 'internal' => 'unit'], - 'warehousemgmt_attr_value_deptype' => ['name' => 'warehousemgmt_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'], - 'warehousemgmt_attr_value_depvalue' => ['name' => 'warehousemgmt_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'], + 'warehousemgmt_attr_value_id' => ['name' => 'warehousemgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_attr_value_default' => ['name' => 'warehousemgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'], + 'warehousemgmt_attr_value_valueStr' => ['name' => 'warehousemgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'], + 'warehousemgmt_attr_value_valueInt' => ['name' => 'warehousemgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'], + 'warehousemgmt_attr_value_valueDec' => ['name' => 'warehousemgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'], + 'warehousemgmt_attr_value_valueDat' => ['name' => 'warehousemgmt_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'], + 'warehousemgmt_attr_value_unit' => ['name' => 'warehousemgmt_attr_value_unit', 'type' => 'string', 'internal' => 'unit'], + 'warehousemgmt_attr_value_deptype' => ['name' => 'warehousemgmt_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'], + 'warehousemgmt_attr_value_depvalue' => ['name' => 'warehousemgmt_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'], ]; /** diff --git a/Models/Stock.php b/Models/Stock.php index 7729802..839dbf3 100755 --- a/Models/Stock.php +++ b/Models/Stock.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\WarehouseManagement\Models; +use Modules\ClientManagement\Models\Client; +use Modules\SupplierManagement\Models\Supplier; use phpOMS\Stdlib\Base\Address; /** @@ -44,8 +46,14 @@ class Stock public int $unit = 0; + public ?Client $client = null; + + public ?Supplier $supplier = null; + public ?Address $address = null; + public bool $inventory = false; + /** * Constructor. * @@ -57,16 +65,4 @@ class Stock { $this->name = $name; } - - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } } diff --git a/Models/StockDistribution.php b/Models/StockDistribution.php index 2aa6c70..265b79a 100644 --- a/Models/StockDistribution.php +++ b/Models/StockDistribution.php @@ -34,7 +34,7 @@ class StockDistribution public int $quantity = 0; - public int $lot = 0; + public ?int $lot = null; public int $item = 0; diff --git a/Models/StockDistributionMapper.php b/Models/StockDistributionMapper.php index e912566..aced4a6 100644 --- a/Models/StockDistributionMapper.php +++ b/Models/StockDistributionMapper.php @@ -36,12 +36,12 @@ final class StockDistributionMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_stock_distribution_id' => ['name' => 'warehousemgmt_stock_distribution_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_stock_distribution_item' => ['name' => 'warehousemgmt_stock_distribution_item', 'type' => 'int', 'internal' => 'item'], - 'warehousemgmt_stock_distribution_lot' => ['name' => 'warehousemgmt_stock_distribution_lot', 'type' => 'int', 'internal' => 'lot'], - 'warehousemgmt_stock_distribution_stock' => ['name' => 'warehousemgmt_stock_distribution_stock', 'type' => 'int', 'internal' => 'stock'], - 'warehousemgmt_stock_distribution_stocktype' => ['name' => 'warehousemgmt_stock_distribution_stocktype', 'type' => 'int', 'internal' => 'stockType'], - 'warehousemgmt_stock_distribution_quantity' => ['name' => 'warehousemgmt_stock_distribution_quantity', 'type' => 'int', 'internal' => 'quantity'], + 'warehousemgmt_stock_distribution_id' => ['name' => 'warehousemgmt_stock_distribution_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_stock_distribution_item' => ['name' => 'warehousemgmt_stock_distribution_item', 'type' => 'int', 'internal' => 'item'], + 'warehousemgmt_stock_distribution_lot' => ['name' => 'warehousemgmt_stock_distribution_lot', 'type' => 'int', 'internal' => 'lot'], + 'warehousemgmt_stock_distribution_stock' => ['name' => 'warehousemgmt_stock_distribution_stock', 'type' => 'int', 'internal' => 'stock'], + 'warehousemgmt_stock_distribution_stocktype' => ['name' => 'warehousemgmt_stock_distribution_stocktype', 'type' => 'int', 'internal' => 'stockType'], + 'warehousemgmt_stock_distribution_quantity' => ['name' => 'warehousemgmt_stock_distribution_quantity', 'type' => 'int', 'internal' => 'quantity'], ]; /** diff --git a/Models/StockLocation.php b/Models/StockLocation.php index aeef0e0..428cf3c 100755 --- a/Models/StockLocation.php +++ b/Models/StockLocation.php @@ -55,16 +55,4 @@ class StockLocation { $this->name = $name; } - - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } } diff --git a/Models/StockLocationMapper.php b/Models/StockLocationMapper.php index 8082eb5..c30bcc8 100755 --- a/Models/StockLocationMapper.php +++ b/Models/StockLocationMapper.php @@ -36,13 +36,13 @@ final class StockLocationMapper extends DataMapperFactory * @since 1.0.0 */ 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'], - 'warehousemgmt_stocklocation_type' => ['name' => 'warehousemgmt_stocklocation_type', 'type' => 'int', 'internal' => 'type'], - 'warehousemgmt_stocklocation_x' => ['name' => 'warehousemgmt_stocklocation_x', 'type' => 'int', 'internal' => 'x'], - 'warehousemgmt_stocklocation_y' => ['name' => 'warehousemgmt_stocklocation_y', 'type' => 'int', 'internal' => 'y'], - 'warehousemgmt_stocklocation_z' => ['name' => 'warehousemgmt_stocklocation_z', 'type' => 'int', 'internal' => 'z'], + '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'], + 'warehousemgmt_stocklocation_type' => ['name' => 'warehousemgmt_stocklocation_type', 'type' => 'int', 'internal' => 'type'], + 'warehousemgmt_stocklocation_x' => ['name' => 'warehousemgmt_stocklocation_x', 'type' => 'int', 'internal' => 'x'], + 'warehousemgmt_stocklocation_y' => ['name' => 'warehousemgmt_stocklocation_y', 'type' => 'int', 'internal' => 'y'], + 'warehousemgmt_stocklocation_z' => ['name' => 'warehousemgmt_stocklocation_z', 'type' => 'int', 'internal' => 'z'], ]; /** @@ -53,8 +53,8 @@ final class StockLocationMapper extends DataMapperFactory */ public const BELONGS_TO = [ 'stock' => [ - 'mapper' => StockMapper::class, - 'external' => 'warehousemgmt_stocklocation_stock', + 'mapper' => StockMapper::class, + 'external' => 'warehousemgmt_stocklocation_stock', ], ]; diff --git a/Models/StockMapper.php b/Models/StockMapper.php index a6e798a..dd71bb5 100755 --- a/Models/StockMapper.php +++ b/Models/StockMapper.php @@ -15,6 +15,8 @@ declare(strict_types=1); namespace Modules\WarehouseManagement\Models; use Modules\Admin\Models\AddressMapper; +use Modules\ClientManagement\Models\ClientMapper; +use Modules\SupplierManagement\Models\SupplierMapper; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; /** @@ -37,10 +39,13 @@ final class StockMapper extends DataMapperFactory * @since 1.0.0 */ 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_unit' => ['name' => 'warehousemgmt_stock_unit', 'type' => 'int', 'internal' => 'unit'], - 'warehousemgmt_stock_address' => ['name' => 'warehousemgmt_stock_address', 'type' => 'int', 'internal' => 'address'], + 'warehousemgmt_stock_id' => ['name' => 'warehousemgmt_stock_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_stock_name' => ['name' => 'warehousemgmt_stock_name', 'type' => 'string', 'internal' => 'name'], + 'warehousemgmt_stock_unit' => ['name' => 'warehousemgmt_stock_unit', 'type' => 'int', 'internal' => 'unit'], + 'warehousemgmt_stock_client' => ['name' => 'warehousemgmt_stock_client', 'type' => 'int', 'internal' => 'client'], + 'warehousemgmt_stock_supplier' => ['name' => 'warehousemgmt_stock_supplier', 'type' => 'int', 'internal' => 'supplier'], + 'warehousemgmt_stock_inventory' => ['name' => 'warehousemgmt_stock_inventory', 'type' => 'bool', 'internal' => 'inventory'], + 'warehousemgmt_stock_address' => ['name' => 'warehousemgmt_stock_address', 'type' => 'int', 'internal' => 'address'], ]; /** @@ -56,6 +61,23 @@ final class StockMapper extends DataMapperFactory ], ]; + /** + * Belongs to. + * + * @var array + * @since 1.0.0 + */ + public const BELONGS_TO = [ + 'client' => [ + 'mapper' => ClientMapper::class, + 'external' => 'warehousemgmt_stock_client', + ], + 'supplier' => [ + 'mapper' => SupplierMapper::class, + 'external' => 'warehousemgmt_stock_supplier', + ], + ]; + /** * Primary table. * diff --git a/Models/StockShelf.php b/Models/StockShelf.php index b2411e8..e5c0fc0 100755 --- a/Models/StockShelf.php +++ b/Models/StockShelf.php @@ -55,16 +55,4 @@ class StockShelf { $this->name = $name; } - - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } } diff --git a/Models/StockShelfMapper.php b/Models/StockShelfMapper.php index 916f203..8972ecb 100755 --- a/Models/StockShelfMapper.php +++ b/Models/StockShelfMapper.php @@ -36,13 +36,13 @@ final class StockShelfMapper extends DataMapperFactory * @since 1.0.0 */ 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'], - 'warehousemgmt_stockshelf_type' => ['name' => 'warehousemgmt_stockshelf_type', 'type' => 'int', 'internal' => 'type'], - 'warehousemgmt_stockshelf_x' => ['name' => 'warehousemgmt_stockshelf_x', 'type' => 'int', 'internal' => 'x'], - 'warehousemgmt_stockshelf_y' => ['name' => 'warehousemgmt_stockshelf_y', 'type' => 'int', 'internal' => 'y'], - 'warehousemgmt_stockshelf_z' => ['name' => 'warehousemgmt_stockshelf_z', 'type' => 'int', 'internal' => 'z'], + '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'], + 'warehousemgmt_stockshelf_type' => ['name' => 'warehousemgmt_stockshelf_type', 'type' => 'int', 'internal' => 'type'], + 'warehousemgmt_stockshelf_x' => ['name' => 'warehousemgmt_stockshelf_x', 'type' => 'int', 'internal' => 'x'], + 'warehousemgmt_stockshelf_y' => ['name' => 'warehousemgmt_stockshelf_y', 'type' => 'int', 'internal' => 'y'], + 'warehousemgmt_stockshelf_z' => ['name' => 'warehousemgmt_stockshelf_z', 'type' => 'int', 'internal' => 'z'], ]; /** @@ -53,8 +53,8 @@ final class StockShelfMapper extends DataMapperFactory */ public const BELONGS_TO = [ 'location' => [ - 'mapper' => StockMapper::class, - 'external' => 'warehousemgmt_stockshelf_location', + 'mapper' => StockMapper::class, + 'external' => 'warehousemgmt_stockshelf_location', ], ]; diff --git a/Models/StockTransaction.php b/Models/StockTransaction.php index 5225503..4d02ca7 100644 --- a/Models/StockTransaction.php +++ b/Models/StockTransaction.php @@ -55,13 +55,17 @@ class StockTransaction public int $item = 0; - public int $fromLot = 0; - public int $fromStock = 0; - public int $fromStockType = 0; + public ?int $fromLot = null; - public int $toLot = 0; - public int $toStock = 0; - public int $toStockType = 0; + public ?int $fromStock = null; + + public ?int $fromStockType = null; + + public ?int $toLot = null; + + public ?int $toStock = null; + + public ?int $toStockType = null; /** * Creator. @@ -89,16 +93,4 @@ class StockTransaction $this->createdBy = new NullAccount(); $this->createdAt = new \DateTimeImmutable('now'); } - - /** - * Get ID. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() - { - return $this->id; - } } diff --git a/Models/StockTransactionMapper.php b/Models/StockTransactionMapper.php index 25f837d..f517799 100644 --- a/Models/StockTransactionMapper.php +++ b/Models/StockTransactionMapper.php @@ -36,18 +36,18 @@ final class StockTransactionMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_stock_transaction_id' => ['name' => 'warehousemgmt_stock_transaction_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_stock_transaction_state' => ['name' => 'warehousemgmt_stock_transaction_state', 'type' => 'int', 'internal' => 'state'], - 'warehousemgmt_stock_transaction_quantity' => ['name' => 'warehousemgmt_stock_transaction_quantity', 'type' => 'int', 'internal' => 'quantity'], - 'warehousemgmt_stock_transaction_type' => ['name' => 'warehousemgmt_stock_transaction_type', 'type' => 'int', 'internal' => 'type'], - 'warehousemgmt_stock_transaction_item' => ['name' => 'warehousemgmt_stock_transaction_item', 'type' => 'int', 'internal' => 'item'], - 'warehousemgmt_stock_transaction_from_lot' => ['name' => 'warehousemgmt_stock_transaction_from_lot', 'type' => 'int', 'internal' => 'fromLot'], - 'warehousemgmt_stock_transaction_from_stock' => ['name' => 'warehousemgmt_stock_transaction_from_stock', 'type' => 'int', 'internal' => 'fromStock'], - 'warehousemgmt_stock_transaction_from_stocktype' => ['name' => 'warehousemgmt_stock_transaction_from_stocktype', 'type' => 'int', 'internal' => 'fromStockType'], + 'warehousemgmt_stock_transaction_id' => ['name' => 'warehousemgmt_stock_transaction_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_stock_transaction_state' => ['name' => 'warehousemgmt_stock_transaction_state', 'type' => 'int', 'internal' => 'state'], + 'warehousemgmt_stock_transaction_quantity' => ['name' => 'warehousemgmt_stock_transaction_quantity', 'type' => 'int', 'internal' => 'quantity'], + 'warehousemgmt_stock_transaction_type' => ['name' => 'warehousemgmt_stock_transaction_type', 'type' => 'int', 'internal' => 'type'], + 'warehousemgmt_stock_transaction_item' => ['name' => 'warehousemgmt_stock_transaction_item', 'type' => 'int', 'internal' => 'item'], + 'warehousemgmt_stock_transaction_from_lot' => ['name' => 'warehousemgmt_stock_transaction_from_lot', 'type' => 'int', 'internal' => 'fromLot'], + 'warehousemgmt_stock_transaction_from_stock' => ['name' => 'warehousemgmt_stock_transaction_from_stock', 'type' => 'int', 'internal' => 'fromStock'], + 'warehousemgmt_stock_transaction_from_stocktype' => ['name' => 'warehousemgmt_stock_transaction_from_stocktype', 'type' => 'int', 'internal' => 'fromStockType'], 'warehousemgmt_stock_transaction_to_lot' => ['name' => 'warehousemgmt_stock_transaction_to_lot', 'type' => 'int', 'internal' => 'toLot'], - 'warehousemgmt_stock_transaction_to_stock' => ['name' => 'warehousemgmt_stock_transaction_to_stock', 'type' => 'int', 'internal' => 'toStock'], - 'warehousemgmt_stock_transaction_to_stocktype' => ['name' => 'warehousemgmt_stock_transaction_to_stocktype', 'type' => 'int', 'internal' => 'toStockType'], - 'warehousemgmt_stock_transaction_bill_element' => ['name' => 'warehousemgmt_stock_transaction_bill_element', 'type' => 'int', 'internal' => 'billElement'], + 'warehousemgmt_stock_transaction_to_stock' => ['name' => 'warehousemgmt_stock_transaction_to_stock', 'type' => 'int', 'internal' => 'toStock'], + 'warehousemgmt_stock_transaction_to_stocktype' => ['name' => 'warehousemgmt_stock_transaction_to_stocktype', 'type' => 'int', 'internal' => 'toStockType'], + 'warehousemgmt_stock_transaction_bill_element' => ['name' => 'warehousemgmt_stock_transaction_bill_element', 'type' => 'int', 'internal' => 'billElement'], ]; /** diff --git a/Models/StockType.php b/Models/StockType.php index b1d7b0c..ce266ab 100644 --- a/Models/StockType.php +++ b/Models/StockType.php @@ -65,13 +65,13 @@ class StockType if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->ref = $this->id; - $this->l11n->setLanguage($lang); + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->ref = $this->id; + $this->l11n->language = $lang; } } @@ -95,7 +95,7 @@ class StockType public function toArray() : array { return [ - 'id' => $this->id, + 'id' => $this->id, ]; } diff --git a/Models/StockTypeL11nMapper.php b/Models/StockTypeL11nMapper.php index 0b42791..8ca1b15 100644 --- a/Models/StockTypeL11nMapper.php +++ b/Models/StockTypeL11nMapper.php @@ -37,10 +37,10 @@ final class StockTypeL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_stock_type_l11n_id' => ['name' => 'warehousemgmt_stock_type_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_stock_type_l11n_name' => ['name' => 'warehousemgmt_stock_type_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], - 'warehousemgmt_stock_type_l11n_type' => ['name' => 'warehousemgmt_stock_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], - 'warehousemgmt_stock_type_l11n_language' => ['name' => 'warehousemgmt_stock_type_l11n_language', 'type' => 'string', 'internal' => 'language'], + 'warehousemgmt_stock_type_l11n_id' => ['name' => 'warehousemgmt_stock_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_stock_type_l11n_name' => ['name' => 'warehousemgmt_stock_type_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'warehousemgmt_stock_type_l11n_type' => ['name' => 'warehousemgmt_stock_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], + 'warehousemgmt_stock_type_l11n_language' => ['name' => 'warehousemgmt_stock_type_l11n_language', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/StockTypeMapper.php b/Models/StockTypeMapper.php index 08b6353..bea188e 100644 --- a/Models/StockTypeMapper.php +++ b/Models/StockTypeMapper.php @@ -36,8 +36,8 @@ final class StockTypeMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'warehousemgmt_stock_type_id' => ['name' => 'warehousemgmt_stock_type_id', 'type' => 'int', 'internal' => 'id'], - 'warehousemgmt_stock_type_name' => ['name' => 'warehousemgmt_stock_type_name', 'type' => 'string', 'internal' => 'name'], + 'warehousemgmt_stock_type_id' => ['name' => 'warehousemgmt_stock_type_id', 'type' => 'int', 'internal' => 'id'], + 'warehousemgmt_stock_type_name' => ['name' => 'warehousemgmt_stock_type_name', 'type' => 'string', 'internal' => 'name'], ]; /** @@ -48,11 +48,11 @@ final class StockTypeMapper extends DataMapperFactory */ public const HAS_MANY = [ 'l11n' => [ - 'mapper' => StockTypeL11nMapper::class, - 'table' => 'warehousemgmt_stock_type_l11n', - 'self' => 'warehousemgmt_stock_type_l11n_type', - 'column' => 'content', - 'external' => null, + 'mapper' => StockTypeL11nMapper::class, + 'table' => 'warehousemgmt_stock_type_l11n', + 'self' => 'warehousemgmt_stock_type_l11n_type', + 'column' => 'content', + 'external' => null, ], ]; diff --git a/Theme/Backend/stock-type-profile.tpl.php b/Theme/Backend/stock-type-view.tpl.php similarity index 98% rename from Theme/Backend/stock-type-profile.tpl.php rename to Theme/Backend/stock-type-view.tpl.php index e90cd64..5561fb2 100644 --- a/Theme/Backend/stock-type-profile.tpl.php +++ b/Theme/Backend/stock-type-view.tpl.php @@ -79,7 +79,7 @@ echo $this->data['nav']->render(); id; ?> printHtml($value->type->title); ?> - printHtml($value->getLanguage()); ?> + printHtml($value->language); ?> printHtml(\substr($value->content, 0, 100))); ?> diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 7cf411e..128e4b7 100755 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -75,8 +75,8 @@ final class Autoloader */ public static function defaultAutoloader(string $class) : void { - $class = \ltrim($class, '\\'); - $class = \strtr($class, '_\\', '//'); + $class = \ltrim($class, '\\'); + $class = \strtr($class, '_\\', '//'); if (\stripos($class, 'Web/Backend') !== false || \stripos($class, 'Web/Api') !== false) { $class = \is_dir(__DIR__ . '/Web') ? $class : \str_replace('Web/', 'MainRepository/Web/', $class); diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index ddc049d..eb0b0b5 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -1,4 +1,15 @@ [ + 'db' => [ 'core' => [ 'masters' => [ - 'admin' => [ + 'admin' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -80,7 +91,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -90,7 +101,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -100,7 +111,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -110,7 +121,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -120,7 +131,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'mysql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '3306', /* db host port */ @@ -132,7 +143,7 @@ $CONFIG = [ ], ], 'postgresql' => [ - 'admin' => [ + 'admin' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -142,7 +153,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -152,7 +163,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -162,7 +173,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -172,7 +183,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -182,7 +193,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'pgsql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '5432', /* db host port */ @@ -194,37 +205,37 @@ $CONFIG = [ ], ], 'sqlite' => [ - 'admin' => [ + 'admin' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'sqlite', /* db type */ 'database' => __DIR__ . '/../Karaka/phpOMS/Localization/Defaults/localization.sqlite', /* db name */ 'weight' => 1000, /* db table prefix */ @@ -232,7 +243,7 @@ $CONFIG = [ ], ], 'mssql' => [ - 'admin' => [ + 'admin' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -242,7 +253,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'insert' => [ + 'insert' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -252,7 +263,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'select' => [ + 'select' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -262,7 +273,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'update' => [ + 'update' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -272,7 +283,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'delete' => [ + 'delete' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -282,7 +293,7 @@ $CONFIG = [ 'weight' => 1000, /* db table prefix */ 'datetimeformat' => 'Y-m-d H:i:s', ], - 'schema' => [ + 'schema' => [ 'db' => 'mssql', /* db type */ 'host' => '127.0.0.1', /* db host address */ 'port' => '1433', /* db host port */ @@ -322,16 +333,16 @@ $CONFIG = [ 'password' => '123456', ], ], - 'log' => [ + 'log' => [ 'file' => [ 'path' => __DIR__ . '/Logs', ], ], - 'page' => [ + 'page' => [ 'root' => '/', 'https' => false, ], - 'app' => [ + 'app' => [ 'path' => __DIR__, 'default' => [ 'app' => 'Backend', @@ -350,7 +361,7 @@ $CONFIG = [ ], ], ], - 'socket' => [ + 'socket' => [ 'master' => [ 'host' => '127.0.0.1', 'limit' => 300, @@ -360,7 +371,7 @@ $CONFIG = [ 'language' => [ 'en', ], - 'apis' => [ + 'apis' => [ ], ];