/** * Updates an existing Product 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); $dPost = Yii::$app->request->post(); if (isset($dPost['ProductUom'])) { $modelDtl = new ProductUom(); $modelDtl->load($dPost); if (!$modelDtl->save()) { print_r($modelDtl->errors); } } if ($model->load($dPost) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_product]); } else { return $this->render('update', ['model' => $model]); } }
public function search($params) { $query = ProductUomModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_puom' => $this->id_puom, 'id_product' => $this->id_product, 'id_uom' => $this->id_uom, 'isi' => $this->isi, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'create_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]); return $dataProvider; }
/** * Finds the ProductUom model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ProductUom the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProductUom::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return integer */ public static function getQtyProductUom($id_product, $id_uom) { $pu = ProductUom::findOne(['id_product' => $id_product, 'id_uom' => $id_uom]); return $pu ? $pu->isi : false; }
/** * @return \yii\db\ActiveQuery */ public function getProductUoms() { return $this->hasMany(ProductUom::className(), ['id_uom' => 'id_uom']); }