<?PHP
require_once("index.config.php");
$db_connection = mysql_connect ($DBHost, $DBUser, $DBPass) OR die (mysql_error());  
$db_select = mysql_select_db ($DBName) or die (mysql_error());
$db_table = $TBL_PR . "events";
function getmicrotime(){ 
    list($usec, $sec) = explode(" ",microtime()); 
    return ((float)$usec + (float)$sec); 
} 
$time_start = getmicrotime();
IF(!isset($_GET['year'])){
    $_GET['year'] = date("Y");
}
IF(!isset($_GET['month'])){
    $_GET['month'] = date("n")+1;
}
$month = addslashes($_GET['month'] - 1);
$year = addslashes($_GET['year']);
$query = "SELECT event_id,event_day,event_ukey,event_status FROM $db_table WHERE event_month='$month' AND event_year='$year' ORDER BY event_ukey";
$query_result = mysql_query ($query);
while ($info = mysql_fetch_array($query_result))
{
    $day = $info['event_day'];
    $event_id = $info['event_id'];
    $events[$day][] = $info['event_id'];
	//Pemanggilan
   // $event_info[$event_id]['0'] = substr($info['event_tiket'], 0, 17);;
    $event_info[$event_id]['1'] = $info['event_ukey'];
	$event_info[$event_id]['2'] = $info['event_status'];
}
$todays_date = date("j");
$todays_month = date("n");
$days_in_month = date ("t", mktime(0,0,0,$_GET['month'],0,$_GET['year']));
$first_day_of_month = date ("w", mktime(0,0,0,$_GET['month']-1,1,$_GET['year']));
$first_day_of_month = $first_day_of_month + 1;
$count_boxes = 0;
$days_so_far = 0;
IF($_GET['month'] == 13){
    $next_month = 2;
    $next_year = $_GET['year'] + 1;
} ELSE {
    $next_month = $_GET['month'] + 1;
    $next_year = $_GET['year'];
}
IF($_GET['month'] == 2){
    $prev_month = 13;
    $prev_year = $_GET['year'] - 1;
} ELSE {
    $prev_month = $_GET['month'] - 1;
    $prev_year = $_GET['year'];
}
?>
<link href="images/calendar.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<script src="images/date_javascript.js"></script>
<script src="images/date_jquery.js"></script>
 <script>
$(function() {
$( "#datepicker" ).datepicker();
$( "#datepicker2" ).datepicker();
});
</script>
<SCRIPT TYPE="text/javascript">
<!--
// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
(key==9) || (key==13) || (key==27) )
return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
return true;

// decimal point jump
else if (dec && (keychar == "."))
{
myfield.form.elements[dec].focus();
return false;
}
else
return false;
}

//-->
</SCRIPT>
<script type="text/javascript">

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/

var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}
function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}
function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> Batasan karakter'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
}

      </script>  
 <link rel="stylesheet" type="text/css" href="flexdropdown.css" />

<script type="text/javascript" src="flexdropdown.js">
/***********************************************
* Flex Level Drop Down Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>       
<table width="100%"  border="0" cellspacing="6" cellpadding="6">
              <tr>
                <td><strong>BARBUK KELUAR - KEMBALI HARIAN  <? $tgl=date("d/m/Y");
$hr_skrg=date("d");
$bl_skrg=date("m");
?> | <?PHP echo "$satker"; ?></strong></td>
              </tr>
              <tr>
                <td>Modul Aplikasi ini digunakan apabila barang bukti tidak di titipkan, dilimpahkan ke PN namun hanya dibawa saat hari sidang saja dan wajib kembali pada sore hari / setelah sidang dengan catatan : TIDAK BOLEH MENGINAP SELAIN DALAM GUDANG BARANG BUKTI. PETUGAS DAPAT MENCETAK DAN MELAKUKAN KONTROL MELALUI LABEL KELUAR MASUK HARIAN DENGAN MELAKUKAN KLIK PADA NAMA TERDAKWA</td>
              </tr>
              <tr>
                <td><div align="center"><span class="currentdate"><? echo date ("F Y", mktime(0,0,0,$_GET['month']-1,1,$_GET['year'])); ?></span><br>
  <br>
</div>
<div align="center"><br>
  <table width="1000" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td><div align="right"><a href="<? echo "index.php?g=home&amp;month=$prev_month&amp;year=$prev_year"; ?>">&lt;&lt;</a></div></td>
      <td width="200"><div align="center">
            
          <select name="month" id="month" onChange="MM_jumpMenu('parent',this,0)">
            <?
			for ($i = 1; $i <= 12; $i++) {
				$link = $i+1;
				IF($_GET['month'] == $link){
					$selected = "selected";
				} ELSE {
					$selected = "";
				}
				echo "<option value=\"index.php?g=home&amp;month=$link&amp;year=$_GET[year]\" $selected>" . date ("F", mktime(0,0,0,$i,1,$_GET['year'])) . "</option>\n";
			}
			?>
          </select>
          <select name="year" id="year" onChange="MM_jumpMenu('parent',this,0)">
		  <?
		  for ($i = 2016; $i <= 2030; $i++) {
		  	IF($i == $_GET['year']){
				$selected = "selected";
			} ELSE {
				$selected = "";
			}
		  	echo "<option value=\"index.php?g=home&amp;month=$_GET[month]&amp;year=$i\" $selected>$i</option>\n";
		  }
		  ?>
          </select>
        </div></td>
      <td><div align="left"><a href="<? echo "index.php?g=home&amp;month=$next_month&amp;year=$next_year"; ?>">&gt;&gt;</a></div></td>
    </tr>
  </table>
  <br>
</div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="2">
        <tr class="topdays"> 
          <td><div align="center">MINGGU</div></td>
          <td><div align="center">SENIN</div></td>
          <td><div align="center">SELASA</div></td>
          <td><div align="center">RABU</div></td>
          <td><div align="center">KAMIS</div></td>
          <td><div align="center">JUMAT</div></td>
          <td><div align="center">SABTU</div></td>
        </tr>
		<tr valign="top" bgcolor="#FFFFFF"> 
		<?
		
		for ($i = 1; $i <= $first_day_of_month-1; $i++) {
			$days_so_far = $days_so_far + 1;
			$count_boxes = $count_boxes + 1;
			echo "<td width=\"100\" height=\"100\" class=\"beforedayboxes\"></td>\n";
		}
		for ($i = 1; $i <= $days_in_month; $i++) {
   			$days_so_far = $days_so_far + 1;
    			$count_boxes = $count_boxes + 1;
			IF($_GET['month'] == $todays_month+1){
				IF($i == $todays_date){
					$class = "highlighteddayboxes";
				} ELSE {
					$class = "dayboxes";
				}
			} ELSE {
				IF($i == 1){
					$class = "highlighteddayboxes";
				} ELSE {
					$class = "dayboxes";
				}
			}
			echo "<td width=\"100\" height=\"100\" class=\"$class\">\n";
			$link_month = $_GET['month'] - 1;
			
			echo "<table width=\"100%\"  border=\"0\" cellspacing=\1\" cellpadding=\"0\">
  <tr>

    <td><div align=\"center\">";
	
//if ($hr_skrg == $i AND $hr_skrg == $i AND $bl_skrg == $link_month) {
		//Print ('NO ALLOWED');} 
 // elseif ($hr_skrg !== $i AND $bl_skrg !== $link_month) {
echo "<a href=\"javascript:MM_openBrWindow('pilih.php?day=$i&amp;month=$link_month&amp;year=$_GET[year]','','width=700,height=300');\" class=\"menu\">BB KELUAR</a>";
//} 

	
	
	echo "</div></td>
  </tr>
</table>";

			
			echo "
			<div align=\"right\"><span class=\"toprightnumber\">\n<a href=\"javascript:MM_openBrWindow('event_add.php?day=$i&amp;month=$link_month&amp;year=$_GET[year]','','width=750,height=500');\">$i</a>&nbsp;</span></div>\n";
			IF(isset($events[$i])){
				echo "<div align=\"left\"><span class=\"eventinbox\">\n";
				while (list($key, $value) = each ($events[$i])) {
				//baris pemanggilan nama terdakwa
					echo "&nbsp;No : <a href=\"index.barbukview.php?ukey=".$event_info[$value]['1']."\" target=\"_blank\">" . $event_info[$value]['1'] . " | " . $event_info[$value]['2'] . "</a>\n<hr size=1>\n";
				}
				echo "</span></div>\n";
				
			}
			echo "</td>\n";
			
			IF(($count_boxes == 7) AND ($days_so_far != (($first_day_of_month-1) + $days_in_month))){
				$count_boxes = 0;
				echo "</TR><TR valign=\"top\">\n";
			}
		}
		$extra_boxes = 7 - $count_boxes;
		for ($i = 1; $i <= $extra_boxes; $i++) {
			echo "<td width=\"100\" height=\"100\" class=\"afterdayboxes\"></td>\n";
			
		}
		$time_end = getmicrotime();
		$time = round($time_end - $time_start, 3);
		?>
        </tr>
      </table></td>
  </tr>
</table>
<p align="center"><span class="footer">&copy; Camelon | Cross Affirmation Management Application<br>
    Halaman dibuat dalam waktu: <? echo $time; ?></span><br><br>
</p></td>
              </tr>
              <tr>
                <td>
                    </div></td>
                  </tr>
                </table>
</td>
              </tr>
</table>
