<hr class="thick-line" style="clear:both;">
<?php
foreach($data_perkara->result() as $row_perkara){
?>

<div id='content' style="margin: 5px;margin-top:10px; ">
    <table width="800" id='infoPerkara' style="font-size:14px; margin: 5px;" >
        <col  width="25%" />
        <col  width="75%" />
        <tbody>
            <tr><td><a href="<?php echo $back;?>">Kembali</a></td></tr>
            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Nomor Eksekusi</td>
                <td><?php echo $row_perkara->eksekusi_nomor_perkara;?></td>
            </tr>
            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Tanggal Permohonan</td>
                <td><?php echo $this->tanggalhelper->convertDayDate($row_perkara->permohonan_eksekusi);?></td>
            </tr>
            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Pemohon Eksekusi</td>
                <td><?php echo $row_perkara->pemohon_eksekusi;?></td>
            </tr>

            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Prodeo</td>
                <td><?php if($row_perkara->prodeo_eksekusi==1){
                        echo "Ya";
                    }else{
                        echo "Tidak";
                    }
                    ?></td>
            </tr>

        </tbody>
    </table>


<?php

    $sisa = 0;
    $debet = 0;
    $kredit = 0;
    $count = $biaya_perkara->num_rows();
    $repeat = false;
    $tahapan = 0;
    $stop = false;
    echo "<div class=\"cssTable\">";
    if($count>0){
        $i=0;
        foreach($biaya_perkara->result() as $row){
            
            if($tahapan == $row->tahapan_id){
                $stop = false;
            }else{

                if($tahapan!=0){
                    echo "<tr>";
                            echo "<th align=\"right\" bgcolor=\"#008C4B\" colspan=\"3\" style=\"text-align: center;\"><font color=\"#fff\">Total</td>";
                            echo "<th align=\"right\" bgcolor=\"#008C4B\" style=\"text-align: right;\" ><font color=\"#fff\">Rp. ".number_format($debet, 0, ',', '.')."</td>";
                            echo "<th class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"><font color=\"#fff\">Rp. ".number_format($kredit, 0, ',', '.')."</td>";
                            echo "<th class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"><font color=\"#fff\">Rp. ".number_format($sisa, 0, ',', '.')."</td>";
                            echo "<th class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"></td>";
                        echo "</tr>";
                    echo "</table>";
                }
            }

            if($tahapan==0 OR $tahapan != $row->tahapan_id){
                $tahapan = $row->tahapan_id;
                $repeat = true;
                $sisa = 0;
                $debet = 0;
                $kredit = 0;
                
            }
            
            if($repeat){
                    if($tahapan!=10){
                        #echo "<div style='padding-top:20px;'></div>";
                    }
                    if($tahapan==10){
                        $tahapannama = " Tingkat Pertama";
                    }elseif($tahapan==20){
                        $tahapannama = " Tingkat Banding";
                    }elseif($tahapan==30){
                        $tahapannama = " Tingkat Kasasi";
                    }elseif($tahapan==40){
                        $tahapannama = " Peninjauan Kembali";
                    }elseif($tahapan==51){
                        $tahapannama = " Eksekusi Hak Tanggungan";
                    }
                    
                    echo "<table id=\"tableStatusPutusan\" width=90%>";
                        echo "<tr>";
                            echo "<td width='5%' class=\"no\" rowspan=\"2\">No</td>";
                            echo "<td width='15%' class=\"dates\" rowspan=\"2\">Tanggal Transaksi</td>";
                            echo "<td width='35%' class=\"uraian\" rowspan=\"2\">Uraian</td>";
                            echo "<td width='36%' colspan=\"3\">Jumlah</td>";
                            echo "<td width='10%' class=\"ket\" rowspan=\"2\">Keterangan</td>";
                            echo "<td width='5%' class=\"ket\" rowspan=\"2\">Aksi</td>";
                        echo "</tr>";
                        
                        echo "<tr>";
                            echo "<td width='12%' bgcolor=\"#008C4B\" style=\"text-align: center;\" class=\"info\"><font color=\"#fff\">Pemasukan</td>";
                            echo "<td width='12%' bgcolor=\"#008C4B\" style=\"text-align: center;\" class=\"info\"><font color=\"#fff\">Pengeluaran</td>";
                            echo "<td width='12%' bgcolor=\"#008C4B\" style=\"text-align: center;\" class=\"info\"><font color=\"#fff\">Sisa</td>";
                        echo "</tr>";
                $repeat = false;
                $stop = false;
            }
            if($row->jenis_transaksi ==1){
                $sisa = $sisa + $row->jumlah;
                $debet = $debet + $row->jumlah;
            }elseif($row->jenis_transaksi == -1){
                $sisa = $sisa - $row->jumlah;
                $kredit = $kredit + $row->jumlah;
            }
                      echo "<tr>";
                            echo "<td class=\"no\" align='center'>".($i+1)."</td>";
                            echo "<td class=\"dates\">".$this->tanggalhelper->convertDayDate($row->tanggal_transaksi)."</td>";
                            echo "<td>".$row->uraian."</td>";
                                if($row->jenis_transaksi ==1){
                                    echo "<td style=\"text-align: right;\">Rp. ".number_format($row->jumlah, 0, ',', '.')."</td>";
                                    echo "<td></td>";
                                    echo "<td style=\"text-align: right;\">Rp. ".number_format($sisa, 0, ',', '.')."</td>";
                                    echo "<td class=\"info\" style=\"text-align: left;\"></td>";
                                    echo "<td class=\"info\"style=\"text-align: center;\">";?><a href="#" onClick="popup_form('<?php echo base_url('add_info_biaya_ht/'.base64_encode($this->encrypt->encode($row_perkara->ht_id)).'/'.base64_encode($this->encrypt->encode($row_perkara->alur_perkara_id)).'/'.base64_encode($this->encrypt->encode($row->id)).'/'.base64_encode($this->encrypt->encode('edit')));?>')">[edit]</a></td><?php
                                }elseif($row->jenis_transaksi == -1){
                                    echo "<td></td>";
                                    echo "<td style=\"text-align: right;\">Rp. ".number_format($row->jumlah, 0, ',', '.')."</td>";
                                    echo "<td style=\"text-align: right;\">Rp. ".number_format($sisa, 0, ',', '.')."</td>";
                                    echo "<td class=\"info\" style=\"text-align: left;\"></td>";
                                    echo "<td class=\"info\"style=\"text-align: center;\">";?><a href="#" onClick="popup_form('<?php echo base_url('add_info_biaya_ht/'.base64_encode($this->encrypt->encode($row_perkara->ht_id)).'/'.base64_encode($this->encrypt->encode($row_perkara->alur_perkara_id)).'/'.base64_encode($this->encrypt->encode($row->id)).'/'.base64_encode($this->encrypt->encode('edit')));?>')">[edit]</a></td><?php
                                }
                            echo "<td>".$row->keterangan."</td>";
                      echo "</tr>";
                            $i++;
            if(($i==$count OR $stop == true)){
                    echo "<tr>";
                            echo "<td align=\"right\" bgcolor=\"#008C4B\" colspan=\"3\" style=\"text-align: center;\"><font color=\"#fff\">Total</td>";
                            echo "<td align=\"right\" bgcolor=\"#008C4B\" style=\"text-align: right;\" ><font color=\"#fff\">Rp. ".number_format($debet, 0, ',', '.')."</td>";
                            echo "<td class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"><font color=\"#fff\">Rp. ".number_format($kredit, 0, ',', '.')."</td>";
                            echo "<td class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"><font color=\"#fff\">Rp. ".number_format($sisa, 0, ',', '.')."</td>";
                            echo "<td class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"></td>";
                            echo "<td class=\"info\" bgcolor=\"#008C4B\" style=\"text-align: right;\"></td>";
                        echo "</tr>";
                    ?>    
                        <tr>
                        <td colspan="8">
                        <a href="#" onClick="popup_form('<?php echo base_url('add_info_biaya_ht/'.base64_encode($this->encrypt->encode($row_perkara->ht_id)).'/'.base64_encode($this->encrypt->encode($row_perkara->alur_perkara_id)));?>')">Tambah</a>
                        </td>
                    <?php echo "</table>";
                    
                $repeat = false;
            }
        }
    }
    echo "</div>";
?>

</div>

</div>
<?php }?>