<?php $__env->startSection('title'); ?>
    <title>Application Users</title>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('banner'); ?>
    <?php echo $__env->make('backend.partials.banner', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('menu'); ?>
    <div class="col-md-10 col-md-offset-1" style="background-color: #7ebb7b">
        <div class="breadcrumbs">
            <div class="container">
                <div class="row">
                    <div class="col-sm-8">
                        <ul>
                            <li><a href="<?php echo url('admin.home'); ?>">Home</a></li>
                            <li class="active">Approve Requisitions</li>
                        </ul><!-- end breadcrumb -->
                    </div><!-- end col -->
                </div><!-- end row -->
            </div><!-- end container -->
        </div><!-- end breadcrumbs -->
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.1/bootstrap3-typeahead.min.js"></script>

    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">

    <div>

        <div class="container spark-screen">
            <div class="row">
                <div class="col-md-4 col-md-offset-4 col-sm-4 text-center">
                    <br/>
                    <div><h3>APPROVE PRODUCT REQUISITIONS</h3></div>
                    <div style="background-color: #ff0000;height: 2px">&nbsp;</div>
                    <br/>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-10 col-md-offset-1" style="overflow-x:auto;">
            <table class="table table-striped table-bordered" id="requsistion-table">
                <thead style="background-color: #b0b0b0">
                <tr>
                    <th>Req No</th>
                    <th>Req Date</th>
                    <th>Req Type</th>
                    <th>product</th>
                    <th>Quantity</th>
                    <th>Action</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>


    <!-- editCategoryModal -->

    
        
            
                
                    
                

                
                    
                    

                        
                            
                            
                                
                                
                                
                            
                            
                            

                            
                        
                    
                    
                        
                            
                            
                        
                    
                
            
        
    


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

<?php $__env->startPush('scripts'); ?>

<script>
    $(function() {
        var table= $('#requsistion-table').DataTable({
            processing: true,
            serverSide: true,
            autoWidth: false,
            responsive: true,
            ajax: 'approve.requisition.data',
            columns: [
                { data: 'refno', name: 'requisitions.refno' },
                { data: 'reqdate', name: 'requisitions.reqdate' },
                { data: 'reqtype', name: 'requisitions.reqtype', orderable: false, searchable: false },
                { data: 'product', name: 'product' },
                { data: 'quantity', name: 'quantity' },
                { data: 'action', name: 'action', orderable: false, searchable: false, printable: false}
            ]
        });

    });

    $('#requsistion-table').on('click', '.btn-approve[data-remote]', function (e) {
        e.preventDefault();

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        var url = $(this).data('remote');
        // confirm then
        $.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            data: {method: '_POST', submit: true},

            success: function () {
                alert('Requisition Data Approved');
            },

            error: function (request, status, error) {
                alert(request.responseText);
            }

        }).always(function (data) {
            $('#requsistion-table').DataTable().draw(false);
        });
    });

    $('#requsistion-table').on('click', '.btn-reject[data-remote]', function (e) {
        e.preventDefault();

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        var url = $(this).data('remote');
        // confirm then
        $.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            data: {method: '_POST', submit: true},

            success: function () {
                alert('Requisition Data Rejected');
            },

            error: function (request, status, error) {
                alert(request.responseText);
            }

        }).always(function (data) {
            $('#requsistion-table').DataTable().draw(false);
        });
    });


</script>

<?php $__env->stopPush(); ?>
<?php echo $__env->make('backend.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>