/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search_supply($params) { $query = Tax::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(['tax_id' => $this->tax_id, 'tax_rate' => $this->tax_rate]); $query->andFilterWhere(['like', 'tax_code', $this->tax_code])->andFilterWhere(['like', 'tax_description', $this->tax_description]); return $dataProvider; }
public function search($input) { $query = Tax::query(); $columns = Schema::getColumnListing('taxes'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }
public function actionGetGstRate($tax_code) { $tax = Tax::find()->where(['tax_code' => $tax_code])->one(); echo Json::encode($tax); }
/** * 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); $categories = Category::find()->orderBy('category_id')->all(); $tax = Tax::find()->orderBy('tax_id')->all(); $tax2 = Tax2::find()->orderBy('tax_id')->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->product_id]); } else { return $this->render('update', ['model' => $model, 'categories' => $categories, 'tax' => $tax, 'tax2' => $tax2]); } }
/** * Finds the Tax model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Tax the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Tax::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }