
@extends('backend.header')
@section('index-content')
<style type="text/css">
    
    .required:after {
    content:" ";
    color: red;
  }
</style>

				<section role="main" class="content-body">
					<header class="page-header">
						<h2>Move Inventory Form</h2>
					</header>
					<div class="row">
						<div class="col-xs-12">
							<div class="right-wrapper">
								<ol class="breadcrumbs">
									<li>
										<a href="{{url('index')}}">
											<i class="fa fa-home"></i>
										</a>
									</li>
									<li><span class="active">Move Inventory Form</span></li>
								</ol>
							</div>
						</div>
					</div>
           	<!-- start: page -->


<div class="row" id="userallotform">
  <div class="col-md-12">
   @if(session('error'))
   <div class="alert alert-danger">{{session('error')}}</div>
   @endif
    @if(session('success'))
   <div class="alert alert-success">{{session('success')}}</div>
    @endif


   <section class="panel mt-2">
    <header class="panel-heading">
        <h4 class="my-0">Move inventory Lights Form</h4>  
        <div class="back-btn-div">
            <button class="btn btn-primary back-btn" onclick="window.history.back()">Back</button>
        </div>

  </header>
  <form action="{{url('editinventorylist')}}" id="outwardsform" method="post" class="form-horizontal" enctype="multipart/form-data">
      @csrf
      <div class="panel-body mb-4">

        <div class="row px-3">
            <div class="form-group">
                <label class="col-sm-2 control-label">From District<span class="required">*</span></label>
                <div class="col-sm-10">
                    <select name="jilla_id" class="h40 w-100" id="jilla_id" required>
                        <option value="">Select Jilla</option>
                        @foreach($jilla as $j)
                        <option value="{{$j->id}}">{{$j->area_name}}</option>

                        @endforeach
                    </select>
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-2 control-label">Make Name<span class="required">*</span></label>
                <div class="col-sm-10">
                    <select name="maker_name" id="maker_name" class="h40 w-100" required>
                        <option value="">Select Make </option>
                        @foreach($makeslist as $make)
                        <option value="{{$make->name}}">{{$make->name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">To District<span class="required">*</span></label>
                <div class="col-sm-10">
                    <select name="to_jilla_id" id="to_jilla_id" class="w-100" onchange="myFunction()" required>
											<option value="">District Name</option>
                                           @foreach($jilla as $j)
											 <option value="{{$j->id}}">{{$j->area_name}}</option>
														@endforeach
                                            <option value="EESL">EESL</option>
											</select>
                </div>
            </div>
         
             <div class="form-group">
                <label class="col-sm-12 control-label text-center mt-4">WATTAGE OF LIGHTS</label>
            </div>
          
            <div class="form-group">
                <label class="col-sm-2 control-label">Transfer Quantity</label>
                <div class="col-sm-10">
                   <div class="row">
                       <div class="col-12 col-sm-6 col-md-4 col-lg-20 pr-2">
                           <div><span id="rcv_qty_18w_span"> </span>
                               <input type="number" name="rcv_qty_18w" id="rcv_qty_18w" placeholder="18 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="rcv_qty_35w_span"> </span>
                               <input type="number" name="rcv_qty_35w" id="rcv_qty_35w" placeholder="35 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="rcv_qty_70w_span"> </span>
                               <input type="number" name="rcv_qty_70w" id="rcv_qty_70w" placeholder="70 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="rcv_qty_110w_span"> </span>
                               <input type="text" name="rcv_qty_110w" id="rcv_qty_110w" placeholder="110 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 pl-2">
                           <div><span id="rcv_qty_190w_span"> </span>
                               <input type="text" name="rcv_qty_190w"  id="rcv_qty_190w" placeholder="190 W" class="form-control">
                           </div>
                       </div>
                   </div>
                </div>
            </div>
              <div class="form-group">
                <label class="col-sm-12 control-label text-center mt-4">SPARE LIGHTS WATTAGE </label>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label pt-0">Transfer Quantity </label>
                <div class="col-sm-10">
                   <div class="row">
                       <div class="col-12 col-sm-6 col-md-4 col-lg-20 pr-2">
                           <div><span id="bufferstck_received_qty_18w_span"> </span>
                              <input type="number" name="bufferstck_received_qty_18w" id="bufferstck_received_qty_18w" placeholder="18 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="bufferstck_received_qty_35w_span"> </span>
                               <input type="number" name="bufferstck_received_qty_35w" id="bufferstck_received_qty_35w" placeholder="35 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="bufferstck_received_qty_70w_span"> </span>
                               <input type="number" name="bufferstck_received_qty_70w" id="bufferstck_received_qty_70w" placeholder="70 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="bufferstck_received_qty_110w_span"> </span>
                               <input type="number" name="bufferstck_received_qty_110w" id="bufferstck_received_qty_110w" placeholder="110 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 pl-2">
                           <div><span id="bufferstck_received_qty_190w_span"> </span>
                               <input type="number" name="bufferstck_received_qty_190w" id="bufferstck_received_qty_190w" placeholder="190 W" class="form-control">
                           </div>
                       </div>
                   </div>
                </div>
            </div>

              <div class="form-group">
                <label class="col-sm-12 control-label text-center mt-4">WATTAGE OF DRIVERS</label>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label pt-0">Transfer Quantity</label>
                <div class="col-sm-10">
                   <div class="row">
                       <div class="col-12 col-sm-6 col-md-4 col-lg-20 pr-2">
                           <div><span id="drivers_received_qty_18w"> </span>

                              <input type="number" name="drivers_received_qty_18w"  id="drivers_received_qty_18w" placeholder="18 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="drivers_received_qty_35w_span"> </span>

                               <input type="number" name="drivers_received_qty_35w"  id="drivers_received_qty_35w"  placeholder="35 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="drivers_received_qty_70w_span"> </span>

                               <input type="number" name="drivers_received_qty_70w" id="drivers_received_qty_70w" placeholder="70 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="drivers_received_qty_110w_span"> </span>

                               <input type="number" name="drivers_received_qty_110w" id="drivers_received_qty_110w" placeholder="110 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 pl-2">
                           <div><span id="drivers_received_qty_190w_span"> </span>

                               <input type="number" name="drivers_received_qty_190w" id="drivers_received_qty_190w" placeholder="190 W" class="form-control">
                           </div>
                       </div>
                   </div>
                </div>
            </div>
            

              <div class="form-group" >
                <label class="col-sm-12 control-label text-center mt-4">WATTAGE OF SPD</label>
            </div>
           
            <div class="form-group">
                <label class="col-sm-2 control-label pt-0">Transfer Quantity</label>
                <div class="col-sm-10">
                   <div class="row">
                       <div class="col-12 col-sm-6 col-md-4 col-lg-20 pr-2">
                           <div><span id="spd_received_qty_18w_span"> </span>
                              <input type="number" name="spd_received_qty_18w" placeholder="18 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="spd_received_qty_35w_span"> </span>
                               <input type="number" name="spd_received_qty_35w"  id="spd_received_qty_35w"  placeholder="35 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="spd_received_qty_70w_span"> </span>
                               <input type="number" name="spd_received_qty_70w" id="spd_received_qty_70w" placeholder="70 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 px-2">
                           <div><span id="spd_received_qty_110w_span"> </span>
                               <input type="number" name="spd_received_qty_110w" id="spd_received_qty_110w" placeholder="110 W" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-20 pl-2">
                           <div><span id="spd_received_qty_190w_span"> </span>
                               <input type="number" name="spd_received_qty_190w"  id="spd_received_qty_190w" placeholder="190 W" class="form-control">
                           </div>
                       </div>
                   </div>
                </div>
            </div>
            

             <div class="form-group" >
                <label class="col-sm-12 control-label text-center mt-4">TILTABLE ADAPTERS</label>
            </div>
           
            
             <!-- <div class="form-group">
                <label class="col-sm-2 control-label pt-0" >Received Quantity</label>
                <div class="col-sm-10">
                   <div class="row">
                       <div class="col-12 ">
                           <div><span id="tiltadap_rcv_qty"> </span>
                              <input type="number" name="tiltadap_rcv_qty"  placeholder="Tiltable adapters Received" class="form-control">
                           </div>
                       </div>
                        
                   </div>
                </div>
            </div> -->

             
      
        <div class="row mt-3">
            <div class="col-12 px-3">
                <div class="text-right pr-2">
                    <input type="submit" class="btn btn-success" value="Submit">
                </div>
            </div>
        </div>
       </div>
    </div>
</form>
</div>

</div>

				</section>
				<!-- <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> -->
				<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
				<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>

<script type="text/javascript">
   

$('.date_of_transfer').datepicker({
  dateFormat: 'dd/mm/yy'
});


</script>
    			<script>
				$(document).ready(function(){
					$('select[name=jilla_id]').on('change', function() {
   var self = this;
   $('select[name=to_jilla_id]').find('option').prop('disabled', function() {
       return this.value == self.value
   });
});

$('select[name=to_jilla_id]').on('change', function() {
  var self = this;
  $('select[name=jilla_id]').find('option').prop('disabled', function() {
      return this.value == self.value
  });

    var jilla_id=$("#jilla_id").val();
    var maker_name=$("#maker_name").val();
       
    var data={
        jilla_id:jilla_id,
        maker_name:maker_name,     
    };

    $.ajax({
        url:'{{("editmoveinventory_store_check")}}',
        method:'get',
        data:data,
        success:function(data)
        {

            console.log(data);
            $('#rcv_qty_18w_span').text(data.w18w??'0');
            $('#rcv_qty_35w_span').text(data.w35w??'0');
            $('#rcv_qty_70w_span').text(data.w70w??'0');
            $('#rcv_qty_110w_span').text(data.w110w??'0');
            $('#rcv_qty_190w_span').text(data.w190w??'0');
            $('#drivers_received_qty_18w_span').text(data.d18w??'0');
            $('#drivers_received_qty_35w_span').text(data.d35w??'0');
            $('#drivers_received_qty_70w_span').text(data.d70w??'0');
            $('#drivers_received_qty_110w_span').text(data.d110w??'0');
            $('#drivers_received_qty_190w_span').text(data.d190w??'0');
            $('#spd_received_qty_18w_span').text(data.s18w??'0');
            $('#spd_received_qty_35w_span').text(data.s35w??'0');
            $('#spd_received_qty_70w_span').text(data.s70w??'0');
            $('#spd_received_qty_110w_span').text(data.s110w??'0');
            $('#spd_received_qty_190w_span').text(data.s190w??'0');
            $('#bufferstck_received_qty_18w_span').text(data.b18w??'0');
            $('#bufferstck_received_qty_35w_span').text(data.b35w??'0');
            $('#bufferstck_received_qty_70w_span').text(data.b70w??'0');
            $('#bufferstck_received_qty_110w_span').text(data.b110w??'0');
            $('#bufferstck_received_qty_190w_span').text(data.b190w??'0');
            //$('#tiltadap_rcv_qty_span').text(data.trq);

            // $('#rcv_qty_18w').val(data.w18w);
            // $('#rcv_qty_35w').val(data.w35w);
            // $('#rcv_qty_70w').val(data.w70w);
            // $('#rcv_qty_110w').val(data.w110w);
            // $('#rcv_qty_190w').val(data.w190w);
            // $('#drivers_received_qty_18w').val(data.d18w);
            // $('#drivers_received_qty_35w').val(data.d35w);
            // $('#drivers_received_qty_70w').val(data.d70w);
            // $('#drivers_received_qty_110w').val(data.d110w);
            // $('#drivers_received_qty_190w').val(data.d190w);
            // $('#spd_received_qty_18w').val(data.s18w);
            // $('#spd_received_qty_35w').val(data.s35w);
            // $('#spd_received_qty_70w').val(data.s70w);
            // $('#spd_received_qty_110w').val(data.s110w);
            // $('#spd_received_qty_190w').val(data.s190w);
            // $('#bufferstck_received_qty_18w').val(data.b18w);
            // $('#bufferstck_received_qty_35w').val(data.b35w);
            // $('#bufferstck_received_qty_70w').val(data.b70w);
            // $('#bufferstck_received_qty_110w').val(data.b110w);
            // $('#bufferstck_received_qty_190w').val(data.b190w);
            // $('#tiltadap_rcv_qty').val(data.trq);


            $('#rcv_qty_18w').attr({"max" : data.w18w??'0'});
            $('#rcv_qty_35w').attr({"max" : data.w35w??'0'});
            $('#rcv_qty_70w').attr({"max" : data.w70w??'0'});
            $('#rcv_qty_110w').attr({"max" : data.w110w??'0'});
            $('#rcv_qty_190w').attr({"max" : data.w190w??'0'});
            $('#drivers_received_qty_18w').attr({"max" : data.d18w??'0'});
            $('#drivers_received_qty_35w').attr({"max" : data.d35w??'0'});
            $('#drivers_received_qty_70w').attr({"max" : data.d70w??'0'});
            $('#drivers_received_qty_110w').attr({"max" : data.d110w??'0'});
            $('#drivers_received_qty_190w').attr({"max" : data.d190w??'0'});
            $('#spd_received_qty_18w').attr({"max" : data.s18w??'0'});
            $('#spd_received_qty_35w').attr({"max" : data.s35w??'0'});
            $('#spd_received_qty_70w').attr({"max" : data.s70w??'0'});
            $('#spd_received_qty_110w').attr({"max" : data.s110w??'0'});
            $('#spd_received_qty_190w').attr({"max" : data.s190w??'0'});
            $('#bufferstck_received_qty_18w').attr({"max" : data.b18w??'0'});
            $('#bufferstck_received_qty_35w').attr({"max" : data.b35w??'0'});
            $('#bufferstck_received_qty_70w').attr({"max" : data.b70w??'0'});
            $('#bufferstck_received_qty_110w').attr({"max" : data.b110w??'0'});
            $('#bufferstck_received_qty_190w').attr({"max" : data.b190w??'0'});
            //$('#tiltadap_rcv_qty').attr({"max" : data.trq});
  
  
        },  
        error:function(data)
        {
           alert(data); 
        }
    });


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

					$("#led_wattage").on("change",function(){
						var jilla_id=$("#jilla_id").val();
						var maker_name=$("#maker_name").val();
						var led_wattage=$(this).val();
						  var data={
                       jilla_id:jilla_id,
                        maker_name:maker_name, 
                         led_wattage:led_wattage, 
                                        };
						$.ajax({
							url:'{{("ledwattageinwards")}}',
							data:data,
							method:'get',
							success:function(data)
							{
								//console.log(data.w18w);
								if(led_wattage=="18 W")
								{
							$('#quantity').text(data.w18w);
						}
							if(led_wattage=="35 W")
								{
							$('#quantity').text(data.w35w);
						}
						if(led_wattage=="70 W")
								{
							$('#quantity').text(data.w70w);
						}
						if(led_wattage=="110 W")
								{
							$('#quantity').text(data.w110w);
						}
						if(led_wattage=="190 W")
								{
							$('#quantity').text(data.w190w);
						}

								
							},	
							error:function(data)
							{
								alert(data);
							}
						});
					});

                    $("#maker_name").on("change",function(){
                        var jilla_id=$("#jilla_id").val();
                        var maker_name=$("#maker_name").val();
                        $.ajax({
                            url:'{{url("invoicenumber")}}?jilla_id='+jilla_id+'&maker_name='+maker_name,
                            method:'get',
                            success:function(data)
                            {
                                //var test=data.split("::");
                                $("#invoice_number").html(data);
                                
                            },  
                            error:function(data)
                            {
                                $("#invoice_number").html("");
                            }
                        });
                    });

                   $("#to_jilla_id").on("change",function(){
                   var to_jilla= $("#to_jilla_id option:selected").text();
                    var from_jilla= $("#jilla_id option:selected").text();

                  $("#remarks").val("Invoice is transfered from "+ from_jilla+" to "+ to_jilla)
                   
                });


					$("#invoice_number").on("change",function(){
                                // var id=$(this).val();
                                
                                 var jilla_id=$("#jilla_id").val();
                                  var maker_name=$("#maker_name").val();
                                   var invoice_number=$("#invoice_number").val();
                                   
                                  var data={
                                       jilla_id:jilla_id,
                                       maker_name:maker_name, 
                                        invoice_number:invoice_number,
                                    
                                        };
                        $.ajax({
                                    url:'{{("editmoveinventory_store_check")}}',
                                    method:'get',
                                    data:data,
                                    success:function(data)
                                    {

                                        console.log(data);
                                        $('#rcv_qty_18w').text(data.w18w);
                                        $('#rcv_qty_35w').text(data.w35w);
                                        $('#rcv_qty_70w').text(data.w70w);
                                        $('#rcv_qty_110w').text(data.w110w);
                                        $('#rcv_qty_190w').text(data.w190w);
                                        $('#drivers_received_qty_18w').text(data.d18w);
                                        $('#drivers_received_qty_35w').text(data.d35w);
                                        $('#drivers_received_qty_70w').text(data.d70w);
                                        $('#drivers_received_qty_110w').text(data.d110w);
                                        $('#drivers_received_qty_190w').text(data.d190w);
                                        $('#spd_received_qty_18w').text(data.s18w);
                                        $('#spd_received_qty_35w').text(data.s35w);
                                        $('#spd_received_qty_70w').text(data.s70w);
                                        $('#spd_received_qty_110w').text(data.s110w);
                                        $('#spd_received_qty_190w').text(data.s190w);
                                        $('#bufferstck_received_qty_18w').text(data.b18w);
                                        $('#bufferstck_received_qty_35w').text(data.b35w);
                                        $('#bufferstck_received_qty_70w').text(data.b70w);
                                        $('#bufferstck_received_qty_110w').text(data.b110w);
                                        $('#bufferstck_received_qty_190w').text(data.b190w);
                                        $('#tiltadap_rcv_qty').text(data.trq);
  
  
  
                                    },  
                                    error:function(data)
                                    {
                                       alert(data); 
                                    }
                                });
                            });


					
					
				});	
					
				
				</script>
	@stop	