Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $id = Yii::$app->user->id;
     $query = EntpCustomer::find();
     $query->joinWith(['customer'])->where('entp_customer.entrepreneur_user_id=' . $id);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['name'] = ['asc' => ['customer.name' => SORT_ASC], 'desc' => ['customer.name' => SORT_DESC]];
     $dataProvider->sort->attributes['pic'] = ['asc' => ['customer.pic' => SORT_ASC], 'desc' => ['customer.pic' => SORT_DESC]];
     $dataProvider->sort->attributes['telephone'] = ['asc' => ['customer.telephone' => SORT_ASC], 'desc' => ['customer.telephone' => SORT_DESC]];
     $dataProvider->sort->attributes['mobile'] = ['asc' => ['customer.mobile' => SORT_ASC], 'desc' => ['customer.mobile' => SORT_DESC]];
     $dataProvider->sort->attributes['email'] = ['asc' => ['customer.email' => SORT_ASC], 'desc' => ['customer.email' => 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(['entrepreneur_user_id' => $this->entrepreneur_user_id, 'customer_id' => $this->customer_id]);
     $query->andFilterWhere(['like', 'customer.name', $this->name])->andFilterWhere(['like', 'customer.pic', $this->pic])->andFilterWhere(['like', 'customer.telephone', $this->telephone])->andFilterWhere(['like', 'customer.mobile', $this->mobile])->andFilterWhere(['like', 'customer.email', $this->email]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
$id = Yii::$app->user->id;
?>

<div class="entp-invoice-form">


    <?php 
$form = ActiveForm::begin();
?>

    <div class="row">
        <div class="col-lg-5">


            <?php 
echo $form->field($model, 'customerSelect')->label('Select Customer')->dropDownList(ArrayHelper::map(EntpCustomer::find()->joinWith('customer')->where('entp_customer.entrepreneur_user_id=' . $id)->all(), 'customer.id', 'customer.name'), ['style' => 'width:230px;', 'tabindex' => '3', 'prompt' => '', 'id' => 'customerSelect']);
?>

            <div id="hehe">

            </div>

            <?php 
echo $form->field($model, 'customer')->textInput(['maxlength' => true, 'id' => 'customer'])->label('Name');
?>

            <?php 
echo $form->field($model, 'address')->textInput(['maxlength' => true, 'id' => 'address']);
?>

            <?php