<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

if(!empty($search_from)){ $from = display_true_date(get_true_date($search_from)); }else{ $from = ''; }
if(!empty($search_to)){ $to = display_true_date(get_true_date($search_to)); }else{ $to = ''; }

?>
<table style="width: 100%; margin: 15px 0px; background: #fff;">
    <tr style="margin: 10px 0px;">
        <td style="width: 50%;"><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 echo print_lang($app_lang,'roznamcha_report'); ?></strong></td>
        <td style="width: 50%;"><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>

<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 style="background: #e2e0e0 !important;">
                                    <td colspan="3" style="background: #e2e0e0 !important; border: none !important; background: #e2e0e0 !important; text-align: right; font-size: 18px;"><strong><?= print_lang($app_lang,'debit_part'); ?></strong></td>
                                    <td style="background: #e2e0e0 !important; border: none !important;"></td>
                                    <td style="background: #e2e0e0 !important; border: none !important; <?php if($app_direction == 'ltr'){echo 'border-right: 1px solid #c3c3c3 !important;';}?>"></td>
                                    <!-- Credit -->
                                    <td style="background: #e2e0e0 !important; border: none !important; <?php if($app_direction == 'rtl'){echo 'border-right: 1px solid #c3c3c3 !important;';}?>"></td>
                                    <td colspan="2" style="background: #e2e0e0 !important; border: none !important; font-size: 18px;"><strong style="position: relative;left: 50px;"><?= print_lang($app_lang,'credit_part'); ?></strong></td>
                                </tr>
                                <tr style="background: #e2e0e0 !important;">
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'sr_#'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'date'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'dr_account'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'dr_amount'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'dr_narration'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'cr_account'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'cr_amount'); ?></th>
                                    <th style="background: #e2e0e0 !important;" class="text-center"><?= print_lang($app_lang,'cr_narration'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                    $i = 1;
                                    $total_receiving_amount = array();
                                    $total_payment_amount = array();
                                    foreach($pageData as $row){ ?>
                                    <tr class="text-center">
                                        <td><?= $i++; ?></td>
                                        <td><?= display_true_date($row['journal_date']); ?></td>
                                        <td><?= array_key_exists($row['receiving_account'], $accounts) ? $accounts[$row['receiving_account']]['name'] : NULL; ?></td>
                                        <td><?= array_key_exists($row['receiving_currency'], $currencies) ? $currencies[$row['receiving_currency']]['symbol'] : NULL; ?><?= amount_number_format($row['receiving_amount']); $total_receiving_amount[] = $row['receiving_amount']; ?></td>
                                        <td><?= $row['receiving_narration']; ?></td>
                                        <td><?= array_key_exists($row['payment_account'], $accounts) ? $accounts[$row['payment_account']]['name'] : NULL; ?></td>
                                        <td><?= array_key_exists($row['payment_currency'], $currencies) ? $currencies[$row['payment_currency']]['symbol'] : NULL; ?><?= amount_number_format($row['payment_amount']); $total_payment_amount[] = $row['payment_amount']; ?></td>
                                        <td><?= $row['payment_narration']; ?></td>
                                    </tr>
                                <?php } ?>
                                    <tr class="text-center">
                                        <td><strong><?= $i++; ?></strong></td>
                                        <td><strong><?= display_true_date(date('Y-m-d')); ?></strong></td>
                                        <td><strong><?= print_lang($app_lang,'total'); ?></strong></td>
                                        <td><strong><?= amount_number_format(array_sum($total_receiving_amount)); ?></strong> </td>
                                        <td></td>
                                        <td></td>
                                        <td><strong><?= amount_number_format(array_sum($total_payment_amount)); ?></strong> </td>
                                        <td></td>
                                    </tr>
                            </tbody>
                        </table>    
                    </div>

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