<?php $__env->startSection('page-title', __('Submissions')); ?>
<?php $__env->startSection('page-heading', __('Submissions')); ?>

<?php $__env->startSection('breadcrumbs'); ?>
    <li class="breadcrumb-item active">
        <?php echo app('translator')->get('Submission'); ?>
    </li>
<?php $__env->stopSection(); ?>

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

    <?php echo $__env->make('partials.messages', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

        <div class="card">
            <div class="card-body">
<div class="col-md-6 text-right">
                            <button type="button" class="btn btn-primary mt-md-4" data-toggle="modal" data-target="#addPersonnelModal">
                                <i class="fas fa-plus mr-2"></i> <?php echo app('translator')->get('Add New Personnel'); ?>
                            </button>
                        </div>
                <form action="" method="GET" id="users-form" class="pb-2 mb-3 border-bottom-light">
                    <div class="row my-3 flex-md-row flex-column-reverse">

                        
                        <div class="col-md-6 mt-2 mt-md-0">
                            <label>Filter By Rank</label>
                            <select name="rank" class="form-control">
                                <?php $__currentLoopData = $ranks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if(is_array($value)): ?>
                                        <optgroup label="<?php echo e($key); ?>">
                                            <?php $__currentLoopData = $value; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subKey => $subValue): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($subKey); ?>" <?php echo e(Request::get('rank') == $subKey ? 'selected' : ''); ?>>
                                                    <?php echo e($subValue); ?>

                                                </option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </optgroup>
                                    <?php else: ?>
                                        <option value="<?php echo e($key); ?>" <?php echo e(Request::get('rank') == $key ? 'selected' : ''); ?>>
                                            <?php echo e($value); ?>

                                        </option>
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                    </div>
                </form>

                <div class="table-responsive" id="users-table-wrapper">
                    <table id="users-table" class="table table-borderless table-striped">
                        <thead>
                            <tr>
                                <th class="min-width-150"><?php echo app('translator')->get('Service Code'); ?></th>
                                <th class="min-width-150"><?php echo app('translator')->get('Name'); ?></th>
                                <th class="min-width-100"><?php echo app('translator')->get('Email'); ?></th>
                                <th class="min-width-100"><?php echo app('translator')->get('Age'); ?></th>
                                <th class="min-width-100"><?php echo app('translator')->get('Passport Number'); ?></th>
                                <th class="min-width-100"><?php echo app('translator')->get('Passport'); ?></th>
                                <th class="min-width-150"><?php echo app('translator')->get('Rank'); ?></th>
                                <th class="min-width-150"><?php echo app('translator')->get('Position'); ?></th> 
                                <th class="min-width-150"><?php echo app('translator')->get('Years of Service'); ?></th> 
                                <th class="min-width-150"><?php echo app('translator')->get('Biography'); ?></th> 
                                <th class="text-center min-width-150"><?php echo app('translator')->get('Action'); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(count($users)): ?>
                                <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        
                                        <td class="align-middle"><?php echo e($user->service_code); ?></td>
                                        <td class="align-middle"><?php echo e($user->name); ?></td>
                                        <td class="align-middle"><?php echo e($user->email); ?></td>
                                        <td class="align-middle"><?php echo e($user->age); ?></td>
                                        <td class="align-middle"><?php echo e($user->passport_number); ?></td>
                                        <td class="align-middle"><?php echo e($user->passport); ?></td>
                                        <td class="align-middle"><?php echo e($user->rank); ?></td>
                                        <td class="align-middle"><?php echo e($user->position); ?></td> 
                                        <td class="align-middle"><?php echo e($user->years_of_service); ?></td> 
                                        <td class="align-middle"><?php echo e($user->biography); ?></td> 
                                        <td class="align-middle"><?php echo e($user->created_at); ?></td> 
                                        <td class="text-center align-middle">
                                            
                                            <a href="<?php echo e(route('users.submission.destroy', $user->id)); ?>"
                                                class="btn btn-icon" title="<?php echo app('translator')->get('Delete Personnel'); ?>" data-toggle="tooltip"
                                                data-placement="top" data-method="DELETE"
                                                data-confirm-title="<?php echo app('translator')->get('Please Confirm'); ?>"
                                                data-confirm-text="<?php echo app('translator')->get('Are you sure that you want to delete this personnel?'); ?>"
                                                data-confirm-delete="<?php echo app('translator')->get('Yes, delete it!'); ?>">
                                                <i class="fas fa-trash"></i>
                                            </a>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php else: ?>
                                <tr>
                                    <td colspan="10"><em><?php echo app('translator')->get('No records found.'); ?></em></td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    
    <?php echo $users->render(); ?>



    <div class="modal fade" id="addPersonnelModal" tabindex="-1" role="dialog" aria-labelledby="addPersonnelModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addPersonnelModalLabel"><?php echo app('translator')->get('Register New Personnel'); ?></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form action="<?php echo e(route('personnel.store')); ?>" method="POST" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-6 form-group">
                            <label><?php echo app('translator')->get('Full Name'); ?></label>
                            <input type="text" name="name" class="form-control" required>
                        </div>
                        <div class="col-md-6 form-group">
                            <label><?php echo app('translator')->get('Email'); ?></label>
                            <input type="email" name="email" class="form-control" required>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-4 form-group">
                            <label><?php echo app('translator')->get('Service Code'); ?></label>
                            <input type="text" name="service_code" class="form-control" required>
                        </div>
                        <div class="col-md-4 form-group">
                            <label><?php echo app('translator')->get('Age'); ?></label>
                            <input type="number" name="age" class="form-control">
                        </div>
                        <div class="col-md-4 form-group">
                            <label><?php echo app('translator')->get('Years of Service'); ?></label>
                            <input type="number" name="years_of_service" class="form-control">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6 form-group">
                            <label><?php echo app('translator')->get('Rank'); ?></label>
                            <select name="rank" class="form-control" required>
                                <?php $__currentLoopData = $ranks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if(is_array($value)): ?>
                                        <optgroup label="<?php echo e($key); ?>">
                                            <?php $__currentLoopData = $value; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subKey => $subValue): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($subKey); ?>"><?php echo e($subValue); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </optgroup>
                                    <?php else: ?>
                                        <option value="<?php echo e($key); ?>"><?php echo e($value); ?></option>
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-6 form-group">
                            <label><?php echo app('translator')->get('Position'); ?></label>
                            <input type="text" name="position" class="form-control">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6 form-group">
                            <label><?php echo app('translator')->get('Passport Number'); ?></label>
                            <input type="text" name="passport_number" class="form-control">
                        </div>
                        <div class="col-md-6 form-group">
                            <label><?php echo app('translator')->get('Passport Photo'); ?></label>
                            <input type="file" name="passport" class="form-control-file">
                        </div>
                    </div>

                    <div class="form-group">
                        <label><?php echo app('translator')->get('Biography'); ?></label>
                        <textarea name="biography" class="form-control" rows="3"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo app('translator')->get('Close'); ?></button>
                    <button type="submit" class="btn btn-primary"><?php echo app('translator')->get('Save Personnel'); ?></button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

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

    <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.10.25/datatables.min.js"></script>

    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/dataTables.buttons.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.bootstrap4.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.html5.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.print.min.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/buttons/1.7.1/js/buttons.colvis.min.js"></script>

    <script>
        $(document).ready(function() {
            $('#users-table').DataTable({
                // Enables the DOM structure for buttons (B), length (l), filtering (f), table (t), info (i), and pagination (p)
                dom: 'Bfrtip',
                // Define the export buttons
                buttons: [
                    'copy', 'csv', 'excel', 'pdf', 'print'
                ],
                // Use the 'columns' option to disable sorting and export on the 'Action' column (index 9)
                "columnDefs": [{
                        "orderable": false,
                        "targets": 9
                    }, // Disable ordering for the 10th column (index 9)
                    {
                        "exportable": false,
                        "targets": 9
                    } // Exclude the 10th column (index 9) from export
                ]
            });
        });
    </script>
    <script>
        $("#status").change(function() {
            $("#users-form").submit();
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/AMPPS/www/military/resources/views/submission/list.blade.php ENDPATH**/ ?>