<?php $__env->startSection('title', 'Manage Sub-Modes of Payments for'.$mode->name); ?>


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

        $(document).ready(function () {

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

            $('#search-mode').select2();

            $('#submit-search').on('click', function (){
                var mode = $('#search-mode').val();
                if(mode == ""){
                    alert('Please Select a Mode of Payment to Search');
                }else{
                    window.location = mode+'?type=summary';
                }
            });


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

        });

        function addSubModeOfPayment(id, name){
            var route_link = '/add-company-sub-mode-of-payment/'+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: 600,
                title: "Create New Sub-Mode of Payment Under "+name,
                buttons: [
                    {
                        text: "Save Details",
                        icon: "ui-icon-check",
                        click: function(e) {
                            if(confirm('Are you sure to Save Entered Sub-Mode Details?')){
                                e.preventDefault();
                                var datas = $('#add-company-sub-mode-of-payment').serializeArray();

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

                                    success: function (res){
                                        // alert(res);
                                        if(res == 'empty field'){
                                            alert('Please fill out the Sub-Mode Name Field marked with RED Asterisk (*)');
                                        }else if(res == 'exists'){
                                            alert('Entered Sub-Mode Name already Exists under '+name);
                                        }else if(res == 'error' ){
                                            window.location = '/company-sub-modes-of-payment/'+id+'?submit=false&type=summary';
                                        }else if(res == 'success'){
                                            window.location = '/company-sub-modes-of-payment/'+id+'?submit=true&type=summary';
                                        }else{
                                            alert('System Encountered an Error. Please Contact System Admin');
                                            window.location = 'company-sub-modes-of-payment/'+id+'?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 Sub-Modes of Payments Under:- <span class="error"><?php echo e($mode->name); ?></span>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('searches'); ?>
    <div style="float: right">
        <br>
        <?php echo Form::open(['method'=>'POST']); ?>

        <div class="guestDetails_input">
            <div class="guestDetails_input" style="text-align: center">
                <select name="search-mode" id="search-mode" style="width: 200px">
                    <option value="">--Select Mode of Payment--</option>
                    <?php if(isset($modes)): ?>
                        <?php $__currentLoopData = $modes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($row->id); ?>"><?php echo e($row->name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                </select>
            </div>
        </div>
        <div class="guestDetails_input">
            <div class="guestDetails_input">
                <button type="button" id="submit-search" style="width: auto; height: 22px; cursor: pointer" title="Search a Product"><i class="fa fa-search" aria-hidden="true"></i></button>
            </div>
        </div>
        <?php echo Form::close(); ?>

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


<?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">Sub-Mode of Payment Added Successfully</div><br>
            <?php elseif($_GET['submit'] == 'false'): ?>
                <div class="notFound">System is unable to save Sub-Mode 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 Sub-Modes of Payment under:- <?php echo e($mode->name); ?>

            <button style="margin-left: 20px; cursor: pointer;height: 25px" onclick="addSubModeOfPayment('<?php echo e($mode->id); ?>', '<?php echo e($mode->name); ?>')">+ Add New Sub-Mode</button>
        </h3>

        <table id="example" class="display" style="width: 100%; border-collapse: collapse; ">
            <thead>
            <tr style="background-color: #a1b5d3">
                <th>No</th>
                <th>Sub-Mode Name</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('#')); ?>" class="inner" style="color: red; font-weight: bold" ><?php echo e($list->name); ?></a></td>
                        <td><?php echo e($list->created_at->format('d/m/Y')); ?></td>
                        <td>
                            <?php if($list->user != null): ?>
                                <?php echo e($list->user->f_nm." ".$list->user->l_nm); ?>

                            <?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>Sub-Mode Name</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()->l_nm); ?></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 Sub-Modes of Payments </h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>
    <ol><b>
            <li>View and amend Company Sub-Modes of Payments i.e for Mobile Payments:- MPESA, PESA LINK</li>
            <li>Add New Sub-Modes of Payments</li>
            <li>Delete/Deactivate Sub-Modes of Payment</li>
        </b>
    </ol>
<?php $__env->stopSection(); ?>






<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\finewood\resources\views/company-sub-modes-of-payment.blade.php ENDPATH**/ ?>