예제 #1
0
 /**
  * Creates a new InventoryActsTb model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($act_id, $dev_id, $wp_id)
 {
     if ($act_id == 0) {
         $model_act = new InventoryActs();
         $model_act->workplace_id = $wp_id;
         $workplace = Workplaces::findOne($wp_id);
         //var_dump($workplace->owner); die;
         $model_act->owner_employee_id = $workplace->owner[0]->id;
         $model_act->exec_employee_id = $workplace->owner[0]->id;
         $model_act->status = 0;
         if ($model_act->save()) {
             $act_id = $model_act->id;
         } else {
             Yii::$app->session->setFlash('error', 'Ошибка при создании Акта инвентарзации');
             return $this->redirect(['inventory-acts/view', 'id' => $act_id]);
         }
     }
     $model = new InventoryActsTb();
     $model->act_id = $act_id;
     $model->device_id = $dev_id;
     $model->status = 'OK!';
     if ($model->save()) {
         return $this->redirect(['inventory-acts/view', 'id' => $act_id]);
     }
 }
예제 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $id_wp = ArrayHelper::getValue($params, 'id_wp');
     if ($id_wp) {
         $query = InventoryActs::find()->where(['workplace_id' => $id_wp]);
     } else {
         $query = InventoryActs::find();
     }
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'workplace_id' => $this->workplace_id, 'owner_employee_id' => $this->owner_employee_id, 'exec_employee_id' => $this->exec_employee_id, 'act_date' => $this->act_date, 'curr_date' => $this->curr_date, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'comm', $this->comm]);
     return $dataProvider;
 }
예제 #3
0
 /**
  * Связываем рабочее место и акты инвентаризации
  */
 public function getInventory()
 {
     return $this->hasMany(InventoryActs::className(), ['workplace_id' => 'id'])->orderBy('act_date DESC');
 }
예제 #4
0
 /**
  * Finds the InventoryActs model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return InventoryActs the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = InventoryActs::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }