/** * Creates a new UrQuestions model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UrQuestions(); $model->user_id = \Yii::$app->user->identity->id; $UrRecords = Ur::find()->orderBy('name'); if (\Yii::$app->user->identity->status == 2) { $UrRecords = $UrRecords->Where(['regional_id' => \Yii::$app->user->identity->id]); } if (\Yii::$app->user->identity->status == 3) { // $UrRecords = $UrRecords->Where(['pi_id' => \Yii::$app->user->identity->id]); } $UrRecords = $UrRecords->all(); //->where(['pi_id' => $user]) if (Yii::$app->request->isPost) { // print_r($model->qfile); $model->qfile = UploadedFile::getInstances($model, 'qfile'); if (!empty($model->qfile)) { $model->qfiles = ""; foreach ($model->qfile as $file) { $fileName = 'files/qfile/' . Functions::str2url($file->baseName) . rand(555, 99999) . '.' . $file->extension; $model->qfiles .= $fileName . "|"; $file->saveAs($fileName); } $model->qfiles = substr($model->qfiles, 0, -1); } } if ($model->load(Yii::$app->request->post()) && ($id = $model->save())) { $info = UrQuestions::getInfo($model->id); Word::ur_questions($info); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'UrRecords' => $UrRecords]); } }