<?php
 namespace App\OfferProfileRules; class Criterion_OwnerCorporateSegment extends CriterionAbstract { public function checkFields(\App\OfferProfileRules\Fields $fields) { return $this->checkField(\Entity\Corporate::select($fields->idOwnerCorporate)->idSegment); } public function checkAssignedValues(\App\MessagesCollector $msgs) { if (($this->operation=='equal' or $this->operation=='notEqual') and !$this->values) { $msgs->addWarning("No company segment set."); } else { foreach($this->values as $idCorpSegment) { if (!\Entity\CorporateSegment::select($idCorpSegment)->recordExists()) { $msgs->addWarning("The corporate segment id `{$idCorpSegment}` is not valid."); } } } } protected function createDescription_getEntityName($code) { return \Entity\CorporateSegment::select($code)->name; } } 