<?php
 namespace App\OfferProfileRules; class OfferDetails_Commission implements OfferDetailsInterface { public $included; public $percent; public $value; public $currency; public function check(\App\MessagesCollector $msgs) { $return = true; if ($this->included===null) { $msgs->addError('Commission included is not set.'); $return = false; } $value = (string)$this->value; $percent = (string)$this->percent; if (!strlen($value) and !strlen($percent)) { $msgs->addWarning('You must set the commission percent or value.'); $return = false; } if (strlen($value) and strlen($percent)) { $msgs->addWarning('The absolute value and the percent cannot be both set at the same time.'); $return = false; } if (strlen($percent) and (!is_numeric($percent) or $percent<0)) { $msgs->addError('The commission percent must be a positive value.'); $return = false; } if (strlen($value)) { if (!is_numeric($value) or $value<0) { $msgs->addError('The commission value cannot be negative.'); $return = false; } if (!\App\Config\Currencies::getInstance()->check($this->currency)) { $msgs->addError('The commission currency is not valid.'); $return = false; } } return $return; } public function getDescription($fullDescription=true) { $_LANG = \App\Loader_Lang::getInstance()->getGlobal(); $return = ''; if ($fullDescription and $this->included!==null){ $return .= $_LANG['OfferProfileRules']['commission'][(Int)$this->included]; } if ($this->percent!==null) { $return .= ' - '.$this->percent.'%'; } elseif ($this->value!==null) { $return .= ' - '.\App\Utils\PriceFormat::format($this->value, $this->currency); } return $return; } } 