Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customer::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(['id' => $this->id, 'photo_id' => $this->photo_id, 'gender' => $this->gender, 'date_of_birth' => $this->date_of_birth, 'token_expired' => $this->token_expired, 'state' => $this->state, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'cus_fullname', $this->cus_fullname])->andFilterWhere(['like', 'token', $this->token]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     /*        $dataProvider->setSort([
                 'attributes' =>[
                     'customerCodeLink'=>[
                         'asc' => ['customer_code' => SORT_ASC],
                         'desc' => ['customer_code' => SORT_DESC],
                     ],
                     'customerNameLink'=>[
                         'asc' => ['customer_name' => SORT_ASC],
                         'desc' => ['customer_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;
     }
     /*        $query->andFilterWhere([
                 'id' => $this->id,
                 'gender' => $this->gender,
                 'customer_type' => $this->customer_type,
                 'birthday' => $this->birthday,
                 'created_at' => $this->created_at,
                 'updated_at' => $this->updated_at,
     
             ]);*/
     if (isset($this->specialQuery_input) && isset($this->specialQuery_options)) {
         $query->andFilterWhere(['like', 'customer_code', $this->specialQuery_input])->orFilterWhere(['like', 'customer_name', $this->specialQuery_input])->orFilterWhere(['like', 'phone_number', $this->specialQuery_input]);
         if ($this->specialQuery_options == 2) {
             $query->andFilterWhere(['>', 'debit', 0]);
         }
         if ($this->specialQuery_options == 3) {
             $query->andFilterWhere(['=', 'customer_type', '1']);
         }
         if ($this->specialQuery_options == 4) {
             $query->andFilterWhere(['=', 'customer_type', '0']);
         }
     } else {
         $query->andFilterWhere(['like', 'customer_code', $this->customer_code])->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['=', 'customer_type', $this->customer_type])->andFilterWhere(['like', 'phone_number', $this->phone_number]);
     }
     return $dataProvider;
 }
Example #3
0
 /**
  * Creates a new Invoice model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Invoice();
     if ($model->load(Yii::$app->request->post())) {
         //get Customer information
         $customer = Customer::find()->where(['id' => 1])->asArray()->one();
         /*          echo '<pre>';
                     print_r(JSON::encode($customer));
                     echo '</pre>';*/
         $model->attribute1 = JSON::encode($customer);
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #4
0
 /**
  * Finds the Customer model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Customer the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Customer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCustomer()
 {
     return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
 }