/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = VehicleDetails::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, 'type' => $this->type]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'vehicle_number', $this->vehicle_number])->andFilterWhere(['like', 'size', $this->size])->andFilterWhere(['like', 'charge_per_km', $this->charge_per_km])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
echo $form->field($model, 'customer_type')->textInput(); ?> </div> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => 15]); ?> </div> </div> <div class="col-xs-12 col-lg-12 no-padding"> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($model, 'vehicle')->dropDownList(ArrayHelper::map(VehicleDetails::find()->where(['status' => 1])->all(), 'id', 'name'), ['prompt' => 'Select Vehicle', 'id' => 'vehicle']); ?> </div> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($model, 'earning_percentage')->textInput(['maxlength' => 4]); ?> </div> </div> <div class="col-xs-12 col-lg-12 no-padding"> <div class="col-xs-12 col-sm-6 col-lg-6"> <?php echo $form->field($model, 'status')->textInput(['maxlength' => 1]);
/** * Finds the VehicleDetails model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return VehicleDetails the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = VehicleDetails::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?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) { return $model->name . ' - ' . MaterialTypes::$measurementType[$model->measurement_type]; }), ['prompt' => 'Select Material', 'style' => 'width:500px', 'onChange' => 'merchantAmount();buyerAmount();']); ?> <?php
/** * @return \yii\db\ActiveQuery */ public function getDriverVehicle() { return $this->hasOne(VehicleDetails::className(), ['id' => 'vehicle']); }