<?php
namespace Entity; class Validator_CorporateCreditCard extends \App\Entity\Utils\Extension_ValidateDefaultAbstract { protected function isAccessible_insert() { $currentMessages = $this->entity->getMessages(); if (!\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Corporates/CreditCards-insert')) { $currentMessages->addWarningCode('noAccessToOption'); } } protected function check_insert() { $fields = $this->entity->getFields(); $currentMessages = $this->entity->getMessages(); if ($fields['idCorporate']) { $corporateEnt = \Entity\Corporate::selectForUpdate($fields['idCorporate']); if (!$corporateEnt->recordExists()) { $currentMessages->addErrorCode('insert_invalidCorporateId'); } elseif ($corporateEnt->deleted) { $currentMessages->addWarningCode('insert_deletedCorporateId'); } } } protected function isAccessible_update() { $currentMessages = $this->entity->getMessages(); if (!\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Corporates/CreditCards-update')) { $currentMessages->addWarningCode('noAccessToOption'); } } protected function isAvailable_update() { $currentMessages = $this->entity->getMessages(); $currentEntityId = $this->entity->getId(); $corporateCC = \Entity\CorporateCreditCard::selectForUpdate($currentEntityId); if (!$corporateCC->recordExists()) { $currentMessages->addErrorCode('update_invalidId'); } elseif ($corporateCC->deleted) { $currentMessages->addWarningCode('update_deletedId'); } } protected function check_update() { $fields = $this->entity->getFields(); $currentMessages = $this->entity->getMessages(); if ($fields['idCorporate']) { $corporateEnt = \Entity\Corporate::selectForUpdate($fields['idCorporate']); if (!$corporateEnt->recordExists()) { $currentMessages->addErrorCode('update_invalidCorporateId'); } elseif ($corporateEnt->deleted) { $currentMessages->addWarningCode('update_deletedCorporateId'); } } } protected function isAccessible_delete() { $currentMessages = $this->entity->getMessages(); if (!\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Partners/Corporates/CreditCards-delete')) { $currentMessages->addWarningCode('noAccessToOption'); } } protected function isAvailable_delete() { $currentEntityId = $this->entity->getId(); $currentMessages = $this->entity->getMessages(); $corporateCC = \Entity\CorporateCreditCard::selectForUpdate($currentEntityId); if (!$corporateCC->recordExists()) { $currentMessages->addErrorCode('delete_invalidId'); } elseif ($corporateCC->deleted) { $currentMessages->addWarningCode('delete_deletedId'); } } }