diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 9a9446c..7340394 100755 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -29,8 +29,8 @@ class Navigation /** * Install navigation providing * - * @param string $path Module path - * @param ApplicationAbstract $app Application + * @param string $path Module path + * @param ApplicationAbstract $app Application * * @return void * diff --git a/Admin/Installer.php b/Admin/Installer.php index 12738a4..f3f8e7b 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -34,24 +34,31 @@ use Modules\WarehouseManagement\Models\StockLocationMapper; */ final class Installer extends InstallerAbstract { - /** + /** * {@inheritdoc} */ public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void { parent::install($dbPool, $info, $cfgHandler); - self::createStock(); + self::createDefaultStock(); } - private static function createStock() : void + /** + * Creates a default stock + * + * @return void + * + * @since 1.0.0 + */ + private static function createDefaultStock() : void { - $stock = new Stock('Default'); - $stock->type = 0; - StockMapper::create($stock); + $stock = new Stock('Default'); + $stock->type = 0; + StockMapper::create($stock); - $stockLocation = new StockLocation((string) ($stock->getId() . '-1')); - $stockLocation->stock = $stock; - StockLocationMapper::create($stockLocation); + $stockLocation = new StockLocation((string) ($stock->getId() . '-1')); + $stockLocation->stock = $stock; + StockLocationMapper::create($stockLocation); } } diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 600ee61..471fdae 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -32,8 +32,8 @@ use Modules\WarehouseManagement\Models\StockShelfMapper; */ final class ApiController extends Controller { - public function eventStockCreateInternal( - int $account, + public function eventStockCreateInternal( + int $account, mixed $old, mixed $new, int $type = 0, @@ -42,23 +42,23 @@ final class ApiController extends Controller string $ref = null, string $content = null, string $ip = null - ) : void - { - $stock = new Stock($new->number); - $stock->type = 1; - StockMapper::create($stock); + ) : void + { + $stock = new Stock($new->number); + $stock->type = 1; + StockMapper::create($stock); - $stockLocation = new StockLocation($stock->name . '-1'); - $stockLocation->stock = $stock->getId(); - StockLocationMapper::create($stockLocation); + $stockLocation = new StockLocation($stock->name . '-1'); + $stockLocation->stock = $stock->getId(); + StockLocationMapper::create($stockLocation); - $stockShelf = new StockShelf($stockLocation->name . '-1'); - $stockShelf->location = $stockLocation->getId(); - StockShelfMapper::create($stockShelf); - } + $stockShelf = new StockShelf($stockLocation->name . '-1'); + $stockShelf->location = $stockLocation->getId(); + StockShelfMapper::create($stockShelf); + } - public function eventBillUpdateInternal( - int $account, + public function eventBillUpdateInternal( + int $account, mixed $old, mixed $new, int $type = 0, @@ -67,24 +67,24 @@ final class ApiController extends Controller string $ref = null, string $content = null, string $ip = null - ) : void - { - if ($trigger === 'POST:Module:Billing-bill_element-create') { - // @todo: if is bill element create, create stock movement + ) : void + { + if ($trigger === 'POST:Module:Billing-bill_element-create') { + // @todo: if is bill element create, create stock movement - } elseif ($trigger === 'POST:Module:Billing-bill_element-update') { - // quantity change - // lot changes - // stock changes - // all other changes ignore! - // check availability again, if not available abort bill - } elseif ($trigger === 'POST:Module:Billing-bill_element-delete') { - // @todo: delete stock movement - } elseif ($trigger === 'POST:Module:Billing-bill-delete') { - // @todo: delete stock movements - } elseif ($trigger === 'POST:Module:Billing-bill-update') { - // is receiver update -> change all movements - // is status update -> change all movements (delete = delete) - } - } + } elseif ($trigger === 'POST:Module:Billing-bill_element-update') { + // quantity change + // lot changes + // stock changes + // all other changes ignore! + // check availability again, if not available abort bill + } elseif ($trigger === 'POST:Module:Billing-bill_element-delete') { + // @todo: delete stock movement + } elseif ($trigger === 'POST:Module:Billing-bill-delete') { + // @todo: delete stock movements + } elseif ($trigger === 'POST:Module:Billing-bill-update') { + // is receiver update -> change all movements + // is status update -> change all movements (delete = delete) + } + } } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 00c205b..49daa90 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -31,7 +31,7 @@ use phpOMS\Views\View; */ final class BackendController extends Controller { - /** + /** * Routing end-point for application behaviour. * * @param RequestAbstract $request Request diff --git a/Models/PermissionState.php b/Models/PermissionState.php index 84778ca..bfbd91a 100755 --- a/Models/PermissionState.php +++ b/Models/PermissionState.php @@ -27,5 +27,6 @@ use phpOMS\Stdlib\Base\Enum; abstract class PermissionState extends Enum { public const STOCK = 1; + public const STOCK_LOCATION = 2; } diff --git a/Models/Stock.php b/Models/Stock.php index 114955f..a46bd27 100755 --- a/Models/Stock.php +++ b/Models/Stock.php @@ -32,17 +32,37 @@ class Stock */ private int $id = 0; + /** + * NAme. + * + * @var string + * @since 1.0.0 + */ public string $name = ''; public int $type = 0; + /** + * Constructor. + * + * @param string $name Stock name + * + * @since 1.0.0 + */ public function __construct(string $name = '') { $this->name = $name; } + /** + * Get id. + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { - return $this->id; + return $this->id; } } diff --git a/Models/StockLocation.php b/Models/StockLocation.php index 57f1625..ae00691 100755 --- a/Models/StockLocation.php +++ b/Models/StockLocation.php @@ -42,13 +42,27 @@ class StockLocation public int $z = 0; + /** + * Constructor. + * + * @param string $name Stock name + * + * @since 1.0.0 + */ public function __construct(string $name = '') { $this->name = $name; } + /** + * Get id. + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { - return $this->id; + return $this->id; } } diff --git a/Models/StockMovement.php b/Models/StockMovement.php index 160e917..01d0905 100755 --- a/Models/StockMovement.php +++ b/Models/StockMovement.php @@ -67,6 +67,11 @@ class StockMovement */ public \DateTimeImmutable $createdAt; + /** + * Constructor. + * + * @since 1.0.0 + */ public function __construct() { $this->createdBy = new NullAccount(); diff --git a/Models/StockMovementType.php b/Models/StockMovementType.php index 0739bd3..bce4045 100755 --- a/Models/StockMovementType.php +++ b/Models/StockMovementType.php @@ -26,21 +26,21 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class StockMovementType extends Enum { - public const MERGE = 1; - public const SPLIT = 2; + public const MERGE = 1; + public const SPLIT = 2; public const INCREASE = 4; public const DECREASE = 8; public const TRANSFER = 16; // @todo: subtypes, maybe creates as database subtypes during install. - public const DESTROY = 1; // 8 - public const RETURN = 1; // 8 - public const INVENTORY_PLUS = 1; // 4 - public const INVENTORY_MINUS = 1; // 8 - public const PURCHASE = 1; // 4 - public const SALE = 1; // 4 + public const DESTROY = 1; // 8 + public const RETURN = 1; // 8 + public const INVENTORY_PLUS = 1; // 4 + public const INVENTORY_MINUS = 1; // 8 + public const PURCHASE = 1; // 4 + public const SALE = 1; // 4 public const MANUFACTURE_CREATE = 1; // 4 - public const MANUFACTURE_USE = 1; // 8 - public const MANUAL = 1; // 1-16 + public const MANUFACTURE_USE = 1; // 8 + public const MANUAL = 1; // 1-16 } diff --git a/Models/StockShelf.php b/Models/StockShelf.php index d2ce756..e0358dd 100755 --- a/Models/StockShelf.php +++ b/Models/StockShelf.php @@ -42,13 +42,27 @@ class StockShelf public int $z = 0; + /** + * Constructor. + * + * @param string $name Shelf name + * + * @since 1.0.0 + */ public function __construct(string $name = '') { $this->name = $name; } + /** + * Get id. + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { - return $this->id; + return $this->id; } }