'Физическое лицо', 'ur' => 'Юридическое лицо', ]; protected $kinds = [ 'certification' => 'Сертификация', 'expertise' => 'Экспертиза', 'quality-control' => 'Рецензирование', 'public-print' => 'Экспертное заключение о публикации в открытой печати', ]; public function scenarios() { $attributes = [ 'type' => [ 'fiz' => ['fio', 'work', 'post', 'bday', 'bmonth', 'byear', 'address', 'phone', 'email', 'agreement_personal'], 'ur' => ['fio', 'work', 'city', 'fax', 'phone', 'email', 'agreement_personal'], ], 'kind' => [ 'certification' => ['training'], 'quality-control' => ['target', 'object'], 'public-print' => ['text_nr', 'spravka'], 'expertise' => ['training'], ] ]; $scenarios = parent::scenarios(); foreach ($this->types as $type => $type_name) { foreach ($this->kinds as $kind => $kind_name) { $scenarios[$type . '/' . $kind] = array_merge($attributes['type'][$type], $attributes['kind'][$kind]); } } return $scenarios; } public function rules() { return [ [['bday', 'bmonth', 'byear', 'address', 'post', 'city', 'fax', 'fio', 'work', 'phone', 'email', 'training', 'target', 'object', 'text_nr', 'spravka'], 'required'], [['bday', 'bmonth', 'byear'], 'integer'], [['type', 'kind', 'phone', 'fax'], 'string', 'max' => 15], [['fio'], 'string', 'max' => 100], [['work', 'post', 'address'], 'string', 'max' => 500], [['email'], 'string', 'max' => 50], [['city'], 'string', 'max' => 45], ['fio', 'parseFio'], ['email', 'email'], [['object', 'text_nr', 'spravka'], 'checkFileExist'], ['agreement_personal', 'required', 'requiredValue' => 1, 'message' => 'Вы должны согласиться'], ]; } public function parseFio($attribute, $params) { $this->$attribute = mb_convert_case($this->$attribute, MB_CASE_TITLE, "UTF-8"); $this->$attribute = preg_replace('/ [ ]+/i', ' ', $this->$attribute); $fio = explode(' ', $this->$attribute); if (!is_array($fio) || count($fio) != 3) { $this->addError($attribute, 'ФИО задан в не полном формате'); return false; } } public function checkFileExist($attribute, $params) { $count = File::find()->where(['id' => $this->$attribute, 'model' => 'request', 'request' => null])->count(); if ($count) return true; $this->addError($attribute, 'Загруженный файл не найден'); return false; } public function attributeLabels() { $labels = [ // fiz 'bday' => 'День рождения', 'bmonth' => 'Месяц рождения', 'byear' => 'Год рождения', 'address' => 'Адрес', 'post' => 'Должность', // ur 'city' => 'Город', 'fax' => 'Факс', // common 'phone' => 'Телефон', 'email' => 'E-mail', // certification 'training' => 'Название средства обучения', // quality-control 'target' => 'Цель рецензирования', 'object' => 'Объект экспертизы', // public-print 'text_nr' => 'Текст научной работы', 'spravka' => 'Авторская справка', ]; $type = reset(explode('/', $this->scenario)); if ($type == 'fiz') { $labels['fio'] = 'ФИО'; $labels['work'] = 'Место работы'; } else { $labels['fio'] = 'Контактное лицо'; $labels['work'] = 'Название организации'; } return $labels; } public function getTypes() { return $this->types; } public function getKinds() { return $this->kinds; } public function submit() { if (!$this->validate()) return false; $request = new Request(); $fields = $this->Scenarios()[$this->scenario]; $request->setAttributes($this->getAttributes($fields)); if (in_array('byear', $fields)) { $request->birthday = $this->byear . '-' . $this->bmonth . '-' . $this->bday . ' 00:00:00'; } list($request['type'], $request['kind']) = explode('/', $this->scenario); if (isset($_COOKIE['partner']) && is_numeric($_COOKIE['partner'])) { $request->partner = $_COOKIE['partner']; } $request->save(); $files_id = array_filter($this->getAttributes(['object', 'text_nr', 'spravka'])); if (empty($request->id)) { Yii::info($request::tableName() . ' => ' . print_r($request->getErrors(), 1), 'submit_errors'); $this->addError('form', 'Произошла ошибка при добавлении заявки'); return false; } File::updateAll(['request' => $request->id], ['id' => $files_id, 'model' => 'request', 'request' => null]); if (!empty($request->partner)) { Mcito::send('partner', 'new', [ 'params' => 'request-' . $request->id, 'user' => $request->partner, 'name' => 'Сертификация', ]); } // Отправляем письмо заявителю $mail = Mail::find()->where(['project' => $request['kind'] . '_' . $request['type'], 'type' => 'register'])->one(); if (!empty($mail)) { Yii::$app->mailer->compose() ->setFrom([Yii::$app->params['systemEmail'] => Yii::$app->params['name']]) ->setTo($this->email) ->setSubject($mail->subject) ->setHtmlBody($mail->text) ->send(); } // Формируем письмо методисту о новой заявка $subject = 'Добавлена заявка "' . $this->kinds[$request['kind']] . '"'; $message = '

Заявка №' . $request->id . '

'; $message .= 'Тип: ' . $this->types[$request['type']] . '
'; // Поля $attributes = $this->getAttributes(['fio', 'work', 'post', 'phone', 'email', 'fax', 'city', 'address', 'bday', 'bmonth', 'byear']); foreach ($attributes as $key => $value) { if (empty($value)) continue; $message .= '' . $this->getAttributeLabel($key) . ': ' . $value . '
'; } $message .= '
'; // Файлы $files = File::find()->where(['id' => $files_id, 'model' => 'request', 'request' => $request->id])->all(); foreach ($files as $file) { $message .= '' . $this->getAttributeLabel($file->type) . '
'; } // Отправляем письмо Yii::$app->mailer->compose() ->setFrom([Yii::$app->params['systemEmail'] => Yii::$app->params['name']]) ->setTo(Yii::$app->params['managerEmail']) ->setSubject($subject) ->setHtmlBody($message) ->send() ; return $request; } } Unknown Class – yii\base\UnknownClassException
Copied! Copy Stacktrace Search Stackoverflow Search Google Exception

Unknown Classyii\base\UnknownClassException

Unable to find 'frontend\models\RequestForm' in file: /home/forge/gost.mcito.ru/gost/frontend/models/RequestForm.php. Namespace missing?

$_COOKIE = [
    '_csrf' => 'fda650f69238c34fb59315d23a56e12f4c0687b71915d44e3827f82a88250187a:2:{i:0;s:5:"_csrf";i:1;s:32:"txal2aE-iMYKGsORVGNYoX9t1to8dx_d";}',
];