<LINK href="../images/index.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
    function refreshAndClose() {
        window.opener.location.reload(true);
        window.close();
    }
</script>
<body onbeforeunload="refreshAndClose();">
<?PHP
include("../../index.cma.db.php");
date_default_timezone_set('ASIA/JAKARTA');
$id1 = $_POST["uid"];
$table1 = $_POST["table"];
$sms1 = $_POST["sms1"];
$sms2 = $_POST["sms2"];
$noagenda1 = $_POST["noagenda"];
$namapenyidik1 = $_POST["namapenyidik"];
$telppenyidik1 = $_POST["telppenyidik"];
//$telppelapor1 = $_POST["telppelapor"];
$spdp_jaksa1 = $_POST["s_jks1"];
$spdp_jaksa2 = $_POST["s_jks2"];
$jaksa1 = $_POST["jaksa1"];
$jaksa2 = $_POST["jaksa2"];
$jaksap16 = 'Tunjuk Jaksa P16 1.'.$jaksa1.'/ 2.'.$jaksa2;
$error = "";
if ($spdp_jaksa1 == ""){$error = "Jaksa 1 Belum dipilih<BR>";}
if ($spdp_jaksa2 == ""){$error = "Jaksa 2 Belum dipilih<BR>";}
if ($error == ""){
//Update database surat
$query = "UPDATE $table1 Set tu_disposisi = '$jaksap16' where tu_noagenda = '$noagenda1'";  
$result = mysql_query($query); 
$query = "UPDATE $table1 Set tu_ekspedisi  = '3' where tu_noagenda = '$noagenda1'";  
$result = mysql_query($query); 
//end database surat
$query = "Select * from tab_dataperkara where t_id = '1'"; 
$result = mysql_query($query); 
if($row2 = mysql_fetch_array($result)){ 
$mytable = $row2['t_table'];
$query = "UPDATE $mytable Set p16_jaksa1  = '$spdp_jaksa1' where uid = '$id1'";  
$result = mysql_query($query); 
$query = "UPDATE $mytable Set p16_jaksa2  = '$spdp_jaksa2' where uid = '$id1'";  
$result = mysql_query($query); 
$SQL     = "SELECT * FROM tab_personil where daftar_pegid = '$spdp_jaksa1'";
$results = mysql_query($SQL);
while ($row = mysql_fetch_array($results)){
$notujuan = $row['daftar_nohp'];
print ('<table width="100%"  border="0" cellspacing="2" cellpadding="2"><tr><td><strong>Pesan terkirim ke Jaksa P16 </strong></td>
</tr><tr><td>&nbsp;</td></tr><tr><td bgcolor="#FF6600"><table width="100%"  border="0" cellspacing="2" cellpadding="2">
<tr><td><strong>Sms Pesan </strong></td></tr><tr><td bgcolor="#FFDFB0"><table width="100%"  border="0" cellspacing="2" cellpadding="2">
<tr><td width="15%">Kepada Jaksa</td><td width="2%">:</td><td width="83%">');
print('<b>'.$jaksa1.'</b>');
print ('</td></tr>');
$isipesan = "$sms1 Penyidik:$namapenyidik1 Telp:$telppenyidik1";
$DestinationNumber=addslashes(strip_tags($notujuan));	
$TextDecoded=addslashes(strip_tags($isipesan)); 
include("../../index.cma.db.php");
$sql="INSERT INTO outbox (`UpdatedInDB` ,`InsertIntoDB` ,`SendingDateTime` ,`Text` ,`DestinationNumber` ,`Coding` ,`UDH` ,`Class` ,`TextDecoded` ,`ID` ,`MultiPart` ,`RelativeValidity` ,`SenderID` ,`SendingTimeOut` ,`DeliveryReport` ,`CreatorID`)
VALUES (NOW() , NOW(), '0000-00-00 00:00:00', NULL , '$DestinationNumber', 'Default_No_Compression', NULL , '-1', '$TextDecoded', NULL , 'false', '-1', NULL , '0000-00-00 00:00:00', 'default', '')";
mysql_query($sql); 
print ('<tr><td>Isi Pesan </td><td>:</td> <td>');
print (''.$isipesan.'');
print ('</td></tr></table></td></tr></table></td></tr></table>');
//Sms Penyidik
if ($telppenyidik1 == "0"){
print ('<table width="100%"  border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td bgcolor="#FF3300"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td>NOMOR PENYIDIK KOSONG. SISTEM TIDAK MENGIRIM SMS NOTIFIKASI</td>
      </tr>
    </table></td>
  </tr>
</table>');
}
elseif ($telppenyidik1 !== "0"){
$isipesan2 = "$sms2 Jaksa: $jaksa1";
$DestinationNumber=addslashes(strip_tags($telppenyidik1));	
$TextDecoded=addslashes(strip_tags($isipesan2)); 
include("../../index.cma.db.php");
$sql="INSERT INTO outbox (`UpdatedInDB` ,`InsertIntoDB` ,`SendingDateTime` ,`Text` ,`DestinationNumber` ,`Coding` ,`UDH` ,`Class` ,`TextDecoded` ,`ID` ,`MultiPart` ,`RelativeValidity` ,`SenderID` ,`SendingTimeOut` ,`DeliveryReport` ,`CreatorID`)
VALUES (NOW() , NOW(), '0000-00-00 00:00:00', NULL , '$DestinationNumber', 'Default_No_Compression', NULL , '-1', '$TextDecoded', NULL , 'false', '-1', NULL , '0000-00-00 00:00:00', 'default', '')";
mysql_query($sql); 
//End Sms Penyidik
$date = date("d");
$month = date("m");
$year = date("Y");
print ('<table width="100%"  border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td bgcolor="#FF3300"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td><b>'.$sms1.' </b>BARU BERHASIL DISIMPAN DAN SMS INFORMASI JAKSA TELAH TERKIRIM KE PENYIDIK <b>'.$namapenyidik1.'</b> Nomor : <b>'.$telppenyidik1.'</b></td>
      </tr>
    </table></td>
  </tr>
</table>');
}

print ('<table width="100%"  border="0" cellspacing="2" cellpadding="2">

	  <tr>
        <td>Sudah disimpan silahkan tutup jendela ini</td>
      </tr>
  </tr>
</table>');
}}}
else
{
echo "$error.";
} 
?>
