
@extends('backend.header')
@section('index-content')
<style>
	.form-control{
		height: 40px;
	}
</style>
<?php
function convertToUnicodeNumber($input) {

	$standard_numsets = array("0","1","2","3","4","5","6","7","8","9");
	$devanagari_numsets = array("०","१","२","३","४","५","६","७","८","९");

	return str_replace($standard_numsets, $devanagari_numsets, $input);
}
?>
<section role="main" class="content-body">
	<header class="page-header">
    <div class="row">
      <div class="col-lg-5">
        <h2>Add Preliminary Survey Form</h2>  
      </div>
    
      <div class="col-lg-5">
        <ol class="breadcrumbs">
            <li>
              <a href="{{url('index')}}">
                <i class="fa fa-home"></i>
              </a>
            </li>
            <li><span class="active">Preliminary Survey Form</span></li>
          </ol>
      </div>
      <div class="col-lg-2">
            <div class="add-btn-div">
              <button class="btn btn-primary back-btn" onclick="window.history.back()" style="margin-right: 25px;">Back</button>
            </div>
      </div>
    </div>
  </header>
	<!-- <header class="page-header">
		<h2>Add Preliminary Survey Form</h2>
	</header> -->
					<!-- <div class="row px-3">
						<div class="col-12">
							<div class="">
								
							</div>
						</div>
					</div> -->

					<!-- start: page -->
					<div class="row mb-5 px-3">
						<!-- <header class="panel-heading">
							<h4 class="my-0">Add Preliminary Survey Form</h4>
							<div class="panel-actions">
								<a href="#" class="fa fa-caret-down"></a>
								<a href="#" class="fa fa-times"></a>
							</div>

						</header>  --> 
						
						@if(session('error'))
						<div class="alert alert-danger">{{session('error')}}</div>
						@endif
						@if(session('success'))
						<div class="alert alert-success">{{session('success')}}</div>
						@endif
						<div class="col-md-12 px-0">
							<form id="form" action="{{url('add_preliminary_survey')}}" class="form-horizontal" method="post" enctype="multipart/form-data">
								@csrf
								<input type="hidden" name="id" value="{{$list->id??''}}">
								<section class="panel">
									
									<div class="panel-body">
										<div class="row px-3">
											<div class="col-md-10">
												<div class="form-group">
													<label class="col-sm-3 control-label">District Name<span class="required">*</span></label>
													<div class="col-sm-9">
														<select name="district_name" class="form-control" id="jilla_id" required>
															<option value="">District Name</option>
															@foreach($jilla as $ai)
															<option value="{{$ai->id}}" @if(isset($list)) @if($ai->id==$list->district_id) Selected @endif @endif>{{$ai->area_name}} </option>

															@endforeach
														</select>

													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Mandal Name<span class="required">*</span></label>
													<div class="col-sm-9">
														<select name="taluka_name" style="height:40px;width:100%;margin-top:0px;" id="taluka"   required>
															<option value="">Mandal Name</option>   
														</select>

													</div>
												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Panchayat Name<span class="required">*</span></label>
													<div class="col-sm-9">
														<select name="gram_name" style="height:40px;width:100%;margin-top:0px;" id="gram_id" required>
															<option value="">Panchayat Name</option>
														</select>

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Sarpanch Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="sarpanch_name" id="Sarpanch_Name" class="form-control" min="0"  placeholder="Sarpanch Name" value="{{$list->sarpanch_name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Sarpanch Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="sarpanch_phone" id="sarpanch_phone" class="form-control" min="0"  placeholder="Sarpanch Phone" value="{{$list->sarpanch_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">GP Secretary Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="gp_secretary_name" id="gp_secretary_name" class="form-control" min="0"  placeholder="GP Secretary Name" value="{{$list->gp_secretary_name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">GP Secretary Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="gp_secretary_phone" id="gp_secretary_phone" class="form-control" min="0"  placeholder="GP Secretary Phone" value="{{$list->gp_secretary_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">VA/Electrician Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="electrician_name" id="electrician_name" class="form-control" min="0"  placeholder="VA/Electrician Name" value="{{$list->electrician_name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">VA/Electrician Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="electrician_phone" id="electrician_phone" class="form-control" min="0"  placeholder="VA/Electrician Phone" value="{{$list->electrician_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">ADE Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="ADE_name" id="ADE_Name" class="form-control" min="0"  placeholder="ADE Name" value="{{$list->ADE_name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">ADE Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="ADE_phone" id="ADE_phone" class="form-control" min="0"  placeholder="ADE Phone" value="{{$list->ADE_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">AE Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="AE_name" id="AE_Name" class="form-control" min="0"  placeholder="AE Name" value="{{$list->AE_name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">AE Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="AE_phone" id="AE_phone" class="form-control" min="0"  placeholder="AE Phone" value="{{$list->AE_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Substation 33/11KV Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="Substation33_11KV_name" id="Substation33_11KV_Name" class="form-control" min="0"  placeholder="Substation 33/11KV Name" value="{{$list->Substation33_11KV_name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Substation 33/11KV Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="Substation33_11KV_phone" id="Substation33_11KV_phone" class="form-control" min="0"  placeholder="Substation 33/11KV Phone" value="{{$list->Substation33_11KV_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Linemen Name</label>
													<div class="col-sm-9">
														<input type="text" 
														name="linemen_name" id="linemen_Name" class="form-control" min="0"  placeholder="Linemen Name" value="{{$list->linemen_Name??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Linemen Phone</label>
													<div class="col-sm-9">
														<input type="text" 
														name="linemen_phone" id="linemen_phone" class="form-control" min="0"  placeholder="Linemen Phone" value="{{$list->linemen_phone??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">18 W</label>
													<div class="col-sm-9">
														<input type="number" 
														name="18_w" id="18_w" class="form-control" min="0"  value="0" value="{{$list->light_18w??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">35 W</label>
													<div class="col-sm-9">
														<input type="number" 
														name="35_w" id="35_w" class="form-control" min="0"   value="{{$list->light_35w??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">70 W</label>
													<div class="col-sm-9">
														<input type="number" 
														name="70_w" id="70_w" class="form-control" min="0"   value="{{$list->light_70w??''}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">110 W</label>
													<div class="col-sm-9">
														<input type="number" 
														name="110_w" id="110_w" class="form-control" min="0"  value="{{$list->light_110w??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">190 W</label>
													<div class="col-sm-9">
														<input type="number" 
														name="190_w" id="190_w" class="form-control" min="0"  value="{{$list->light_190w??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">8.1mts Poles</label>
													<div class="col-sm-9">
														<input type="number" 
														name="pole8mts" id="pole8mts" class="form-control" min="0"  value="{{$list->pole8mts??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">9.1mts Poles</label>
													<div class="col-sm-9">
														<input type="number" 
														name="pole9mts" id="pole9mts" class="form-control" min="0"  value="{{$list->pole9mts??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">12mts Poles</label>
													<div class="col-sm-9">
														<input type="number" 
														name="pole12mts" id="pole12mts" class="form-control" min="0"  value="{{$list->pole12mts??'0'}}">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Poles without 3rd Wire </label>
													<div class="col-sm-9">
														<input type="number" 
														name="pole_withoutwire" id="pole_withoutwire" class="form-control" min="0"  value="{{$list->pole_withoutwire??'0'}}">

													</div>

												</div>
												<div class="col-12">
													<div class="text-right">
														<button class="btn btn-primary" type="submit">Submit</button>
													</div>
												</div>
											</div>
										</div>									
									</div>
								</section>
							</form>
						</div>

					</div>
					<!-- end: page -->

				</section>
				<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
				<script>

					@if(isset($list))
					var id="{{$list->district_id}}";
					var gram_id="{{$list->mandal_id}}"
						get_mandals(id);
						get_gram(gram_id)
					@endif

					$(document).ready(function(){
						$("#jillaid").on("change",function(){
							var id=$(this).val();
							get_mandals(id)
							
						});

					});	

					function get_mandals(id) {
						$.ajax({
								url:'{{url("jillaid")}}/'+id,
								method:'get',
								success:function(data)
								{
								//var test=data.split("::");
								$("#taluka").html(data);
								@if(isset($list))

								$("#taluka").val("{{$list->mandal_id}}");
								@endif
								
							},	
							
							error:function(data)
							{
								$("#aname").html("");
							}
						});
					}

					function get_gram(id) {
						$.ajax({
								url:'{{url("getgram")}}/'+id,
								method:'get',
								success:function(data)
								{
								//var test=data.split("::");
								
								var dt="<option value=''>Please Select Gram</option>";
							var res=data.split("-");
							for(var i=0;i<res.length-1;i++)
							{
								var tdt = res[i].split("_");
								dt +="<option value='"+tdt[0]+"'>"+tdt[1]+"</option>";
							}
							$('#gram_id').html(dt);

							@if(isset($list))

					
					$("#gram_id").val("{{$list->gram_id}}");
					
					@endif
								
							},	
							
							error:function(data)
							{
								$("#aname").html("");
							}
						});
					}

					


					
</script>
@stop	