public function editConsumableAction() { /** * @var General $apartmentServiceGeneral * @var Storage $storageService * @var Office $officeService * @var ApartmentGroup\Usages\Building $buildingService * @var AssetService $assetService */ $auth = $this->getServiceLocator()->get('library_backoffice_auth'); $hasAssetManagementGlobal = $auth->hasRole(Roles::ROLE_ASSET_MANAGEMENT_GLOBAL); if (!$hasAssetManagementGlobal) { return $this->redirect()->toUrl('/'); } $id = $this->params()->fromRoute('id', 0); $assetService = $this->getServiceLocator()->get('service_warehouse_asset'); $basicInfo = $assetService->getConsumableBasicInfoById($id); if (FALSE === $basicInfo) { Helper::setFlashMessage(['error' => TextConstants::ERROR_NO_ITEM]); return $this->redirect()->toUrl('/'); } $storageService = $this->getServiceLocator()->get('service_warehouse_storage'); $storageList = $storageService->searchStorageByName(false); $locationList = []; foreach ($storageList as $storage) { array_push($locationList, ['id' => AssetService::ENTITY_TYPE_STORAGE . '_' . $storage->getId(), 'info' => $storage->getCityName(), 'label' => 'storage', 'text' => $storage->getName(), 'type' => AssetService::ENTITY_TYPE_STORAGE]); } $categoryService = $this->getServiceLocator()->get('service_warehouse_category'); $allActiveConsumableCategories = $categoryService->getCategories([Category::CATEGORY_TYPE_CONSUMABLE]); $allActiveCategoriesArray = []; foreach ($allActiveConsumableCategories as $row) { $allActiveCategoriesArray[$row->getId()] = $row->getName(); } $assetConsumableForm = new AssetConsumableForm($id, $allActiveCategoriesArray, $basicInfo); $finalStatuses = OrderService::getIrreversiblyStatuses(); $orderService = $this->getServiceLocator()->get('service_wh_order_order'); $ordersRelated = $orderService->getRelatedOrders($basicInfo->getCategoryId(), $basicInfo->getLocationEntityId(), $basicInfo->getLocationEntityType(), $finalStatuses); $hasOrderManagementGlobal = $auth->hasRole(Roles::ROLE_WH_ORDER_MANAGEMENT_GLOBAL); /** * @var Logger $loggerService */ $loggerService = $this->getServiceLocator()->get('ActionLogger'); $actionLogs = $loggerService->getDatatableData(Logger::MODULE_ASSET_CONSUMABLE, $id); return ['id' => $id, 'basicInfo' => $basicInfo, 'form' => $assetConsumableForm, 'location' => $basicInfo->getLocationEntityType() . '_' . $basicInfo->getLocationEntityId(), 'locationList' => $locationList, 'ordersRelated' => $ordersRelated, 'hasOrderManagementGlobal' => $hasOrderManagementGlobal, 'historyData' => json_encode($actionLogs)]; }