Beispiel #1
0
 /**
  * Creates a new Device model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Device();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 public function actionIn()
 {
     if (User::hasRole('admin')) {
         $model = new Device();
         //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         //\Yii::trace('### ### ### Тест лога');
         //\Yii::trace(Yii::$app->request->post());
         if ($model->load(Yii::$app->request->post())) {
             //\Yii::trace('### ### ### If');
             //return $this->redirect(['/table/device/view', 'id' => $model->id]);
             $searchModel = new DataListSearch();
             $dataProvider = $searchModel->search(['DataListSearch' => ['id_device' => $model->id, 'typeDataRef' => 'b']]);
             //Получаем массив данных из таблицы
             $allq = DataList::find()->select(['data_list.id', 'number', 'time_point'])->joinWith('idDataRef')->where(['id_device' => $model->id, 'type_data_ref' => 'b'])->createCommand()->queryAll();
             return $this->render('in', ['model' => $model, 'r' => 1, 'dataProvider' => $dataProvider, 'qwery' => $allq]);
         } else {
             //\Yii::trace('### ### ### Else');
             return $this->render('in', ['model' => $model, 'r' => NULL]);
         }
     } else {
         throw new NotFoundHttpException('Страница не найдена.');
     }
 }