@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> Outward Of Arms/Clamps Form</h2>  
          </div>
        
          <div class="col-lg-5">
            <!-- <ol class="breadcrumbs">
                <li>
                  <a href="{{url('index')}}">
                    <i class="fa fa-home"></i>
                </a>
            </li>
        </ol> -->
          </div>
          <div class="col-lg-2">
              <div class="back-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> Outward Of Arms/Clamps 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>
        </ol>
        </div>
        </div>
    </div> -->



<!-- allot user code here -->
<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">
   <!--  <header class="panel-heading">
        <h4 class="my-0">Outward Of Arms/Clamps 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('admin_outwards_armsclamps')}}" id="armsform" 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">District Name</label>
                <div class="col-sm-10">
                    <select name="jilla_id" class="h40 w-100" id="jilla_id" >
                        <option value="">Select District</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">Vendor</label>
                <div class="col-sm-10">
                    <select name="vendor_id" class="h40 w-100" id="vendor_id" >
                        <option value="">Select Vendor</option>
                          @foreach($vendorslists as $v)
                        <option value="{{$v->id}}">{{$v->name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">Invoice Number</label>
                <div class="col-sm-10">
                    <select name="invoice_number" id="invoice_number"  class="invoice_number h40 w-100" >
                        <option value="">Select Invoice Number</option>
                          @foreach($invoicelists as $invoicelist)
                        <option value="{{$invoicelist->invoice_number}}">{{$invoicelist->invoice_number}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
        <!--     <div class="form-group">
                <label class="col-sm-2 control-label">Supplied by</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text"  name="suplied_by" class="form-control">
                    </div>
                </div>
            </div> -->
          <!--   <div class="form-group">
                <label class="col-sm-2 control-label">Invoice Number</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text"  name="invoice_number" id="invoice_number" class="invoice_number form-control">
                    </div>
                </div>
            </div> -->
          
           
            <div class="form-group">
                <label class="col-sm-2 control-label">Transfer Date</label>
                <div class="col-sm-10">
                    <div>
                        <input type="date" name="date_of_receiving" class="form-control">
                    </div>
                </div>
            </div>
            <!-- <div class="form-group">
                <label class="col-sm-2 control-label">Received Quantity</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text" name="received_quantity" class="form-control">
                    </div>
                </div>
            </div> -->
            <div class="form-group">
                <label class="col-sm-2 control-label">Files</label>
                <div class="col-sm-10">
                    <div>
                        <input type="file" name="files" class="form-control" multiple="multiple">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">Remarks</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text" name="remarks" class="form-control">
                    </div>
                </div>
            </div>
               <div class="form-group">
                <label class="col-sm-2 control-label">Transfer Aluminium Cable</label>
                <div class="col-sm-10">
                    <div> <span id="quantity6"> </span>
                        <input type="text"  name="received_aluminium_cable" class="form-control">
                    </div>
                </div>
            </div>
             <div class="form-group">
                <label class="col-sm-12 control-label text-center mt-4">CLAMPS SET</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-40 pr-2">
                           <div> <span id="quantity3"> </span>
                               <input type="text" name="received_clams_set_25" id="received_clams_set_25" placeholder="Clamps set 25" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-40 px-2">
                           <div> <span id="quantity4"> </span>
                               <input type="text" name="received_clams_set_40_2" id="received_clams_set_40_2" placeholder="Clamps set 40*2" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-40 px-2">
                           <div> <span id="quantity5"> </span>
                               <input type="text" name="received_clams_set_40_3" id="received_clams_set_40_3" placeholder="Clamps set 40*3" class="form-control">
                           </div>
                       </div>
                        
                   </div>
                </div>
            </div>
             <div class="form-group">
                <label class="col-sm-12 control-label text-center mt-4">Arms </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-40 pr-2">
                           <div> <span id="quantity"> </span>
                               <input type="text" name="received_arms_dia_25" id="received_arms_dia_25" placeholder="Arms Dia 25" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-40 px-2">
                           <div> <span id="quantity1"> </span>
                               <input type="text" name="received_arms_dia_inner_32" id="received_arms_dia_inner_32" placeholder="Arms Dia 32" class="form-control">
                           </div>
                       </div>
                        <div class="col-12 col-sm-6 col-md-4 col-lg-40 px-2">
                           <div> <span id="quantity2"> </span>
                               <input type="text" name="received_arms_dia_inner_40" id="received_arms_dia_inner_40" placeholder="Arms Dia 40" class="form-control">
                           </div>
                       </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>
</form>
</div>

</div>

</section>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>

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


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

                                        //console.log(data.a25d);
                                        $('#received_arms_dia_25').val(data.a25d);
                                        $('#received_arms_dia_inner_32').val(data.a32d);
                                        $('#received_arms_dia_inner_40').val(data.a40d);
                                        $('#received_clams_set_25').val(data.c25s);
                                        $('#received_clams_set_40_2').val(data.c402s);
                                        $('#received_clams_set_40_3').val(data.c403s);
                        
                                        $('#quantity6').val(data.cbl);
  
  
                                    },  
                                    error:function(data)
                                    {
                                       alert(data); 
                                    }
                                });
                            });


      $("#armsform").validate({
      rules: {

        jilla_id: 'required',
         vendor_id: 'required',
          date_of_receiving: 'required',
         received_aluminium_cable: 'required', 
       
       

            received_arms_dia_25: {
              required: function(element){
                      if($('#received_arms_dia_inner_32').val() == "" && $('#received_arms_dia_inner_40').val() == "")

                        {
                         return true;
                        }else{
                          return false; 
                            }
                  }
          },

           
              received_clams_set_25: {
              required: function(element){
                      if($('#received_clams_set_40_2').val() == "" && $('#received_clams_set_40_3').val() == "")

                        {
                         return true;
                        }else{
                          return false; 
                            }
                  }
          },
      
      },


      messages: {
              
                received_arms_dia_25: 'Please Enter Atleast One Wattage',
               
                received_clams_set_25: 'Please Enter Atleast One Wattage',
               },

         submitHandler: function(form) {
                form.submit();
                          }
                  });

</script>
@stop

