<div class="form-group row {{ $errors->has('amphurs_id') ? 'has-error' : '' }}">
    <label for="amphurs_id" class="col-md-2 control-label"> อำเภอ</label>
    <div class="col-md-4">
        <select class="form-control" id="amphurs_id" name="amphurs_id" onChange="get_tambons(this.value)"  required>
        	  <option value="" style="display: none;"
    {{ old('amphurs_id', optional(optional(optional($people)->mooban)->tambon)->amphurs_id ?: '') == '' ? 'selected' : '' }}
    disabled selected>
    ระบุ  อำเภอ
</option>

@foreach ($amphurs as $key => $amphur)
    <option value="{{ $key }}"
        {{ old('amphurs_id', optional(optional(optional($people)->mooban)->tambon)->amphurs_id) == $key ? 'selected' : '' }}>
        {{ $amphur }}
    </option>
@endforeach

	 
        </select>
        
        {!! $errors->first('amphurs_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>



<div class="form-group row {{ $errors->has('tambons_id') ? 'has-error' : '' }}">
    <label for="tambons_id" class="col-md-2 control-label"> ตำบล</label>
    <div class="col-md-4">
        <select class="form-control" id="tambons_id" name="tambons_id" onChange="get_moobans(this.value )" required>
        	    <option value="" style="display: none;"  {{ old('tambons_id', optional(optional($people)->mooban)->tambons_id ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ ควบคุมตำบล</option>
        	@foreach ($tambons as $key => $tambon)
			    <option value="{{ $key }}"  {{ old('tambons_id', optional(optional($people)->mooban)->tambons_id ?: '') == $key ? 'selected' : '' }}>
			    	{{ $tambon }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('tambons_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('moobans_id') ? 'has-error' : '' }}">
    <label for="moobans_id" class="col-md-2 control-label">หมู่บ้าน</label>
    <div class="col-md-4">
        <select class="form-control" id="moobans_id" name="moobans_id" onChange="get_homes(this.value )" required>
        	    <option value="" style="display: none;" {{ old('moobans_id', optional($people)->moobans_id ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ หมู่บ้าน</option>
        	@foreach ($moobans as $key => $mooban)
			    <option value="{{ $key }}" {{ old('moobans_id', optional($people)->moobans_id) == $key ? 'selected' : '' }}>
			    	{{ $mooban }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('moobans_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>


<div class="form-group row {{ $errors->has('homes_id') ? 'has-error' : '' }}" >
    <label for="homes_id" class="col-md-2 control-label">บ้านเลขที่</label>
    <div class="col-md-4">
        <select class="form-control" id="homes_id" name="homes_id"  required>
        	    <option value=""  {{ old('homes_id', optional($people)->homes_id ?: '') == '' ? 'selected' : '' }}   selected>ระบุ บ้านเลขที่ (หากไม่มีให้เลือก ให้เพิ่มในช่อง เพิ่มบ้านเลขที่)</option>
                 <option value="0">เพิ่มบ้านเลขที่ด้านล่าง</option>
        	@foreach ($homes as $key => $home)
			    <option value="{{ $key }}" {{ old('homes_id', optional($people)->homes_id) == $key ? 'selected' : '' }}>
			    	{{ $home }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('homes_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>


<div class="form-group row {{ $errors->has('address') ? 'has-error' : '' }}">
    <label for="address" class="col-md-2 control-label">เพิ่มบ้านเลขที่</label>
    <div class="col-md-4">
        <input type="text" class="form-control" id="address" name="address" placeholder="ระบุ บ้านเลขที่">
        	   
        
        {!! $errors->first('address', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>


<div class="form-group row {{ $errors->has('idcard') ? 'has-error' : '' }}">
    <label for="idcard" class="col-md-2 control-label">เลขบัตรประชาชน</label>
    <div class="col-md-4">
        <input class="form-control" name="idcard" type="text" id="idcard" value="{{ old('idcard', optional($people)->idcard) }}" maxlength="13" placeholder="ระบุ เลขบัตรประชาชน">
        {!! $errors->first('idcard', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

 



<div class="form-group row {{ $errors->has('gender') ? 'has-error' : '' }}">
    <label for="gender" class="col-md-2 control-label">เพศ</label>
    <div class="col-md-4">
        <select class="form-control" id="gender" name="gender" required>
        	    <option value="" style="display: none;" {{ old('gender', optional($people)->gender ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ เพศ</option>
        	@foreach (['ชาย' => 'ชาย',
'หญิง' => 'หญิง',
'สาวสอง' => 'สาวสอง'] as $key => $text)
			    <option value="{{ $key }}" {{ old('gender', optional($people)->gender) == $key ? 'selected' : '' }}>
			    	{{ $text }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('gender', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('name') ? 'has-error' : '' }}">
    <label for="name" class="col-md-2 control-label">ชื่อ-สกุล</label>
    <div class="col-md-4">
        <input class="form-control" name="name" type="text" id="name" value="{{ old('name', optional($people)->name) }}" maxlength="100" placeholder="ระบุ ชื่อ-สกุล" required>
        {!! $errors->first('name', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('born') ? 'has-error' : '' }}">
    <label for="born" class="col-md-2 control-label">ปีเกิด</label>
    <div class="col-md-4">
        <input class="form-control" name="born" type="text" id="born" value="{{ old('born', optional($people)->born) }}" min="2460" max="{{  date('Y')+526 }}" placeholder="ระบุ ปีเกิด">
        {!! $errors->first('born', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('age') ? 'has-error' : '' }}">
    <label for="age" class="col-md-2 control-label">อายุ</label>
    <div class="col-md-4">
        <input class="form-control" name="age" type="text" id="age" value="{{ old('age', optional($people)->age) }}" min="18" max="120" placeholder="ระบุ อายุ">
        {!! $errors->first('age', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('tel') ? 'has-error' : '' }}">
    <label for="tel" class="col-md-2 control-label">เบอร์โทร</label>
    <div class="col-md-4">
        <input class="form-control" name="tel" type="text" id="tel" value="{{ old('tel', optional($people)->tel) }}" maxlength="45" placeholder="ระบุ เบอร์โทร">
        {!! $errors->first('tel', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('positions_id') ? 'has-error' : '' }}">
    <label for="positions_id" class="col-md-2 control-label">ตำแหน่ง/ยศ</label>
    <div class="col-md-4">
        <select class="form-control" id="positions_id" name="positions_id" required>
        	    <option value="" style="display: none;" {{ old('positions_id', optional($people)->positions_id ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ ตำแหน่ง/ยศ</option>
        	@foreach ($positions as $key => $position)
			    <option value="{{ $key }}" {{ old('positions_id', optional($people)->positions_id) == $key ? 'selected' : '' }}>
			    	{{ $position }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('positions_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('educations_id') ? 'has-error' : '' }}">
    <label for="educations_id" class="col-md-2 control-label">ระดับการศึกษา</label>
    <div class="col-md-4">
        <select class="form-control" id="educations_id" name="educations_id" required>
        	    <option value="" style="display: none;" {{ old('educations_id', optional($people)->educations_id ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ ระดับการศึกษา</option>
        	@foreach ($education as $key => $education)
			    <option value="{{ $key }}" {{ old('educations_id', optional($people)->educations_id) == $key ? 'selected' : '' }}>
			    	{{ $education }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('educations_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('residence') ? 'has-error' : '' }}">
    <label for="residence" class="col-md-2 control-label">ถิ่นที่อยู่</label>
    <div class="col-md-4">
        <select class="form-control" id="residence" name="residence" required>
        	    <option value="" style="display: none;" {{ old('residence', optional($people)->residence ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ ถิ่นที่อยู่</option>
        	@foreach (['ในพื้นที่' => 'ในพื้นที่',
'นอกพื้นที่' => 'นอกพื้นที่'] as $key => $text)
			    <option value="{{ $key }}" {{ old('residence', optional($people)->residence) == $key ? 'selected' : '' }}>
			    	{{ $text }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('residence', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('residence_detail') ? 'has-error' : '' }}">
    <label for="residence_detail" class="col-md-2 control-label">รายละเอียดถิ่นที่อยู่(กรณีนอกพื้นที่ ถ้ามี)</label>
    <div class="col-md-4">
        <input class="form-control" name="residence_detail" type="text" id="residence_detail" value="{{ old('residence_detail', optional($people)->residence_detail) }}" maxlength="150" placeholder="ระบุ รายละเอียดถิ่นที่อยู่(กรณีนอกพื้นที่ ถ้ามี)">
        {!! $errors->first('residence_detail', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('vote_location') ? 'has-error' : '' }}">
    <label for="vote_location" class="col-md-2 control-label">การเลือกตั้งในเขต</label>
    <div class="col-md-4">
        <select class="form-control" id="vote_location" name="vote_location">
        	    <option value=""   {{ old('vote_location', optional($people)->vote_location ?: '') == '' ? 'selected' : '' }}   selected>ระบุ การเลือกตั้งในเขต (ยังไม่สามารถระบุได้)</option>
        	@foreach (['ในเขต' => 'ในเขต',
'นอกเขต' => 'นอกเขต'] as $key => $text)
			    <option value="{{ $key }}" {{ old('vote_location', optional($people)->vote_location) == $key ? 'selected' : '' }}>
			    	{{ $text }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('vote_location', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('associates_id') ? 'has-error' : '' }}">
    <label for="associates_id" class="col-md-2 control-label">ฝ่าย</label>
    <div class="col-md-4">
        <select class="form-control" id="associates_id" name="associates_id">
        	    <option value=""   {{ old('associates_id', optional($people)->associates_id ?: '') == '' ? 'selected' : '' }}   selected>ระบุ ฝ่าย(ยังไม่สามารถระบุได้) </option>
      
        	@foreach ($associates as $key => $associate)
			    <option value="{{ $key }}" {{ old('associates_id', optional($people)->associates_id) == $key ? 'selected' : '' }}>
			    	{{ $associate }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('associates_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('image') ? 'has-error' : '' }}">
    <label for="image" class="col-md-2 control-label">ภาพ</label>
    <div class="col-md-4">
        <div class="input-group uploaded-file-group">
            <label class="input-group-btn">
                <span class="btn btn-default">
                   ไฟล์เอกสาร (ถ้ามี)<input type="file" name="image" id="image" class="hidden">
                </span>
            </label>
            <input type="text" class="form-control uploaded-file-name" readonly>
        </div>

        @if (isset($people->image) && !empty($people->image))
            <div class="input-group input-width-input">
                <span class="input-group-addon">
                    <input type="checkbox" name="custom_delete_image" class="custom-delete-file" value="1" {{ old('custom_delete_image', '0') == '1' ? 'checked' : '' }}> Delete
                </span>

                <span class="input-group-addon custom-delete-file-name">
                    {{ $people->image }}
                </span>
            </div>
        @endif
        {!! $errors->first('image', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>
@php /*
<div class="form-group row {{ $errors->has('users_id') ? 'has-error' : '' }}">
    <label for="users_id" class="col-md-2 control-label">ผู้บันทึกข้อมูล</label>
    <div class="col-md-4">
        <select class="form-control" id="users_id" name="users_id">
        	    <option value="" style="display: none;" {{ old('users_id', optional($people)->users_id ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ ผู้บันทึกข้อมูล</option>
        	@foreach ($users as $key => $user)
			    <option value="{{ $key }}" {{ old('users_id', optional($people)->users_id) == $key ? 'selected' : '' }}>
			    	{{ $user }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('users_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>
*/ @endphp
<div class="form-group row {{ $errors->has('tracking_users_id') ? 'has-error' : '' }}">
    <label for="tracking_users_id" class="col-md-2 control-label">ผู้รับผิดชอบในการหาเสียง</label>
    <div class="col-md-4">
        <select class="form-control" id="tracking_users_id" name="tracking_users_id">
        	    <option value="" style="display: none;" {{ old('tracking_users_id', optional($people)->tracking_users_id ?: '') == '' ? 'selected' : '' }} disabled selected>ระบุ ผู้รับผิดชอบในการหาเสียง</option>
        	@foreach ($trackingUsers as $key => $trackingUser)
			    <option value="{{ $key }}" {{ old('tracking_users_id', optional($people)->tracking_users_id) == $key ? 'selected' : '' }}>
			    	{{ $trackingUser }}
			    </option>
			@endforeach
        </select>
        
        {!! $errors->first('tracking_users_id', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('etc') ? 'has-error' : '' }}">
    <label for="etc" class="col-md-2 control-label">คำอธิบาย บุคคลเพิ่มเติม</label>
    <div class="col-md-4">
        <input class="form-control" name="etc" type="text" id="etc" value="{{ old('etc', optional($people)->etc) }}" maxlength="250" placeholder="ระบุ คำอธิบาย บุคคลเพิ่มเติม">
        {!! $errors->first('etc', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('lat') ? 'has-error' : '' }}">
    <label for="lat" class="col-md-2 control-label">ละติจูดบ้าน</label>
    <div class="col-md-4">
        <input class="form-control" name="lat" type="number" id="lat" value="{{ old('lat', optional($people)->lat) }}" min="0"  placeholder="ระบุ ละติจูด">
        {!! $errors->first('lat', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

<div class="form-group row {{ $errors->has('lon') ? 'has-error' : '' }}">
    <label for="lon" class="col-md-2 control-label">ลองจิจูดบ้าน</label>
    <div class="col-md-4">
        <input class="form-control" name="lon" type="number" id="lon" value="{{ old('lon', optional($people)->lon) }}" min="0"   placeholder="ระบุ ลองจิจูด">
        {!! $errors->first('lon', '<p class="form-text text-muted">:message</p>') !!}
    </div>
</div>

