<?php $__env->startSection('title', 'Manage Company Modes of Payments'); ?>


<?php $__env->startSection('internal-js'); ?>
    <script>

        $(document).ready(function () {

            $('#example').dataTable();
            $('#example1').dataTable();


            $('#summary-url').on('click', function (){
                window.history.pushState({}, null, '?type=summary');
            });
            $('#log-url').on('click', function (){
                window.history.pushState({}, null, '?type=log');
            });

        });

        function addMainPaymentMode(){
            var route_link = '/add-company-main-payment-mode';

            $('#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: 600,
                title: "Create New Main Payment Mode for the Company",
                buttons: [
                    {
                        text: "Save Details",
                        icon: "ui-icon-check",
                        click: function(e) {
                            if(confirm('Are you sure to Save Entered Mode Of Payment Details?')){
                                e.preventDefault();
                                var datas = $('#add-company-main-payment-mode').serializeArray();

                                $.ajax({
                                    method: "POST",
                                    url: route_link,
                                    data: datas,

                                    success: function (res){
                                        // alert(res);
                                        if(res == 'empty fields'){
                                            alert('Please fill out all Fields marked with RED Asterisk (*)');
                                        }else if(res == 'mode exists'){
                                            alert('Entered Mode Name already Exists');
                                        }else if(res == 'error' ){
                                            window.location = '/company-payment-modes?submit=false&type=summary';
                                        }else if(res == 'success'){
                                            window.location = '/company-payment-modes?submit=true&type=summary';
                                        }else{
                                            alert('System Encountered an Error. Please Contact System Admin');
                                            window.location = 'company-payment-modes?type=summary&error=system';
                                        }
                                    }
                                });
                                return false;
                            }
                        }
                    }
                ],
                open: function() {
                    $(this).parent().css({'top': 50});
                }
            });
        }
    </script>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('internal-css'); ?>
    <style>
        #example th, td {
            text-align: left;
            padding: 5px;
        }
        #example tr:hover {background-color: #a3aef6;}
        #example1 th, td {
            text-align: left;
            padding: 5px;
        }
        #example1 tr:hover {background-color: #a3aef6;}
    </style>

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


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


<?php $__env->startSection('heading'); ?>
    Manage Company Main Modes of Payment
<?php $__env->stopSection(); ?>
<?php $__env->startSection('done-by', ''); ?>


<?php $__env->startSection('content'); ?>
    <?php if(isset($_GET['submit'])): ?>
        <div>
            <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['submit'] == 'true'): ?>
                <div class="yesFound">Mode of Payment Added Successfully</div><br>
            <?php elseif($_GET['submit'] == 'false'): ?>
                <div class="notFound">System is unable to saveMode of Payment Details entered . Please Contact System Admin for Assistance</div><br>
            <?php endif; ?>
        </div>
    <?php endif; ?>

    <div class="tab">
        <button class="tablinks" onclick="openCity(event, 'general')" <?php if(isset($_GET['type']) && $_GET['type'] == 'summary'): ?>id="defaultOpen" <?php else: ?> id="summary-url"<?php endif; ?>>General</button>
        <?php if(app('UserReads')->log == 1): ?>
            <button class="tablinks" onclick="openCity(event, 'log')" <?php if(isset($_GET['type']) && $_GET['type'] == 'log'): ?>id="defaultOpen" <?php else: ?> id="log-url"<?php endif; ?>>LOG
                <?php if(isset($history)): ?>
                    <span class="
                <?php if(count($history) > 0): ?>
                countItems
                <?php else: ?>
                zeroItems
                <?php endif; ?>">
               &nbsp;<?php echo e(count($history)); ?>&nbsp;
            </span>
                <?php endif; ?>
            </button>
        <?php endif; ?>
    </div>

    <div class="tabcontent" id="general">
        <span onclick="this.parentElement.style.display='none'" class="topright">&times</span>
        <h3 class="error">Customize Company Main Payment Modes
            <button style="margin-left: 20px; cursor: pointer;height: 25px" onclick="addMainPaymentMode()">+ Add New Payment Mode</button>
        </h3>

        <table id="example" class="display" style="width: 100%; border-collapse: collapse; ">
            <thead>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Mode Name</th>
                <th>Details</th>
                <th>No. of Sub-Modes</th>
                <th>Date Created</th>
                <th>User</th>
                <th></th>
                <th></th>
            </tr>
            </thead>
            <tbody>
            <?php if(isset($lists)): ?>
                <?php $__currentLoopData = $lists; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td class="ar"></td>
                        <td><a href="<?php echo e(url('company-sub-modes-of-payment/'.$list->id.'?type=summary')); ?>" class="inner" style="color: red; font-weight: bold" ><?php echo e($list->name); ?></a></td>
                        <td><?php echo e($list->details); ?></td>
                        <td>
                            <?php if($list->subModes != null): ?>
                                <b><?php echo e(count($list->subModes)); ?></b>
                            <?php endif; ?>
                        </td>
                        <td><?php echo e($list->created_at->format('d/m/Y')); ?></td>
                        <td>
                            <?php if($list->user != null): ?>
                                <?php echo e($list->user->firstName." ".$list->user->lastName); ?>

                            <?php else: ?>
                                -
                            <?php endif; ?>
                        </td>

                        <td><a href="javascript: editDetails('<?php echo e($list->id); ?>');"><b class="error"><i class="fa fa-pencil fa-md" style="font-size: 15px" title="Edit Mode"></i></b></a></td>
                        <td><b><i onclick="delMode('<?php echo e($list->id); ?>','<?php echo e($list->name); ?>')" class="fa fa-trash-o" style="font-size: 16px; cursor: pointer" title="Delete Mode"></i></b></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endif; ?>
            </tbody>

            <tfoot>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Mode Name</th>
                <th>Details</th>
                <th>No. of Sub-Modes</th>
                <th>Date Created</th>
                <th>User</th>
                <th></th>
                <th></th>
            </tr>
            </tfoot>
        </table>
    </div>

    <div class="tabcontent" id="log">
        <span onclick="this.parentElement.style.display='none'" class="topright">&times</span>
        <h3 class="error">Audit Trails [LOGs]</h3>
        <table id="example1" class="display" style="width:100%; border-collapse: collapse">
            <thead>
            <tr style="background-color: #a1b5d3">
                <th style="text-align: left">No</th>
                <th style="text-align: left">Log Narration.</th>
                <th style="text-align: left">User</th>
                <th style="text-align: left">Date & Time</th>
            </tr>
            </thead>
            <tbody>

            <?php if(isset($history)): ?>
                <?php $__currentLoopData = $history; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $histo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td style="width: 50px" class="br"></td>
                        <td class="error"><?php echo $histo->narration; ?></td>
                        <td><?php echo e(\App\Models\User::where('id', $histo->created_by)->first()->lastName); ?></td>
                        <td><?php echo e($histo->created_at->format('d/m/Y') .' at '. $histo->created_at->format('h:i:s a')); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endif; ?>
            </tbody>
            <tfoot>
            <tr style="background-color: #a1b5d3">
                <th style="text-align: left">No</th>
                <th style="text-align: left">Log Narration.</th>
                <th style="text-align: left">User</th>
                <th style="text-align: left">Date & Time</th>
            </tr>
            </tfoot>
        </table>
    </div>
<?php $__env->stopSection(); ?>




<?php $__env->startSection('modal_heading'); ?>
    <h1>Setup Company Main Payment Modes </h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>
    <ol><b>
            <li>View and amend Company Main Payment Modes i.e Cheques, Mobile Payments and Bank Transfers</li>
            <li>Add New Payment Modes</li>
            <li>Delete/Deactivate Payment Modes</li>
        </b>
    </ol>
<?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/company-payment-modes.blade.php ENDPATH**/ ?>