<?php $__env->startSection('title', 'Batch Data'); ?>

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

    <section>
        <div class="row">
            <div class="col-12">

                <div class="card">

                    <div class="card-content">
                        <div class="card-header">
                             <h1>Batch Data</h1>

                        </div>
                        <div class="card-body card-dashboard">
                            <?php echo $__env->make('inc.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                            <table class="table table-bordered datatable" id="datatable" style="z-index: 3;">
                                <thead>
                                <tr class="bg-dark white">
                                    <th class="border-dark border-darken-1">S No.</th>
                                    <th class="border-dark border-darken-1">Batch ID</th>
                                    <th class="border-dark border-darken-1">Number of Cards</th>
                                    <th colspan="2" class="border-dark border-darken-1 text-center">Union Pay</th>
                                    <th colspan="2" class="border-dark border-darken-1 text-center">Pay Pak</th>
                                    <th class="border-dark border-darken-1">Date/Time</th>
                                    <th class="border-dark border-darken-1">Courier Partner</th>
                                    <th class="border-dark border-darken-1">Action</th>
                                </tr>
                                <tr>
                                    <th colspan="3" class="border-dark border-darken-1"></th>
                                    <th class="border-dark border-darken-1">Booked</th>
                                    <th class="border-dark border-darken-1">Pending</th>
                                    <th class="border-dark border-darken-1">Booked</th>
                                    <th class="border-dark border-darken-1">Pending</th>
                                    <th colspan="3" class="border-dark border-darken-1"></th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>


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

<?php $__env->startSection('css'); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('app-assets/vendors/css/forms/icheck/custom.css')); ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('app-assets/vendors/css/forms/icheck/icheck.css')); ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('app-assets/vendors/css/forms/selects/select2.min.css')); ?>">
<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <script src="<?php echo e(asset('app-assets/vendors/js/forms/icheck/icheck.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('app-assets/js/scripts/forms/checkbox-radio.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('app-assets/vendors/js/forms/select/select2.full.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('app-assets/vendors/js/forms/validation/jquery.validate.min.js')); ?>" type="text/javascript"></script>

   <script src="<?php echo e(asset('app-assets/vendors/js/extensions/sweetalert.min.js')); ?>" type="text/javascript"></script>

    <script src="<?php echo e(asset('app-assets/vendors/js/forms/validation/additional-methods.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('app-assets/vendors/js/forms/extended/inputmask/jquery.inputmask.bundle.min.js')); ?>" type="text/javascript"></script>
    <script src="<?php echo e(asset('js/datatable_buttons.js')); ?>" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            jQuery.fn.DataTable.Api.register( 'buttons.exportData()', function ( options ) {
                if ( this.context.length ) {
                    body = [];
                    var params = table.ajax.params();
                    params.start = 0;
                    params.length = -1;
                    var jsonResult = $.ajax({
                        url: '<?php echo e(route('batch_data.ajax')); ?>',
                        data: params,
                        success: function (result) {
                            head = [];
                            head.push('S.No');
                            head.push('Batch ID');
                            head.push('Number of Cards');
                            head.push('');
                            head.push('Union Pay');
                            head.push('');
                            head.push('Pay Pak');
                            head.push('Courier Partner');
                            head.push('Date/Time');

                            row = [];
                                row.push('');
                                row.push('');
                                row.push('');
                                row.push('Booked');
                                row.push('Pending');
                                row.push('Booked');
                                row.push('Pending');
                                row.push('');
                                row.push('');
                                
                                body.push(row);
                            $.each(result.data, function(index, values) {
                                row = [];
                                row.push(index + 1);
                                row.push(values.id);
                                row.push(values.card_numbers);
                                row.push(values.up_booked);
                                row.push(values.up_pending);
                                row.push(values.paypak_booked);
                                row.push(values.paypak_pending);
                                row.push(values.preferred_logics_id);
                                row.push(values.date);
                                body.push(row);
                            });
                            
                        },
                        async: false
                    });

                    return {body: body, header: head};
                }
            } );

            //table start
               var table =  $('.datatable').DataTable({
                   dom: '<"d-inline-block"l><"pull-right"B>tipr',
    
                        buttons: [{
                        extend: 'excel',
                        title: 'Batch Data',
                        className: 'btn btn-dark',
                        text: '<i class="la la-file-excel-o"></i> Excel',
                        },
                        ],
                   
                    scrollX: true, scrollY: '500px',
                    lengthMenu: [[50, 100, 500, 1000, -1], [50, 100, 500, 1000, 'All']],
                    pageLength: 50,
                    pagingType: 'full_numbers',
                    processing: true,
                    language: {
                        processing: data_table_loader
                    },
                    serverSide: true,
                    ajax: '<?php echo e(route('batch_data.ajax')); ?>',
                   rowId: 'id',
                    order: [[0, 'desc']],
                    columns: [
                        {orderable: false, searchable: false, name: 'serial_number', class: 'align-middle serial_number', targets: 1, render: function (data, type, row) {return '';}},
                        {data: 'id', name: 'batch_data.id', class: 'align-middle card_numbers'},
                        {data: 'card_numbers', name: 'batch_data.card_numbers', class: 'align-middle card_numbers'},
                        {data: 'up_booked', name: 'batch_data.up_booked', class: 'align-middle up_booked'},
                        {data: 'up_pending', name: 'batch_data.up_pending', class: 'align-middle up_pending'},
                        {data: 'paypak_booked', name: 'batch_data.paypak_booked', class: 'align-middle paypak_booked'},
                        {data: 'paypak_pending', name: 'batch_data.paypak_pending', class: 'align-middle paypak_pending'},
                        {data: 'created_at', name: 'batch_data.created_at', class: 'align-middle created_at'},
                        {data: 'preferred_logics_id', name: 'batch_data.preferred_logics_id', class: 'align-middle preferred_logics_id'},
                        {data: 'action', name: 'action', class: 'align-middle text-center action', orderable: false, searchable: false}
                    ],
                   rowCallback: function(row, data, index) {
                       var info = table.page.info();
   
                       $('td:eq(0)', row).html(index + 1 + info.page * info.length);
    
                   },
                   initComplete: function() {
                       var search = $('<tr role="row" class="bg-dark bg-lighten-1 search"></tr>').appendTo(this.api().table().header());
    
                       var td = '<td style="padding:5px;" class="border-dark border-lighten-2"><fieldset class="form-group m-0 position-relative has-icon-right"></fieldset></td>';
                       var input = '<input type="text" class="form-control form-control-sm input-sm primary">';
                       var icon = '<div class="form-control-position primary"><i class="la la-search"></i></div>';
                      this.api().columns().every(function(column_id) {
                           var column = this;
                           var header = column.header();
    
                           if ($(header).is('.serial_number') || $(header).is('.action') ) {
                               $(td).appendTo($(search));
                           }
                           else {
                               var current = $(input).appendTo($(search)).on('change', function() {
                                   column.search($(this).val(), false, false, true).draw();
                               }).wrap(td).after(icon);
    
                               if (column.search()) {
                                   current.val(column.search());
                               }
                           }
                       });
                       
                       this.api().table().columns.adjust();
                   }
                });

        });
  
        $("#addSourceData").on("show.bs.modal", function(e) {
            var $invoker = $(e.relatedTarget);
            var action = $invoker.attr('rel');

            if(action == 'addsourcedata'){
                $.get( "/source_data/form", function( data ) {
                    $("#addSourceDataDiv").html(data);
                });
            }

        });
       
        $("#editCourier").on("show.bs.modal", function(e) {
            var $invoker = $(e.relatedTarget);
            var action = $invoker.attr('rel');
            var id = $(e.relatedTarget).data('target-id');
            

            if(action == 'editcourier'){
                $.get( "batch_data/"+id+"/edit_courier/form", function( data ) {
                    $("#editCourierDiv").html(data);
                });
            }
        });

        $("#editBatch").on("show.bs.modal", function(e) {
            var $invoker = $(e.relatedTarget);
            var action = $invoker.attr('rel');
            var id = $(e.relatedTarget).data('target-id');
            console.log(id);

            if(action == 'editbatch'){
           
                $.get( "batch_data/"+id+"/edit/form", function( data ) {
                    $("#editCourierDiv").html(data);
                });
            }
        });
        // editBatch
     
    </script>

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

<?php echo $__env->make('layout.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\catalyst\resources\views/batch_data/show_batch_data.blade.php ENDPATH**/ ?>