<?php
namespace Modules\Admin\Banks; class Controller extends \App\Mvc\Controller\Window\PaginatedListing\PaginatedEntityListing { protected $useSqlTransaction = true; protected $listOrderingColumns = ['bankName', 'bankCode', 'addTime']; protected function insert_createEntityObject($formData) :\Entity\Bank { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $bank = \Entity\Bank::insert(); if ($CFG['useAlternativeNames']['bankName']) { $bank->nameStandard = $formData['name']['standard']; $bank->nameLocal = $formData['name']['local']; } else { $bank->nameStandard = $formData['name']; } $bank->bankCode = $formData['bankCode']; return $bank; } protected function update_getDefaultFormData($id) :array { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $bank = \Entity\Bank::select($id); $formData = []; if ($CFG['useAlternativeNames']['bankName']) { $formData['name']['standard'] = $bank->nameStandard; $formData['name']['local'] = $bank->nameLocal; } else { $formData['name'] = $bank->nameStandard; } $formData['bankCode'] = $bank->code; return $formData; } protected function update_createEntityObject($formData) { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $bank = \Entity\Bank::update($this->updateIdRecord); if ($CFG['useAlternativeNames']['bankName']) { $bank->nameStandard = $formData['name']['standard']; $bank->nameLocal = $formData['name']['local']; } else { $bank->nameStandard = $formData['name']; } $bank->bankCode = $formData['bankCode']; return $bank; } protected function delete_createEntityObject($id) { return \Entity\Bank::delete($id); } protected function optionDefineParams(\App\Mvc\View\Utils\RowOptions\Option\Option $option, $selection) { switch($option->getId()){ case 'insert': $option->determineOperationAvailability(\Entity\Bank::insert()); break; case 'update': foreach ($selection as $selectedItem) { if (!$option->determineOperationAvailability(\Entity\Bank::update($selectedItem))) { break; } } break; case 'delete': foreach ($selection as $selectedItem) { if (!$option->determineOperationAvailability(\Entity\Bank::delete($selectedItem))) { break; } } break; case 'showOffices': break; default: return false; } return true; } protected function optionGetEntityName($id) { return \Entity\Bank::select($id)->nameStandard; } }