<?php echo $__env->make('dashboard.include.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

  
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0"></h1>
            <a href="/remainingstock">Go Back</a>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/home">Home</a></li>
              <li class="breadcrumb-item active">View Barcode</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
        <div class="card card-success">
        <div class="card-header">
            <h3 class="card-title">View Barcode</h3>
        </div>
            <div class="card-body">
            <?php $__currentLoopData = $pro; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dadetail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="row">
                <div class="col-md-9"> 
                </div>
                <div class="col-md-3"> 
                    <form class="form-horizontal" method="POST" action="/downloadcsvnotused" enctype="multipart/form-data">
                        <?php echo e(csrf_field()); ?>

                        <input type="hidden" name="prorealname" value="<?php echo e($dadetail->name); ?>">         
                        <input type="hidden" name="proname" value="<?php echo e($dadetail->id); ?>">    
                        <button type="submit" class="btn btn-primary btn-block button">Download Not Used Barcodes</button>
                     </form>
                </div>
            </div><br>
            <div class="row">
                <div class="col-md-9"> 
                    <div class="form-group">
                        <label for="">Product Name &nbsp;&nbsp;: &nbsp;&nbsp;</label><?php echo e($dadetail->name); ?>

                    </div>
                </div>
                <div class="col-md-3"> 
                    <label for="">Stcok&nbsp;&nbsp; : &nbsp;&nbsp;</label><?php echo e($dadetail->stock); ?>

                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <br>

            <table id="example2" class="table table-bordered" style="width:100%">
                        <thead>
                            <tr>
                                <th>Id</th>
                                <th>Purches ID</th>
                                <th>Barcode</th>
                                <th>Status</th>
                            </tr>
                        </thead>
                        <tbody>
                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supdatad): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($supdatad->id); ?></td>
                            <td><?php echo e($supdatad->pur_pro); ?></td>
                            <td><?php echo e($supdatad->barcode); ?></td>
                            <td class="text-center">
                            <?php if($supdatad->itemstatus=='0'): ?>
                            <span class="badge badge-warning">Not Used</span>
                            <?php elseif($supdatad->itemstatus=='1'): ?>
                            <span class="badge badge-success">Used Barcode</span>
                            <?php elseif($supdatad->itemstatus=='2'): ?>
                            <span class="badge badge-danger">Damage</span>
                            <?php endif; ?>
                            </td>                       
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    </table>
            </div>
        </div>
      </div>
    </section>
  </div>

  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;

<script>
$(document).ready(function() {
    $('#example').DataTable();
    $('#example2').DataTable();
} );
</script>
<script>

$(document).on('click', '.bankdetailsdelete', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    var supid = $(this).data('supllierid');
    let ele = this;
    console.log(id);

                swal({
                title: "Are you sure?",
                text: "Are you Sure to Remove this Tracking Number",
                icon: "warning",
                showCancelButton: true,
    confirmButtonColor: '#3085d6',
    cancelButtonColor: '#d33',
    confirmButtonText: 'Yes, delete it!',
                dangerMode: true,
            }).then(function(isConfirm) {
                
                if (isConfirm.value===true) {

                        $.ajax({
                            url: "<?php echo e(url('/deletedeliveryrange')); ?>/"+id ,
                            method: "POST",
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            cache: false,
                            contentType: false,
                            processData: false,
                            dataType: 'JSON',
                            data:{
                                "id":id
                            },
                            success: function (result, code, ex) {
                                swal("Done!", "It was successfully!", "success");
                            },
                            error: function (jqXHR, textStatus, errorThrown) {
                                swal("Warning", "Unable to Process your request", "error");
                            },
                        });

                } else {
                    swal("Cancelled", "No Removed", "error");
                }
            })
});

      
$('#bankmodel').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
var supid = button.data('tracking') 
var id = button.data('id') 



var modal = $(this)
modal.find('.modal-body #id').val(id)
modal.find('.modal-body #tracking').val(supid)

})


$('#trckingupdate').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/rangetrackinupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                swal("Done!", "It was successfully!", "success");
                $("#bankmodel").modal('hide');  
                location.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });

$('input[name=min_no]').change(function() { 
    var min = $(this).val();
    var max = parseInt($('#max_no').val());
    if(max<=min){
        $(document).Toasts('create', {
        class: 'bg-danger',
        title: 'Warning',
        subtitle: 'Close',
        body: 'Min Value cannot be greater than Max Value.'
      })

      $(':input[type="submit"]').prop('disabled', true);
    }
    else{
        $(':input[type="submit"]').prop('disabled', false);
    }

 });
 $('input[name=max_no]').change(function() { 
    var max = $(this).val();
    var min = parseInt($('#min_no').val());

    if(max<=min){
        $(document).Toasts('create', {
        class: 'bg-danger',
        title: 'Warning',
        subtitle: 'Close',
        body: 'Min Value cannot be greater than Max Value.'
      })
      $(':input[type="submit"]').prop('disabled', true);
    }
    else{
        $(':input[type="submit"]').prop('disabled', false);
    }

 });
// $('#min_no').on('input',function(e){
//     var min = $(this).val();
//     var max = parseInt($('#max_no').val());
//     if(max<=min){
//         $(document).Toasts('create', {
//         class: 'bg-danger',
//         title: 'Warning',
//         subtitle: 'Close',
//         body: 'Min Value cannot be greater than Max Value.'
//       })

//     }
//     else{
//     }

// });

// $('#max_no').on('input',function(e){
//     var max = $(this).val();
//     var min = parseInt($('#min_no').val());

//     if(max<=min){
//         $(document).Toasts('create', {
//         class: 'bg-danger',
//         title: 'Warning',
//         subtitle: 'Close',
//         body: 'Min Value cannot be greater than Max Value.'
//       })

//     }
//     else{
//     }

// });
</script>