<?php $__env->startPush('datatable-styles'); ?>
    <?php echo $__env->make('sections.datatable_css', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('filter-section'); ?>
<?php if (isset($component)) { $__componentOriginald1a72e1108842d163a80559e15f530b4 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald1a72e1108842d163a80559e15f530b4 = $attributes; } ?>
<?php $component = App\View\Components\Filters\FilterBox::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('filters.filter-box'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\Filters\FilterBox::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>

    <!-- DESIGNATION START -->
    <div class="select-box d-flex py-2 pr-lg-3 pr-md-3 px-0 border-right-grey border-right-grey-sm-0">
        <p class="mb-0 pr-2 f-14 text-dark-grey d-flex align-items-center"> <?php echo app('translator')->get('app.designation'); ?></p>
        <div class="select-status">
            <select class="form-control select-picker" name="designation" id="designation">
                <option value="all"><?php echo app('translator')->get('app.all'); ?></option>
                <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($department->id); ?>"><?php echo e(($department->team_name)); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>
    </div>
    <!-- DESIGNATION END -->
    <div class="select-box d-flex py-2 px-lg-3 px-md-3 px-0 border-right-grey border-right-grey-sm-0">
        <p class="mb-0 pr-2 f-14 text-dark-grey d-flex align-items-center"> <?php echo app('translator')->get('app.department'); ?></p>
        <div class="select-status">
            <select class="form-control select-picker" name="department" id="department">
                <option value="all"><?php echo app('translator')->get('app.all'); ?></option>
                <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($department->id); ?>"><?php echo e(($department->team_name)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>
    </div>

    <div class="select-box d-flex py-2 px-lg-3 px-md-3 px-0 border-right-grey border-right-grey-sm-0">
        <p class="mb-0 pr-2 f-14 text-dark-grey d-flex align-items-center"
           id="select-label"><?php echo app('translator')->get('payroll::app.employee'); ?></p>
        <div class="select-status">
            <select class="form-control select-picker" name="employee_id"  id="selectEmployee" data-live-search="true">
            <option value="all"><?php echo app('translator')->get('app.all'); ?></option>
                <?php $__currentLoopData = $employees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if (isset($component)) { $__componentOriginal6c7097547485b98631a37d273a171e9f = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal6c7097547485b98631a37d273a171e9f = $attributes; } ?>
<?php $component = App\View\Components\UserOption::resolve(['user' => $item,'pill' => true] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('user-option'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\UserOption::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal6c7097547485b98631a37d273a171e9f)): ?>
<?php $attributes = $__attributesOriginal6c7097547485b98631a37d273a171e9f; ?>
<?php unset($__attributesOriginal6c7097547485b98631a37d273a171e9f); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal6c7097547485b98631a37d273a171e9f)): ?>
<?php $component = $__componentOriginal6c7097547485b98631a37d273a171e9f; ?>
<?php unset($__componentOriginal6c7097547485b98631a37d273a171e9f); ?>
<?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>
    </div>
    <div class="select-box d-flex py-2 pr-lg-3 pr-md-3 px-0 border-right-grey border-right-grey-sm-0">
        <p class="mb-0 pr-2 f-14 text-dark-grey d-flex align-items-center"><?php echo app('translator')->get('app.select'); ?> <?php echo app('translator')->get('app.year'); ?></p>
        <div class="select-status">
            <select class="form-control select-picker" name="year" id="year">
                <?php for($i = $year; $i >= ($year-4); $i--): ?>
                    <option <?php if($i == $year): ?> selected <?php endif; ?> value="<?php echo e($i); ?>"><?php echo e($i); ?></option>
                <?php endfor; ?>
            </select>
        </div>
    </div>

    <div class="select-box d-flex py-2 px-lg-3 px-md-3 px-0 border-right-grey border-right-grey-sm-0">
        <p class="mb-0 pr-2 f-14 text-dark-grey d-flex align-items-center"
           id="select-label"><?php echo app('translator')->get('app.select'); ?> <?php echo app('translator')->get('app.month'); ?></p>
        <div class="select-status">
            <select class="form-control select-picker" name="month" id="month">
                <?php $__currentLoopData = $months; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $monthName): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e(($key + 1)); ?>" <?php if($month == ($key + 1)): ?> selected <?php endif; ?>> <?php echo e(__('app.months.'.ucfirst($monthName) )); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>
    </div>

    <!-- SEARCH BY TASK END -->

    <!-- RESET START -->
    <div class="select-box d-flex py-1 px-lg-2 px-md-2 px-0">
        <?php if (isset($component)) { $__componentOriginal5e57c6582b8a883148a28bb7ee46d2ad = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal5e57c6582b8a883148a28bb7ee46d2ad = $attributes; } ?>
<?php $component = App\View\Components\Forms\ButtonSecondary::resolve(['icon' => 'times-circle'] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('forms.button-secondary'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\Forms\ButtonSecondary::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => 'btn-xs d-none','id' => 'reset-filters']); ?>
            <?php echo app('translator')->get('app.clearFilters'); ?>
         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal5e57c6582b8a883148a28bb7ee46d2ad)): ?>
<?php $attributes = $__attributesOriginal5e57c6582b8a883148a28bb7ee46d2ad; ?>
<?php unset($__attributesOriginal5e57c6582b8a883148a28bb7ee46d2ad); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal5e57c6582b8a883148a28bb7ee46d2ad)): ?>
<?php $component = $__componentOriginal5e57c6582b8a883148a28bb7ee46d2ad; ?>
<?php unset($__componentOriginal5e57c6582b8a883148a28bb7ee46d2ad); ?>
<?php endif; ?>
    </div>
    <!-- RESET END -->

 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald1a72e1108842d163a80559e15f530b4)): ?>
<?php $attributes = $__attributesOriginald1a72e1108842d163a80559e15f530b4; ?>
<?php unset($__attributesOriginald1a72e1108842d163a80559e15f530b4); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald1a72e1108842d163a80559e15f530b4)): ?>
<?php $component = $__componentOriginald1a72e1108842d163a80559e15f530b4; ?>
<?php unset($__componentOriginald1a72e1108842d163a80559e15f530b4); ?>
<?php endif; ?>


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

<?php $__env->startSection('content'); ?>
    <!-- CONTENT WRAPPER START -->
    <div class="content-wrapper">
        <!-- Add Task Export Buttons Start -->

        <div class="row">
            <div class="col-md-6 mb-3">
                <div
                    class="bg-white p-20 rounded b-shadow-4 d-flex justify-content-between align-items-center mt-3 mt-lg-0 mt-md-0">
                    <div class="d-block ">
                        <h5 class="f-15 f-w-500 mb-20 text-darkest-grey"> <?php echo app('translator')->get('payroll::modules.payroll.approvedStatus'); ?> </h5>
                        <div class="d-flex">
                            <p class="mb-0 f-21 font-weight-bold text-blue d-grid mr-5">
                                <span id="requested">0</span>
                                <span class="f-12 font-weight-normal text-lightest"><?php echo app('translator')->get('payroll::modules.payroll.requested'); ?></span>
                            </p>

                            <p class="mb-0 f-21 font-weight-bold text-success d-grid mr-5">
                                <span id="approved">0</span>
                                <span class="f-12 font-weight-normal text-lightest"><?php echo app('translator')->get('app.approved'); ?></span>
                            </p>

                            <p class="mb-0 f-21 font-weight-bold text-danger d-grid mr-5">
                                <span id="rejected">0</span>
                                <span class="f-12 font-weight-normal text-lightest"><?php echo app('translator')->get('app.rejected'); ?></span>
                            </p>
                            <p class="mb-0 f-21 font-weight-bold text-warning d-grid mr-5">
                                <span id="pending">0</span>
                                <span class="f-12 font-weight-normal text-lightest"><?php echo app('translator')->get('app.pending'); ?></span>
                            </p>
                        </div>
                    </div>
                    <div class="d-block">
                        <i class="fa fa-thumbs-up text-lightest f-27"></i>
                    </div>
                </div>
            </div>
            <div class="col-md-6 mb-3">
                <div
                    class="bg-white p-20 rounded b-shadow-4 d-flex justify-content-between align-items-center mt-3 mt-lg-0 mt-md-0">
                    <div class="d-block ">
                        <h5 class="f-15 f-w-500 mb-20 text-darkest-grey"> <?php echo app('translator')->get('payroll::modules.payroll.overtimeHoursSummery'); ?> </h5>
                        <div class="d-flex">
                            <p class="mb-0 f-21 font-weight-bold  d-grid mr-5">
                                <span id="overtimeHours">0</span>
                                <span class="f-12 font-weight-normal text-lightest"><?php echo app('translator')->get('payroll::modules.payroll.overtimeHours'); ?></span>
                            </p>

                            <p class="mb-0 f-21 font-weight-bold d-grid mr-5">
                                <span id="compensation">0</span>
                                <span class="f-12 font-weight-normal text-lightest"><?php echo app('translator')->get('payroll::modules.payroll.compensation'); ?></span>
                            </p>

                        </div>
                    </div>
                    <div class="d-block">
                        <i class="fa fa-hourglass text-lightest f-27"></i>
                    </div>
                </div>
            </div>
        </div>

        <div class="d-flex" id="table-actions">
            <?php if(!is_null($userPolicy) || user()->hasRole('admin')): ?>
                <?php if (isset($component)) { $__componentOriginaldbb84df4c3a5cbdd95fb35d18ba6410f = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginaldbb84df4c3a5cbdd95fb35d18ba6410f = $attributes; } ?>
<?php $component = App\View\Components\Forms\LinkPrimary::resolve(['link' => 'javascript:;','icon' => 'plus'] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('forms.link-primary'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(App\View\Components\Forms\LinkPrimary::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => 'mr-3 float-left mb-2 mb-lg-0 mb-md-0 add-request']); ?>
                    <?php echo app('translator')->get('payroll::modules.payroll.addRequest'); ?>
                 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginaldbb84df4c3a5cbdd95fb35d18ba6410f)): ?>
<?php $attributes = $__attributesOriginaldbb84df4c3a5cbdd95fb35d18ba6410f; ?>
<?php unset($__attributesOriginaldbb84df4c3a5cbdd95fb35d18ba6410f); ?>
<?php endif; ?>
<?php if (isset($__componentOriginaldbb84df4c3a5cbdd95fb35d18ba6410f)): ?>
<?php $component = $__componentOriginaldbb84df4c3a5cbdd95fb35d18ba6410f; ?>
<?php unset($__componentOriginaldbb84df4c3a5cbdd95fb35d18ba6410f); ?>
<?php endif; ?>
            <?php endif; ?>
        </div>
        <!-- Add Task Export Buttons End -->
        <!-- Task Box Start -->
        <div class="d-flex flex-column w-tables rounded mt-3 bg-white">

            <?php echo $dataTable->table(['class' => 'table table-hover border-0 w-100']); ?>


        </div>
        <!-- Task Box End -->
    </div>
    <!-- CONTENT WRAPPER END -->

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

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

    <script>
        getOvertimeData();

        $('#overtime-request').on('preXhr.dt', function (e, settings, data) {

            const designation = $('#designation').val();
            const department = $('#department').val();
            const year = $('#year').val();
            const month = $('#month').val();
            const employee = $('#selectEmployee').val();
            data['designation'] = designation;
            data['department'] = department;
            data['year'] = year;
            data['month'] = month;
            data['employee'] = employee;
        });

        const showTable = () => {
            window.LaravelDataTables["overtime-request"].draw(false);
            getOvertimeData();
        }

        function getOvertimeData() {

            const designation = $('#designation').val();
            const department = $('#department').val();
            const year = $('#year').val();
            const month = $('#month').val();
            const employee = $('#selectEmployee').val();

            var url = "<?php echo e(route('overtime-request-data')); ?>?designation="+designation+"&department="+department+"&year="+year+"&month="+month+"&employee="+employee;

            $.easyAjax({
                type: 'GET',
                url: url,
                success: function (response) {
                    console.log(response.overtimeData);
                    $('#requested').html(response.overtimeData.requested);
                    $('#approved').html(response.overtimeData.approved);
                    $('#rejected').html(response.overtimeData.rejected);
                    $('#pending').html(response.overtimeData.pending);
                    $('#overtimeHours').html(response.overtimeData.overtimeHours);
                    $('#compensation').html(response.overtimeData.compensation);
                }
            });
        }

        $('#designation, #department, #selectEmployee, #year, #month').on('change keyup',
            function () {
                if ($('#designation').val() !== "all") {
                    $('#reset-filters').removeClass('d-none');
                } else if ($('#department').val() !== "all") {
                    $('#reset-filters').removeClass('d-none');
                } else if ($('#search-text-field').val() != "") {
                    $('#reset-filters').removeClass('d-none');
                } else {
                    $('#reset-filters').addClass('d-none');
                }

                showTable();
            });

        $('#reset-filters').click(function () {
            $('#filter-form')[0].reset();
            $('.filter-box .select-picker').selectpicker("refresh");
            $('#reset-filters').addClass('d-none');
            showTable();
        });

        $('body').on('click', '.add-request', function () {
            let url = '<?php echo e(route("overtime-requests.create")); ?>';
            $(MODAL_LG + ' ' + MODAL_HEADING).html('...');
            $.ajaxModal(MODAL_LG, url);
        });


        $('body').on('click', '.editRequest', function () {
            const requestId = $(this).data('request-id');
            let url = '<?php echo e(route("overtime-requests.edit", ":id")); ?>';
            url = url.replace(':id', requestId);

            $(MODAL_LG + ' ' + MODAL_HEADING).html('...');
            $.ajaxModal(MODAL_LG, url);
        });

        $('body').on('click', '.showRequest', function () {
            const requestId = $(this).data('request-id');
            let url = '<?php echo e(route("overtime-requests.show", ":id")); ?>';
            url = url.replace(':id', requestId);

            $(MODAL_LG + ' ' + MODAL_HEADING).html('...');
            $.ajaxModal(MODAL_LG, url);
        });

         /* delete overtime request */
         $('#overtime-request').on('click', '.delete-request-table-row', function () {
            let obj = $(this).closest('tr');
            var id = $(this).data('request-id');
            Swal.fire({
                title: "<?php echo app('translator')->get('messages.sweetAlertTitle'); ?>",
                text: "<?php echo app('translator')->get('messages.recoverRecord'); ?>",
                icon: 'warning',
                showCancelButton: true,
                focusConfirm: false,
                confirmButtonText: "<?php echo app('translator')->get('messages.confirmDelete'); ?>",
                cancelButtonText: "<?php echo app('translator')->get('app.cancel'); ?>",
                customClass: {
                    confirmButton: 'btn btn-primary mr-3',
                    cancelButton: 'btn btn-secondary'
                },
                showClass: {
                    popup: 'swal2-noanimation',
                    backdrop: 'swal2-noanimation'
                },
                buttonsStyling: false
            }).then((result) => {
                if (result.isConfirmed) {

                    var url = "<?php echo e(route('overtime-requests.destroy', ':id')); ?>";
                    url = url.replace(':id', id);

                    var token = "<?php echo e(csrf_token()); ?>";

                    $.easyAjax({
                        type: 'POST',
                        url: url,
                        blockUI: true,
                        data: {
                            '_token': token,
                            '_method': 'DELETE'
                        },
                        success: function (response) {
                            if (response.status == "success") {
                                obj.remove();
                                showTable();
                            }
                        }
                    });
                }
            });
        });
        /* PAYROLL SALARY SCRIPTS */



        /* delete overtime request */
         $('#overtime-request').on('click', '.acceptButton', function () {
            var id = $(this).data('request-id');
            var type = $(this).data('type');

            var butonText = "<?php echo app('translator')->get('payroll::messages.confirmAccept'); ?>";
            if(type != 'accept'){
                butonText = "<?php echo app('translator')->get('payroll::messages.confirmReject'); ?>";
            }
            Swal.fire({
                title: "<?php echo app('translator')->get('messages.sweetAlertTitle'); ?>",
                text: "<?php echo app('translator')->get('payroll::messages.recoverRecord'); ?>",
                icon: 'warning',
                showCancelButton: true,
                focusConfirm: false,
                confirmButtonText: butonText,
                cancelButtonText: "<?php echo app('translator')->get('app.cancel'); ?>",
                customClass: {
                    confirmButton: 'btn btn-primary mr-3',
                    cancelButton: 'btn btn-secondary'
                },
                showClass: {
                    popup: 'swal2-noanimation',
                    backdrop: 'swal2-noanimation'
                },
                buttonsStyling: false
            }).then((result) => {
                if (result.isConfirmed) {

                    var url = "<?php echo e(route('overtime-request-accept', ':id')); ?>?type="+type;
                    url = url.replace(':id', id);

                    $.easyAjax({
                        type: 'GET',
                        url: url,
                        blockUI: true,
                        success: function (response) {
                            if (response.status == "success") {
                                showTable();
                            }
                        }
                    });
                }
            });
        });
        /* PAYROLL SALARY SCRIPTS */

        $('#overtime-request').on('change', '.change-status', function (e) {
            e.preventDefault();
            const id = $(this).data('request-id');
            const status = $(this).val();
            const token = "<?php echo e(csrf_token()); ?>";
            if (id !== undefined && id != '') {
                $.easyAjax({
                    url: '<?php echo e(route("overtime-change-status")); ?>',
                    type: "POST",
                    data: {request_id: id, status: status, _token: token},
                    success: function (response) {
                        if (response.status === "success") {
                            showTable();
                        }
                    }
                })
            }
        });

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

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/smartdigitants/public_html/oneops.co.uk/oneops.ai/Modules/Payroll/Providers/../Resources/views/overtime-request/index.blade.php ENDPATH**/ ?>