<!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="list-print-container">
        <table class="header-pp" >
            <tr><td colspan="4" class="s2 text-center"><?= $branch->CompanyName; ?></td></tr>
            <tr><td colspan="4" class="s2 text-center"><?= $branch->BranchName; ?></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($BeginDate1)) ?> - <?= date('d M Y', strtotime($EndDate1)) ?> s/d <?= date('d M Y', strtotime($BeginDate2)) ?> - <?= date('d M Y', strtotime($EndDate2)) ?></td></tr>
            <tr><td>&nbsp;</td></tr>
        </table>

       <table class="content-pp">
            <tr>
                <th class="s4 text-left" align="left" width="100">Description</th>
                <th class="s4 text-right" align="right">
                    <?php echo date('d M Y', strtotime($BeginDate1)).' - '.date('d M Y', strtotime($EndDate1));?>
                </th>
                <th class="s4 text-right" align="right">
                     <?php echo date('d M Y', strtotime($BeginDate2)).' - '.date('d M Y', strtotime($EndDate2));?>
                </th>
                <th class="s4" align="right">Variance</th>
                <th class="s4" align="right">%Var.</th>
            </tr>

             <!-- REVENUE -->
            <tr>
                <td align='left' class="s5 text-left" colspan="5"><span><b>OPERATING REVENUE</b></span></td>
            </tr>
    
            <?php for($x=0;$x<count($arr_revenue);$x++):?>
           <tr class="over_report">
                <td class="s5 text-left" align='Left' width="250"><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'].'/'.$BeginDate1.'/'.$EndDate2;?>','icon-journal')"><?php echo $arr_revenue[$x]['Account_Name'];?></a></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_revenue[$x]['balance1'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_revenue[$x]['balance1'])?></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_revenue[$x]['balance2'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_revenue[$x]['balance2'])?></td>
                <?php 
                    $variance   =  $arr_revenue[$x]['balance2'] - $arr_revenue[$x]['balance1'];
                    $var_persen =  @($variance / $arr_revenue[$x]['balance2']) * 100;
                ?> 
                <td class="s5 text-right" align='right'><?= number_format(abs($variance),"2",",",".")?></td>
                <td class="s5 text-right" align='right'><?= number_format(abs($var_persen),"2",",",".").'%';?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td colspan="1"></td>
                <td colspan="4"><hr/></td>
            </tr>

            <tr class="over_report">
                <td class="s5 text-left" align='Left'><b>Total Operating Revenue</b></td>
                <td class="s5 text-right" align='right' style="<?= ($revenue_group1 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($revenue_group1)?></b></td>
                <td class="s5 text-right" align='right' style="<?= ($revenue_group2 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($revenue_group2)?></b></td>
                 <?php 
                    $variance   =  ($revenue_group2 - $revenue_group1);
                    $var_persen =  @($variance / $revenue_group2) * 100;
                ?>
                <td class="s5 text-right" align='right' style="<?= ($variance < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($variance) ?></b></span></td> 
                <td class="s5 text-right" align='right'><b><?= number_format(abs($var_persen),"2",",",".").'%';?></b></td>
            </tr>

            <tr height='15'><td colspan="5"></td></tr>

            <!-- COGM -->
            <tr>
                <td align='left' class="s5 text-left" colspan="5"><span><b>COGM / COGS (Cost of Goods Made)</b></span></td>
            </tr>
    
            <?php for($x=0;$x<count($arr_cogm);$x++):?>
            <tr class="over_report">
                <td class="s5 text-left" align='Left' width="250"><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'].'/'.$BeginDate1.'/'.$EndDate2;?>','icon-journal')"><?php echo $arr_cogm[$x]['Account_Name'];?></a></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_cogm[$x]['balance1'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_cogm[$x]['balance1'])?></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_cogm[$x]['balance2'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_cogm[$x]['balance2'])?></td>
                <?php 
                    $variance   =  $arr_cogm[$x]['balance2'] - $arr_cogm[$x]['balance1'];
                    $var_persen =  @($variance / $arr_cogm[$x]['balance2']) * 100;
                ?> 
                <td class="s5 text-right" align='right'><?= number_format(abs($variance),"2",",",".")?></td>
                <td class="s5 text-right" align='right'><?= number_format(abs($var_persen),"2",",",".").'%';?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td colspan="1"></td>
                <td colspan="4"><hr/></td>
            </tr>

            <tr class="over_report">
                <td class="s5 text-left" align='Left'><b>Total Operating Cogm</b></td>
                <td class="s5 text-right" align='right' style="<?= ($cogm_group1 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($cogm_group1)?></b></td>
                <td class="s5 text-right" align='right' style="<?= ($cogm_group2 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($cogm_group2)?></b></td>
                 <?php 
                    $variance   =  ($cogm_group2- $cogm_group1);
                    $var_persen =  @($variance / $cogm_group2) * 100;
                ?>
                <td class="s5 text-right" align='right' style="<?= ($variance < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($variance) ?></b></span></td> 
                <td class="s5 text-right" align='right'><b><?= number_format(abs($var_persen),"2",",",".").'%';?></b></td>
            </tr>

            <tr height='15'><td colspan="5"></td></tr>

            <!-- EXPENSE  -->
            <tr>
                <td align='left' class="s5 text-left" colspan="5"><span><b>OPERATING EXPENSES</b></span></td>
            </tr>
    
            <?php for($x=0;$x<count($arr_expense);$x++):?>
            <tr class="over_report">
                <td class="s5 text-left" align='Left' width="250"><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'].'/'.$BeginDate1.'/'.$EndDate2;?>','icon-journal')"><?php echo $arr_expense[$x]['Account_Name'];?></a></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_expense[$x]['balance1'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_expense[$x]['balance1'])?></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_expense[$x]['balance2'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_expense[$x]['balance2'])?></td>
                <?php 
                    $variance   =  $arr_expense[$x]['balance2'] - $arr_expense[$x]['balance1'];
                    $var_persen =  @($variance / $arr_expense[$x]['balance2']) * 100;
                ?> 
                <td class="s5 text-right" align='right'><?= number_format(abs($variance),"2",",",".")?></td>
                <td class="s5 text-right" align='right'><?= number_format(abs($var_persen),"2",",",".").'%';?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td colspan="1"></td>
                <td colspan="4"><hr/></td>
            </tr>

            <tr class="over_report">
                <td class="s5 text-left" align='Left'><b>Total Operating Expense</b></td>
                <td class="s5 text-right" align='right' style="<?= ($expense_group1 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($expense_group1)?></b></td>
                <td class="s5 text-right" align='right' style="<?= ($expense_group2 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($expense_group2)?></b></td>
                 <?php 
                    $variance   =  ($expense_group2- $expense_group1);
                    $var_persen =  @($variance / $expense_group2) * 100;
                ?>
                <td class="s5 text-right" align='right' style="<?= ($variance < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($variance) ?></b></span></td> 
                <td class="s5 text-right" align='right'><b><?= number_format(abs($var_persen),"2",",",".").'%';?></b></td>
            </tr>

            <tr height='15'><td colspan="5"></td></tr>

            <!-- OTHER REVENUE  -->
            <tr>
                <td align='left' class="s5 text-left" colspan="5"><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 text-left" align='Left' width="250"><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'].'/'.$BeginDate1.'/'.$EndDate2;?>','icon-journal')"><?php echo $arr_other_revenue[$x]['Account_Name'];?></a></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_other_revenue[$x]['balance1'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_other_revenue[$x]['balance1'])?></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_other_revenue[$x]['balance2'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_other_revenue[$x]['balance2'])?></td>
                <?php 
                    $variance   =  $arr_other_revenue[$x]['balance2'] - $arr_other_revenue[$x]['balance1'];
                    $var_persen =  @($variance / $arr_other_revenue[$x]['balance2']) * 100;
                ?> 
                <td class="s5 text-right" align='right'><?= number_format(abs($variance),"2",",",".")?></td>
                <td class="s5 text-right" align='right'><?= number_format(abs($var_persen),"2",",",".").'%';?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td colspan="1"></td>
                <td colspan="4"><hr/></td>
            </tr>

            <tr class="over_report">
                <td class="s5 text-left" align='Left'><b>Total Operating Other Revenue</b></td>
                <td class="s5 text-right" align='right' style="<?= ($other_revenue_group1 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($other_revenue_group1)?></b></td>
                <td class="s5 text-right" align='right' style="<?= ($other_revenue_group2 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($other_revenue_group2)?></b></td>
                 <?php 
                    $variance   =  ($other_revenue_group2- $other_revenue_group1);
                    $var_persen =  @($variance / $other_revenue_group2) * 100;
                ?>
                <td class="s5 text-right" align='right' style="<?= ($variance < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($variance) ?></b></span></td> 
                <td class="s5 text-right" align='right'><b><?= number_format(abs($var_persen),"2",",",".").'%';?></b></td>
            </tr>

            <tr height='15'><td colspan="5"></td></tr>

            <!-- OTHER EXPENSE  -->
            <tr>
                <td align='left' class="s5 text-left" colspan="5"><span><b>OPERATING OTHER EXPENSE</b></span></td>
            </tr>
    
            <?php for($x=0;$x<count($arr_other_expense);$x++):?>
            <tr class="over_report">
                <td class="s5 text-left" align='Left' width="250"><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'].'/'.$BeginDate1.'/'.$EndDate2;?>','icon-journal')"><?php echo $arr_other_expense[$x]['Account_Name'];?></a></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_other_expense[$x]['balance1'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_other_expense[$x]['balance1'])?></td>
                <td class="s5 text-right" align='right' style="<?= ($arr_other_expense[$x]['balance2'] < 0)? 'color:#FF6666' : '' ?>"><?= formatRp_acc($arr_other_expense[$x]['balance2'])?></td>
                <?php 
                    $variance   =  $arr_other_expense[$x]['balance2'] - $arr_other_expense[$x]['balance1'];
                    $var_persen =  @($variance / $arr_other_expense[$x]['balance2']) * 100;
                ?> 
                <td class="s5 text-right" align='right'><?= number_format(abs($variance),"2",",",".")?></td>
                <td class="s5 text-right" align='right'><?= number_format(abs($var_persen),"2",",",".").'%';?></td>
            </tr>
            <?php endfor;?>

            <tr>
                <td colspan="1"></td>
                <td colspan="4"><hr/></td>
            </tr>

            <tr class="over_report">
                <td class="s5 text-left" align='Left' width="250"><b>Total Operating Other Expense</b></td>
                <td class="s5 text-right" align='right' style="<?= ($other_expense_group1 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($other_expense_group1)?></b></td>
                <td class="s5 text-right" align='right' style="<?= ($other_expense_group2 < 0)? 'color:#FF6666' : '' ?>"><b><?= formatRp_acc($other_expense_group2)?></b></td>
                 <?php 
                    $variance   =  ($other_expense_group2- abs($other_expense_group1));
                    $var_persen =  @($variance / $other_expense_group2) * 100;
                ?>
                <td class="s5 text-right" align='right' style="<?= ($variance < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($variance) ?></b></span></td> 
                <td class="s5 text-right" align='right'><b><?= number_format(abs($var_persen),"2",",",".").'%';?></b></td>
            </tr>
            
            <tr height='30'><td colspan="5"></td></tr>

            <tr>
                <td colspan="1"></td>
                <td colspan="4"><hr/></td>
            </tr>

            <tr class="over_report">
                <td class="s4 text-left" align='Left' width="250"><b>NET PROFIT / LOSS</b></td>
                <td class="s4 text-right" align='right' style="<?= ($PL1 < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($PL1) ?></b></span></td>
                <td class="s4 text-right" align='right' style="<?= ($PL2 < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($PL2) ?></b></span></td>
                <?php 
                    $variance   =  ($PL2 - abs($PL1));
                    $var_persen =  @($variance / $PL2) * 100;
                ?>
                <td class="s4 text-right" align='right' style="<?= ($variance < 0)? 'color:#FF6666' : '' ?>"><span><b><?= formatRp_acc($variance) ?></b></span></td> 
                <td class="s4 text-right" align='right'><b><?= number_format(abs($var_persen),"2",",",".").'%';?></b></td>
            </tr>

            <tr height='50' colspan='5'><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  = $("#list-print-container").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>
