<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Journal <?php echo $menu_label ?></title>
    </head>

    <body style="width:auto; margin:auto">
        <div style="padding:24.5px"> </div>
        <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr><td colspan="8" class="s2"><?php echo $detail[0]->CompanyName ?></td></tr>
            <tr><td colspan="8" class="s2"><?php echo $detail[0]->BranchName; ?></td></tr>
            <tr><td colspan="8" class="s1">General Ledger History</td></tr>
            <tr><td colspan="8" class="s2">From : <?= $begin_date ?>  s/d  <?= $end_date ?></td></tr>
            <tr><td colspan="8" class="s1">&nbsp;</td></tr>
    
            <tr>
		<td width="120" class="s4">Transaction No</td>
		<td width="50"  class="s4" hidden>Trans_Type</td>
		<td width="80"  class="s4">Account No</td>
		<td width="130" class="s4">Account Name</td>
		<td width="60"  class="s4" align="right">Debit (Base)</td>
		<td width="10"  class="s4" align="right"></td>
		<td width="60"  class="s4" align="right">Credit (Base)</td>
		<td width="60"  class="s4" align="right">Debit (Prime)</td>
		<td width="60"  class="s4" align="right">Credit (Prime)</td>
            </tr>  

            <tr>
                <!--<td class="s3" colspan="4"> <?php echo 'Transaction Number : ';?> <?php echo $detail[0]->Journal_Number; ?> <?php echo 'Description : ';?> <?php echo $detail[0]->Journal_Desc; ?> </td>-->
            </tr>

            <tr height="7px">
                <td colspan="4"></td>                    
            </tr>
                    
            <?php 
            $saldo_status       = 0;
            $total_saldo_debet  = 0;
            $total_saldo_credit = 0;
            ?>

            <?php foreach($detail as $row){
                if($row->Saldo_Credit > 0) {                    
                    if($saldo_status == 0) {?>
                        <tr height="5px">
                            <td colspan="4"></td>                    
                        </tr>
                    <?php } 

                    $saldo_status   = 1; 
                    $debit_prime    = 0;
                    $credit_prime   = abs($row->Amount_Currency);
                } 
                else { 
                    $debit_prime    = abs($row->Amount_Currency);
                    $credit_prime   = 0;
                }?>
                    
                <tr height="15px">
                    <td class="s3"><a href='#' onClick="trasanction_load('<?= $row->Trans_Type?>', '<?= $row->Journal_Number ?>');"><b><?php echo $row->Journal_Number; ?></b></a></td>
                    <td class="s3" hidden><?php echo $row->Trans_Type ?></td>
                    <td class="s3"><?php echo $row->Account_Number ?></td>
                    <td class="s5"><?php echo $row->Account_Name ?></td>
                    <td class="s5" align="right"><?php echo number_format($row->Saldo_Debet,"2",",","."); ?></td>
                    <td class="s5" align="right"></td>
                    <td class="s5" align="right"><?php echo number_format($row->Saldo_Credit,"2",",","."); ?></td>
                    
                    <td class="s5" align="right"><?php echo number_format($debit_prime,"2",",","."); ?></td>
                    <td class="s5" align="right"><?php echo number_format($credit_prime,"2",",","."); ?></td>
                </tr> 
                
            <?php 
                $total_saldo_debet  = $total_saldo_debet + $row->Saldo_Debet;
                $total_saldo_credit = $total_saldo_credit + $row->Saldo_Credit;            
            } ?>
	
            <td class="s5" align="right" colspan="3">&nbsp;</td>
            
            <td><hr/></td>
            <td width='20'>&nbsp;</td>
            <td><hr/></td>

            <tr>
                <td align="right" colspan="3">&nbsp;</td>
                <td class="s5" align="right"><b><?php echo number_format($total_saldo_debet,"2",",","."); ?></b></td>
                <td></td>
                <td class="s5" align="right"><b><?php echo number_format($total_saldo_credit,"2",",","."); ?></b></td>
            </tr>
        </table>
    </body>
    
    <script type="text/javascript">
        function trasanction_load(InitialCharTrans, Trans_Number){
            var Tbl;
            var TabTitle;
            var LinkTo;

            switch(InitialCharTrans){
                case 'PInv':
                    Tbl         = 'at_purchaseinvoice';
                    TabTitle    = 'Purchase Invoice';
                    LinkTo      = 'list/purchases_invoice';
                    break;
                    
                case 'PPay':
                    Tbl         = 'at_purchasepayment';
                    TabTitle    = 'Purchase Payment';
                    LinkTo      = 'list/purchases_payment';
                    break;

                case 'SInv':
                    Tbl         = 'at_salesinvoice';
                    TabTitle    = 'Sales Invoice';
                    LinkTo      = 'list/sales_invoice';
                    break;
                    
                case 'SRec':
                    Tbl         = 'at_salesreceipt';
                    TabTitle    = 'Sales Receipt';
                    LinkTo      = 'list/sales_receipt';
                    break;

                case 'EBon':
                    Tbl         = 'at_expensecashbon';
                    TabTitle    = 'Expense Cash-Bon';
                    LinkTo      = 'activities/purchases_expense_cashbon';
                    break;

                case 'CPay':
                    Tbl         = 'at_cashpayment';
                    TabTitle    = 'Payment <= 250.000';
                    LinkTo      = 'list/payment';
                    break;

                case 'CDep':
                    Tbl         = 'at_cashdeposit';
                    TabTitle    = 'Deposit';
                    LinkTo      = 'activities/deposit';
                    break;

                case 'BSweep':
                    Tbl         = 'at_banksweep';
                    TabTitle    = 'Sweep BANK';
                    LinkTo      = 'activities/swift_bank';
                    break;

                case 'ADebt':
                    Tbl         = 'at_afiliasidebt';
                    TabTitle    = 'Piutang Afiliasi';
                    LinkTo      = 'list/piutang_afiliasi';
                    break;

                case 'AIns':
                    Tbl         = 'at_afiliasiinstallment';
                    TabTitle    = 'Payment Afiliasi';
                    LinkTo      = 'list/payment_afiliasi';
                    break;

                case 'EDebt':
                    Tbl         = 'at_employeedebt';
                    TabTitle    = 'Piutang Karyawan';
                    LinkTo      = 'activities/piutang_karyawan';
                    break;

                case 'EIns':
                    Tbl         = 'at_employeeinstallment';
                    TabTitle    = 'Payment Karyawan';
                    LinkTo      = 'activities/payment_karyawan';
                    break;

                case 'TCash':
                    Tbl         = 'at_transfercash';
                    TabTitle    = 'Transfer To Petty Cash';
                    LinkTo      = 'list/transaksi_antar_kas';
                    break;

                default:
                    Tbl         = '';
                    TabTitle    = '';
                    LinkTo      = '';
            }

            parent.tab_edit(TabTitle, LinkTo, 'icon-edit', 'edit', Trans_Number);
        }
    </script>
</html>

