

<?php $__env->startSection('title','Item - Inventory WELL GROUP '); ?>

<?php $__env->startSection('content'); ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.css">
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0 text-dark">MR Report</h1>
                </div><!-- /.col -->
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#">Item setup</a></li>
                        <li class="breadcrumb-item active">MR Report</li>
                    </ol>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->


    <!-- Main content -->
    <section class="content">
        <div class="col-lg-12">
            <div class="row">

                
                <div class="col-lg-12">
                    <div class="card card-success card-outline">
                        
                        <!-- /.card-header -->
                        <div class="card-body" style="display: block;">
                            
                            <div id="showTable">
                                 
                                <div class="table-responsive">
                                    <table class="table table-hover" id="productTable">
                                        <thead>
                                        <tr>
                                            <td> #SL</td>
                                            <td> MRR No</td>
                                            <td> Client Name</td>
                                            <td>Date</td>
                                            <td> Delivery Challan</td>
                                            <td> PO No</td>
                                             <td> Serial No</td>
                                            <td> Action</td>
                                        </tr>
                                        </thead>

                                        <tbody id="tbodyItem">
                                        <?php $__currentLoopData = $goods_in; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$info): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                            <?php
                                                $purchase_product = App\PurchaseProduct::where('purchase_id', $info->purchase_id)->first();
                                                if($purchase_product){
                                                    $supplier_id = $purchase_product->supplier_id;
                                                    $supplier_name = App\Supplier::find($supplier_id)->name;
                                                }else{
                                                    $supplier_name = 'No Name';
                                                }
                                            ?>
                                            <tr id="tr-<?php echo e($info->id); ?>">
                                                <td> <?php echo e($key + 1); ?></td>
                                                <td> <?php echo e($info->mrr_no); ?></td>
                                                <td><?php echo e($supplier_name); ?></td>
                                                <td> <?php echo e(dateFormat($info->created_at)); ?></td>
                                                <td> <?php echo e($info->chalan); ?></td>
                                                <td>PO - <?php echo e($info ? $info->purchase ? $info->purchase->purchase_no : null : null); ?></td>
                                                <td> <?php echo e($info->serial_no); ?></td>
                                                <td>
                                                    <a onclick="window.open('<?php echo e(url('mr-report')); ?>/<?php echo e($info->id); ?>/print')" class="btn bg-primary"><i class="fa fa-print"></i>&nbsp;Print</a>
                                                    <?php if(Auth::user()->id == 8): ?>
                                                      <button onclick="Delete(<?php echo e($info->id); ?>)" class="btn bg-danger"><i class="fa fa-trash"></i>&nbsp;Delete</button>
                                                    <?php endif; ?>
                                                    
                                                </td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>

                                    </table>


                                </div>


                            </div>

                        </div>
                        <!-- /.card-body -->
                    </div>
                </div>
                

            </div>
        </div>

    </section><!-- /.content -->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('style'); ?>
                                    <!-- DataTables -->
    <link rel="stylesheet" href="<?php echo e(asset('plugins/datatables/dataTables.bootstrap4.css')); ?>">
<?php $__env->stopSection(); ?>

<?php $__env->startSection('plugin'); ?>
    <!-- DataTables -->
    <script src="<?php echo e(asset('plugins/datatables/jquery.dataTables.js')); ?>"></script>
    <script src="<?php echo e(asset('plugins/datatables/dataTables.bootstrap4.js')); ?>"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.4/jquery-confirm.min.js"></script>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <!-- page script -->
    <script type="text/javascript">
          function Delete(id) {
            $.confirm({
                title: 'Confirm!',
                content: '<hr><strong class="text-danger">Are you sure to delete ?</strong><hr>',
                buttons: {
                    confirm: function () {
                        $.ajax({
                          headers: { 'X-CSRF-TOKEN' : '<?php echo e(csrf_token()); ?>' },
                          url: "<?php echo e(url('mr-report')); ?>/"+id,
                          type: 'DELETE',
                          dataType: 'json',
                          data: {},
                          success:function(response) {
                            if(response.success){
                              $('#tr-'+id).fadeOut();
                            }else{
                              $.alert({
                                title:"Whoops!",
                                content:"<hr><strong class='text-danger'>Something Went Wrong!</strong><hr>",
                                type:"red"
                              });
                            }
                          }
                        });
                    },
                    cancel: function () {

                    }
                }
            });   
          }
                
        $(document).ready(function () {
            table = $("#productTable").DataTable();
        });
        var table;
        $(document).ready(function () {
            table = $("#productTable").DataTable();
        });

        $(document).on("change",".department_id",function () {
            var group_id = $(this).val();
            table.clear().draw();
            var row = "<tr> <td colspan='9' style='background: red;padding: 10px;color: #fff3cd;font-size: 1rem;text-align: center;'> Please wait item loading ............. </td>  </tr>";
            $("#tbodyItem").html(row);


            $.ajax({
                method:"post",
                url : "<?php echo e(route('groupwise.productList')); ?>",
                data : { group_id:group_id,_token:'<?php echo e(csrf_token()); ?>'},
                success:function (response) {
                    $('#showTable').html(response);
                    //var obj =  JSON.parse(response).length;
                    // console.log(response.success);

                    // for (var i=0;i<response.success.sl.length;i++){
                    //     table.row.add([
                    //         response.success.sl[i],
                    //         response.success.code[i],
                    //         response.success.name[i],
                    //         response.success.department[i],
                    //         response.success.group[i],
                    //         response.success.unit[i],
                    //         response.success.price[i],
                    //         response.success.description[i],
                    //         response.success.edit[i]
                    //     ]).draw();
                    // }

                }
            })
        });

    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.fixed', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/welluugs/purchase.wellgrouperp.com/resources/views/inventory/goodsin/mr-report.blade.php ENDPATH**/ ?>