@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">
        <h2>Outward Of CCMS From vendor</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 mt-2">
    <header class="panel-heading">
        <h4 class="my-0">Outward Of CCMS 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('vendor_outwards_ccms')}}" id="ccmsform" 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</label>
                <div class="col-sm-10">
                    <select name="jilla_id" class="h40 w-100 jilla_id" 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">Mandal Name</label>
                <div class="col-sm-10">
                    <select name="mandal_id" class="h40 w-100" id="aname" >
                       <option value="">Mandal Name</option>
                            @foreach($taluka as $ai)
                            <option value="{{$ai->id}}">{{$ai->area_name}}</option>
                             @endforeach  
                    </select>
                </div>
            </div>
           <!--    <div class="form-group">
                <label class="col-sm-2 control-label">Invoice Number<span class="required">*</span></label>
                <div class="col-sm-10">
                    <select name="invoice_number"  id="invoice_number" class="h40 w-100" required>
                        <option value="">Select Invoice Number </option>
                       
                        <option value=""></option>
                        
                    </select>
                </div>
            </div> -->
             <div class="form-group">
                <label class="col-sm-2 control-label">SUBVendor</label>
                <div class="col-sm-10">
                    <select name="subvendor_id" class="h40 w-100" id="subvendor_id" >
                        <option value="">Select SubVendor</option>
                        @foreach($subvendorslists as $v)
                        <option value="{{$v->id}}">{{$v->name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">Make Name</label>
                <div class="col-sm-10">
                    <select name="maker_name" class="h40 w-100" id="maker_name" >
                        <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">Phase Name</label>
                <div class="col-sm-10">
                    <select name="phase_name" class="h40 w-100" id="phase_name" >
                    <option value="">Select Ph Value </option>
                    <option value="1-ph">1 ph</option>
                    <option value="2-ph">2 ph </option>
                    <option value="3-ph">3 ph</option>
                    <option value="4-ph">4 ph</option>
                    <option value="5-ph">5 ph</option>
                     </select>
                </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" class="form-control">
                    </div>
                </div>
            </div>
           -->
           <!-- 
            <div class="form-group">
                <label class="col-sm-2 control-label">Invoice Date</label>
                <div class="col-sm-10">
                    <div>
                        <input type="date" name="invoice_date" class="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">Aluminium Cable</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text"  name="aluminium_cable" class="form-control">
                    </div>
                </div>
            </div> -->
            <!-- <div class="form-group">
                <label class="col-sm-2 control-label">Description</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text"  name="description" class="form-control">
                    </div>
                </div>
            </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">Received Cable(*if Any)</label>
                <div class="col-sm-10">
                    <div>
                        <input type="text"  name="received_cable" 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-12 control-label text-center mt-4">CCMS PH Quantity</label>
            </div>

             <div class="form-group">
                <label class="col-sm-2 control-label">Transfer Quantity</label>
                <div class="col-sm-10">
                    <div><span id="quantity1"> </span>
                        <input type="text"  name="ccms_ph_receive_quantity" class="form-control" required>
                    </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 type="text/javascript">
 

    $("#date_of_receiving").change(function () {
    var invoice_date = document.getElementById("invoice_date").value;
    var date_of_receiving = document.getElementById("date_of_receiving").value;

    if ((Date.parse(date_of_receiving) <= Date.parse(invoice_date))) {
        alert("date_of_receiving date should be greater than invoice_date date");
        document.getElementById("date_of_receiving").value = "";
              }
     });



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

  $(".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("");
                            }
                        });
                    });
   $("#jilla_id").on("change",function(){
                                // var id=$(this).val();
                                 var jilla_id=$("#jilla_id").val();
                                 //var invoice_number=$("#invoice_number").val();
                                  var data={
                                       jilla_id:jilla_id,
                                       // invoice_number:invoice_number, 
                                        };
                        $.ajax({
                                    url:'{{("subvendor_ccms_store_check")}}',
                                    method:'get',
                                    data:data,
                                    success:function(data)
    
                                    {

                                        //console.log(data.a25d);
                                        $('#quantity1').text(data.rccms1w);
                                    
  
  
                                    },  
                                    error:function(data)
                                    {
                                       alert(data); 
                                    }
                                });
                            });



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

   
    
     

    
</script>
@stop
