/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $static_params)
 {
     $query = TrxTransactionDetails::find()->where($static_params);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'transaction_id' => $this->transaction_id, 'batch' => $this->batch, 'net_weight' => $this->net_weight, 'total_weight' => $this->total_weight, 'pallet_weight' => $this->pallet_weight, 'kitted_unit' => $this->kitted_unit, 'manufacturing_date' => $this->manufacturing_date, 'expiry_date' => $this->expiry_date, 'creator_id' => $this->creator_id, 'updater_id' => $this->updater_id, 'updated_date' => $this->updated_date]);
     $query->andFilterWhere(['like', 'material_code', $this->material_code])->andFilterWhere(['like', 'pallet_no', $this->pallet_no])->andFilterWhere(['like', 'pallet_type', $this->pallet_type])->andFilterWhere(['like', 'status', $this->status]);
     // start date range filter
     if (isset($this->start_date) && $this->start_date != null) {
         $startDate = explode(' - ', $this->start_date);
         $startDateFrom = Yii::$app->dateFormatter->convert($startDate[0]);
         $startDateTo = Yii::$app->dateFormatter->convert($startDate[1]);
         $query->andFilterWhere(['between', 'start_date', $startDateFrom, $startDateTo]);
     }
     // created date range filter
     if (isset($this->created_date) && $this->created_date != null) {
         $createdDate = explode(' - ', $this->created_date);
         $createdDateFrom = Yii::$app->dateFormatter->convert($createdDate[0]);
         $createdDateTo = Yii::$app->dateFormatter->convert($createdDate[1]);
         $query->andFilterWhere(['between', 'created_date', $createdDateFrom, $createdDateTo]);
     }
     return $dataProvider;
 }
Beispiel #2
0
 public function getTransactionDetails($conditions = null)
 {
     // to retrieve all *active* material conversions by their index and order them by their ID:
     $model = TrxTransactionDetails::find()->where($conditions)->one();
     return $model;
 }