
@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>Edit GP CCMS Type Form</h2>  
          </div>
          <div class="col-lg-7">
                <div class="back-btn-div">
                    <button class="btn btn-primary back-btn" style="margin-right: 25px;" onclick="window.history.back()">Back</button>
                </div>
        </div>
      </header>
	<!-- <header class="page-header">
		<h2>Edit GP CCMS Type Form</h2>
					</header>
					<div class="row px-3">
						<div class="col-12">
							<div class="">
								<button class="btn btn-primary" onclick="window.history.back()">Back</button>
							</div>
						</div>
					</div> -->

					<!-- start: page -->
					<div class="row mb-5 px-3">
						<!-- <header class="panel-heading">
							<h4 class="my-0">Edit GP CCMS Type 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('ccms_types_update')}}/{{$pr->id}}" class="form-horizontal" method="post" enctype="multipart/form-data">
								@csrf
								<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="{{$pr->district_id}}">District Name</option>
															@foreach($jilla as $ai)
															<option value="{{$ai->id}}" @if($pr->district_id==$ai->id) Selected @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="{{$pr->area_mandal->id}}">{{$pr->area_mandal->area_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="{{$pr->area_gram->id}}">{{$pr->area_gram->area_name}}</option>
														</select>

													</div>

												</div>
											 	<div class="form-group">
													<label class="col-sm-3 control-label">Phase No<span class="required">*</span></label>
													<div class="col-sm-9">
													
														<select name="phase_no" style="height:40px;width:100%;margin-top:0px;"  class="w-100" id="phase_no" required>
															<option value="{{$pr->phase_no}}">Phase-{{$pr->phase_no}}</option>
														</select>

													</div>

												</div> 
												<div class="form-group">
													<label class="col-sm-3 control-label">CCMS Type<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="text" 
														name="ccms_type" value="{{$pr->ccms_type??0}}" class="form-control" required >

													</div>

												</div>
											
												<div class="form-group">
													<label class="col-sm-3 control-label">Survey Qty<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="number" 
														name="survey_qty" id="35_w"  value="{{$pr->survey_qty??0}}" class="form-control" min="1" required >

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Supplied Qty<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="number" 
														name="supply_qty"  value="{{$pr->supply_qty??0}}" class="form-control" min="1" required >

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Installed Qty<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="number" 
														name="install_qty" value="{{$pr->install_qty??0}}" class="form-control" min="1" required >

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Balance Qty to be Install<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="number" 
														name="balance_qty_install" id="balance_qty_install" value="{{$pr->balance_qty_install??0}}" class="form-control" min="0" required value="0">

													</div>

												</div>
												<div class="form-group">
													<label class="col-sm-3 control-label">Balance Qty. to be supplied<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="number" 
														name="balance_qty_supply" id="balance_qty_supply" value="{{$pr->balance_qty_supply??0}}" class="form-control" min="0" required value="0">

													</div>

												</div>
													<div class="form-group">
													<label class="col-sm-3 control-label">Cable used<span class="required">*</span></label>
													<div class="col-sm-9">
														<input type="number" 
														name="cable_used" value="{{$pr->cable_used??0}}" class="form-control" min="1" required >

													</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 type="text/javascript">
				$("#gram_id").on("change",function()
				{
					var id=$(this).val();
			
			$.ajax({
				url:'{{url("/gram_survey_phase_status")}}/'+id,
				method:'get',
				dataType:"json",
				success:function(data)
				{
					var dataRow="<option value=''>Select Phase</option>";
					if(data.length > 0){
					data.forEach(el => {
                   
                    dataRow+= `<option value="${el.phase_no}">Phase - ${el.phase_no}</option>`;
                                });
                       
                   }else{
                   	dataRow+="<option value='1'>Phase-1</option>";
                   }
                   $("#phase_no").html(dataRow);
                  
				},	
				error:function(data)
				{
					$("#status").val("0");
				}
			});

			// $("#jilla_id").on("change",function(){
			// 			var id=$(this).val();
			// 			$.ajax({
			// 				url:"{{url('/jillaid')}}/"+id,
			// 				method:'get',
			// 				success:function(data)
			// 				{
			// 					//var test=data.split("::");
			// 					$("#aname").html(data);
								
			// 				},	
			// 				error:function(data)
			// 				{
			// 					$("#aname").html("");
			// 				}
			// 			});
			// 		});
		});
			</script>	
@stop	