<?php

namespace App\OfferProfileRules;

class Criterion_ImportedServiceBookOffice extends CriterionAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \App\OfferProfileRules\CriterionAbstract::checkFields()
	 */
	public function checkFields(\App\OfferProfileRules\Fields $fields)
	{
		return $this->checkField($fields->importedServiceBookOffice);
	}


	/**
	 * (non-PHPdoc)
	 * @see \App\OfferProfileRules\CriterionAbstract::checkAssignedValues()
	 */
	public function checkAssignedValues(\App\MessagesCollector $msgs)
	{

		// check that at least one value set
		if (($this->operation=='equal' or $this->operation=='notEqual') and !$this->values) {
			$msgs->addWarning("No book office code set.");
		}
		else {
			// check the empty values
			foreach($this->values as $elem) {
				if (!$elem) {
					$msgs->addWarning("You cannot set an empty book office code.");
				}
			}
		}

	}

	/**
	 * (non-PHPdoc)
	 * @see \App\OfferProfileRules\CriterionAbstract::createDescription_getEntityName()
	 */
	protected function createDescription_getEntityName($code)
	{
		return $code;
	}

}
