<?php $__env->startSection('title', 'Company Main Accounts'); ?>


<?php $__env->startSection('internal-js'); ?>
    <script>
        $(document).ready(function () {
            $('#mainAccounts').dataTable();

        });

        function addNewAccount(){
            var route_link = '/add-company-main-account';

            $('#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>')
            .load(encodeURI(route_link))
            .dialog({
                modal: true,
                width: 750,
                title: "Create a New Main Account for the Company",

                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);
                                $("#my-button-1").text('Please Wait....');
                                var datas = $('#add-company-main-accounts').serializeArray();

                                $.ajax({
                                    method: "POST",
                                    url: route_link,
                                    data: datas,
                                    success: function (res){
                                        if(res == 'success'){
                                            window.location = '/finance-main-ledgers?submit=true';
                                        }else if(res == 'empty type'){
                                            alert('Please Select the Type of Main Account to be created');
                                            $("#my-button-1").attr('disabled', false);
                                            $("#my-button-1").text('Save Details');
                                        }else if(res == 'empty name'){
                                            alert('Please the Name of Main Account to be created');
                                            $("#my-button-1").attr('disabled', false);
                                            $("#my-button-1").text('Save Details');
                                        }else if(res == 'empty category'){
                                            alert('Please Select the Category of Main Account to be created');
                                            $("#my-button-1").attr('disabled', false);
                                            $("#my-button-1").text('Save Details');
                                        }else if(res == 'empty category type'){
                                            alert('Please Select the CurrentAsset Type to be proceed');
                                            $("#my-button-1").attr('disabled', false);
                                            $("#my-button-1").text('Save Details');
                                        }else if(res == 'name exists'){
                                            alert('Entered Account Name already Exists. Please check the Name');
                                            $("#my-button-1").attr('disabled', false);
                                            $("#my-button-1").text('Save Details');
                                        }else if(res == 'error'){
                                            alert('An Error occurred and System is unable to perform the requested action. Try again');
                                            location.reload();
                                        }else{
                                            alert('System Encountered an Error. Please Contact System Admin');
                                            location.reload();
                                        }
                                    }
                                });
                            }
                            return false;
                        }
                    }
                ],
                open: function() {
                    $(this).parent().css({'top': 50});
                }
            });
        }
    </script>
<?php $__env->stopSection(); ?>


<?php $__env->startSection('internal-css'); ?>
    <style>
        .inputDivider{
            border: 1px solid gray; border-radius: 5px;
        }
        #example tr:hover {background-color: #a3aef6;}
        #example th, td {
            text-align: left;
            padding: 4px;
        }
        #mainAccounts th, td {
            text-align: left;
            padding: 5px;
        }

    </style>

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



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


<?php $__env->startSection('heading'); ?>
    Company Financial Main Accounts
<?php $__env->stopSection(); ?>
<?php $__env->startSection('done-by', ""); ?>


<?php $__env->startSection('content'); ?>
    <p class="error" style="text-align: center">On this Page, You can See all Main Account Types Setup for the Company</p>

    <div class="guestDetails_inputDivider"></div>
    <h3 class="error">
        Active Finance Main Accounts
        <button onclick="addNewAccount()" class="section-button">+ Add New Main Account</button>
    </h3>
    <table id="mainAccounts" class="display" style="width: 100%;border-collapse: collapse">
        <thead>
        <tr style="background-color: #a1b5d3">
            <th>No.</th>
            <th>Name</th>
            <th>Category</th>
            <th>Date Created</th>
            <th>User</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <th colspan="5" style="text-align: center; padding: 6px; background-color: lightcyan"><span class="error">BALANCE SHEET ACCOUNTS</span></th>
        </tr>
        <?php $__currentLoopData = $ledgers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php if($row->type == 'BS'): ?>
                <tr>
                    <td class="ar"></td>
                    <td><a href="<?php echo e(url('#')); ?>" class="inner"><span class="error"><?php echo e(strtoupper($row->name)); ?></span></a></td>
                    <td><?php echo e($row->accountType($row->category)); ?></td>
                    <td><?php echo e(date('d/m/Y', strtotime($row->created_at))); ?></td>
                    <td>
                        <?php if($row->user != null): ?>
                            <?php echo e($row->user->firstName." ".$row->user->lastName); ?>

                        <?php endif; ?>
                    </td>
                </tr>
            <?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php if($bsAccounts == 'empty'): ?>
            <tr>
                <td colspan="5" style="text-align: center">No Balance Sheet Accounts Available in Table</td>
            </tr>
        <?php endif; ?>

        <tr>
            <th colspan="5" style="text-align: center; padding: 6px; background-color: lightcyan"><span class="error">PROFIT & LOSS ACCOUNTS</span></th>
        </tr>
        <?php $__currentLoopData = $ledgers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php if($row->type == 'PL'): ?>
                <tr>
                    <td class="br"></td>
                    <td><a href="<?php echo e(url('#')); ?>" class="inner"><span class="error"><?php echo e(strtoupper($row->name)); ?></span></a></td>
                    <td><?php echo e($row->accountType($row->category)); ?></td>
                    <td><?php echo e(date('d/m/Y', strtotime($row->created_at))); ?></td>
                    <td>
                        <?php if($row->user != null): ?>
                            <?php echo e($row->user->firstName." ".$row->user->lastName); ?>

                        <?php endif; ?>
                    </td>
                </tr>
            <?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        <?php if($plAccounts == 'empty'): ?>
            <tr>
                <td colspan="5" style="text-align: center">No Profit & Loss Accounts Available in Table</td>
            </tr>
        <?php endif; ?>
        </tbody>
    </table>

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



<?php $__env->startSection('modal_heading'); ?>
    <h1>Company Financial Main Accounts</h1>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('modal_title'); ?>
    <h3><u>Dashboard Functionalities</u></h3>

    <li>On this Page, you are provided with a breakdown of the Company Main Accounts, Thus:</li>
    <ol>
        <li>You can identify any mis-entry entered</li>
        <li>View Different Account Types</li>
        <li>Add New Main Accounts Types</li>
    </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\edwulp_chemist\resources\views/finance-main-ledgers.blade.php ENDPATH**/ ?>