<?php
namespace Modules\Orders\ImportedOrders\ProcessServicesList; class Controller extends \App\Mvc\Controller\Popup\PaginatedListing\ListingAbstract { protected $listOrderingColumns = ['addTime']; protected function initialize() { parent::initialize(); $this->actionsCfg['index'] = ['checkSection' => false, 'checkOption' => false,]; $this->actionsCfg['list'] = ['checkSection' => false, 'checkOption' => false,]; $this->actionsCfg['listRecords'] = ['checkSection' => false, 'checkOption' => false,]; } protected function optionDefineParams(\App\Mvc\View\Utils\RowOptions\Option\Option $option, $selection) { switch($option->getId()){ case 'addServiceOnOrder': $alreadyImportedService = \Modules\Orders\OrderForm\Model_Handler::getInstance()->getImportedServiceIds(); foreach ($selection as $id) { $importedServiceEnt = \Entity\ImportedService::select($id); if (in_array($id, $alreadyImportedService)) { $option->setDisabled(); $option->addMessage('warning', sprintf($this->lang['index']['options']['reasons']['addServiceOnOrder']['alreadyImported'], ($importedServiceEnt->offerExternalSystemReservationId?$importedServiceEnt->offerExternalSystemReservationId:$importedServiceEnt->idServiceExtSys))); break; } if ($importedServiceEnt->isPackage) { if (count($selection)>1) { $option->setDisabled(); $option->addMessage('info', $this->lang['index']['options']['reasons']['addServiceOnOrder']['onlyOnePackageCanBeImportedAtATime']); break; } foreach ($importedServiceEnt->packageSubservicesList as $subserviceDetails) { if ($subserviceDetails['processStatus'] != 'new') { $option->setDisabled(); $option->addMessage('warning', sprintf($this->lang['index']['options']['reasons']['addServiceOnOrder']['subserviceAlreadyImported'], $subserviceDetails['idServiceTina'])); break; } } } } break; case 'autoAddServiceOnOrder': $alreadyImportedService = \Modules\Orders\OrderForm\Model_Handler::getInstance()->getImportedServiceIds(); foreach ($selection as $id) { $importedServiceEnt = \Entity\ImportedService::select($id); if (in_array($id, $alreadyImportedService)) { $option->setDisabled(); $option->addMessage('warning', sprintf($this->lang['index']['options']['reasons']['addServiceOnOrder']['alreadyImported'], ($importedServiceEnt->offerExternalSystemReservationId?$importedServiceEnt->offerExternalSystemReservationId:$importedServiceEnt->idServiceExtSys))); break; } if ($importedServiceEnt->isPackage) { if (count($selection)>1) { $option->setDisabled(); $option->addMessage('info', $this->lang['index']['options']['reasons']['addServiceOnOrder']['onlyOnePackageCanBeImportedAtATime']); break; } foreach ($importedServiceEnt->packageSubservicesList as $subserviceDetails) { if ($subserviceDetails['processStatus'] != 'new') { $option->setDisabled(); $option->addMessage('warning', sprintf($this->lang['index']['options']['reasons']['addServiceOnOrder']['subserviceAlreadyImported'], $subserviceDetails['idServiceTina'])); break; } } } } break; case 'filterOrder' : foreach ($selection as $selectedId) { if (!\Entity\ImportedService::select($selectedId)->offerExternalSystemReservationId) { $option->setDisabled(); break; } } break; case 'remoteLoad': break; } return true; } protected function actionIndex_preRender(\App\Mvc\ModelAbstract $model, \App\Mvc\ViewAbstract $view, Array $R) { $view->setOutputVar('idOrder', $R['idOrder']); } protected function optionGetEntityName($id) { return \Entity\ImportedService::select($id)->getId(); } }