OEModule\OphCiExamination\models\OphCiExamination_Workflow_Rule::beforeValidate PHP Method

beforeValidate() public method

public beforeValidate ( )
    public function beforeValidate()
    {
        $whereParams = array();
        if ($this->id) {
            $where = 'id != :id and ';
            $whereParams[':id'] = $this->id;
        } else {
            $where = '';
        }
        if (!$this->subspecialty_id) {
            $where .= ' subspecialty_id is null and ';
        } else {
            $where .= ' subspecialty_id = :subspecialty_id and ';
            $whereParams[':subspecialty_id'] = $this->subspecialty_id;
        }
        if (!$this->episode_status_id) {
            $where .= ' episode_status_id is null';
        } else {
            $where .= ' episode_status_id = :episode_status_id';
            $whereParams[':episode_status_id'] = $this->episode_status_id;
        }
        if (self::model()->find($where, $whereParams)) {
            //$this->addError('id','There is already a rule for this subspecialty and episode status combination');
        }
        return parent::beforeValidate();
    }