<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head><title>Profit & Loos Reporting</title></head>
    
    <body style="width:auto; margin:auto">
        <div style="padding:2px">
            <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'" onClick="link_print('report/view_to_report/profit_loss_report/<?php foreach($Revenue as $row){echo $row->Journal_Number;}?>');">Print</a>
        </div><br />
		
        <table width="40%" border="0" cellspacing="0" cellpadding="0" style="margin-left:350px; margin-top:10px;margin-bottom:150px;" >
            <tr><td colspan="4" class="s0"><?= $company[0]->CompanyName; ?></td></tr>
            <tr><td colspan="4" class="s1">Profit & Loos Report</td></tr>
            <tr><td colspan="4" class="s2">From</td></tr>
            <tr><td>&nbsp;</td></tr>
        </table>

        <table width="40%" border="0" cellspacing="1" cellpadding="1" style="margin-left:350px;margin-top:10px;" style="width:auto; margin:auto">
            <tr>
                <td width="40"  align='center' class="s4">Description</td>
                <td width="10" align='center' class="s4">Saldo Amount</td>
            </td>

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

            <!-- REVENUE -->
            <?php 
            $total_saldo    = 0;
            $sigma_saldo    = 0;
            
            foreach($Revenue as $row){
                if($row->Total_Debet > 0){
                    $saldo_amount = $row->Total_Debet;
                }
                else{
                    $saldo_amount = $row->Total_Credit;
                }
                
                $total_saldo = $total_saldo + $saldo_amount;
                ?>
            
                <tr>
                    <td class="s5" align='Left' style='padding-left:15px'><?= $row->Account_Name; ?></td>
                    <td class="s5" align='right'><a href="<?php echo site_url('report/index_to_report/profit_loss_report'); ?>"><?= number_format($saldo_amount,"2",",",".")?></a> </td>
                </tr>
            <?php 
            } 
            $sigma_saldo    = $sigma_saldo + $total_saldo;
            ?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
            <tr>
                <td class="s5" align='Left'><b>Total Operating Revenue</b></td>
                <td class="s5" align='right'><?= number_format($total_saldo,"2",",",".")?></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 
            $total_saldo    = 0;
            
            foreach($COGM as $row){
                if($row->Total_Debet > 0){
                    $saldo_amount = $row->Total_Debet;
                }
                else{
                    $saldo_amount = $row->Total_Credit;
                }
                
                $total_saldo = $total_saldo + $saldo_amount;
                ?>
            
                <tr>
                    <td class="s5" align='Left' style='padding-left:15px'><?= $row->Account_Name; ?></td>
                    <td class="s5" align='right'><a href="<?php echo site_url('report/index_to_report/profit_loss_report'); ?>"><?= number_format($saldo_amount,"2",",",".")?></a> </td>
                </tr>
            <?php 
            } 
            $sigma_saldo    = $sigma_saldo + $total_saldo;
            ?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
            <tr>
                <td class="s5" align='Left'><b>Total COGM/COGS</b></td>
                <td class="s5" align='right'><?= number_format($total_saldo,"2",",",".")?></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 
            $total_saldo    = 0;
            
            foreach($Expense as $row){
                if($row->Total_Debet > 0){
                    $saldo_amount = $row->Total_Debet;
                }
                else{
                    $saldo_amount = $row->Total_Credit;
                }
                
                $total_saldo = $total_saldo + $saldo_amount;
                ?>
            
                <tr>
                    <td class="s5" align='Left' style='padding-left:15px'><?= $row->Account_Name; ?></td>
                    <td class="s5" align='right'><a href="<?php echo site_url('report/index_to_report/profit_loss_report'); ?>"><?= number_format($saldo_amount,"2",",",".")?></a> </td>
                </tr>
            <?php 
            } 
            $sigma_saldo    = $sigma_saldo + $total_saldo;
            ?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
            <tr>
                <td class="s5" align='Left'><b>Total Operating Expenses</b></td>
                <td class="s5" align='right'><?= number_format($total_saldo,"2",",",".")?></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 
            $total_saldo    = 0;
            
            foreach($OtherRevenue as $row){
                if($row->Total_Debet > 0){
                    $saldo_amount = $row->Total_Debet;
                }
                else{
                    $saldo_amount = $row->Total_Credit;
                }
                
                $total_saldo = $total_saldo + $saldo_amount;
                ?>
            
                <tr>
                    <td class="s5" align='Left' style='padding-left:15px'><?= $row->Account_Name; ?></td>
                    <td class="s5" align='right'><a href="<?php echo site_url('report/index_to_report/profit_loss_report'); ?>"><?= number_format($saldo_amount,"2",",",".")?></a> </td>
                </tr>
            <?php 
            } 
            $sigma_saldo    = $sigma_saldo + $total_saldo;
            ?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
            <tr>
                <td class="s5" align='Left'><b>Total Operating Other Revenue</b></td>
                <td class="s5" align='right'><?= number_format($total_saldo,"2",",",".")?></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 
            $total_saldo    = 0;
            
            foreach($OtherExpense as $row){
                if($row->Total_Debet > 0){
                    $saldo_amount = $row->Total_Debet;
                }
                else{
                    $saldo_amount = $row->Total_Credit;
                }
                
                $total_saldo = $total_saldo + $saldo_amount;
                ?>
            
                <tr>
                    <td class="s5" align='Left' style='padding-left:15px'><?= $row->Account_Name; ?></td>
                    <td class="s5" align='right'><a href="<?php echo site_url('report/index_to_report/profit_loss_report'); ?>"><?= number_format($saldo_amount,"2",",",".")?></a> </td>
                </tr>
            <?php 
            } 
            $sigma_saldo    = $sigma_saldo + $total_saldo;
            ?>

            <tr>
                <td></td>
                <td><hr/></td>
            </tr>
            
            <tr>
                <td class="s5" align='Left'><b>Total Operating Other Expenses</b></td>
                <td class="s5" align='right'><?= number_format($total_saldo,"2",",",".")?></td>
            </tr>
    </table>
    </body>
</html>