<?php
$t="INSERT INTO tbl_acgroups (acgroup_id, acgroup_code, acgroup_name, posting_side, created_on, created_by, remarks, status, display_order)
SELECT 5, '5', 'Equity', 'CR', '2023-05-22', 'admin', '', 1, 2
WHERE NOT EXISTS (
    SELECT 1 FROM tbl_acgroups WHERE acgroup_id = 5
);
";
$this->db->query($t);
$LiabilitiesAccounts = $this->acc->getAccountsByGroup(2);
$EquityAccounts = $this->acc->getAccountsByGroup(5);
$AssetsAccounts = $this->acc->getAccountsByGroup(1);
$LiabilitiesTotal = $this->acc->getAccountBalanceByGroup(2);
$EquityTotal = $this->acc->getAccountBalanceByGroup(5);
$AssetsTotal = $this->acc->getAccountBalanceByGroup(1, false);

$IncomeAccounts = $this->acc->getAccountsByGroup(3);
$ExpenseAccounts = $this->acc->getAccountsByGroup(4);
$IncomesTotal = $this->acc->getAccountBalanceByGroup(3);
$ExpensesTotal = $this->acc->getAccountBalanceByGroup(4);
$PL = $IncomesTotal - $ExpensesTotal;
$LiabilitiesTotal=$LiabilitiesTotal+$EquityTotal+$PL;
?>
<div class="content-wrapper">
  
    <div class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col">
                    <div class="card card-primary card-outline">
                        <div class="card-header">
                            <h5 class="m-0"><?php echo $pageTitle; ?> </h5>
                        </div>
                        <div class="card-body">
                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th colspan="4">Balance Sheet Statement</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="bg-dark">

                                        <th>Liabilities</th>
                                        <th class="col-2">Amount</th>
                                        <th>Assets</th>
                                        <th class="col-2">Amount</th>
                                    </tr>

                                    <tr class="bg-light">
                                        <td colspan="2">
                                            <?php $this->acc->showTable($LiabilitiesAccounts); ?>
                                            <?php $this->acc->showTable($EquityAccounts); ?>
                                        </td>
                                        <td colspan="2">
                                            <?php $this->acc->showTable($AssetsAccounts, false); ?>
                                        </td>

                                    </tr>



                                </tbody>
                                <tfoot>



                                    <tr class="bg-light">

                                        <th>Net Profit:</th>
                                        <th><?php echo myCurrency($PL); ?></th>
                                        <th></th>
                                        <th></th>
                                    </tr>
                                    <tr class="bg-light">

                                        <th>Total Liabilities:</th>
                                        <th><?php echo myCurrency($LiabilitiesTotal); ?></th>
                                        <th>Total Assets: </th>
                                        <th><?php echo myCurrency($AssetsTotal); ?></th>
                                    </tr>

                                </tfoot>

                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>