<?PHP
$tu_dbtahun1 = $_POST["tu_dbtahun"];
$tahun2 = $_POST["tahun"];
$jenis1 = $_POST["jenis"];
$day = $_POST["day"];
$month = $_POST["month"];
$year = $_POST["year"];
$tu_tglsrt1 = "$day/$month/$year";
$day1 = $_POST["day1"];
$month1 = $_POST["month1"];
$year1 = $_POST["year1"];
$tu_tglterima1 = "$day1/$month1/$year1";
$tu_jenissurat1 = $_POST["tu_jenissurat"];
$tu_noagenda1 = $_POST["tu_noagenda"];
$tu_asalsrt1 = $_POST["tu_asalsrt"];
$tu_nosrt1 = $_POST["tu_nosrt"];
$tu_lamp1 = $_POST["tu_lamp"];
$tu_perihal1 = $_POST["tu_perihal"];
$error = "";
if ($tu_dbtahun1 == ""){$error = "DATABASE WAJIB DIPILIH<BR>";}
if ($tu_tglsrt1 == ""){$error = "TANGGAL SURAT BELUM DI INPUT<BR>";}
if ($tu_tglterima1 == ""){$error = "TANGGAL TERIMA SURAT BELUM DI INPUT<BR>";}
if ($tu_noagenda1 == ""){$error = "NO URUT AGENDA BELUM DI INPUT<BR>";}
if ($tu_asalsrt1 == ""){$error = "ASAL SURAT BELUM DI INPUT<BR>";}
if ($tu_nosrt1 == ""){$error = "NO SURAT BELUM DI INPUT<BR>";}
if ($tu_perihal1 == ""){$error = "PERIHAL SURAT BELUM DI INPUT<BR>";}
include("../index.cma.db.php");
$query = "Select * from $tu_dbtahun1 where tu_noagenda = '$tu_noagenda1'";
$result = mysql_query($query); 
if ($row = mysql_fetch_array($result)){ 
if  ($row["tu_noagenda"] == $tu_noagenda1){$error = "$error <b>TIDAK BOLEH ADA DUPLIKASI/NOMOR AGENDA GANDA YAITU NO AGENDA : $tu_noagenda1<b><br><br>SOLUSI : REFRESH / LOGOUT TERLEBIH DAHULU\n";}
}
if ($error == ""){
$query = "INSERT INTO $tu_dbtahun1 (tu_tglsrt, tu_jenissurat, tu_tglterima, tu_noagenda, tu_asalsrt,  tu_nosrt, tu_lamp, tu_perihal, tu_print) VALUES
 ('$tu_tglsrt1','$tu_jenissurat1','$tu_tglterima1','$tu_noagenda1','$tu_asalsrt1','$tu_nosrt1','$tu_lamp1','$tu_perihal1','1')";
$result = mysql_query($query);
print ('<table width="100%"  border="0" cellspacing="1" cellpadding="1">
  <tr>
    <td bgcolor="#993300"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td bgcolor="#FF6600">SURAT MASUK BERHASIL DISIMPAN | <a href="index.php?g=postingsuratkeluar&i=index&day='.$day.'&month='.$month.'&year='.$year.'&table='.$tahun2.'&jenis='.$jenis1.'" class="menu">INPUT LAGI TAHUN YANG SAMA KLIK DISINI<a></td>
      </tr>
    </table></td>
  </tr>
</table>');
}
else
{
echo "$error.";
} 
?>