<?php $__env->startSection('title', 'Setup Employee Tax Bands'); ?>


<?php $__env->startSection('internal-js'); ?>
    <script>
        $(document).ready(function () {
            $('#active-table').dataTable({
                dom: 'lBfrtip',
                buttons: [
                    { extend: 'excel', className: 'download-buttons' },
                    { extend: 'pdf', className: 'download-buttons' }
                ],
                "paging":   false,
            });
        });

        
        function addNewTaxBand(){
            var route_link = '/add-tax-band';

            $('#edit_dialog_content').html('<div style="text-align: center; margin: 20px 0 20px 0;"><img src="<?php echo e(asset('images/loads/loader.gif')); ?>" border=0></div>');
            $('#edit_dialog_content').load(encodeURI(route_link));
            $('#edit_dialog_content').dialog({
                modal: true,
                width: 500,
                title: "Add New Tax Band",

                buttons: [
                    {
                        text: "Save Details",
                        icon: "ui-icon-check",
                        id: "my-button-1",
                        click: function(e) {
                            if(confirm('Are you sure to Save Entered Details?')){
                                e.preventDefault();
                                $("#my-button-1").attr('disabled', true).text('Please Wait....');
                                var datas = $('#add-tax-band').serializeArray();

                                $.ajax({
                                    method: "POST",
                                    url: route_link,
                                    data: datas,
                                    success: function (res){
                                        if(res == 'success'){
                                            window.location = '/setup-tax-calculator?addTaxBand=true';
                                        }else if(res == 'empty fields'){
                                            alert('Please provide both the From and To Figures');
                                            $("#my-button-1").attr('disabled', false).text('Save Details');
                                        }else if(res == 'exists'){
                                            alert('The Entered Tax Band already Exists');
                                            $("#my-button-1").attr('disabled', false).text('Save Details');
                                        }else{
                                            alert('System Encountered an Error. Please Contact System Admin');
                                        }
                                    }
                                });
                            }
                            return false;
                        }
                    }
                ],
                open: function() {
                    $(this).parent().css({'top': 50});
                }
            });
        }

        
        function updateTaxBand(id) {
            var route_link = '/update-tax-band/' + id;

            $('#edit_dialog_content').html('<div style="text-align: center; margin: 20px 0 20px 0;"><img src="<?php echo e(asset('images/loads/loader.gif')); ?>" border=0></div>');
            $('#edit_dialog_content').load(encodeURI(route_link));
            $('#edit_dialog_content').dialog({
                modal: true,
                width: 750,
                title: "Update Tax Band Details",

                buttons: [
                    {
                        text: "Save Details",
                        icon: "ui-icon-check",
                        id: "my-button-1",
                        click: function (e) {
                            if (confirm('Are you sure to Save Entered Details?')) {
                                e.preventDefault();
                                $("#my-button-1").attr('disabled', true).text('Please Wait....');
                                var datas = $('#update-tax-band').serializeArray();

                                $.ajax({
                                    method: "POST",
                                    url: route_link,
                                    data: datas,
                                    success: function (res) {
                                        if (res == 'success') {
                                            window.location = '/setup-tax-calculator?updateTaxBand=true';
                                        } else if (res == 'empty number') {
                                            alert('Please Provide Tax Band Details to Proceed');
                                            $("#my-button-1").attr('disabled', false).text('Save Details');
                                        } else {
                                            alert('System Encountered an Error. Please Contact System Admin');
                                        }
                                    }
                                });
                            }
                            return false;
                        }
                    }
                ],
                open: function () {
                    $(this).parent().css({'top': 50});
                }
            });
        }
    </script>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('internal-css'); ?>
    <style>
        #active-table th, td {
            text-align: left;
            padding: 4px;
        }
        #active-table tr:hover {background-color: #cbd1f8;}
        .switch-certificate {
            position: relative;
            display: inline-block;
            width: 38px;
            height: 17px;
        }
    </style>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('headers'); ?>
    <?php echo $__env->make('headers.hr-header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('heading', 'Tax Bands Listing'); ?>


<?php $__env->startSection('content'); ?>
    <?php if(isset($_GET['addTaxBand'])): ?>
        <div class="error-section">
            <span onclick="this.parentElement.style.display='none'" class="topright" style="color: white ;margin-top: -4px;font-weight: bold; margin-right: 5px">&times</span>
            <?php if($_GET['addTaxBand'] == 'true'): ?>
                <div class="yesFound">New Tax Band has been Created Successfully</div><br>
            <?php elseif($_GET['addTaxBand'] == 'false'): ?>
                <div class="notFound">There was an error while trying to Create Tax Band</div><br>
            <?php endif; ?>
        </div>
    <?php endif; ?>
    <div class="tab">
        <button class="tablinks" onclick="openCity(event, 'deductions')" id="defaultOpen">Active Tax Bands</button>
    </div>

    <div id="deductions" class="tabcontent">
        <h3 class="error">
           Tax Bands
            <button onclick="addNewTaxBand()" class="section-button">+ Add New Tax Band</button>
        </h3>
        <table id="active-table" class="display" style="width: 100%; border-collapse: collapse; ">
            <thead>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Amount From:</th>
                <th>Amount To</th>
                <th>Rate/Amount</th>
                <th>Created By</th>
                <th>Date & Time</th>
                <th>Edit</th>
            </tr>
            </thead>
            <tbody>
            <?php $__currentLoopData = $bands; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td class="ar"></td>
                    <td><b><?php echo number_format($row->from,2); ?></b></td>
                    <td><b><?php echo number_format($row->to,2); ?></b></td>
                    <td><b class="error">
                            <?php echo number_format($row->rate, 2); ?>

                            <?php if($row->rate < 100): ?>
                            %
                            <?php endif; ?>

                        </b>
                    </td>
                    <td>
                        <?php if($row->user): ?>
                            <?php echo $row->user->firstName." ".$row->user->lastName; ?>

                        <?php endif; ?>
                    </td>
                    <td><?php echo $row->created_at->format('d/m/Y H:i:s a'); ?></td>
                    <td><i class="fa fa-pencil error" style="font-size: 14px; cursor: pointer"></i></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
            <tfoot>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Amount From:</th>
                <th>Amount To</th>
                <th>Rate/Amount</th>
                <th>Created By</th>
                <th>Date & Time</th>
                <th>Edit</th>
            </tr>
            </tfoot>
        </table>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('modal_heading'); ?>
    <h1>Setup Tax Calculator</h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>
    <b>
        <ol>
            <li>View Available Tax Bands </li>
            <li>Add New Tax Bands</li>
        </ol>
    </b>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/zedarroot/public_html/edwulp/resources/views/hr/employees/setup-tax-calculator.blade.php ENDPATH**/ ?>