<?
include("../index.globalconfig.php");
require_once("index.config.php");
//session_start();
$db_connection = mysql_connect ($DBHost, $DBUser, $DBPass) OR die (mysql_error());  
$db_select = mysql_select_db ($DBName) or die (mysql_error());
if($use_auth)
{
	if(!isset($_SESSION['admin_id']))
	{
		if ((!isset($_POST['USER'])) AND (!isset($_POST['PASS']))) {
		?>
		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
		<html>
		<head>
		<title>JADWAL SIDANG</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<link href="images/calendar.css" rel="stylesheet" type="text/css">
		<style type="text/css">
<!--
body {
	background-color: #FFEADF;
}
-->
</style></head>
		<body>
		<br><br>
		<form name="form1" method="post" action="event_add.php" onsubmit="return formCheck(this);">
		  <table border="0" align="center" cellpadding="0" cellspacing="0">
			<tr> 
			  <td>Username:</td>
			</tr>
			<tr> 
			  <td><input name="USER" type="text" id="USER"></td>
			</tr>
			<tr> 
			  <td height="15">Password:</td>
			</tr>
			<tr> 
			  <td><input name="PASS" type="password" id="PASS"></td>
			</tr>
			<tr> 
			  <td height="50"><div align="center">
				  <input type="submit" name="Submit" value="           login           ">
				</div></td>
			</tr>
		  </table>
		<input type="hidden" name="day" id="day" value="<? echo $_GET['day']; ?>">
		<input type="hidden" name="month" id="month" value="<? echo $_GET['month']; ?>">
		<input type="hidden" name="year" id="year" value="<? echo $_GET['year']; ?>">
		<input type="hidden" name="id" id="id" value="<? echo $_GET['id']; ?>">
		</form>
		</body>
		</html>
		<?
			exit;
		} 
		ELSE
		{
			$query = "SELECT admin_id FROM ".$TBL_PR."admins WHERE admin_username='".addslashes($_POST['USER'])."' AND admin_password='".addslashes(md5($_POST['PASS']))."' LIMIT 1";
			$query_result = mysql_query ($query);
			while ($info = mysql_fetch_array($query_result))
			{
				$admin_id = $info['admin_id'];
			}
		
			IF(isset($admin_id))
			{
				$_SESSION['admin_id'] = $admin_id;
			}
			ELSE
			{
				header("Location: event_add.php?day=".$_POST['day']."&month=".$_POST['month']."&year=".$_POST['year']."&id=" . $_POST['id']);
				exit;
			}
		}
	}
}
IF(isset($_POST['submit']))
{
	$db_table = $TBL_PR . "events";
	$_POST['description'] = substr($_POST['description'],0,500);
	$_POST['title'] = substr($_POST['title'],0,30);
	$event_nobesuk1 ="{$_POST[no]}{$_POST[satker]}{$_POST[kode]}/{$_POST[month]}/{$_POST[year]}";
$event_identitas1 ="{$_POST[11]}|{$_POST[12]}|{$_POST[13]}|{$_POST[14]}|{$_POST[15]}|{$_POST[16]}|{$_POST[17]}|{$_POST[18]}|{$_POST[19]}|{$_POST[20]}|{$_POST[21]}|{$_POST[22]}|{$_POST[25]}|{$_POST[26]}|{$_POST[27]}|{$_POST[28]}";


	mysql_query("INSERT INTO $db_table ( `event_id` , `event_day` , `event_month` , `event_year` , `event_tiket` ,`event_nobesuk` ,`event_identitas`,`event_regtahanan` , `event_pdm`) VALUES ('', '".addslashes($_POST['day'])."', '".addslashes($_POST['month'])."', '".addslashes($_POST['year'])."','".addslashes($_POST['tiket'])."','$event_nobesuk1','$event_identitas1','".addslashes($_POST['regtah'])."', '".addslashes($_POST['regpdm'])."')");
	$_POST['month'] = $_POST['month'] + 1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MASUKKAN IJIN BESUK BARU</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language='javascript' type="text/javascript">
<!--
 function redirect_to(where, closewin)
 {
 	opener.location= 'index.php?' + where;
 	
 	if (closewin == 1)
 	{
 		self.close();
 	}
 }
  //-->
 </script>
</head>
<body onLoad="javascript:redirect_to('month=<? echo $_POST['month'].'&year='.$_POST['year']; ?>',1);">
</body>
</html>
<?
}
ELSE 
{
?>
<?PHP
include("index.config.php");
$tiket1 = $_GET["tiket"];
$query = "Select * from besuk_events where event_tiket = '$tiket1'"; 
$result = mysql_query($query); 
if($row = mysql_fetch_array($result)){
$identitas = $row["event_identitas"];;
$cuts = explode("|", $identitas);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MASUKKAN JADWAL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="images/calendar.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	background-color: #FFEADF;
}
-->
</style>
    <script type="text/javascript">
      function updateText()
    {	
    var dd = document.getElementById("jaksa1");
    var ddtext = dd.options[dd.selectedIndex].text;
    var sp_ddtext = ddtext.replace(/[^. a-zA-Z]+/g,'');
    document.getElementById("jaksa").value = sp_ddtext;
    }
    </script>
	<script language="JavaScript">
<!--
/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function formCheck(formobj){
	var fieldRequired = Array("terdakwa", "alamat", "jaksa", "agenda");
	var fieldDescription = Array("terdakwa", "alamat", "jaksa", "agenda");
	var alertMsg = "ISIAN TIDAK BOLEH KOSONG:\n";
	var l_Msg = alertMsg.length;
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-option":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

// -->
</script>

</head>
<body>
<form name="formcheck" method="post" action="" onsubmit="return formCheck(this);">
ISIAN BESUK<hr>
  <table width="100%" border="0" cellspacing="4" cellpadding="4">
    <tr> 
      <td ><span class="addevent">TANGGAL BESUK</span></td>
      <td >:</td>
      <td ><select name="day" id="day">
          <option value="1" <? IF($_GET['day'] == "1"){ echo "selected"; } ?>>01</option>
          <option value="2" <? IF($_GET['day'] == "2"){ echo "selected"; } ?>>02</option>
          <option value="3" <? IF($_GET['day'] == "3"){ echo "selected"; } ?>>03</option>
          <option value="4" <? IF($_GET['day'] == "4"){ echo "selected"; } ?>>04</option>
          <option value="5" <? IF($_GET['day'] == "5"){ echo "selected"; } ?>>05</option>
          <option value="6" <? IF($_GET['day'] == "6"){ echo "selected"; } ?>>06</option>
          <option value="7" <? IF($_GET['day'] == "7"){ echo "selected"; } ?>>07</option>
          <option value="8" <? IF($_GET['day'] == "8"){ echo "selected"; } ?>>08</option>
          <option value="9" <? IF($_GET['day'] == "9"){ echo "selected"; } ?>>09</option>
          <option value="10" <? IF($_GET['day'] == "10"){ echo "selected"; } ?>>10</option>
          <option value="11" <? IF($_GET['day'] == "11"){ echo "selected"; } ?>>11</option>
          <option value="12" <? IF($_GET['day'] == "12"){ echo "selected"; } ?>>12</option>
          <option value="13" <? IF($_GET['day'] == "13"){ echo "selected"; } ?>>13</option>
          <option value="14" <? IF($_GET['day'] == "14"){ echo "selected"; } ?>>14</option>
          <option value="15" <? IF($_GET['day'] == "15"){ echo "selected"; } ?>>15</option>
          <option value="16" <? IF($_GET['day'] == "16"){ echo "selected"; } ?>>16</option>
          <option value="17" <? IF($_GET['day'] == "17"){ echo "selected"; } ?>>17</option>
          <option value="18" <? IF($_GET['day'] == "18"){ echo "selected"; } ?>>18</option>
          <option value="19" <? IF($_GET['day'] == "19"){ echo "selected"; } ?>>19</option>
          <option value="20" <? IF($_GET['day'] == "20"){ echo "selected"; } ?>>20</option>
          <option value="21" <? IF($_GET['day'] == "21"){ echo "selected"; } ?>>21</option>
          <option value="22" <? IF($_GET['day'] == "22"){ echo "selected"; } ?>>22</option>
          <option value="23" <? IF($_GET['day'] == "23"){ echo "selected"; } ?>>23</option>
          <option value="24" <? IF($_GET['day'] == "24"){ echo "selected"; } ?>>24</option>
          <option value="25" <? IF($_GET['day'] == "25"){ echo "selected"; } ?>>25</option>
          <option value="26" <? IF($_GET['day'] == "26"){ echo "selected"; } ?>>26</option>
          <option value="27" <? IF($_GET['day'] == "27"){ echo "selected"; } ?>>27</option>
          <option value="28" <? IF($_GET['day'] == "28"){ echo "selected"; } ?>>28</option>
          <option value="29" <? IF($_GET['day'] == "29"){ echo "selected"; } ?>>29</option>
          <option value="30" <? IF($_GET['day'] == "30"){ echo "selected"; } ?>>30</option>
          <option value="31" <? IF($_GET['day'] == "31"){ echo "selected"; } ?>>31</option>
        </select>
		<select name="month" id="month">
          <option value="1" <? IF($_GET['month'] == "1"){ echo "selected"; } ?>>01</option>
          <option value="2" <? IF($_GET['month'] == "2"){ echo "selected"; } ?>>02</option>
          <option value="3" <? IF($_GET['month'] == "3"){ echo "selected"; } ?>>03</option>
          <option value="4" <? IF($_GET['month'] == "4"){ echo "selected"; } ?>>04</option>
          <option value="5" <? IF($_GET['month'] == "5"){ echo "selected"; } ?>>05</option>
          <option value="6" <? IF($_GET['month'] == "6"){ echo "selected"; } ?>>06</option>
          <option value="7" <? IF($_GET['month'] == "7"){ echo "selected"; } ?>>07</option>
          <option value="8" <? IF($_GET['month'] == "8"){ echo "selected"; } ?>>08</option>
          <option value="9" <? IF($_GET['month'] == "9"){ echo "selected"; } ?>>09</option>
          <option value="10" <? IF($_GET['month'] == "10"){ echo "selected"; } ?>>10</option>
          <option value="11" <? IF($_GET['month'] == "11"){ echo "selected"; } ?>>11</option>
          <option value="12" <? IF($_GET['month'] == "12"){ echo "selected"; } ?>>12</option>
        </select>
		 <select name="year" id="year">
          <option value="2016" <? IF($_GET['year'] == "2016"){ echo "selected"; } ?>>2016</option>
          <option value="2017" <? IF($_GET['year'] == "2017"){ echo "selected"; } ?>>2017</option>
          <option value="2018" <? IF($_GET['year'] == "2018"){ echo "selected"; } ?>>2018</option>
          <option value="2019" <? IF($_GET['year'] == "2019"){ echo "selected"; } ?>>2019</option>
          <option value="2020" <? IF($_GET['year'] == "2020"){ echo "selected"; } ?>>2020</option>
		  <option value="2021" <? IF($_GET['year'] == "2021"){ echo "selected"; } ?>>2021</option>
		  <option value="2022" <? IF($_GET['year'] == "2022"){ echo "selected"; } ?>>2022</option>
		  <option value="2023" <? IF($_GET['year'] == "2023"){ echo "selected"; } ?>>2023</option>
		  <option value="2024" <? IF($_GET['year'] == "2024"){ echo "selected"; } ?>>2024</option>
		  <option value="2025" <? IF($_GET['year'] == "2025"){ echo "selected"; } ?>>2025</option>
		  <option value="2026" <? IF($_GET['year'] == "2026"){ echo "selected"; } ?>>2026</option>
		  <option value="2027" <? IF($_GET['year'] == "2027"){ echo "selected"; } ?>>2027</option>
		  <option value="2028" <? IF($_GET['year'] == "2028"){ echo "selected"; } ?>>2028</option>
		  <option value="2029" <? IF($_GET['year'] == "2029"){ echo "selected"; } ?>>2029</option>
		  <option value="2030" <? IF($_GET['year'] == "2030"){ echo "selected"; } ?>>2030</option>
        </select> <span class="addeventextrainfo">TGL/BLN/THN</span></td>
    </tr>

  </table>
  <table width="100%"  border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td><strong>FORM BESUK TAHANAN / SURAT PENGANTAR BESUK TAHANAN </strong></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#FF0000"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td bgcolor="#FFFFFF"><form action="inc_op/pidum_berkas_t2_besuktahanan_add.php" method="post" name="besuktahanan" id="besuktahanan">
            <table width="100%"  border="0" cellspacing="4" cellpadding="4">
              <tr>
                <td width="26%"><div align="center"><strong><?PHP echo "$kejari"; ?></strong></div></td>
                <td width="46%">&nbsp;</td>
                <td width="28%">&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><div align="center"><strong>SURAT IZIN MENGUNJUNGI TAHANAN
<? $tgl=date("d/m/Y");
$th_skrg=date("Y");
$bl_skrg=date("m");
?>                </strong>                  
                    <hr size="1">
                </div></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td><div align="center">Nomor:<input name="no" type="text" id="no" value="" size="5"><input name="satker" type="satker" id="kode" value="<?PHP echo "$kodesurat"; ?>" size="15">
                <select name="kode" id="kode">
                  <option value="Epp.2">Epp.2</option>
                  <option value="Ep.2">Ep.2</option>
                  <option value="Euh.2">Euh.2</option>
                </select>
                /<?php echo $bl_skrg ?>/<?php echo $th_skrg ?></div></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="3"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
                    <tr>


                      <td colspan="5"><strong>Diberikan Kepada </strong></td>
                    </tr>
                    <tr>
                      <td width="5%">&nbsp;</td>
                      <td width="26%">Nama Lengkap </td>
                      <td width="3%">:</td>
                      <td colspan="2"><input name="11" type="text" id="11" value="<?PHP echo $cuts[0]; ?>" size="40"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Alamat</td>
                      <td>:</td>
                      <td colspan="2"><input name="12" type="text" id="12" value="<?PHP echo $cuts[1]; ?>" size="50"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Pekerjaan</td>
                      <td>:</td>
                      <td colspan="2"><input name="13" type="text" value="<?PHP echo $cuts[2]; ?>" id="13"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Hubungan</td>
                      <td>:</td>
                      <td colspan="2"><input name="14" type="text" value="<?PHP echo $cuts[3]; ?>" id="14"></td>
                    </tr>
                    <tr>
                      <td colspan="5"><strong>Untuk mengunjungi Tahanan </strong></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Nama Lengkap </td>
                      <td>:</td>
                      <td colspan="2"><input name="15" type="text" id="15" value="<?PHP echo $cuts[4]; ?>" size="40"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Tempat Lahir </td>
                      <td>:</td>
                      <td colspan="2"><input name="16" type="text" value="<?PHP echo $cuts[5]; ?>" id="16"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Umur/Tanggal Lahir </td>
                      <td>:</td>
                      <td colspan="2"><input name="17" type="text" value="<?PHP echo $cuts[6]; ?>" id="17"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Jenis Kelamin </td>
                      <td>:</td>
                      <td colspan="2"><select name="18" id="18">
                          <option value="LAKI-LAKI">LAKI-LAKI</option>
                          <option value="PEREMPUAN">PEREMPUAN</option>
                          <option selected><?PHP echo $cuts[7]; ?></option>
                      </select></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Kebangsaan</td>
                      <td>:</td>
                      <td colspan="2"><input name="19" type="text" id="19" value="<?PHP echo $cuts[8]; ?>"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Tempat Tinggal </td>
                      <td>:</td>
                      <td colspan="2"><input name="20" type="text" id="20" size="60" value="<?PHP echo $cuts[9]; ?>"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Agama</td>
                      <td>:</td>
                      <td colspan="2"><input name="21" type="text" id="21" value="<?PHP echo $cuts[10]; ?>"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Pekerjaan</td>
                      <td>:</td>
                      <td colspan="2"><input name="22" type="text" id="22" value="<?PHP echo $cuts[11]; ?>"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Reg. Tahanan Nomor </td>
                      <td>:</td>
                      <td colspan="2"><input name="regtah" type="text" id="regtah" value="<?PHP echo htmlspecialchars($row['event_regtahanan']); ?>" size="50"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Reg. Perkara Nomor </td>
                      <td>:</td>
                      <td colspan="2"><input name="regpdm" type="text" id="regpdm" value="<?PHP echo htmlspecialchars($row['event_pdm']); ?>" size="50"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Keperluan</td>
                      <td>:</td>
                      <td colspan="2"><input name="25" type="text" id="25" size="50" value="<?PHP echo $cuts[14]; ?>"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Izin Berlaku </td>
                      <td>:</td>
                      <td colspan="2">Hari
                          <select name="26" id="26">
                            <option value="SENIN">SENIN</option>
							<option value="SELASA">SELASA</option>
							<option value="RABU">RABU</option>
                            <option value="KAMIS">KAMIS</option>
                            <option selected>--PILIH--</option>
                          </select>
                    Tanggal
                    <input name="27" type="text" id="27" size="30" value="<? echo $_GET['day']; ?>/<? echo $_GET['month']; ?>/<? echo $_GET['year']; ?>"></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td colspan="2">Jam 08.00 WIB sampai dengan 12.00 WIB </td>
                    </tr>
                    <tr>
                      <td>Tiket : <input name="tiket" type="hidden" id="tiket" size="20" value="<?PHP echo htmlspecialchars($row['event_tiket']); ?>"><?PHP echo htmlspecialchars($row['event_tiket']); ?></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                      <td colspan="5">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td width="21%">&nbsp;</td>
                      <td width="45%"><div align="center"><?PHP echo "$kota"; ?>, <?PHP echo $tgl2=date("d M Y");?>  </div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td><div align="center">AN. KEPALA <?PHP echo "$kejari"; ?> </div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td><div align="center">KEPALA SEKSI TINDAK PIDANA UMUM </div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td><div align="center"></div></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td><div align="center"><?PHP echo "$kasipidum"; ?><br><?PHP echo "$pangkatnip"; ?></div></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td colspan="3">
                  <div align="center"> </div></td>
              </tr>
              <tr>
                <td colspan="3"><div align="center">
                  <input type="reset" name="Reset" value="KOSONGKAN">
                  <input name="submit" type="submit" id="submit2" value="INPUT BESUK">

                </div></td>
              </tr>
              <tr>
                <td colspan="3">&nbsp;</td>
              </tr>
            </table>
        </form>


</body>

</html>
<? 
} }
?>