예제 #1
0
  public function run ()
  {
  
    DB::table('districts')->delete();

    District::create([
    
      'cname' => '黄浦区',

      'ename' => 'HuangPu District',
  
      'code' => 1,

      'city_id' => 1,

      'active' => 1
    
    ]);
  
    District::create([
    
      'cname' => '浦东新区',

      'ename' => 'HuangPu District',
  
      'code' => 2,

      'city_id' => 1,

      'active' => 1
    
    ]);
  
  
  }
예제 #2
0
 public function actionLoaddistrict($id = null)
 {
     //$id คือ รหัส pk ของจังหวัด
     $districts = District::find()->where(['province_id' => $id])->orderBy('district_name')->all();
     $option = '<option value="">-กรุณาเลือกอำเภอ-</option>';
     foreach ($districts as $d) {
         $option .= '<option value="' . $d->id . '">' . $d->district_name . '</option>';
     }
     echo $option;
 }
예제 #3
0
 public function actionFind()
 {
     $searchForm = new FindForm();
     $view['districtList'] = ArrayHelper::map(District::find()->where("district != ''")->orderBy('district')->all(), 'id_district', 'district');
     $params = ArrayHelper::merge(Yii::$app->request->getQueryParams(), Yii::$app->request->post());
     $searchForm->load($params);
     if (implode('', $searchForm->toArray())) {
         //$view['list'] = $searchForm->search();
     } else {
         $amount = (int) ArrayHelper::getValue(Main::findBySql("select count(id_person) as amount from main")->asArray()->one(), 'amount');
     }
     $view['pagination'] = new Pagination(['pageSize' => 10]);
     //dd($amount);
     $dataProvider = new ActiveDataProvider(['query' => $searchForm->getSearchQuery(), 'totalCount' => $amount ? $amount : null, 'pagination' => $view['pagination']]);
     //dd($dataProvider);
     $view['dataProvider'] = $dataProvider;
     $view['searchForm'] = $searchForm;
     return $this->render('find', $view);
 }
예제 #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function getEdit($id)
 {
     $this->districts = District::all('id', 'name');
     $area = Area::find($id);
     if ($area) {
         return view('modules.area.form', array('is_edit' => true, 'area' => $area, 'districts' => $this->districts));
     } else {
         return $this->notFoundResponse();
     }
 }
예제 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function postDestroy()
 {
     if ($this->request->ajax()) {
         $id = $this->request['id'] ?: '';
         $data = District::find($id);
         if ($data) {
             $data->delete();
         }
         $response = array('url' => route('place.index'));
         return $response;
     }
 }
예제 #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $value = District::find($id);
     if ($value == null) {
         return response(['errorMessage' => 'Not Found'], 404);
     }
     $value->delete();
     return response('', 200);
 }
예제 #7
0
/* @var $this yii\web\View */
/* @var $model app\models\Contact */
/* @var $form yii\widgets\ActiveForm */
if($model->isNewRecord){
    $province = [];
    $district = [];
    $tambon = [];
    
    $district_list = [];
    $tambon_list = [];
}else{
    $province = $model->tambon->province_id;
    $district = $model->tambon->district_id;
    $tambon = $model->tambon_id;
    
    $district_list = ArrayHelper::map(District::find()
            ->where(['province_id'=>$province])->all(), 'id', 'district_name');
    $tambon_list = ArrayHelper::map(Tambon::find()
            ->where(['district_id'=>$district])->all(), 'id', 'tambon_name');
}

?>

<div class="contact-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'firstname')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'lastname')->textInput(['maxlength' => true]) ?>
예제 #8
0
 /**
  * Update the profile
  *
  * @param  int  $id
  * @return Response
  */
 public function updateprofile($id)
 {
     $data['user'] = User::findOrFail($id);
     $data['sectors'] = Sector::lists('name', 'id');
     $data['districts'] = District::lists('district', 'id');
     $districtsselected = PartnerDistrict::get_districts_selected($id);
     $data['districtsselected'] = PartnerDistrict::format_selected($districtsselected);
     $data['cancelbtn'] = Permission::hasPermission('users.index');
     return view('users.profile', $data);
 }
예제 #9
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data['project'] = $project = Project::find($id);
     if ($project) {
         $data['sectors'] = Sector::lists('name', 'id');
         $data['states'] = State::lists('state', 'id');
         $data['districts'] = District::where('state_id', $data['project']->state_id)->lists('district', 'id');
         $data['taluks'] = Taluk::where('district_id', $data['project']->district_id)->lists('taluk', 'id');
         $data['cancelbtn'] = Permission::hasPermission('projects.index');
         return view('projects.edit', $data);
     } else {
         Session::flash($this->danger, Lang::get('ruban.project.notfound'));
         return Redirect::route('ruban.projects.index');
     }
 }
예제 #10
0
 public function getDistricts()
 {
     return @$this->hasOne(District::className(), ['DISTRICT_ID' => 'province']);
 }
예제 #11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBaseDistricts()
 {
     return $this->hasMany(District::className(), ['province_id' => 'id']);
 }
예제 #12
0
 /**
  * Get districts that belong to the city/province by city_id
  *
  * @param int $id City id
  *
  * @return \Illuminate\Support\Collection $collection
  */
 protected function _getDistrictsByCityId($id)
 {
     $dbRaw = DB::raw("id, CONCAT(type, ' ', name) as name");
     $districts = District::where('city_id', $id)->select($dbRaw)->orderBy('name')->get();
     return $districts;
 }
예제 #13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getDistrict()
 {
     return $this->hasOne(District::className(), ['id' => 'district_id']);
 }
예제 #14
0
 protected function getDistrict($id)
 {
     $datas = District::find()->where(['AMPHUR_ID' => $id])->all();
     return $this->MapData($datas, 'DISTRICT_ID', 'DISTRICT_NAME');
 }
예제 #15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data['card'] = $card = Card::find($id);
     if ($card) {
         $data['sectors'] = Sector::lists('name', 'id');
         $data['districts'] = District::groupby($this->district)->lists($this->district, 'id');
         $data['projects'] = Project::orderby('name', 'asc')->lists('name', 'id');
         $data['listbtn'] = Permission::hasPermission('cards.update');
         return view('cards.edit', $data);
     } else {
         Session::flash('danger', Lang::get('ruban.card.notfound'));
         return Redirect::route('ruban.cards.index');
     }
 }
예제 #16
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function getEdit($id)
 {
     $this->districts = District::all('id', 'name');
     $street = Street::find($id);
     if ($street) {
         return view('modules.street.form', array('is_edit' => true, 'street' => $street, 'districts' => $this->districts));
     } else {
         return $this->notFoundResponse();
     }
 }
예제 #17
0
 public function getdistrict()
 {
     $equipmenttypes = District::where($this->state_id, Input::get('id'))->orderby('district', 'asc')->lists('district', 'id');
     $out = '<option value="">Select Option</option>';
     if ($equipmenttypes) {
         foreach ($equipmenttypes as $key => $equipmenttype) {
             $out .= '<option value="' . $key . '">' . $equipmenttype . '</option>';
         }
     }
     echo $out;
 }
예제 #18
0
  public function getReceiverinfo (Request $request)
  {
    $user = Auth::user();

    $receiverInfoSet = ReceiverInfo::where('uid', '=', $user->id)

      ->where('active', '=', '1')

      ->orderBy('last_used', 'desc')

      ->orderBy('created_at', 'desc')

      ->get();

    $provinceSet = Province::all();      

    $provinces = array();

    foreach ($provinceSet as $province) {
    
      array_push($provinces, $province);
    
    }

    $cities = City::all();

    $districts = array();

    foreach ($cities as $city) {
    
      $district = District::where('city_code', '=', $city->code) 

        ->where('active', '=', '1')

        ->first();

      if ($district) {

        array_push($districts, $district);
    
      }

    }

    $receiverInfos = array();

    foreach ($receiverInfoSet as $receiverInfo) {
    
      array_push($receiverInfos, $receiverInfo);
    
    }

    $data = [
    
      'receiverInfos' => $receiverInfos,

      'provinces' => $provinces,

      'cities' => $cities,

      'districts' => $districts,

      'receiverActive' => true,

      'wTitle' => '个人中心 - 收货人信息'
    
    ];

    return view('profile/receiver_info', $data);
  
  }
예제 #19
0
  public function getDistrict (Request $request) 
  {
    $city = $request->input('city'); 
  
    $districts = District::where('city_code', '=', $city)

      ->where('active', '=', 1)

      ->get();

    $html = $this->districtList($districts);

    return $this->successResponse('res', $html);
  
  }