<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title><?php echo $menu_label ?></title>
  <link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/custom/css/print_new.css">
</head>
<style type="text/css">
  @media print {
    .noPrint { display: none; }
  }
</style>
<body>
    <div id="form-header" data-options="region:'north',border:false">
        <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>

    <div id="print-container-pp">
        <table class="header-pp">
            <tr><td colspan="4" class="s2 text-center"><?= $branch->CompanyName; ?></td></tr>
            <tr><td colspan="4" class="s1 text-center">Profit &amp; Loss Report</td></tr>
            <tr><td colspan="4" class="s2 text-center">From : <?= date('d M Y', strtotime($BeginDate)) ?>  s/d  <?= date('d M Y', strtotime($EndDate)) ?></td></tr>
            <tr><td>&nbsp;</td></tr>
        </table>

        <table class="content-pp">
            <tr>
                <td width="40" align='left' class="s4">Description</td>
                <td width="10" align='right' class="s4">Saldo Amount</td>
            
            </tr>

            <tr>
                <td width="40"  align='left' class="s5"><span><b>OPERATING REVENUE</b></span></td>
            </tr>

            <!-- REVENUE -->
            <?php for($x=0;$x<count($arr_revenue);$x++):?>
             <tr class="over_report">
                <td class="s5" align='Left'><a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true" onClick="parent.tab_add('View Journal Profit & Loss','<?php echo 'report/index_financial_statement/open_journal_transaction/'.$arr_revenue[$x]['Account_Number'].'/'.$BeginDate.'/'.$EndDate.'/TRUE';?>','icon-journal')"><?php echo $arr_revenue[$x]['Account_Name'];?></a></td>
                <td class="s5" align='right' style="<?= ($arr_revenue[$x]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_revenue[$x]['balance'])?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
             <tr class="over_report">
                <td class="s5" align='Left'><b>Total Operating Revenue</b></td>
                <td class="s5" align='right' style="<?= ($revenue_group < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($revenue_group)?></b></td>
            </tr>

            <tr height='15'><td></td></tr>

            <tr>
                <td width="40"  align='left' class="s3"><span><b>COGM / COGS (Cost of Goods Made)</b></span></td>
            </tr>
            
            <!-- COGM/COGS -->
            <?php for($x=0;$x<count($arr_cogm);$x++):?>
             <tr class="over_report">
                <td class="s5" align='Left'><a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true" onClick="parent.tab_add('View Journal Profit & Loss','<?php echo 'report/index_financial_statement/open_journal_transaction/'.$arr_cogm[$x]['Account_Number'].'/'.$BeginDate.'/'.$EndDate.'/TRUE';?>','icon-journal')"><?php echo $arr_cogm[$x]['Account_Name'];?></a></td>
                <td class="s5" align='right' style="<?= ($arr_cogm[$x]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_cogm[$x]['balance'])?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
             <tr class="over_report">
                <td class="s5" align='Left'><b>Total COGM/COGS</b></td>
                <td class="s5" align='right' style="<?= ($cogm_group < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($cogm_group)?></b></td>
            </tr>
            
            <tr height='15'><td></td></tr>

            <!-- Expneses -->
            <tr>
                <td width="40"  align='left' class="s5"><span><b>OPERATING EXPENSES</b></span></td>
            </tr>

            <?php for($x=0;$x<count($arr_expense);$x++):?>
             <tr class="over_report">
                <td class="s5" align='Left'><a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true" onClick="parent.tab_add('View Journal Profit & Loss','<?php echo 'report/index_financial_statement/open_journal_transaction/'.$arr_expense[$x]['Account_Number'].'/'.$BeginDate.'/'.$EndDate.'/TRUE';?>','icon-journal')"><?php echo $arr_expense[$x]['Account_Name'];?></a></td>
                <td class="s5" align='right' style="<?= ($arr_expense[$x]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_expense[$x]['balance'])?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>

             <tr class="over_report">
                <td class="s5" align='Left'><b>Total Operating Expenses</b></td>
                <td class="s5" align='right' style="<?= ($expense_group < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($expense_group)?></b></td>
            </tr>
            
            <tr height='15'><td></td></tr>
            
            <!-- Other Revenue -->
            <tr>
                <td width="40"  align='left' class="s5"><span><b>OPERATING OTHER REVENUE</b></span></td>
            </tr>

            <?php for($x=0;$x<count($arr_other_revenue);$x++):?>
             <tr class="over_report">
                <td class="s5" align='Left'><a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true" onClick="parent.tab_add('View Journal Profit & Loss','<?php echo 'report/index_financial_statement/open_journal_transaction/'.$arr_other_revenue[$x]['Account_Number'].'/'.$BeginDate.'/'.$EndDate.'/TRUE';?>','icon-journal')"><?php echo $arr_other_revenue[$x]['Account_Name'];?></a></td>
               <td class="s5" align='right' style="<?= ($arr_other_revenue[$x]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_other_revenue[$x]['balance'])?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
             <tr class="over_report">
                <td class="s5" align='Left'><b>Total Operating Other Revenue</b></td>
                <td class="s5" align='right' style="<?= ($other_revenue_group < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($other_revenue_group)?></b></td>
            </tr>
            
            <tr height='15'><td></td></tr>
        
            <!-- Other Expense -->
            <tr>
                <td width="40"  align='left' class="s5"><span><b>OPERATING OTHER EXPENSES</b></span></td>
            </tr>
            
            <?php for($x=0;$x<count($arr_other_expense);$x++):?>
             <tr class="over_report">
                <td class="s5" align='Left'><a href="#" class="easyui-linkbutton" id="preview-linkbutton" data-options="plain:true" onClick="parent.tab_add('View Journal Profit & Loss','<?php echo 'report/index_financial_statement/open_journal_transaction/'.$arr_other_expense[$x]['Account_Number'].'/'.$BeginDate.'/'.$EndDate.'/TRUE';?>','icon-journal')"><?php echo $arr_other_expense[$x]['Account_Name'];?></a></td>
                <td class="s5" align='right' style="<?= ($arr_other_expense[$x]['balance'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_other_expense[$x]['balance'])?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
             <tr class="over_report">
                <td class="s5" align='Left'><b>Total Operating Other Expenses</b></td>
                <td class="s5" align='right' style="<?= ($other_expense_group < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($other_expense_group)?></b></td>
            </tr>

            <tr height='30'><td></td></tr>
            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
             <tr class="over_report">
                <td class="s4" align='Left'><b>NET PROFIT / LOSS</b></td>
                <td class="s4" align='right' style="<?= ($PL < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($PL) ?></b></span></td>
            </tr>
 
            <tr height='50'><td></td></tr>
        </table>
    </div>
    
    <script type="text/javascript">
       function print_detail(){
          //var opt_print   = $("input[type='radio'][name='opt_print']:checked").val();
          var data_print  = $("#print-container-pp").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>
</body>
</html>
