/**
  * 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]);
     }
 }
예제 #2
0
 /**
  * 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;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSanphams()
 {
     return $this->hasMany(Sanpham::className(), ['loaisanpham_id' => 'loaisanpham_id']);
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSanpham()
 {
     return $this->hasOne(Sanpham::className(), ['sanpham_id' => 'sanpham_id']);
 }
예제 #5
0
 /**
  * Finds the Sanpham model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Sanpham the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Sanpham::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdSanpham()
 {
     return $this->hasOne(Sanpham::className(), ['id_sanpham' => 'id_sanpham']);
 }
예제 #7
0
 public function actionPreview($id)
 {
     $model = Sanpham::findOne($id);
     return $this->render('preview', ['model' => $model]);
 }