<?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">Confirm Orders Packing</h1>
          </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">Confirm Orders Packing</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
          <div class="row">
          <div class="col-md-12">
          <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <table class="table borderless"  border="0">
                        <tbody>
                        <tr>
                        <td class="text-center" ><h3> <?php if($data->deliveryservice=="-"): ?> Rider Name - <?php echo e($data->userget->name); ?> <?php else: ?> <b>Delivery Partner - </b> <?php echo e($data->deliveryse->deliveryname); ?> <?php endif; ?></h3></td>
                        </tr>
                        </tbody>
                    </table>  
                    <table class="table borderless"  border="0">
                        <tbody>
                            <tr>
                            <td class="text-left"><b>Invoice ID - </b>  <?php echo e($data->id); ?></td>
                            <td class="text-center"><b>Customer Name - </b>  <?php echo e($data->name); ?></td>
                            <!-- <td class="text-right"><b>Tracking Code - </b> <?php echo e($data->tracking); ?> </td> -->
                            <td class="text-right"><b>COD - </b> <?php if($data->paymentmethod=="paid"): ?>0.00 Already Paid <?php else: ?><?php echo e($data->cod); ?><?php endif; ?></td>
                            </tr>
                        </tbody>
                    </table>  
                    <form method="post" id="formFilter">
                    <?php echo e(csrf_field()); ?>

                        <input type="hidden" value="<?php echo e($data->id); ?>" name="id">
                    </form>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
          </div>
                    <hr>
        <div class="row">
          <div class="col-md-4">
                    <form method="post" id="barcodeaddpacking">
                        <?php echo e(csrf_field()); ?>

                        <input type="hidden" class="form-control" name="id" id="id" value="<?php echo e($cus_id); ?>" required>
                        <input type="text" class="form-control barcodetxt" name="barcode" id="barcode" placeholder="Barcode" required autofocus>
                    </form>
                </div>
          </div><br>
          <div class="row">
            <div class="col-md-12">
                <table id="example12" class="table table-bordered" style="width:100%;">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Product Name</th>
                            <th>Barcode</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                </table>
            </div>
          </div>



          <!-- <div class="row">
            <div class="col-md-12">
                <table id="example1" class="table table-bordered" style="width:100%;">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Product Name</th>
                            <th>Barcode</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $prodata; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datapro): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td><?php echo e($datapro->id); ?></td>
                                <td><?php echo e($datapro->ordersbarcodepro->name); ?></td>
                                <td><?php echo e($datapro->barcode); ?></td>
                                <td class="text-center">
                                <?php if($datapro->status=='0'): ?>
                                <span class="badge badge-warning">Not Added Barcode</span>
                                <?php elseif($datapro->status=='1'): ?>
                                <span class="badge badge-success">Barcode Add successfully</span>
                                <?php endif; ?>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                        </tbody>
                </table>
            </div>
          </div> -->
         

          </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() {
  var table = $('#example12').DataTable({
        "ajax": {   "url": '/getdataprobarcode',
                    "type": 'POST',
                    "data": function ( d ) {
                    return $('#formFilter').serialize();
                    }
        },
        columns: [
            { data: 'id', name: 'id' },
            {  data: 'productname', name: 'productname' },
            { data: 'barcode', name: 'barcode'},
            { data: 'action', name: 'action', orderable: false, searchable: false}
        ]
    });
} );





// $('input[name=barcode]').change(function() { 
//     $("#barcodeaddpacking").submit();
//  });

$('.barcodetxt').bind("enterKey",function(e){
    $("#barcodeaddpacking").submit();
});

    $('#barcodeaddpacking').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/cmbopackingbarcodeupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data) {
                jQuery.each(data, function(key,value){
                    if(value=="1"){
                        $('#barcode').val("");
                        $("#barcode").focus();
                        swal({
                            title: "Error!",
                            text: "This Barcode is not in the database",
                            icon: "error",
                            button: "OK",
                        });
  
                    }
                    else if(value=="2"){
                        $('#barcode').val("");
                        $("#barcode").focus();
                        swal({
                            title: "Error!",
                            text: "Product Not Matching",
                            icon: "error",
                            button: "OK",
                        });

                    }
                    else if(value=="3"){
                        $('#barcode').val("");
                        $("#barcode").focus();
                        swal({
                            title: "Error!",
                            text: "All Barcode Added successfully",
                            icon: "error",
                            button: "OK",
                        });
                    }
                    else if(value=="4"){
                        window.location.href = '/inventorycolombo';

                    }
                    else if(value=="5"){
                        $('#barcode').val("");
                        $("#barcode").focus();
                        swal({
                            title: "Error!",
                            text: "All Barcode Add not Complete",
                            icon: "error",
                            button: "OK",
                        });

                    }
                    else{
                        toastr.success('Barcode add successfully!')
                        // location.reload();
                        $('#example12').DataTable().ajax.reload();
                        $('#barcode').val("");
                        $("#barcode").focus();
                    }
                
        });
                
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
        })
    });



</script>

<script>
<?php if(session('success')): ?>
        // swal("Success!","<?php echo e(session('success')); ?>","success");
        toastr.success('Your work has been successfully!')

<?php endif; ?>
<?php if(session('error')): ?>
    swal({
            title: "Error!",
            text: "<?php echo e(session('error')); ?>",
            icon: "error",
            button: "OK",
        });
<?php endif; ?>

</script>
