/** * Updates an existing Chitiethoadon model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $list1 = Sanpham::find()->all(); $list2 = Hoadon::find()->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect('index.php?r=chitiethoadon%2Findex'); } else { return $this->render('update', ['model' => $model, 'list1' => $list1, 'list2' => $list2]); } }
public function actionIndex() { $lst = Sanpham::find()->where(['status' => 1])->all(); $result = []; if (count($lst) > 0) { foreach ($lst as $item) { $line = Loaisanpham::findOne($item->id_lsp); array_push($result, ['station' => $item, 'line' => $line]); } } return $this->render('index', ['listLine' => $result]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Sanpham::find(); $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; } $query->andFilterWhere(['id_sanpham' => $this->id_sanpham, 'id_loaisanpham' => $this->id_loaisanpham, 'masp' => $this->masp, 'record_status' => $this->record_status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Lists all Sanpham models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Sanpham::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }