Exemple #1
0
 public static function FetchCity($code)
 {
     if (\Yii::$app->language == "en") {
         $field = 'title';
     } else {
         $field = 'title_ar';
     }
     $cities = Cities::find()->where('government_code=' . $code)->all();
     $listData = ArrayHelper::map($cities, 'id', $field);
     return $listData;
 }
Exemple #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cities::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]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name_en', $this->name_en]);
     return $dataProvider;
 }
 public function actionCities()
 {
     $code = $_REQUEST['code'];
     if (\Yii::$app->language == "en") {
         $field = 'title';
     } else {
         $field = 'title_ar';
     }
     $cities = Cities::find()->where('government_code="' . $code . '"')->all();
     if (count($cities) > 0) {
         echo "<option value=''>" . Yii::t('easyii', 'District') . "</option>";
         foreach ($cities as $city) {
             echo "<option value='" . $city->id . "'>" . $city->{$field} . "</option>";
         }
     } else {
         echo "<option>--</option>";
     }
 }
Exemple #4
0
echo $form->field($model, 'email')->textInput(['maxlength' => true, 'placeholder' => $model->getAttributeLabel('email')])->label(false);
?>
                    </div>
                </div>
            </div>
            <div class="col-lg-1"></div>
        </div>
        <div class="row">
            <div class="col-lg-3">
                <p>Address information</p>
            </div>
            <div class="col-lg-8">
                <div class="row">
                    <div class="col-lg-6">
                        <?php 
echo $form->field($model, 'city')->dropDownList(ArrayHelper::map(Cities::find()->all(), 'id', 'name'), ['prompt' => 'Choose a City', 'onchange' => '$.post("' . Yii::$app->urlManager->createUrl('customers/lists') . '",{id:$(this).val()}, 
                                            function( data ) {
                                                $( "select#customers-suburb" ).html( data );
                                            });'])->label(false);
?>
                    </div>
                    <div class="col-lg-6">
                        <?php 
echo $form->field($model, 'street')->textInput(['maxlength' => true, 'placeholder' => $model->getAttributeLabel('street')])->label(false);
?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-6">
                        <?php 
echo $form->field($model, 'suburb')->dropDownList(ArrayHelper::map(Suburbs::find()->asArray()->all(), 'id', 'name'), ['prompt' => 'Choose a suburb'])->label(false);
Exemple #5
0
        
        <h3>delivery details</h3>
        
        <div class="row">
            <div class="col-lg-9">
                <div class="row">
                    <div class="col-lg-12">
                        <?php 
echo $form->field($model, 'address')->textInput(['maxlength' => true, 'placeholder' => $model->getAttributeLabel('address')])->label(false);
?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-6">
                        <?php 
echo $form->field($model, 'city')->dropDownList(ArrayHelper::map(Cities::find()->all(), 'id', 'name'), ['prompt' => 'Choose a City'])->label(false);
?>
                    </div>
                    <div class="col-lg-6">
                        <?php 
echo $form->field($model, 'zipcode')->textInput(['maxlength' => true, 'placeholder' => $model->getAttributeLabel('zipcode')])->label(false);
?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <?php 
echo $form->field($model, 'comments')->textarea(['rows' => 6, 'placeholder' => $model->getAttributeLabel('comments')])->label(false);
?>
                    </div>
                </div>
Exemple #6
0
                            <?php 
echo $form->field($filterForm, 'government')->dropDownList($listData, ['prompt' => Yii::t('easyii', 'Governorate'), 'class' => 'btn btn-findUs dropdown-toggle', 'onchange' => '
                $.post( "' . Yii::$app->urlManager->createUrl('stores/cities?code=') . '"+$(this).val(), function( data ) {
                  $( "select#gadgetsstoresfilterform-district" ).html( data );
                })'])->label('');
?>




                    </div>
                    <div class="col-md-4">
                        <?php 
if (isset($filterForm->government) and $filterForm->government != '') {
    $cities = \app\models\Cities::find()->where('government_code="' . $filterForm->government . '"')->all();
    $listData = \yii\helpers\ArrayHelper::map($cities, 'id', 'title');
} else {
    $listData = [];
}
?>


                           <?php 
echo $form->field($filterForm, 'district')->dropDownList($listData, ['prompt' => Yii::t('easyii', 'District'), 'class' => 'btn btn-findUs dropdown-toggle'])->label('');
?>
                    </div>

                    <div class="row">
                        <div class="col-md-12">
<!--                                <img src="--><?php 
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Cities::find($id)->delete();
     return redirect()->back();
 }