<?
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_addukey.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_addukey.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);


	mysql_query("INSERT INTO $db_table ( `event_id` , `event_day` , `event_month` , `event_year` , `event_ukey` ,`event_barang` ,`event_jaksa`) VALUES ('', '".addslashes($_POST['day'])."', '".addslashes($_POST['month'])."', '".addslashes($_POST['year'])."','".addslashes($_POST['ukey'])."','".addslashes($_POST['barang'])."', '".addslashes($_POST['jaksa'])."')");
	$_POST['month'] = $_POST['month'] + 1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>BARBUK</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?g=bbkeluar&' + 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.db.php");
$ukey1 = $_GET["ukey"];
$query = "(SELECT * FROM $tahun_now where UKEY = '$ukey1') 
           UNION
  
           (SELECT * FROM $tahun_before where UKEY = '$ukey1')"; 



$result = mysql_query($query); 
if($row = mysql_fetch_array($result)){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MASUKKAN BB KELUAR</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("barang", "ukey", "jaksa");
	var fieldDescription = Array("barang", "ukey", "jaksa");
	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 BB KELUAR
<hr>
  <table width="100%" border="0" cellspacing="4" cellpadding="4">
    <tr> 
      <td ><span class="addevent">TANGGAL BB KELUAR </span></td>
      <td >:</td>
      <td ><input name="day" type="hidden" value="<?PHP echo $day =$_GET['day']; ?>"><?PHP echo $day =$_GET['day']; ?>/<input name="month" type="hidden" value="<?PHP echo $day =$_GET['month']; ?>"><?PHP echo $month =$_GET['month']; ?>/<input name="year" type="hidden" value="<?PHP echo $day =$_GET['year']; ?>"><?PHP echo $year =$_GET['year']; ?>
           </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 BB KELUAR PENGELOLAAN BARANG BUKTI <?PHP echo "$satker"; ?></strong></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#FF0000"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
      <tr>
        <td bgcolor="#FFFFFF">
            <table width="100%"  border="0" cellspacing="4" cellpadding="4">
              <tr>
                <td width="100%"><table width="100%"  border="0" cellspacing="4" cellpadding="4">
                    <tr>
                      <td width="5%">&nbsp;</td>
                      <td width="26%">Ukey</td>
                      <td width="3%">:</td>
                      <td width="66%"><input name="ukey" type="text" id="ukey" value="<?PHP echo htmlspecialchars($row['UKEY']); ?>" size="50">
                        ID :
                          <input name="id" type="hidden" id="id" size="20" value="<?PHP echo htmlspecialchars($row['ID']); ?>">
                      <?PHP echo htmlspecialchars($row['ID']); ?> Nama Terdakwa : <?PHP echo htmlspecialchars($row['TERDAKWA']); ?></td>
                    </tr>
					 <tr>
                      <td>&nbsp;</td>
                      <td>Barang</td>
                      <td>:</td>
                      <td><textarea name="barang" cols="50" wrap="VIRTUAL" id="barang" readonly><?PHP echo htmlspecialchars($row['NAMABARANG']); ?></textarea></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>Jaksa Penanggungjawab </td>
                      <td>:</td>
                      <td><?php 
	mysql_connect("localhost", "root", "benk");
mysql_select_db("cma");
	$sql = "SELECT * FROM tab_personil where daftar_jenis = '1' ORDER BY daftar_nama";
    $result = mysql_query($sql);
    ?>
    <select name="jaksa1" id="jaksa1" class="font" onChange="updateText();"><option value="" selected></option>
    <?php while($row = mysql_fetch_array($result))
    { ?>
    <option value="<?php echo $row['daftar_nama']; ?>" class="font"><?php echo $row['daftar_nama']; ?></option>
    <?php }?>
    </select></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td><input name="jaksa" type="text" id="jaksa" size="40"></td>
                    </tr>
                   
                    <tr>
                      <td colspan="4">&nbsp;</td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td>
                  <div align="center"> </div></td>
              </tr>
              <tr>
                <td><div align="center">
                  <input type="reset" name="Reset" value="KOSONGKAN">
                  <input name="submit" type="submit" id="submit2" value="INPUT BB KELUAR">

                </div></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
              </tr>
            </table>
        </form>


</body>

</html>
<? 
} }
?>