<?PHP
include("../index.cma.db.php");
include("../index.globalconfig.php");
include("../index.embed.php");
$query = "Select * from $mytable"; 
$result = mysql_query($query); 
if($row = mysql_fetch_array($result)){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><?PHP echo $satker; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK href="images/index.css" rel="stylesheet" type="text/css">
<LINK href="images/menu.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	background-image: url();
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<script language="javascript" type="text/javascript">
<!--
/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}
// -->
</script></head>

<body>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#FF6600"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td bgcolor="#FF0000"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="700" height="50">
              <param name="movie" value="../themes/top_merah.swf">
              <param name="quality" value="high">
              <embed src="../themes/top_merah.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="50"></embed>
            </object></td>
          </tr>
        </table>
        <table width="100%"  border="0" cellspacing="6" cellpadding="6">
          <tr>
            <td><span class="style1">SELAMAT DATANG OPERATOR PIDUM </span></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><div class="drop">
                <ul class="drop_menu">
                  <li><a href='index.php'><strong>HOME</strong></a>
                      <ul>
 

                        <li><a href='index.php?g=beranda&i=index'>BERANDA & NOTIFIKASI</a></li>
                      
                      </ul>
                  </li>
                 
                
                  <li><a href='../index.logout.php'><strong>LOGOUT</strong></a> </li>
                </ul>
            </div></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td bgcolor="#FFF0F0"><table width="100%"  border="0" cellspacing="8" cellpadding="8">
              <tr>
                <td bgcolor="#FFCCCC"><strong>PRATUT</strong></td>
              </tr>
              <tr>
                <td><table width="100%"  border="0" cellspacing="8" cellpadding="8">
                  <tr>
                    <td><?
include("../index.cma.db.php");
$mytable = "$tahun_before";
$edisi = substr($mytable,15,4);
$page2 = $_GET["page2"];
if(empty($action))
{
if (empty($order)) $order =  2;
if (empty($page2))  $page2  =  1;
if (empty($hits))  $hits  = 500;
$start = $hits*($page2-1);
$query = "SELECT * FROM $mytable";
$res = mysql_query("$query"); 
$xnum = mysql_num_rows($res);
$stw2 = (int)($xnum/$hits);
if ($xnum%$hits > 0) {$stw2++;}
$np = $page2+1;
$pp = $page2-1;
if ($page2 == 1) { $pp=1; }
if ($np > $stw2) { $np = $stw2;} 
echo "TOTAL PERKARA <strong>$edisi</strong> SEBANYAK <strong>$xnum</strong> TERSANGKA | ";
for ($i=1;$i<=$stw2;$i++) {if($page2==$i){
echo "<b> HAL $i |</b> ";} 
else{echo "<a href=\"index.php?g=pratut&i=index&page2=$i#tab1\"> $i |</a>";}}
print ('<br><br>');
$query  = "SELECT * FROM $mytable ";
if(!empty($squery)) { $query .= "LIKE \"%$squery%\" ";}
$query .= "ORDER BY uid DESC LIMIT $start,$hits";
$res = mysql_query($query);
print ('<table class="tableWithFloatingHeader" width="100%"  border="0" cellspacing="1" cellpadding="1" bgcolor="#B05800">
        <thead><tr>
<th width="23%"><strong>NAMA TERSANGKA <br>SURAT DARI<br>PASAL</strong></th>
<th width="7%"><strong>Tanggal SPDP</strong></th>
<th width="7%"><strong>P17<br>29 Hari</strong></th>
<th width="7%"><strong>SPDP Kembali<br>29 Hari</strong></th>
<th width="7%"><strong>Berkas Tahap 1</strong></th>
<th width="7%"><strong>Status Berkas<br>7 Hari</strong></th>
<th width="7%"><strong>P18</strong></th>
<th width="7%"><strong>P19</strong></th>
<th width="7%"><strong>Status P19<br>14 Hari</strong></th>
<th width="7%"><strong>Tanggal P21</strong></th>
<th width="7%"><strong>Status P21<br>29 Hari </strong></th>
<th width="7%"><strong>Tanggal SKPP/P20/DIVERSI</strong></th>
</tr></thead>');
 $x=0;
  while($row = mysql_fetch_array($res))
  {
   $x++;
   if($x==2) {$barva = "FF6600";$x=0;} else {$barva = "FFFFCC";$x=1;}
   
//---------kolom 1
print ('<tbody><tr bgcolor=#'.$barva.'><td><b>'.$row['spdp_namatsk'] .'</b><br>');
$polisi1 = $row['spdp_dari'];
 mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$sql=mysql_query("select * from tab_polisi where p_nomor = '$polisi1'");
while ($data=mysql_fetch_array($sql)){
print(''.$data['p_nama'].'');
}
print ('<br><i>'. $row['spdp_pasal'].'</i><br>Jaksa:');
$jaksa1 = $row['p16_jaksa1'];
 mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$sql=mysql_query("select * from tab_personil where daftar_pegid = '$jaksa1'");
while ($data=mysql_fetch_array($sql)){
print('<b>'.$data['daftar_nama'].'</b>');
}
print ('</td>');
 //---------kolom 2
print ('<td><center>'. $row['spdp_terimatgl'].'</center>');
$tgl1 = $row['spdp_terimatgl']; $tgl2 = date("d/m/Y"); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = $jd2 - $jd1;
$timelate = "29"; //BATAS TELAT
$selisih2 = $selisih - $timelate;
if ($row['berkas_tahap1tgl'] == "" && $row['berkas_tahap1p17tgl'] == "" && $row['berkas_sp3'] == "") { //LIMITASI
if($selisih>=29) { 
$id = $row['uid'];
print ('<center><img src="images/idcred.gif" width="32" height="16">');
print ('<br>Lewat: '.$selisih2.'Hr<br><font color="red"><b>Terbitkan P17:<br>'. $row['spdp_telattgl'].'</b></font>');
echo "<br><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p17\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>SET P17</b></a></center>";
$query = "UPDATE $mytable SET late_spdp = '3' WHERE uid = '$id'";
$result = mysql_query($query);
}
elseif($selisih<29){ 
print ('<center><img src="images/idcgreen.gif" width="32" height="16">');
print ('<br>Jalan: '.$selisih.'Hr</center>');
} 
} 
print ('</td>');
print ('<td><center>'. $row['berkas_tahap1p17tgl'].'</center></td>');
//------kolom 3
print ('<td>');
$id = $row['uid'];
if ($row['berkas_tahap1p17tgl'] !== "" && $row['berkas_kembali'] !== "1" && $row['berkas_tahap1tgl'] == "") {
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap1p17tgl']; //tgl p18
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
$timelate = "29";
$selisih2 = $selisih - $timelate;
//if ($row['berkas_tahap1p18tgl'] == "") {
if($selisih>=$timelate ) { 
$id = $row['uid'];
print ('<center><img src="images/idcred.gif" width="32" height="16" alt="KEMBALIKAN SPDP">');
print ('<br>Lewat : '.$selisih.'Hr<br><font color="red"><b>Kembali<br>SPDP:<br>'. $row['berkas_telattgl'].'</b></font></center>');
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=spdpkembali\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\"><b>Warning Kembalikan SPDP</b></a></center>";
$query = "UPDATE $mytable SET late_spdpkembali = '3' WHERE uid = '$id'";
$result = mysql_query($query);
}
elseif($selisih<$timelate ){ 
print ('<center><img src="images/idcgreen.gif" width="32" height="16">');
print ('<br>Jalan: '.$selisih.'Hr</center>');
}
}
elseif ($row['berkas_kembali'] == "1" && $row['berkas_tahap1tgl'] == "") {
print ('<center>BUAT SURAT SPDP KEMBALI</center>');
}
print ('</td>');
//------Kolom 4
print ('<td>');
if ($row['berkas_tahap1tgl'] !== "") {print '<center>'.$row['berkas_tahap1tgl'].'</center>';} 
elseif ($row['berkas_tahap1tgl'] == "") {
echo "<br><center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=berkastahap1\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST</b></a></center>";
print ('</td>');
}
//------Kolom 5
print ('<td>');
if ($row['berkas_tahap1tgl'] !== "" && $row['berkas_tahap1p18tgl'] == "" && $row['berkas_tahap1p21tgl'] == "" && $row['berkas_p20'] == ""){
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap1tgl']; //tgl p18
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
$timelate = "7";
$selisih2 = $selisih - $timelate;
//if ($row['berkas_tahap1p18tgl'] == "") {
if($selisih>=7) { 
$id = $row['uid'];
print ('<center><img src="images/idcred.gif" width="32" height="16" alt="TENTUKAN SIKAP P21"></center>');
print ('<br><center>Lewat : '.$selisih.'Hr dr'.$timelate.' hr <br><font color="red"><b>Terbitkan P21:<br>'. $row['berkas_telattgl'].'</b></font></center>');
echo "<br><center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p21\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST</b></a></center>";
$query = "UPDATE $mytable SET late_berkas = '3' WHERE uid = '$id'";
//$query = "UPDATE $mytable SET late_spdpkembali = '3' WHERE uid = '$id'";
//$query = "UPDATE $mytable SET late_spdp = '0', late_p21 = '0', late_berkas = '0', late_spdpkembali = '0' WHERE uid = '$id'"; //UNTUK PENYETINGAN SEMENTARA JIKA SUDAH BERI TANDA //
$result = mysql_query($query);

}
elseif($selisih<7){ 
print ('<center><img src="images/idcgreen.gif" width="32" height="16">');
print ('<br>Run: '.$selisih.'day(s) From '.$timelate.'days</center>');
//FUNGSI POST p18
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p18\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST P18</b></a></center>";
}}
elseif ($row['berkas_tahap1p18tgl'] !== "" or $row['berkas_tahap1p21tgl'] !== "" or $row['berkas_sp3'] !== "" and $row['berkas_tahap1tgl'] !== "") {
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p18\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>BERKAS OK</b></a></center>";

} 
print ('</td>');
 //---------6
 print ('<td>');
//if ($row['berkas_tahap1tgl'] !== "" && $row['berkas_tahap1p21tgl'] == "" && $row['berkas_tahap1p18tgl'] == "") {
//echo "<br><center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p18\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\"><b>[POST]</b></a></center>";
//} 
//elseif ($row['berkas_tahap1p18tgl'] !== "") {
//print ('<center>'. $row['berkas_tahap1p18tgl'].'</center>');}
//--------------coba notif p18
if ($row['berkas_tahap1p19tgl'] == "" && $row['berkas_tahap1p21tgl'] == "" && $row['berkas_p20'] == "" && $row['berkas_tahap1p18tgl'] !== "") {
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap1p18tgl']; //tgl p18
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
$timelate = "7"; //SESUAI KUHAP Menyatakan Sikap 7 Hari untuk P18/P19 14 Hari
$selisih2 = $selisih - $timelate;
//if ($row['berkas_tahap1p18tgl'] == "") {
if($selisih>=7) { 
$id = $row['uid'];
print ('<center>'.$row['berkas_tahap1p18tgl'].'<br><img src="images/idcred.gif" width="32" height="16"></center>');
print ('<br><center>Lewat:'.$selisih.'Hari<br> Batas 14 Hari <br><font color="red"><b>Terbitkan P19:<br>'. $row['berkas_telattgl'].'</b></font></center>');
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p19\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST P19</b></a></center>";
$query = "UPDATE $mytable SET late_berkas = '3' WHERE uid = '$id'";
//$query = "UPDATE $mytable SET late_spdpkembali = '3' WHERE uid = '$id'";
//$query = "UPDATE $mytable SET late_spdp = '0', late_p21 = '0', late_berkas = '0', late_spdpkembali = '0' WHERE uid = '$id'"; //UNTUK PENYETINGAN SEMENTARA JIKA SUDAH BERI TANDA //
$result = mysql_query($query);
}
elseif($selisih<7){ 
print ('<center><img src="images/idcgreen.gif" width="32" height="16">');
print (''.$row['berkas_tahap1p18tgl'].'');
print ('<br>Run: '.$selisih.'day(s) From '.$timelate.'days</center>');
//FUNGSI POST p19
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p19\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST P19</b></a></center>";
}}
elseif ($row['berkas_tahap1p18tgl'] !== "" && $row['berkas_tahap1p21tgl'] == "" && $row['berkas_p20'] == "" && $row['berkas_tahap1tgl'] !== "") {
print ('<center><b>BERKAS<br>BELUM LENGKAP</b></center>');
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p19\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST P19</b></a></center>";

} 
print ('</td>');
//---------7
 print ('<td>');
if ($row['berkas_tahap1p19tgl'] == "") {
print ('<center><font color="green"><b><center>-</center></b></font>');} 
elseif ($row['berkas_tahap1p19tgl'] !== '') {
print ('<center>'. $row['berkas_tahap1p19tgl'].'<center>');} 
print ('</td>');
//---------8
print ('<td>');
if ($row['berkas_tahap1p18tgl'] !== "" && $row['berkas_tahap1p19tgl'] !== "" && $row['berkas_tahap1p21tgl'] == "" && $row['berkas_sp3'] == "") {
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap1p19tgl']; 
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 = $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
$timelate = "20";
$selisih2 = $selisih - $timelate;
//if ($row['berkas_tahap1p18tgl'] == "") {
if($selisih>=20) { 
print ('<center><img src="images/idcred.gif" width="32" height="16" alt="TERBITKAN SURAT BIASA ATAS P19 BELUM TERPENUHI">');
print ('<br>Left : '.$selisih.'day(s)<br>From '.$timelate.'days <br><font color="red"><b>Terbitkan <br>P19-SB<br>'. $row['berkas_tahap1telatp18'].'</b></font></center>');
//print ('<a href=".slm_pidum/pidum_berkas_t1_p19kembali_post.php?uid='.$id.'&table='.$mytable.'" class="menu">SET</a>');
//$query = "UPDATE $mytable SET late_spdpkembali = '3' WHERE uid = '$id'";
//$result = mysql_query($query);
}
elseif($selisih<30){ 
print ('<center><img src="images/idcgreen.gif" width="32" height="16">');
print ('<br>Run: '.$selisih.'day(s)<br> From '.$timelate.'days</center>');
} }
elseif ($row['berkas_tahap1p21tgl'] !== "") {
print ('<center><b>SUDAH<br>P21</b></enter>');
} 
print ('</td>');
//---------10
print ('<td>');
if ($row['berkas_tahap1p21tgl'] == "" && $row['berkas_tahap1tgl'] !== "") {
echo "<center><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p21\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST P21</b></a></center>";
} 
elseif ($row['berkas_tahap1p21tgl'] !== '' && $row['berkas_tahap1tgl'] !== "") {
print ('<center>'. $row['berkas_tahap1p21tgl'].'</center>');
} 
print ('</td>');
//---------11
print ('<td>');
if ($row['berkas_tahap2tgl'] == "" && $row['berkas_tahap1p21tgl'] !== "" && $row['berkas_p20'] == "") {
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap1p21tgl']; //tgl p18
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
$timelate = "30";
$selisih2 = $selisih - $timelate;
//if ($row['berkas_tahap1p18tgl'] == "") {
if($selisih>=30) { 
$id = $row['uid'];
print ('<center><img src="images/idcred.gif" width="32" height="16" alt="TENTUKAN SIKAP SEGERA BUAT P21A">');
print ('<br>Left : '.$selisih.'day(s)From '.$timelate.'days <br><font color="red"><b>Terbitkan P21A:<br>'. $row['berkas_telattgl'].'</b></font></center>');
$query = "UPDATE $mytable SET late_p21 = '3' WHERE uid = '$id'";
$result = mysql_query($query);
}
elseif($selisih<30){ 
print ('<center><img src="images/idcgreen.gif" width="32" height="16">');
print ('<br>Run: '.$selisih.'day(s) From '.$timelate.'days</center>');
} }
elseif ($row['berkas_tahap2tgl'] !== "") {
print ('<center><img src="images/tahap_tut.png" width="80" height="50"></enter>');
$id = $row['uid'];
$query = "UPDATE $mytable SET late_spdp = '0', late_p21 = '0', late_berkas = '0', late_spdpkembali = '0' WHERE uid = '$id'"; //UNTUK PENYETINGAN SEMENTARA JIKA SUDAH BERI TANDA //
$result = mysql_query($query);
} 
print ('</td>');
 //---------12
 print ('<td>');
if ($row['berkas_p20'] == "" && $row['berkas_tahap2tgl'] == "" && $row['berkas_limpahp31tgl'] == "" ) {
echo "<center><b><a href=\"index.pratut.post.tahapan.php?uid=$id&table=$mytable&do=p20\" onclick=\"NewWindow(this.href,'mywin','600','300','yes','center');return false\" onfocus=\"this.blur()\">POST<br>P20/SP3/Diversi</a></b></center>";
} 
elseif ($row['berkas_p20'] !=="") {
print ('<font color="green"><b><center>DIHENTIKAN<br>'.$row['berkas_p20'].'<br>'.$row['berkas_diversi'].'</center></b></font>');
} 
print ('</td>');
print ('</tr>');} 
print ('</tbody> </table>');
echo "<br><br>Ditampilkan $hits /Halaman";
}
?>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td bgcolor="#FFCCCC"><strong>PENUNTUTAN</strong></td>
              </tr>
              <tr>
                <td><table width="100%"  border="0" cellspacing="8" cellpadding="8">
                  <tr>
                    <td><?
include("../index.cma.db.php");
$mytable = "$tahun_before";
$edisi = substr($mytable,15,4);
$page2 = $_GET["page2"];
if(empty($action))
{
if (empty($order)) $order =  2;
if (empty($page2))  $page2  =  1;
if (empty($hits))  $hits  = 500;
$start = $hits*($page2-1);
$query = "SELECT * FROM $mytable WHERE berkas_tahap1p21tgl !='' && berkas_p20 ='' ORDER BY uid DESC";
$res = mysql_query("$query"); 
$xnum = mysql_num_rows($res);
$stw2 = (int)($xnum/$hits);
if ($xnum%$hits > 0) {$stw2++;}
$np = $page2+1;
$pp = $page2-1;
if ($page2 == 1) { $pp=1; }
if ($np > $stw2) { $np = $stw2;} 
echo "TOTAL PERKARA TAHAP PENUNTUTAN <strong>$edisi</strong> SEBANYAK <strong>$xnum</strong> TERSANGKA | ";
for ($i=1;$i<=$stw2;$i++) {if($page2==$i){
echo "<b> HAL $i |</b> ";} 
else{echo "<a href=\"index.php?g=tut&i=index&page2=$i#tab1\"> $i |</a>";}}
print ('<br><br>');
$query  = "SELECT * FROM $mytable ";
if(!empty($squery)) { $query .= "LIKE \"%$squery%\" ";}
$query .= "WHERE berkas_tahap1p21tgl !='' && berkas_p20 ='' ORDER BY uid DESC LIMIT $start,$hits";
$res = mysql_query($query);
print ('<table id="myTable" width="100%"  border="0" cellspacing="1" cellpadding="1" bgcolor="#B05800">
        <thead><tr>
<td width="30%"><strong>NAMA TERSANGKA/SURAT DARI/PASAL</strong></td>
<td width="10%"><strong>P21</strong></td>
<td width="15%"><strong>PANTAUAN P21</strong></td>
<td width="10%"><strong>TAHAP 2</strong></td>
<td width="15%"><strong>STATUS TAHAP 2</strong></td>
<td width="10%"><strong>LIMPAH</strong></td>
<td width="10%"><strong>SKPP/DIVERSI</strong></td>
</tr></thead><tbody>');
 $x=0;
  while($row = mysql_fetch_array($res))
  {
   $x++;
   if($x==2) {$barva = "FF6600";$x=0;} else {$barva = "FFFFCC";$x=1;}
print ('<tr bgcolor=#'.$barva.'><td><b>'.$row['spdp_namatsk'] .'</b><br>');
$polisi1 = $row['spdp_dari'];
 mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$sql=mysql_query("select * from tab_polisi where p_nomor = '$polisi1'");
while ($data=mysql_fetch_array($sql)){
print(''.$data['p_nama'].'');
}

$id = $row['uid'];

print ('<i><br>'. $row['spdp_pasal'].'</i><br>Jaksa:<b>');
$jaksa1 = $row['p16_jaksa1'];
 mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$sql=mysql_query("select * from tab_personil where daftar_pegid = '$jaksa1'");
while ($data=mysql_fetch_array($sql)){
print('<b>'.$data['daftar_nama'].'</b>');
}
print ('</b></td>');
print ('<td><center>'.$row['berkas_tahap1p21tgl'].'</center></td>');
print ('<td>');
 //start
if ($row['berkas_tahap1p21tgl'] !== '' && $row['berkas_tahap2tgl'] == '') { //jika p21 ada maka di proses statusnya
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap1p21tgl']; //Tgl P21
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
//$selisih2 = strtotime ( '-7 day' , strtotime ( $jd2 ) ) ;
$timelate1 = "30"; //TGL MAKSIMAL p21 jika lebih terbitkan P21A oleh Pratut
$selisih2 = $selisih - $timelate;
//----IF KEDUA 
if ($row['berkas_tahap2tgl'] == '') {
if($selisih>=$timelate1) { 
$id = $row['uid'];
print ('<center><img src="./images/idcred.gif" width="32" height="16">');
print ('<br>Left : '.$selisih.'day(s)From '.$timelate1.'days');
echo "<br><a href=\"index.tut.post.tahapan.php?uid=$id&table=$mytable&do=p21a\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>SET P21.A</b></a></center>";
}
//$query = "UPDATE $mytable SET late_p31 = '3' WHERE uid = '$id'";
//$result = mysql_query($query);
//TUTUP
elseif($selisih<$timelate1){ 
print ('<center><img src="./images/idcgreen.gif" width="32" height="16">');
print ('<br>Run: '.$selisih.'day(s) From '.$timelate1.'days</center>');  //telat
}}
elseif ($row['berkas_tahap1p21tgl'] !== '' && $row['berkas_tahap2tgl'] !== '') {
print ('<center><b>SUDAH TAHAP 2</b></center>');
} }
print ('</td>');
////-------------------------------------END STATUS p21
print ('<td>');
if ($row['berkas_tahap2tgl'] == "" && $row['berkas_tahap1p21tgl'] !== '') {
echo "<center><a href=\"index.tut.post.tahapan.php?uid=$id&table=$mytable&do=tahap2\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>POST TAHAP 2</b></a></center>";
} 
elseif ($row['berkas_tahap2tgl'] !== '' && $row['berkas_tahap1p21tgl'] !== '') {
print ('<center>'. $row['berkas_tahap2tgl'].'</center>');} 
print ('</td>');
print ('<td>');
 //start
if ($row['berkas_tahap2tgl'] !== '') {
date_default_timezone_set('ASIA/JAKARTA'); 
$tgl1 = $row['berkas_tahap2tgl']; 
$tgl2 = date('d/m/Y'); 
$pecah1 = explode("/", $tgl1);$date1 = $pecah1[0];$month1 = $pecah1[1];$year1 = $pecah1[2];
$pecah2 = explode("/", $tgl2);$date2 = $pecah2[0];$month2 = $pecah2[1];$year2 =  $pecah2[2];
$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);
$selisih = abs($jd2 - $jd1);
//$selisih2 = strtotime ( '-7 day' , strtotime ( $jd2 ) ) ;
$timelate2 = "20";
$selisih2 = $selisih - $timelate2;
//----
if ($row['berkas_limpahp31tgl'] == '') {
if($selisih>=$timelate2) { 
$id = $row['uid'];
print ('<center><img src="./images/idcred.gif" width="32" height="16" alt="SEGERA LIMPAH">');
print ('<br>Left : '.$selisih.'day(s)From '.$timelate2.'days <br><font color="red"><b>T7 Habis<br>'. $row['berkas_t2t7hbs'].'</b></font>');
echo "<a href=\"index.tut.post.tahapan.php?uid=$id&table=$mytable&do=p31\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>SET P-31</b></a></center>";
$query = "UPDATE $mytable SET late_p31 = '3' WHERE uid = '$id'";
$result = mysql_query($query);}//TUTUP
elseif($selisih<$timelate2){ 
print ('<center><img src="./images/idcgreen.gif" width="32" height="16">');
print ('<br>Run: '.$selisih.'day(s) From '.$timelate2.'days</center>');
}} //telat
if ($row['berkas_limpahp31tgl'] !== '') {
print ('<center><b>OK</b></enter>');
}}
print ('</td>');
print ('<td>');
if ($row['berkas_limpahp31tgl'] == "" && $row['berkas_tahap2tgl'] !== "") {
echo "<a href=\"index.tut.post.tahapan.php?uid=$id&table=$mytable&do=p31\" onclick=\"NewWindow(this.href,'mywin','600','200','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>SET P-31</b></a></center>";
}
elseif ($row['berkas_limpahp31tgl'] !== '' && $row['berkas_tahap2tgl'] !== "") {
print ('<center>SUDAH DILIMPAH<br>'. $row['berkas_limpahp31tgl'].'<center>');} 
print ('</td>');
 print ('<td>');
if ($row['berkas_skpp'] == "" && $row['berkas_diversitut'] == "" && $row['berkas_diversi'] == "" && $row['berkas_p20'] == "" ) {
echo "<center><b><a href=\"index.tut.post.tahapan.php?uid=$id&table=$mytable&do=skpp\" onclick=\"NewWindow(this.href,'mywin','600','300','yes','center');return false\" onfocus=\"this.blur()\">POST<br>SKPP/Diversi</a></b></center>";
} 
elseif ($row['berkas_skpp'] !== "" && $row['berkas_diversi'] == "" && $row['berkas_diversitut'] !== "" && $row['berkas_p20'] == "" ) {
print ('<font color="green"><b><center>DIHENTIKAN<br>DIVERSI/SKPP<br>'.$row['berkas_skpp'].'<br>'.$row['berkas_diversitut'].'</center></b></font>');
} 
print ('</td>');
print ('</tr>');} 
print ('</tbody></table>');
echo "<br><br>Ditampilkan $hits /Halaman";
}
?>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td bgcolor="#FFCCCC"><strong>EKSEKUSI</strong></td>
              </tr>
              <tr>
                <td><table width="100%"  border="0" cellspacing="8" cellpadding="8">
                  <tr>
                    <td><?
include("../index.cma.db.php");
$mytable = "$tahun_before";
$edisi = substr($mytable,15,4);
$page2 = $_GET["page2"];
if(empty($action))
{
if (empty($order)) $order =  2;
if (empty($page2))  $page2  =  1;
if (empty($hits))  $hits  = 500;
$start = $hits*($page2-1);
$query = "SELECT * FROM $mytable WHERE berkas_tahap1p21tgl !='' && berkas_p20 ='' ORDER BY uid DESC";

$res = mysql_query("$query"); 
$xnum = mysql_num_rows($res);
$stw2 = (int)($xnum/$hits);
if ($xnum%$hits > 0) {$stw2++;}
$np = $page2+1;
$pp = $page2-1;
if ($page2 == 1) { $pp=1; }
if ($np > $stw2) { $np = $stw2;} 
echo "PENCATATAN EKSEKUSI <strong>$edisi</strong> SEBANYAK <strong>$xnum</strong> TERSANGKA | ";
for ($i=1;$i<=$stw2;$i++) {if($page2==$i){
echo "<b> HAL $i |</b> ";} 
else{echo "<a href=\"index.php?g=tuthome&d=inc_op&page2=$i#tab1\"> $i |</a>";}}
print ('<br><br>');
$query  = "SELECT * FROM $mytable ";
if(!empty($squery)) { $query .= "LIKE \"%$squery%\" ";}
$query .= "WHERE p16_jaksa1 !='0' && berkas_p20 ='' ORDER BY uid DESC LIMIT $start,$hits";
$res = mysql_query($query);
print ('<table id="myTable" width="100%"  border="0" cellspacing="1" cellpadding="1" bgcolor="#B05800">
        <thead><tr>
<td width="25%"><strong>NAMA TERSANGKA/SURAT DARI/PASAL</strong></td>
<td width="27%"><strong>TAP SIDANG & MAJELIS</strong></td>
<td width="12%"><strong>TUNTUTAN</strong></td>
<td width="12%"><strong>PUTUSAN</strong></td>
<td width="12%"><strong>UPAYA HUKUM</strong></td>
<td width="12%"><strong>P48&BA-20</strong></td>

</tr></thead><tbody>');
 $x=0;
  while($row = mysql_fetch_array($res))
  {
   $x++;
   if($x==2) {$barva = "FF6600";$x=0;} else {$barva = "FFFFCC";$x=1;}
print ('<tr bgcolor=#'.$barva.'><td><b>'.$row['spdp_namatsk'] .'</b><br>');
$polisi1 = $row['spdp_dari'];
 mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$sql=mysql_query("select * from tab_polisi where p_nomor = '$polisi1'");
while ($data=mysql_fetch_array($sql)){
print(''.$data['p_nama'].'');
}
$id = $row['uid'];

print ('<br><i>'. $row['spdp_pasal'].'</i><br>Jaksa:<b>');

$jaksa1 = $row['p16_jaksa1'];
 mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$sql=mysql_query("select * from tab_personil where daftar_pegid = '$jaksa1'");
while ($data=mysql_fetch_array($sql)){
print('<b>'.$data['daftar_nama'].'</b>');
}
print ('</b></td>');
print ('<td>');
if ($row['berkas_limpahp31tgl'] !== "" && $row['berkas_taptglsidang'] == "") {
echo "<a href=\"index.eksekusi.post.tahapan.php?uid=$id&table=$mytable&do=tapsidang\" onclick=\"NewWindow(this.href,'mywin','600','320','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>TAP TGL SIDANG & MAJELIS HAKIM</b></a>";
}
elseif ($row['berkas_limpahp31tgl'] == "" && $row['berkas_taptglsidang'] == "") {
print ('<center>BELUM LIMPAH<center>');
} 
elseif ($row['berkas_taptglsidang'] !== "" && $row['berkas_taptglsidang'] !== "") {
print ('<center>'.$row['berkas_taptglsidang'].'<br>'.$row['berkas_tapnomor'].'<br>'.$row['berkas_taphakim'].'<center>');
} 
print ('</td>');
print ('<td>');
if ($row['berkas_taptglsidang'] !== "" && $row['berkas_tuttgl'] == "") {
echo "<a href=\"index.eksekusi.post.tahapan.php?uid=$id&table=$mytable&do=tuntutan\" onclick=\"NewWindow(this.href,'mywin','600','300','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>ISI TUNTUTAN</b></a>";
}
elseif ($row['berkas_taptglsidang'] == "" && $row['berkas_tuttgl'] == "") {
print ('<center>BELUM ADA TAP SIDANG<center>');
} 
elseif ($row['berkas_taptglsidang'] !== "" && $row['berkas_tuttgl'] !== "") {
print ('<center><img src="images/done.jpg" width="80" height="20"><center>');
} 
print ('</td>');

print ('<td>');
if ($row['berkas_tuttgl'] !== "" && $row['berkas_ptstgl'] == "") {
echo "<a href=\"index.eksekusi.post.tahapan.php?uid=$id&table=$mytable&do=putusan\" onclick=\"NewWindow(this.href,'mywin','600','350','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>PUTUSAN</b></a>";
}
elseif ($row['berkas_tuttgl'] == "" && $row['berkas_ptstgl'] == "") {
print ('<center>BELUM TUNTUTAN<center>');
} 
elseif ($row['berkas_tuttgl'] !== "" && $row['berkas_ptstgl'] !== "") {
print ('<center><img src="images/done.jpg" width="80" height="20"><center>');
} 
print ('</td>');



print ('<td>');
if ($row['berkas_tuttgl'] !== "" && $row['berkas_ptstgl'] !== "" && $row['berkas_p48tgl'] == "") {
print ('Banding:'.$row['berkas_tglbanding'].'<br>');
print ('Kasasi:'.$row['berkas_tglkasasi'].'<br>');
echo "<a href=\"index.eksekusi.post.tahapan.php?uid=$id&table=$mytable&do=upayahukum\" onclick=\"NewWindow(this.href,'mywin','600','300','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>UPAYA HUKUM</b></a>";
}
elseif ($row['berkas_tuttgl'] == "" && $row['berkas_ptstgl'] == "" && $row['berkas_p48tgl'] == "") {
print ('<center>BELUM TUT/PUTUS<center>');
} 
elseif ($row['berkas_tuttgl'] !== "" && $row['berkas_ptstgl'] !== "" && $row['berkas_p48tgl'] !== "") {
print ('<center>INKRAHT<center>');
} 
print ('</td>');
//Eksekusi
print ('<td>');
if ($row['berkas_tuttgl'] !== "" && $row['berkas_ptstgl'] !== "" && $row['berkas_p48tgl'] == "") {

echo "<a href=\"index.eksekusi.post.tahapan.php?uid=$id&table=$mytable&do=eksekusi\" onclick=\"NewWindow(this.href,'mywin','600','350','yes','center');return false\" onfocus=\"this.blur()\" class=\"menu\"><b>EKSEKUSI T & BB</b></a>";
}
elseif ($row['berkas_tuttgl'] == "" && $row['berkas_ptstgl'] == "" && $row['berkas_p48tgl'] == "") {
print ('<center>BELUM TUT/PUTUS<center>');
} 
elseif ($row['berkas_tuttgl'] !== "" && $row['berkas_ptstgl'] !== "" && $row['berkas_p48tgl'] !== "") {
print ('<center>'.$row['berkas_p48tgl'].'<br>INKRAHT<center>');
} 
print ('</td>');



print ('</tr>');} 
print ('</tbody></table>');
echo "<br><br>Ditampilkan $hits /Halaman";
}
?></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#FF0000"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td><?PHP echo $satker; ?> | <?PHP echo $alamat; ?></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<? } ?>
