コード例 #1
0
ファイル: InvoicesaleSearch.php プロジェクト: nirantarnoy/st2
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Invoicesale::find();
     // add conditions that should always apply here
     $query->joinWith(['customername', 'salename']);
     // ชื่อ relation
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['customer'] = ['asc' => ['Sys_SaleCustomer.Cus_Name' => SORT_ASC], 'desc' => ['Sys_SaleCustomer.Cus_Name' => SORT_DESC]];
     $dataProvider->sort->attributes['saleman'] = ['asc' => ['Sys_SaleData.Sale_Name' => SORT_ASC], 'desc' => ['Sys_SaleData.Sale_Name' => SORT_DESC]];
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['recid' => $this->recid, 'saledate' => $this->saledate, 'shipdate' => $this->shipdate, 'shipto' => $this->shipto, 'currency' => $this->currency, 'currencyrate' => $this->currencyrate, 'createdate' => $this->createdate]);
     $query->andFilterWhere(['like', 'saleno', $this->saleno])->andFilterWhere(['like', 'refno', $this->refno])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'shipfrom', $this->shipfrom])->andFilterWhere(['like', 'paymentterm', $this->paymentterm])->andFilterWhere(['like', 'Sys_SaleCustomer.Cus_Name', $this->customer])->andFilterWhere(['like', 'Sys_SaleData.Sale_Name', $this->saleman]);
     //   ->andFilterWhere(['like', 'createby', $this->createby]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Finds the Invoicesale model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Invoicesale the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Invoicesale::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }