/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = DriverDetails::find(); $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, 'dob' => $this->dob, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'vehicle', $this->vehicle])->andFilterWhere(['like', 'earning_percentage', $this->earning_percentage]); return $dataProvider; }
public function actionDriverlist() { $out = DriverDetails::find()->where(['status' => 1, 'customer_type' => 3])->all(); $selected = ''; if (isset($_POST['depdrop_parents'])) { $vehicle_id = $_POST['depdrop_parents']; $driver_details = DriverDetails::find()->where(['vehicle' => $vehicle_id])->One(); if ($driver_details) { $selected = $driver_details->id; } } echo Json::encode(['output' => $out, 'selected' => $selected]); //return true; }
<?php echo $form->field($model, 'merchant')->dropDownList(ArrayHelper::map(CustomerDetails::find()->where(['status' => 1, 'customer_type' => 1])->all(), 'id', 'name'), ['prompt' => 'Select Merchant', 'style' => 'width:500px', 'onChange' => 'merchantAmount();']); ?> <?php echo $form->field($model, 'buyer')->dropDownList(ArrayHelper::map(CustomerDetails::find()->where(['status' => 1, 'customer_type' => 2])->all(), 'id', 'name'), ['prompt' => 'Select Buyer', 'style' => 'width:500px', 'onChange' => 'buyerAmount();']); ?> <?php echo $form->field($model, 'vehicle_id')->dropDownList(ArrayHelper::map(VehicleDetails::find()->where(['status' => 1])->all(), 'id', 'name'), ['prompt' => 'Select Vehicle', 'style' => 'width:500px', 'id' => 'vehicle-id', 'onChange' => 'calculateKMA();']); ?> <?php echo $form->field($model, 'driver_id')->widget(DepDrop::classname(), ['options' => ['id' => 'driver_id', 'style' => 'width:500px'], 'data' => ArrayHelper::map(DriverDetails::find()->where(['status' => 1, 'customer_type' => 3])->all(), 'id', 'name'), 'pluginOptions' => ['depends' => ['vehicle-id'], 'placeholder' => 'Select driver', 'url' => Url::to(['/business/driver/driverlist'])]]); ?> <?php echo $form->field($model, 'material_id')->dropDownList(ArrayHelper::map(MaterialTypes::find()->where(['status' => 1])->all(), 'id', function ($model, $defaultValue) { return $model->name . ' - ' . MaterialTypes::$measurementType[$model->measurement_type]; }), ['prompt' => 'Select Material', 'style' => 'width:500px', 'onChange' => 'merchantAmount();buyerAmount();']); ?> <?php echo $form->field($model, 'size')->textInput(['maxlength' => 100, 'style' => 'width:500px', 'onChange' => 'merchantAmount();buyerAmount();']); ?>