<!DOCTYPE html>
<html>
<head>
  @include('title')
  

  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap/dist/css/bootstrap.min.css')}}">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/font-awesome/css/font-awesome.min.css')}}">
  <!-- Ionicons -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/Ionicons/css/ionicons.min.css')}}">
  <!-- Theme style -->
  <link rel="stylesheet" href="{{asset('lte/dist/css/AdminLTE.min.css')}}">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="{{asset('lte/dist/css/skins/_all-skins.min.css')}}">
  
  <!-- bootstrap wysihtml5 - text editor -->
  <link rel="stylesheet" href="{{asset('lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css')}}">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="{{asset('lte/plugins/iCheck/all.css')}}">

  <!-- bootstrap datepicker -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css')}}">
  
  <link rel="stylesheet" href="{{asset('lte/plugins/timepicker/bootstrap-timepicker.min.css')}}">
  <!-- DataTables -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css')}}">

  <!-- Select2 -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/select2/dist/css/select2.min.css')}}">
  
</head>
<body class="hold-transition skin-blue fixed sidebar-mini">
<div class="wrapper">
  
  @include('headertag')
  <!-- Left side column. contains the logo and sidebar -->
  @include('leftside')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
  <!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    Material Request Contract
  </h1>
  <ol class="breadcrumb">
    <li><a href="{{route('contract_material_request.list')}}"><i class="fa fa-dashboard"></i> Material Request Contract</a></li>
    <li class="active">create</li>
  </ol>
</section>

<div class="modal modal-info fade" id="modal-info">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Last Orders</h4>
      </div>
      <div class="modal-body">
        <table class="table table-bordered">
        <thead>
        <tr>
          <th>Sl No.</th>
          <th>MR Number</th>
          <th>Date</th>
          <th>Add</th>
          
        </tr>
        </thead>
        <tbody>
         <?php $c = 1; ?>
        @foreach($last_entries as $data)
        <tr> 
          <td>{{$c++}}</td>
          <td>{{$data->request_no}}</td>
          <td>{{date('d-m-Y',strtotime($data->request_date))}}</td>
          <?php
            $id = $data->id."-".$x;
          ?>
          <td class="center"><a href="{{route('sea_last_enteries.add',$id)}}"><i class="fa fa-fw fa-plus" style="color: blue;"></i></a></td>
        </tr>
        @endforeach
        </tbody>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
      </div>
    </div>
          <!-- /.modal-content -->
  </div>
        <!-- /.modal-dialog -->
</div>
      <!-- /.modal --> 

      <div class="modal modal-warning fade" id="modal-warning">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
              <h4 class="modal-title">OFFERS</h4>
            </div>
            <div class="modal-body">
              <table class="table table-bordered">
                <thead>
                <tr>
                  <th>OFFER</th>
                  <th>Type</th>
                </tr>
                </thead>
                <tbody>
                @foreach($nfn as $not)
                <tr>                   
                  <td>{{$not->matter}}</td>
                  <td>{{$not->type['name']}}</td>
                </tr>
                @endforeach
              </tbody>
              </table>
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
              </div>
            </div>
            <!-- /.modal-content -->
          </div>
          <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->

<!-- Main content -->
<section class="content">
  <!-- Main row -->
  <div class="row">
    <!-- Left col -->
    <section class="col-lg-12 connectedSortable">
            <!-- Custom tabs (Charts with tabs)-->

      <div class="box box-info">
        <div class="box-header with-border">
          @if(Session::has('exist'))
          <div class="alert alert-danger alert-dismissible">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            Product Already Requested
          </div>
          @endif
          <div class="form-group col-md-3" style="display: inline;">
            <div class="input-group date ">
              <div class="input-group-addon">
                <i class="fa fa-calendar"></i>
              </div>
            <div>
            <input type="text" class="form-control pull-right datepicker" value="{{date('d-F-Y')}}" disabled="">
          </div>
        </div>
      <!-- /.input group -->
      </div>
      <div class="col-md-3">
        <h3 style="display: inline;">{{$material_request->req_no}}</h3>
      </div>
      <div class="col-md-2 pull-right">
        <!-- <button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-info">
        Last Order Pick-up
        </button> -->
      </div>
            
    <div class="pull-right">
        <!-- <a class="btn btn-app" data-toggle="modal" onclick="jsNot()" data-target="#modal-warning" style="background: none;border:none;">
          <i class="fa fa-bell-o" style="margin-top: -12px;font-size: 23px; color: orange"></i>
          <span id="count" class="badge bg-yellow" style="right:10px;">@if($n_type_count != 0){{$n_type_count}}@endif</span> 
        </a> -->

                <!-- <button type="button" class="btn btn-warning" data-toggle="modal" onclick="jsNot()" data-target="#modal-warning" style="background: transparent;border: none;"><i class="fa fa-fw  fa-exclamation-circle" style="color: orange;"></i>
                @if($n_type_count != 0)<sup><span id="count" class="label label-warning">{{$n_type_count}}</span></sup>@endif
                </button> -->
    </div>

     
              
  </div>
  <div class="box box-default">
    <form role="form" action="{{route('contract_material_request_p.store')}}" method="POST">
    <!-- /.box-header -->
    <div class="box-body">
      <div class="row">
        <div class="col-md-6">
          <div class="form-group">
            <label>Supplier Name<i style="color: red">*</i></label>
            <select class="form-control select2" id="supplier_id" name="supplier_id" style="width: 100%;" required="required">
              <option value="">--Select--</option>
              @foreach($suppliers as $sup)
                <option value="{{$sup->id}}" @if($contract['supplier_id'] == $sup->id) selected @endif>{{$sup->name}}</option>
              @endforeach
            </select>
          </div>
          <!-- /.form-group -->
          <div class="form-group">
            <label>Contact Person<i style="color: red">*</i></label>
            <input type="text" name="contact_person" value="{{$contract['contact_person']}}" id="contact_person" class="form-control" required="required">
          </div>
          <!-- /.form-group -->
        </div>
        <!-- /.col -->
        <div class="col-md-6">
          <div class="form-group">
            <label>Type of Contract<i style="color: red">*</i></label>
            <select class="form-control select2" id="contract_type" name="contract_type" style="width: 100%;">
              <option value="">--Select--</option>
              @foreach($contract_types as $type)
              <option value="{{$type->id}}" @if($contract['contract_id'] == $type->id) selected @endif>{{$type->name}}</option>
              @endforeach
            </select>
          </div>
          <!-- /.form-group -->
          <div class="form-group">
            <label>Port of Arrival<i style="color: red">*</i></label>
            <input type="text" name="port_of_arrival" value="{{$contract['port_arrival']}}" id="port_of_arrival" class="form-control" required="required">
          </div>
          <!-- /.form-group -->
        </div>
        <!-- /.col -->
        <div class="col-md-6">
          <div class="form-group">
            <label>Mobile Number<i style="color: red">*</i></label>
            <input type="text" class="form-control" value="{{$contract['mobile_no']}}" id="mobile_no" name="mobile_no" required="required">
          </div>
          <!-- /.form-group -->
          <div class="form-group">
            <label>Email Id<i style="color: red">*</i></label>
            <input type="text" name="email_id" value="{{$contract['email_id']}}" id="email_id" class="form-control" required="required">
          </div>
          <!-- /.form-group -->
        </div>
        <!-- /.col -->
        <div class="col-md-6">
          <div class="form-group">
            <label>Payment Terms<i style="color: red">*</i></label>
            <input type="text" class="form-control" value="{{$contract['payment_terms']}}" id="payment_terms" name="payment_terms" required="required">
          </div>
          <!-- /.form-group -->
          <div class="form-group">
            <label>Shipping Terms<i style="color: red">*</i></label>
            <input type="text" name="shipping_terms" value="{{$contract['shipping_terms']}}" id="shipping_terms" class="form-control" required="required">
          </div>
          <!-- /.form-group -->
        </div>
        <!-- /.col -->
        <div class="col-md-6">
          <div class="form-group">
            <label>Address<i style="color: red">*</i></label>
            <textarea class="form-control" id="address" name="address" required="required">{{$contract['address']}}</textarea>
          </div>
          <!-- /.form-group -->
          <div class="form-group">
            <label>Time Frame From<i style="color: red">*</i></label>
            <input type="text" name="from_date" value="{{date('d-m-Y', strtotime($contract['time_frame_from']))}}" id="from_date" autocomplete="off"  class="form-control datepicker" required="required">
          </div>
          <!-- /.form-group -->
        </div>
        <!-- /.col -->
        <div class="col-md-6">
          <div class="form-group">
            <label>Terms &amp; Conditions<i style="color: red">*</i></label>
            <textarea class="form-control" id="terms_conditions" name="terms_conditions" required="required">{{$contract['terms_and_condition']}}</textarea>
          </div>
          <!-- /.form-group -->
          <div class="form-group">
            <label>Time Frame To<i style="color: red">*</i></label>
            <input type="text" name="end_date" value="{{date('d-m-Y',strtotime($contract['time_frame_to']))}}" id="end_date" autocomplete="off" class="form-control datepicker" required="required">
          </div>
          <!-- /.form-group -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div>
    <!-- /.box-body -->
    <div class="box-footer">
      
    </div>
  </div>
  <!-- /.box-header -->
  <div class="box-body">

              
                <input type="hidden" name="_token" value="{{{ csrf_token() }}}">
                <input type="hidden" id="req_id" name="x" value="{{$x}}">
                        <!-- text input -->
                        <div class="col-sm-5">                          
                            <div class="form-group">
                            <label class="col-sm-2 control-label">Product<i style="color: red">*</i></label>

                            <div class="col-sm-9">
                              <select class="form-control select2" name="product" id="product" required>
                              <option value="">-- select --</option>
                              @foreach($prd as $product)
                              <option value="{{$product->id}}">{{$product->name}} - {{$product->code}}</option>
                              @endforeach
                            </select>
                            </div>
                          </div>
                          <br>
                          <br>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">Packing</label>

                            <div class="col-sm-9">
                              <select class="form-control" name="grade" id="grade">
                                <option value="">-- select --</option>
                              </select>
                            </div>
                          </div>
                          <br>
                          <br>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">Grade</label>

                            <div class="col-sm-9">
                              <select class="form-control" name="standard" id="standard">
                                <option value="">-- select --</option>
                              </select>
                            </div>
                          </div>
                          <br>
                          <br>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">Unit<i style="color: red">*</i></label>

                            <div class="col-sm-9">
                              <select class="form-control" name="unit" id="unit" required>
                              <option>-- select --</option>
                              
                              </select>
                            </div>
                          </div>
                          <br>
                          <br>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">Quantity<i style="color: red">*</i></label>

                            <div class="col-sm-9">
                              <input type="number" name="qty" class="form-control" placeholder="Enter" required>
                            </div>
                          </div>
                          <br>
                          <br>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">Schedule<i style="color: red">*</i></label>

                            <div class="col-sm-9">
                              <select class="form-control" name="schedule" id="schedule" required>
                                <option value="">-- select --</option>
                                @foreach($schedules as $schedule)
                                <option value="{{$schedule->id}}">{{$schedule->name}}</option>
                                @endforeach
                              </select>
                            </div>
                          </div>
                          <br>
                          <br>
                          <div class="form-group">
                            <label class="col-sm-2 control-label">Unit Price<i style="color: red">*</i></label>

                            <div class="col-sm-9">
                              <input type="number" step="0.01" id="unit_price" name="unit_price" class="form-control" placeholder="Enter" required>
                            </div>
                          </div>
                          <br>
                          <br>
                          <input type="hidden" name="current_date" id="current_date" date="{{date('01-M-Y')}}" value="{{date('M-y')}}">
                          <div class="form-group col-sm-9 col-sm-push-7">
                            <button type="submit" class="btn btn-primary pull-left">Add</button>
                            <button type="reset" class="btn btn-default">Refresh</button>
                          </div>
                        </div>
    </form>                    

              <form action="{{route('contract_material_request.submit')}}" method="POST">
                <input type="hidden" name="_token" value="{{{ csrf_token() }}}">
                <input type="hidden" name="x" value="{{$x}}">
             
              <div class="col-sm-5">
              <div class="form-group">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                    <th style="width: 10px">#</th>
                    <th>Product</th>
                    <th>Packing</th>
                    <th>Unit</th>
                    <th>Qty</th>
                    <th>Date</th>
                    <th>Edit</th>
                    <th>Delete</th>
                </tr>
                </thead>
                <tbody>
                  <?php $c = 1; ?>
                  @if($x != 0)
                  @foreach($products as $prd)
                    <tr id="{{$prd->id}}">
                      <td class="order">{{$c++}}</td>
                      <td>{{$prd->product['name']}}</td>
                      <td>{{$prd->grade['grade']}}</td>
                      <td>{{$prd->unit['unit']}}</td>
                      <td>{{$prd->qty}}</td>
                      <td>{{date('d-m-Y',strtotime($prd->requested_month))}}</td>
                      <td>
                        <a href="{{route('contract_mr_product.edit',$prd->id)}}" <i class='fa fa-fw fa-pencil'></i></a>
              
                      </td>
                      <td>
                        <a href="#" onclick="jsDelete({{$prd->id}})" class='btn-danger delete'><i class='fa fa-fw fa-trash'></i></a>
              
                      </td>
                    </tr>
                  @endforeach
                  @endif
                </tbody>
              </table>
            </div>
            <div class="form-group ">
              <div class="btn">
                <input type="submit" name="submit" value="Submit">
              </div>
              <div class="btn">
                <input type="submit" name="draft" value="Save as Draft">
              </div>
              
            </div>
          </div>
        </form>
            </div>
          </div>

          
            <!-- /.nav-tabs-custom -->

            <!-- Chat box -->
            
            <!-- /.box (chat box) -->

            
            <!-- quick email widget -->

            @if($x)
            <div class="box">
              <div class="box-header">
                <h3 class="box-title">Comments</h3>
              </div>
              <!-- /.box-header -->
              <div class="box-body no-padding">
                
              </div>
              <!-- /.box-body -->
              <div class="box-footer box-comments">
              @foreach($mr_sea_cmts as $mr_sea)
                <div class="box-comment">
                  <!-- User image -->
                  <div class="comment-text">
                        <span class="username"><i class="fa fa-comments bg-yellow"></i>
                          {{strtoupper($mr_sea->commentUser->name)}}
                          <span class="text-muted pull-right">{{date('d-m-Y H:i', strtotime($mr_sea->created_at))}}</span>
                        </span><!-- /.username -->
                    {{strtoupper($mr_sea->comment)}}
                  </div>
                  <!-- /.comment-text -->
                </div>
                <!-- /.box-comment -->
              @endforeach
              </div>
              <!-- /.box-footer -->
              <div class="box-footer">
                <form action="#" id="comment_form" method="post">
                  <!-- .img-push is used to add margin to elements next to floating images -->
                  
                  <div class="img-push">
                    <input type="text" id="mr_sea_comment" autocomplete="off" name="mr_sea_comment" class="form-control input-sm" placeholder="Press enter to post comment">
                  </div>
                </form>
              </div>
              <!-- /.box-footer -->
            </div>
            <!-- /.box -->
            @endif
          </section>
          <!-- /.Left col -->
          
        </div>
        <!-- /.row (main row) -->

      </section>
      <!-- /.content -->
    </div>
  <!-- /.content-wrapper -->

    
  
  @include('footertag')

  <!-- Control Sidebar -->
  @include('rightside')
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

  <!-- jQuery 3 -->
  <script src="{{asset('lte/bower_components/jquery/dist/jquery.min.js')}}"></script>
  <!-- jQuery UI 1.11.4 -->
  <script src="{{asset('lte/bower_components/jquery-ui/jquery-ui.min.js')}}"></script>
  <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
  <script>
    $.widget.bridge('uibutton', $.ui.button);
  </script>
  <!-- Bootstrap 3.3.7 -->
  <script src="{{asset('lte/bower_components/bootstrap/dist/js/bootstrap.min.js')}}"></script>
  
  <!-- Sparkline -->
  <script src="{{asset('lte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js')}}"></script>
  
  <!-- Bootstrap WYSIHTML5 -->
  <script src="{{asset('lte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js')}}"></script>
  <!-- Slimscroll -->
  <script src="{{asset('lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js')}}"></script>
  <!-- FastClick -->
  <script src="{{asset('lte/bower_components/fastclick/lib/fastclick.js')}}"></script>
  <!-- AdminLTE App -->
  <script src="{{asset('lte/dist/js/adminlte.min.js')}}"></script>
  
  <!-- AdminLTE for demo purposes -->
  <script src="{{asset('lte/dist/js/demo.js')}}"></script>

  <!-- iCheck 1.0.1 -->
<script src="{{asset('lte/plugins/iCheck/icheck.min.js')}}"></script>

<!-- bootstrap datepicker -->
<script src="{{asset('lte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js')}}"></script>

<!--DataTables-->
<script src="{{asset('lte/bower_components/datatables.net/js/jquery.dataTables.min.js')}}"></script>
<script src="{{asset('lte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js')}}"></script>

<!-- Select2 -->
<script src="{{asset('lte/bower_components/select2/dist/js/select2.full.min.js')}}"></script>

<script>
  $(function () {
    $('#example1').DataTable()
    $('.select2').select2()
  })
</script>

<!-- Page script -->
<script>
  

    //Date picker
    $('.datepicker').datepicker({
      autoclose: true,
      format: 'dd-mm-yyyy',
    })

    
</script>

<script type="text/javascript">
  $(document).ready(function(){


    $(".check").click(function(){

      if ($(this).prop("checked") == true) {
        
        var prod_id = $(this).val();
        var sup_id = $("#sup_id").val();
        
       $.get("{{ url('add/product')}}", 
              { product: prod_id,supplier: sup_id }, 
              function(data) {
              console.log(data);
            });         
      }
      
    });


    $("#comment_form").submit(function(e){
      e.preventDefault();
      var sea_c = $("#mr_sea_comment").val();
      var mid = $("#req_id").val();
      
      if($.trim(sea_c) == '') {
        $("#mr_sea_comment").css("border-color","RED");
      } else {
        $("#mr_sea_comment").css("border-color","");
        $("#mr_sea_comment").val('');
        $("#comment_close").trigger('click');
        $.get("{{url('sea_material_request/comment')}}", {mrid: mid, comment: sea_c}, function(data){

          $(".box-comments").append('<div class="box-comment"><div class="comment-text"><span class="username"><i class="fa fa-comments bg-yellow"></i>'+data.enter_by+'<span class="text-muted pull-right">'+data.created_at+'</span></span>'+data.comment+'</div></div>');
          // var sl = $('.table-condensed tr:last-child td:first-child').html();
          // sl = (typeof sl === "undefined")? 1 : parseInt(sl)+1;
          // $(".table-condensed").append("<tr><td>"+sl+"</td><td>"+data.comment+"</td><td>"+data.enter_by+"</td><td>"+data.created_at+"</td></tr>");
        });
      }
    });

  }); 
</script>

<script type="text/javascript">
  $(document).ready(function(){

    $(".check").click(function(){

      if ($(this).prop("checked") == false) {
        var prod_id = $(this).val();
        var sup_id = $("#sup_id").val();
        
       $.get("{{ url('update/product')}}", 
              { product: prod_id,supplier: sup_id }, 
              function(data) {
             
            });         
      }
      
    });

    $("#schedule").change(function(){
      var schedule_txt = $("#schedule option:selected").html();
      if(schedule_txt == 'NORMAL') {
        $("#req_mnth").append("<option value='"+$("#current_date").attr('date')+"'>"+$("#current_date").val()+"</option>");
        $("#req_mnth").val($("#current_date").attr('date'));
        $("#req_mnth").prop('disabled', 'disabled');
      } else {
        $("#req_mnth option[value='"+$("#current_date").attr('date')+"']").remove();
        $("#req_mnth").prop('disabled', false);
      }
    });

    $("#grade").change(function(){
      var grd = $(this).val();
      var prd = $("#product").val();

      if(grd != '') {
        $("#standard").empty();
        $("#standard").append("<option value=''>--- Select ---</option>");
        $.get("{{url('product_grade_standards')}}", {product: prd, grade: grd}, function(stddata){
          $.each(stddata, function(ind,elem){
            $("#standard").append("<option value='"+elem.id+"'>"+elem.standard+"</option>");
          });
        });
      }
    });

    $("#supplier_id").change(function(){
      var supid = $("#supplier_id").val();
      if(supid != '') {
        $("#contact_person").val('');
        $("#mobile_no").val('');
        $("#payment_terms").val('');
        $("#email_id").val('');
        $("#shipping_terms").val('');
        $("#address").val('');
        $.get("{{url('supplier_details')}}", {supplier: supid}, function(supdata){
            
            $("#contact_person").val(supdata.contact_p1);
            $("#mobile_no").val(supdata.contact_no1);
            $("#payment_terms").val('');
            $("#email_id").val(supdata.email1);
            $("#shipping_terms").val(supdata.shipping_terms);
            $("#address").val(supdata.address);
        });
      }
    });
    
  }); 
</script>

<!-- <script type="text/javascript">
  jQuery("#category").change(function()
  {   
      var category = $("#category").val();
      $("#product").empty();
      $.get("{{url('mr_product/show')}}",
          {option: category},
          function(data){
            console.log(data);
            $("#product").append("<option value=''>"+"-- select --"+"</option>");
            $.each(data, function(index,element){
                $("#product").append("<option value='"+ element.id +"'>" +element.name+ "</option>");
            });
          });
  });
</script> -->

<script type="text/javascript">
  jQuery("#product").change(function()
  {
      var product = $(this).val();

      $.get("{{url('mr_unit/show')}}",
          {option: product},
          function(data){
            console.log(data);
            $("#unit").empty();
            $("#grade").empty();
            $("#unit").append("<option value=''>"+"-- select --"+"</option>");
            $.each(data[0], function(index,element){
                $("#unit").append("<option value='"+ element.id +"'>" +element.unit+ "</option>");
            });

            $("#grade").append("<option value=''>"+"-- select --"+"</option>");
            $.each(data[1], function(index,element){
                $("#grade").append("<option value='"+ element.id +"'>" +element.grade+ "</option>");
            });
          });
  });
</script>

<!-- <script type="text/javascript">
  jQuery("#unit").change(function()
  { 
      var unit = $(this).val();
      var product = $("#product").val();

      $.get("{{url('mr_grade/show')}}",
          {unit: unit, prd: product},
          function(data){
            console.log(data);
            $("#grade").empty();
            $("#grade").append("<option value=''>"+"-- select --"+"</option>");
            $.each(data, function(index,element){
                $("#grade").append("<option value='"+ element.id +"'>" +element.grade+ "</option>");
            });
          });
  });
</script> -->

<script type="text/javascript">
  function jsDelete(value)
  {   
    var r = confirm("Are you sure you want to delete this product?");
    if (r == true) {
      $.get("{{url('contract_mr_product/delete')}}",
          {option: value},
          function(data){
            $('#'+value).remove();
            // $('a').closest('tr').remove();
            $('td.order').text(function (i) {
          return i + 1;
        });
          });
    }
     
  }
</script>


<script type="text/javascript">
  function jsAdd(value)
  {   
     $.get("{{url('last_entries')}}",
          {option: value},
          function(data){
            
          });
  }
</script>

<script type="text/javascript">
  function jsNot()
  {   
    $.get("{{url('notification_read')}}",
          function(data){
            console.log(data);
            $('#count').hide();
          });
  }
</script>
</body>

</html>
