<?php
 namespace App\Config; class ClientInvoicesCompensate extends \App\Config\SystemVars { protected $dbVarsPrefix = 'ClientInvoices_Compensate_'; protected $dbVarsList = [ 'cashingDocType', 'cashingIdUser', ]; protected function save_check() { parent::save_check(); if ($this->itemsList) { foreach($this->itemsList as $var=>$value) { switch ($var) { case 'cashingDocType': if ($value && !\App\Config\CashingDocuments::getInstance()->exists($value)) { $this->addErrorMessage("The cashing document is not valid."); } break; case 'cashingIdUser': if ($value) { $userEnt = \Entity\User::select($value); if (!$userEnt->recordExists() || $userEnt->deleted) { $this->addErrorMessage("The selected user is not valid."); } } break; default: $this->addErrorMessage("The var `{$var}` is invalid"); } } } } } 