<?php
 namespace Modules\Partners\Customers\Segments; class Controller extends \App\Mvc\Controller\Window\PaginatedListing\PaginatedEntityListing { protected $useSqlTransaction = true; protected $listOrderingColumns = ['name', 'addTime', 'lastUpdateTime']; protected function initialize() { parent::initialize(); $this->actionsCfg['insert'] = ['checkSection' => false,]; $this->actionsCfg['update'] = ['checkSection' => false,]; $this->actionsCfg['delete'] = ['checkSection' => false,]; } protected function optionDefineParams(\App\Mvc\View\Utils\RowOptions\Option\Option $option, $selection) { $_LANG = \App\Loader_Lang::getInstance()->getGlobal(); switch($option->getId()){ case 'insert': $option->determineOperationAvailability(\Entity\CustomerSegment::insert()); break; case 'update': foreach ($selection as $selectedItem) { if (!$option->determineOperationAvailability(\Entity\CustomerSegment::update($selectedItem))) { break; } } break; case 'delete': foreach ($selection as $selectedItem) { if (!$option->determineOperationAvailability(\Entity\CustomerSegment::delete($selectedItem))) { break; } } break; default: return false; } return true; } protected function optionGetEntityName($id) { $entity = \Entity\CustomerSegment::select($id); return $entity->name; } protected function insert_createEntityObject($formData) { $custSeg = \Entity\CustomerSegment::insert(); $custSeg->name = $formData['segmentName']; return $custSeg; } protected function update_createEntityObject($formData) { $custSeg = \Entity\CustomerSegment::update($formData['id']); $custSeg->name = $formData['segmentName']; return $custSeg; } protected function delete_createEntityObject($idRecord) { return \Entity\CustomerSegment::delete($idRecord); } protected function update_getDefaultFormData($idEntity) { $formData = []; $custSeg = \Entity\CustomerSegment::select($idEntity); $formData['segmentName'] = $custSeg->name; return $formData; } }