<style type="text/css">
::-webkit-scrollbar {
    display: none;
}
#dynamic-content-container{background: #fff;}
    .navbar-default.navbar-static-side{display: none !important;}
    #page-wrapper{margin: 0px !important; padding: 0 !important;}
    .row.border-bottom{display: none !important;}
    .footer.fixed{display: none;}
    .ibox-content{padding: 0 !important;}
    body {
    -webkit-print-color-adjust:exact;
    background: #fff;
    }

</style>

<table style="width: 100%; background: #fff;">
    <tr>
        <td><img style="width: 100%; height: 200px;" src="<?= get_branch_image('report'); ?>"></td>
    </tr>
</table>

<?php

$currency_symbol = array_key_exists($search_currency, $currencies) ? $currencies[$search_currency]['symbol'] : NULL;
$account_name = array_key_exists($search_account, $accounts) ? $accounts[$search_account]['name'] : NULL;
if(!empty($search_from)){$from = display_true_date($search_from);}else{$from = '';}
if(!empty($search_to)){$to = display_true_date($search_to);}else{$to = '';}

?>

<table style="width: 100%; margin: 15px 0px; background: #fff;">
    <tr style="margin: 10px 0px;">
        <td style="width: 25%;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= strtoupper(print_lang($app_lang,'type')); ?>:</strong></span> <strong style="font-size: 14px;"><?php if(!empty($search_type)){echo ucfirst($search_type).' '.print_lang($app_lang,'statement');} ?></strong></td>
        <td style="width: 25%;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= strtoupper(print_lang($app_lang,'currency')); ?>:</strong></span> <strong style="font-size: 14px;"><?php if(!empty($search_currency)){echo ucfirst($currency_symbol);} ?></strong></td>
        <td style="width: 25%;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= strtoupper(print_lang($app_lang,'account')); ?>:</strong></span> <strong style="font-size: 14px;"><?php if(!empty($search_account)){echo ucfirst($account_name);} ?></strong></td>
        <td style="width: 25%;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= strtoupper(print_lang($app_lang,'date')); ?>:</strong></span> <strong style="font-size: 14px;"><?php if(!empty($from)){echo $from."  -  ".$to;}else{echo print_lang($app_lang,'overall');} ?></strong></td>
    </tr>
</table>

<table style="width: 100%; margin: 5px 0px; background: #fff;">
    <tr style="margin: 5px 0px;">
        <td style="width: 33.3%; text-align: center;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= print_lang($app_lang,'ledger_overall_debit'); ?>:</strong></span> <strong style="font-size: 14px;"><?php echo amount_number_format( $totals_Data['parent_ledger_stats']['debit'] ); ?></strong></td>
        <td style="width: 33.3%; text-align: center;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= print_lang($app_lang,'ledger_overall_credit'); ?>:</strong></span> <strong style="font-size: 14px;"><?php echo amount_number_format( $totals_Data['parent_ledger_stats']['credit'] ); ?></strong></td>
        <td style="width: 33.3%; text-align: center;"><span style="color: #bb0d0d !important; padding: 4px;"><strong style="color: #bb0d0d !important; font-size: 15px;"><?= print_lang($app_lang,'ledger_overall_balance'); ?>:</strong></span> <strong style="font-size: 14px;"><?php echo amount_number_format( $totals_Data['parent_ledger_stats']['balance'] ); ?></strong></td>
    </tr>
</table>

<hr>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th class="text-center"><?= print_lang($app_lang,'sr_#'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'date'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'narration'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'debit'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'credit'); ?></th>
                                    <th class="text-center"><?= print_lang($app_lang,'balance'); ?></th>
                                    <th class="text-center" style="min-width: 150px; max-width: 150px;"><?= print_lang($app_lang,'remarks'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $debits = array();
                                $credits = array();
                                ?>
                                <?php $i = 1; foreach($pageData['child_records'] as $row){ ?>

                                    <?php
                                    $color = array_key_exists($row['uid'],$accounts_cross_checks) ? empty($accounts_cross_checks[$row['uid']]['color']) ? '#ffffff' : $accounts_cross_checks[$row['uid']]['color'] : '#ffffff';
                                    $remarks = array_key_exists($row['uid'],$accounts_cross_checks) ? $accounts_cross_checks[$row['uid']]['remarks'] : NULL;
                                    $is_checked = array_key_exists($row['uid'],$accounts_cross_checks) ? $accounts_cross_checks[$row['uid']]['is_checked'] : 'no';
                                    ?>

                                    <tr class="text-center" style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;">
                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;"><?= $i++; ?></td>
                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;"><?= display_true_date(date('Y-m-d h:i:s A',strtotime($row['date']))); ?></td>
                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;"><?= strip_tags($row['narration']); ?></td>
                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;"><?= round_decimels_digits($row['debit']); $debits[] = $row['debit']; ?></td>
                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;"><?= round_decimels_digits($row['credit']); $credits[] = $row['credit']; ?></td>
                                        
                                        <?php
                                        $row_balance = get_ledgers_balance($debits,$credits);
                                        $balance_color = ($row_balance >= 0) ? '#2B9C1B' : '#ec4758';
                                        ?>

                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important; color: <?= $balance_color; ?> !important;"><?= amount_number_format($row_balance); ?></td>
                                        <td style="background-color: <?= $color ?> !important; -webkit-background-color: <?= $color ?> !important;" class="accounts-report-remarks-col"><?= $remarks; ?></td>
                                    </tr>

                                <?php } ?>
                                <tr class="text-center">
                                    <td><?= $i++; ?></td>
                                    <td><?= display_true_date(date('Y-m-d h:i:s A')); ?></td>
                                    <td><?= print_lang($app_lang,'total'); ?></td>
                                    <td><strong><?= round_decimels_digits($pageData['parent_ledger_stats']['debit']); ?></strong></td>
                                    <td><strong><?= round_decimels_digits($pageData['parent_ledger_stats']['credit']); ?></strong></td>
                                    
                                    <?php
                                    $total_balance = get_ledgers_balance($debits,$credits);
                                    $balance_color = ($total_balance >= 0) ? '#2B9C1B' : '#ec4758';
                                    ?>

                                    <td style="color: <?= $balance_color; ?> !important;"><?= amount_number_format($total_balance); ?></td>
                                    <td></td>
                                </tr>
                            </tbody>
                        </table>    
                    </div>

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