/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Courier::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, 'max_delivery_days' => $this->max_delivery_days, 'min_delivery_days' => $this->min_delivery_days, 'avg_delivery_days' => $this->avg_delivery_days, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
Esempio n. 2
0
?>

    <?php 
echo $form->field($model, 'order_date')->widget(\yii\jui\DatePicker::classname(), ['options' => ['class' => 'form-control'], 'dateFormat' => 'yyyy-MM-dd']);
?>

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

    <?php 
if (!$model->isNewRecord) {
    ?>

    <?php 
    $allCouriers = ArrayHelper::map(\app\models\Courier::find()->orderBy('id')->all(), 'id', 'name');
    ?>
    <?php 
    echo $form->field($model, 'courier_id')->dropDownList($allCouriers, ['prompt' => ' -- Select Courier --'])->label('Courier');
    ?>

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

    <?php 
    echo $form->field($model, 'shipment_date')->widget(\yii\jui\DatePicker::classname(), ['options' => ['class' => 'form-control'], 'dateFormat' => 'yyyy-MM-dd']);
    ?>

    <?php 
    echo $form->field($model, 'delivery_date')->widget(\yii\jui\DatePicker::classname(), ['options' => ['class' => 'form-control'], 'dateFormat' => 'yyyy-MM-dd']);
 /**
  * Finds the Courier model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Courier the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Courier::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 /**
  * boot
  * observing model
  *
  */
 public static function boot()
 {
     parent::boot();
     Courier::observe(new CourierObserver());
 }
Esempio n. 5
0
 /**
  * Relationship with Courier
  */
 public function getCourier()
 {
     return $this->hasOne(Courier::className(), ['id' => 'courier_id']);
 }