Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $static_params)
 {
     $query = TrxTransactions::find()->where($static_params);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'pallet_count' => $this->pallet_count, 'quantity' => $this->quantity, 'weight' => $this->weight, 'packaging_id' => $this->packaging_id, 'creator_id' => $this->creator_id, 'updater_id' => $this->updater_id, 'updated_date' => $this->updated_date]);
     $query->andFilterWhere(['like', 'customer_code', $this->customer_code])->andFilterWhere(['like', 'inbound_no', $this->inbound_no])->andFilterWhere(['like', 'sap_no', $this->sap_no])->andFilterWhere(['like', 'plant_location', $this->plant_location])->andFilterWhere(['like', 'storage_location', $this->storage_location])->andFilterWhere(['like', 'unit', $this->unit])->andFilterWhere(['like', 'lower_hu', $this->lower_hu])->andFilterWhere(['like', 'remarks', $this->remarks])->andFilterWhere(['like', 'truck_van', $this->truck_van])->andFilterWhere(['like', 'status', $this->status]);
     // 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;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new TrxTransactions model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $this->initUser();
     if (null !== Yii::$app->request->post('cancel')) {
         $this->redirect(['index']);
     } else {
         $model = new TrxTransactions();
         $model_plant_location = new MstPlantLocation();
         $date = date('Y-m-d H:i:s');
         // @TODO Use Yii dateformatter
         // set defaults
         // $model->id 	= strtotime(date("Ymdhis")); // @TODO should be set onBeforeSave in TrxTransactions model
         $model->id = date("mdyhs");
         // @TODO should be set onBeforeSave in TrxTransactions model
         // @TODO: transfer updating of status/created/updated details to model
         // set status, created and updated details
         $model->status = Yii::$app->params['STATUS_PROCESS'];
         $model->creator_id = Yii::$app->user->id;
         $model->created_date = $date;
         $model->updater_id = Yii::$app->user->id;
         $model->updated_date = $date;
         if ($model->load(Yii::$app->request->post())) {
             $model->actual_gr_date = Yii::$app->dateFormatter->convert($model->getAttribute('actual_gr_date'));
             $model->remarks = Yii::$app->user->identity->username . '@: ' . Yii::$app->request->post('TrxTransactions')['remarks'];
             if ($model->validate() && $model->save()) {
                 return $this->redirect(['menu', 'id' => $model->id]);
             }
         } else {
             // Get customer list
             $customer_list = ArrayHelper::map(Yii::$app->modelFinder->getCustomerList(), 'code', 'name');
             $plant_list = Yii::$app->modelFinder->getPlantList(null, ['plant_location' => Yii::$app->user->identity->assignment]);
             $storage_list = array();
             foreach ($plant_list as $key => $value) {
                 $storage_list[$value['storage_location']] = $value['storage_location'] . ' - ' . $value['storage_name'];
             }
             return $this->render('create', ['model' => $model, 'customer_list' => $customer_list, 'storage_list' => $storage_list]);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Finds the TrxTransactions model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return TrxTransactions the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 public function findTransactionModel($id)
 {
     if (($model = TrxTransactions::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }