<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/custom/css/print_new.css">
<style type="text/css">
    .ahover:hover{
        cursor: pointer;
        color:blue;
    }
</style>
</head>
<body>
    <div id="form-header" data-options="region:'north',border:false">
        <input type="hidden" name="hdn_begin_date" id="hdn_begin_date"/>
        <input type="hidden" name="hdn_end_date" id="hdn_end_date"/>
        
        <div id="form-header-wrapper">
          <table cellpadding="0" cellspacing="0" width="100%">
              <tr>
                  <td  valign="middle">
                      <a href="#" class="easyui-linkbutton noPrint" data-options="plain:true,iconCls:'icon-print'" onClick="print_detail()">Print</a>
                   </td>
              </tr>
          </table>  
        </div>     
        <div id="print-container-balancesheet">

            <table border="0" cellspacing="1" cellpadding="3" data-options="fit:true" style="margin:0 auto;padding:0;">

                <tr><td colspan="2" class="s2"><?= $branch->CompanyName ?></td></tr>
                <tr><td colspan="2" class="s1">Balance Sheet Report</td></tr>
                <tr><td colspan="2" class="s2">Period : <?= $month ?> <?= $year ?></td></tr>
                <tr><td>&nbsp;</td></tr>

                <tr>
                    <td width="400" align='left' class="s4">Description</td>
                    <td width="120" align='right' class="s4">Saldo Amount</td>
                </tr>
                
                <?php for($x=0;$x<count($group);$x++):?>

                    <?php $count_x = count($group[$x]) - 2;?>

                    <?php for($i=0;$i<$count_x;$i++):?>

                        <?php $count_i = count($group[$x][$i]) - 2;?>

                        <?php for($n=0;$n<$count_i;$n++):?>

                            <?php if($group[$x]['Acc_Type_Name'] == 'Liability'):?>

                                <tr>
                                    <td></td>
                                    <td align="right"><hr></td>
                                </tr>

                                <tr class="over_report">
                                    <td width="400" align='left' class="s5"><span style="font-weight:800;">Total Assets</span></td>
                                    <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($total_asset < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($total_asset);?></span></td>
                                </tr>

                                 <tr>
                                    <td height="15" colspan="2"></td>
                                </tr>

                            <?php endif;?>

                            <?php if($group[$x][$i][$n]['AccountLevel'] == 0):?>

                                <tr class="over_report">
                                    <td width="400" align='left' class="s5" colspan="2"><span class="ahover" style="font-weight:700;" onclick="open_transaction_balancesheet('<?=$group[$x][$i][$n]['AccountNumber'];?>','<?=$bulan;?>','<?=$tahun;?>')"><?= $group[$x][$i][$n]['AccountName'];?></span></td>
        
                                </tr>

                            <?php elseif($group[$x][$i][$n]['AccountLevel'] == 1):?>

                                <?php if($i == 0 and $n == 0):?>
                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5" colspan="2"><span style="font-weight:600;margin-left:5px"><?= $group[$x]['Acc_Type_Name'];?></span></td>
                                    </tr>
                                <?php endif;?>

                                <tr class="over_report">
                                    <td width="400" align='left' class="s5"><span class="ahover" style="font-weight:600;margin-left:20px" onclick="open_transaction_balancesheet('<?=$group[$x][$i][$n]['AccountNumber'];?>','<?=$bulan;?>','<?=$tahun;?>')"><?= $group[$x][$i][$n]['AccountName'];?></span></td>
                                    <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x][$i][$n]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x][$i][$n]['balance']);?></span></td>
                                </tr>

                                <?php if( ($i+1) == $count_x and ($n+1) == $count_i):?>

                                    <tr>
                                        <td></td>
                                        <td align="right"><hr></td>
                                    </tr>

                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5"><span style="font-weight:600;margin-left:5px">Total <?= $group[$x]['Acc_Type_Name'];?></span></td>
                                        <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x]['total_acc_type'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x]['total_acc_type']);?></span></td>
                                    </tr>

                                    <tr>
                                        <td height="15" colspan="2"></td>
                                    </tr>

                                <?php endif;?>

                            <?php elseif($group[$x][$i][$n]['AccountLevel'] == 2):?>
                                
                                <?php if($i == 0 and $n == 0):?>
                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5" colspan="2"><span style="font-weight:600;margin-left:10px"><?= $group[$x]['Acc_Type_Name'];?></span></td>
                                    </tr>
                                <?php endif;?>

                               <tr class="over_report">
                                    <td width="400" align='left' class="s5"><span class="ahover" style="font-weight:500;margin-left:30px" onclick="open_transaction_balancesheet('<?=$group[$x][$i][$n]['AccountNumber'];?>','<?=$bulan;?>','<?=$tahun;?>')"><?= $group[$x][$i][$n]['AccountName'];?></span></td>
                                    <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x][$i][$n]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x][$i][$n]['balance']);?></span></td>
                                </tr>

                                <?php if( ($i+1) == $count_x and ($n+1) == $count_i):?>

                                    <tr>
                                        <td></td>
                                        <td align="right"><hr></td>
                                    </tr>

                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5"><span class="ahover" style="font-weight:600;margin-left:10px" >Total <?= $group[$x]['Acc_Type_Name'];?></span></td>
                                        <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x]['total_acc_type'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x]['total_acc_type']);?></span></td>
                                    </tr>

                                    <tr>
                                        <td height="15" colspan="2"></td>
                                    </tr>

                                <?php endif;?>
                                
                            <?php elseif($group[$x][$i][$n]['AccountLevel'] == 3):?>
                               
                                <?php if($i == 0 and $n == 0):?>
                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5" colspan="2"><span style="font-weight:600;margin-left:15px"><?= $group[$x]['Acc_Type_Name'];?></span></td>
                                    </tr>
                                <?php endif;?>

                                <tr class="over_report">
                                    <td width="400" align='left' class="s5"><span class="ahover" style="font-weight:400;margin-left:40px" onclick="open_transaction_balancesheet('<?=$group[$x][$i][$n]['AccountNumber'];?>','<?=$bulan;?>','<?=$tahun;?>')"><?= $group[$x][$i][$n]['AccountName'];?></span></td>
                                    <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x][$i][$n]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x][$i][$n]['balance']);?></span></td>
                                </tr>

                                <?php if( ($i+1) == $count_x and ($n+1) == $count_i):?>

                                    <tr>
                                        <td></td>
                                        <td align="right"><hr></td>
                                    </tr>

                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5"><span style="font-weight:600;margin-left:15px">Total  <?= $group[$x]['Acc_Type_Name'];?></span></td>
                                        <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x]['total_acc_type'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x]['total_acc_type']);?></span></td>
                                    </tr>

                                    <tr>
                                        <td height="15" colspan="2"></td>
                                    </tr>
                                    
                                <?php endif;?>
                                
                            <?php else:?>

                                <?php if($i == 0 and $n == 0):?>
                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5" colspan="2"><span style="font-weight:600;margin-left:20px"><?= $group[$x]['Acc_Type_Name'];?></span></td>
                                    </tr>
                                <?php endif;?>
                                
                                <tr class="over_report">
                                    <td width="400" align='left' class="s5"><span class="ahover" style="font-weight:normal;margin-left:50px" onclick="open_transaction_balancesheet('<?=$group[$x][$i][$n]['AccountNumber'];?>','<?=$bulan;?>','<?=$tahun;?>')"><?= $group[$x][$i][$n]['AccountName'];?></span></td>
                                    <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x][$i][$n]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x][$i][$n]['balance']);?></span></td>
                                </tr>

                                <?php if( ($i+1) == $count_x and ($n+1) == $count_i):?>

                                    <tr>
                                        <td></td>
                                        <td align="right"><hr></td>
                                    </tr>

                                    <tr class="over_report">
                                        <td width="400" align='left' class="s5"><span style="font-weight:600;margin-left:20px">Total <?= $group[$x]['Acc_Type_Name'];?></span></td>
                                        <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($group[$x]['total_acc_type'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($group[$x]['total_acc_type']);?></span></td>
                                    </tr>

                                    <tr>
                                        <td height="15" colspan="2"></td>
                                    </tr>
                                <?php endif;?>
                               
                            <?php endif;?>

                        <?php endfor;?>

                    <?php endfor;?>

                <?php endfor;?>

                <tr>
                    <td></td>
                    <td align="right"><hr></td>
                </tr>

                <tr class="over_report">
                    <td width="400" align='left' class="s5"><span style="font-weight:800;">Total Liability</span></td>
                    <td width="120" align='right' class="s5"><span style="font-weight:700;<?= ($total_liability < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($total_liability);?></span></td>
                </tr>

                 <tr>
                    <td height="15" colspan="2"></td>
                </tr>

                <tr height='50' colspan="2"><td></td></tr>            
            </table>
        </div>
    </div>

</body>
</html>

<script type="text/javascript">

function open_transaction_balancesheet(AccountNumber,bulan,tahun){
    parent.tab_add('Journal Balance Sheet Report', '<?= "report/index_financial_statement/open_journal_balance_sheet_consolidation_report/" ?>'+ AccountNumber + '/' + bulan + '/' + tahun,'icon-journal');
}

function print_detail(){
  //var opt_print   = $("input[type='radio'][name='opt_print']:checked").val();
  var data_print  = $("#print-container-balancesheet").html();
  Popup(data_print);
  
}

function Popup(data) 
{
    var mywindow = window.open('', 'print-container', 'height=528,width=700');
    var css = css_print_lama();
    mywindow.document.write('<html><head><title>Print Detail</title>');
    mywindow.document.write(css);
    mywindow.document.write('</head><body >');
    mywindow.document.write(data);
    mywindow.document.write('</body></html>');

    mywindow.document.close(); // necessary for IE >= 10
    mywindow.focus(); // necessary for IE >= 10

    mywindow.print();
    mywindow.close();

    return true;
}

</script>
