<hr class="thick-line" style="clear:both;">
<?php
foreach($data_perkara->result() as $row_perkara){
?>
<link href="<?php echo base_url();?>resources/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="<?php echo base_url('resources/css/AdminLTE.min.css') ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<div id='content' style="margin: 5px;margin-top:10px; ">

    <table width="100%" id='infoPerkara' style="font-size:14px; margin: 5px;" >
        <col  width="15%" />
        <col  width="85%" />
        <tbody>
            <tr>
                <td style="padding-left:2px" colspan="3">
                    <a href="<?php echo $back;?>" class="btn btn-default btn-sm"><i class="fa fa-reply-all"></i> Kembali</a>
                    |
                    <a href="#" onClick="popup_form('<?php echo base_url('c_edit_jurnal_prodeo/popup_edit_jurnal/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id)).'/'.base64_encode($this->encrypt->encode($tahapanidperkara)));?>')" class="btn btn-default btn-sm">Ubah Status Prodeo</a>
                </td>            
            </tr>        
            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Nomor Perkara</td>
                <td colspan='3'><?php echo $row_perkara->nomor_perkara;?></td>
                
            </tr>
            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Tanggal Pendaftaran</td>
                <td colspan='3'><?php echo $this->tanggalhelper->convertDayDate($row_perkara->tanggal_pendaftaran);?></td>
            </tr>
            <?php
            if($row_perkara->alur_perkara_id==1 && $row_perkara->tahapan_terakhir_id<20){
              echo "
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Penggugat</td>
                        <td colspan='3'>".$row_perkara->pihak1_text."</td>
                    </tr>
            
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Tergugat</td>
                        <td colspan='3'>".$row_perkara->pihak2_text."</td>
                    </tr>";
            }elseif($row_perkara->alur_perkara_id==2 && $row_perkara->tahapan_terakhir_id<20){
              echo "<tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Pemohon</td>
                        <td colspan='3'>".$row_perkara->pihak1_text."</td>
                    </tr>";

            }elseif(($row_perkara->alur_perkara_id==1 || $row_perkara->alur_perkara_id==15) && $row_perkara->tahapan_terakhir_id==20){
              echo "
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Penggugat</td>
                        <td colspan='3'>".$row_perkara->pihak1_text."</td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Tergugat</td>
                        <td colspan='3'>".$row_perkara->pihak2_text."</td>
                    </tr>";

            }elseif(($row_perkara->alur_perkara_id==1 || $row_perkara->alur_perkara_id==2 || $row_perkara->alur_perkara_id==15 || $row_perkara->alur_perkara_id==16) && $row_perkara->tahapan_terakhir_id==30){
              echo "
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Penggugat</td>
                        <td colspan='3'>".$row_perkara->pihak1_text."</td>
                    </tr>
            
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Tergugat</td>
                        <td colspan='3'>".$row_perkara->pihak2_text."</td>
                    </tr>";

            }elseif(($row_perkara->alur_perkara_id==1 || $row_perkara->alur_perkara_id==2 || $row_perkara->alur_perkara_id==15 || $row_perkara->alur_perkara_id==16) && $row_perkara->tahapan_terakhir_id==40){
              echo "
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Tergugat</td>
                        <td colspan='3'>".$row_perkara->pihak2_text."</td>
                    </tr>
                    <tr>
                        <td bgcolor='#008C4B'><font color='#fff'>Penggugat</td>
                        <td colspan='3'>".$row_perkara->pihak1_text."</td>
                    </tr>";

            }

            ?>
            <tr>
                <td bgcolor='#008C4B'><font color='#fff'>Prodeo</td>
                <td><?php echo $is_prodeo;?></td>
				<td style="text-align:right;">
                    <?php 
                    if ($alurperkaraid==1 OR $alurperkaraid==2 OR $alurperkaraid==7 OR $alurperkaraid==8 OR $alurperkaraid==15 OR $alurperkaraid==16){
						echo '<a href="#" style="color:white;margin-right:5px;" onClick="popup_form(\''.base_url('c_template_agama_perdata_pemberitahuan_putusan/popup_sisa_panjar/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id))).'\')" class="btn btn-warning btn-sm"><i class="fa fa-print"></i> Pengembalian Sisa Panjar</a>';                        
                    } ?>
                </td>
                <td style="text-align:right;">
                    <?php 
                    if ($alurperkaraid==1 OR $alurperkaraid==2 OR $alurperkaraid==7 OR $alurperkaraid==8 OR $alurperkaraid==15 OR $alurperkaraid==16){
						 echo '<a href="#" style="color:white;margin-right:5px;" onClick="popup_form(\''.base_url('c_template_agama_perdata_pemberitahuan_putusan/popup_teguran_panjar/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id))).'\')" class="btn btn-warning btn-sm"><i class="fa fa-print"></i> Teguran Biaya</a>';                         
                    } ?>
                </td>
                <td style="padding-right:30px">
                    <?php 
                    if ($alurperkaraid==1 OR $alurperkaraid==2 OR $alurperkaraid==7 OR $alurperkaraid==8 OR $alurperkaraid==15 OR $alurperkaraid==16){                        
                        echo '<a href="#" style="color:white" onClick="popup_form(\''.base_url('c_template_agama_perdata_skum/popup_bukti_bayar/'.base64_encode($this->encrypt->encode($tahapanidperkara)).'/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id))).'\')" class="btn btn-warning btn-sm"><i class="fa fa-print"></i> Bukti Bayar - SKUM</a>';                        
                    } ?>
                </td>
				<td style="padding-right:30px">
                    <?php 
                    if ( $alurperkaraid==9 OR $alurperkaraid==10 OR $alurperkaraid==11){                       
                        echo '<a href="#" style="color:white" onClick="popup_form(\''.base_url('c_template_tun_skum/popup_bukti_bayar/'.base64_encode($this->encrypt->encode($tahapanidperkara)).'/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id))).'\')" class="btn btn-warning btn-sm"><i class="fa fa-print"></i> Bukti Bayar - SKUM TUN</a>';                        
                    } ?>
                </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=\"4\" 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>";
                            if ($this->authorization->HasRuleEditJurnalBiaya())
                                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==50){
                        $tahapannama = " Eksekusi";
                    }
                    
                    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='15%' class=\"dates\" rowspan=\"2\">Pihak</td>";
                            echo "<td width='36%' colspan=\"3\">Jumlah</td>";
                            echo "<td width='10%' class=\"ket\" rowspan=\"2\">Keterangan</td>";
                            if ($this->authorization->HasRuleEditJurnalBiaya())
                                echo "<td width='5%' class=\"ket\" rowspan=\"2\">Aksi</td>";
                        echo "</tr>";
                        
                        echo "<tr>";
                            echo "<td width='12%' bgcolor=\"#008C4B\" style=\"text-align: center;border-left: 1px solid white;\" 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->pihak_id==NULL){
                               if($tahapan<20 AND $row_perkara->alur_perkara_id!=2 AND $row_perkara->alur_perkara_id!=16 AND $row_perkara->jenis_perkara_id!=346){
                                    echo "<td>Penggugat</td>";
                                }else{
                                    echo "<td>Pemohon</td>";
                                }
                            }elseif($row->pihak_ke==1){
                               echo "<td>".$row->nama."(P)</td>";
                            }elseif($row->pihak_ke==2){
                               echo "<td>".$row->nama."(T)</td>";                                
                            }elseif($row->pihak_ke==3){
                               echo "<td>".$row->nama."(I)</td>";                                
                            }elseif($row->pihak_ke==4){
                               echo "<td>".$row->nama."(TT)</td>";                                
                            }

                                if($row->jenis_transaksi ==1){
                                    echo "<td style=\"text-align: right;\">Rp. ".number_format($row->jumlah, 0, ',', '.')."</td>";
                                    echo "<td></td>";                                   
                                }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;\">".$row->keterangan;
                                if(in_array($row->kategori_id,array(4,5,6))){
                                    if($row->keterangan!=''){
                                        echo "<br>";
                                    }
                                    if($row->jurusita!=''){
                                        echo "(".$row->jurusita.")";
                                    }
                                }
                                echo "</td>";
                    if ($this->authorization->HasRuleEditJurnalBiaya()){
                        echo "<td class=\"info\"style=\"text-align: center;\">";?><a href="#" onClick="popup_form('<?php echo base_url('add_info_biaya/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id)).'/'.base64_encode($this->encrypt->encode($row_perkara->alur_perkara_id)).'/'.base64_encode($this->encrypt->encode($tahapan_id)).'/'.base64_encode($this->encrypt->encode($row->id)).'/'.base64_encode($this->encrypt->encode('edit')));?>')">[edit]</a>
                        </td>
                        <?php
                    }
                    echo "</tr>";
                            $i++;
            if(($i==$count OR $stop == true)){
                    echo "<tr>";
                            echo "<td align=\"right\" bgcolor=\"#008C4B\" colspan=\"4\" 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>
                        <?php
                        if ($this->authorization->HasRuleAddJurnalBiaya()){
                        ?>
                        <td colspan="9">
                        <a href="#" onClick="popup_form('<?php echo base_url('add_info_biaya/'.base64_encode($this->encrypt->encode($row_perkara->perkara_id)).'/'.base64_encode($this->encrypt->encode($row_perkara->alur_perkara_id)).'/'.base64_encode($this->encrypt->encode($tahapan_id)));?>')">Tambah</a>
                        </td>
                    <?php }
                    echo "</table>";
                    
                $repeat = false;
            }
        }
    }
    echo "</div>";
?>

</div>

</div>
<?php }?>

<script type="text/javascript">
function kembali(){
    javascript:window.history.go(-1);
}
</script>