<table width="100%"  border="0" cellspacing="8" cellpadding="8">
  <tr>
    <td><?
include("../index.cma.db.php");
mysql_connect("$server", "$username", "$password");
mysql_select_db("$database");
$query = "Select * from tab_dataperkara where t_id = '1'"; 
$result = mysql_query($query); 
if($row2 = mysql_fetch_array($result)){ 
$mytable = $row2['t_table'];
$edisi = $row2['t_tahun'];
$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 p16_jaksa1 !='0' 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 $edisi SEBANYAK <strong>$xnum</strong> TERSANGKA | ";
for ($i=1;$i<=$stw2;$i++) {if($page2==$i){
echo "<b> HAL $i |</b> ";} 
else{echo "<a href=\"?g=pratut&i=index&page2=$i#tab1\"> $i |</a>";}}
print ('<br><br>');
$query  = "SELECT * FROM $mytable ";
if(!empty($squery)) { $query .= "LIKE \"%$squery%\" ";}
$query .= "WHERE p16_jaksa1 !='0' 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 = "14";
$selisih2 = $selisih - $timelate;
//if ($row['berkas_tahap1p18tgl'] == "") {
if($selisih>=14) { 
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>
