/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CustomerDetails::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, 'customer_type' => $this->customer_type]); $query->where(['<>', 'customer_type', 3]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'place', $this->place])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'account_details', $this->account_details])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * Finds the CustomerDetails model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CustomerDetails the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CustomerDetails::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="trips-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'date_of_travel')->widget(yii\jui\DatePicker::className(), ['clientOptions' => ['dateFormat' => 'dd-mm-yyyy', 'changeMonth' => true, 'changeYear' => true, 'autoSize' => true, 'yearRange' => '1900:' . (date('Y') + 1)], 'options' => ['class' => 'form-control', 'placeholder' => $model->getAttributeLabel('date_of_travel'), 'style' => 'width:500px']]); ?> <?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) {