<?php
//penggunaan session_start harus ada di awal
if(!isset($_SESSION)){session_start();}
?>
<!DOCTYPE html>
<!-- tulisan 'DOCTYPE html' ==> INI HARUS HARUS ADA DAN LETAKNYA PALING ATAS (case sensitive)
sumber: 
http://users.tpg.com.au/j_birch/plugins/superfish/download/ 
en.wikipedia.org/wiki/Document_type_declaration
-->
<html>
<head>
<!-- title>HEADER</title -->
<!-- Mengisi Icon Logo Sritex di browser cek juga index.php -->
<link rel="shortcut icon" href="gambar/IconBrowser.ico" type="image/x-icon"/> 

<!-- Cara panggil file .css -->
<!-- <link rel="stylesheet" href="basic.css"/> -->


<style type="text/css">
<!--
#Info {
	position:absolute;
	left:700px;
	top:48px;
	width:228px;
	height:56px;
	z-index:1;
}
#LoginUser{
	position:relative;
	visibility: hidden;
}
#Garis {
	position:absolute;
	width:900px;
	height:1px;
	left: 17px;
	top: 92px;
}
#isiMenu {
	position: absolute;
	width:900px;
	height:1px;
	left: 17px;
	top: 105px;
}
#fieldsetBc {
	width:880px;
}
.sf-menu {line-height: 1;}
.createdby {font-size: xx-small}

-->
</style>

<!-- Loading All Function -->
<script type="text/javascript" src="AllFunc.js">  </script> 


<script>
	//Membuat Tanggal dan jam skrg
	//membuat jam : http://mkr-site.blogspot.com/2013/02/menampilkan-tanggal-waktu-jam-javascript.html
	function startTime() {
		bulan=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
		dayx=['Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu'];

		var today=new Date();
		curr_hour=today.getHours();
		curr_min=today.getMinutes();
		curr_sec=today.getSeconds();
		curr_hour=checkTime(curr_hour);
		curr_min=checkTime(curr_min);
		curr_sec=checkTime(curr_sec);
		day=dayx[today.getDay()];
		date=today.getDate();
		month=today.getMonth();
		year=today.getFullYear();
		//alert(today.getDate());

		isi_div=document.getElementById('LoginUser').innerHTML;
		document.getElementById('Info').innerHTML=isi_div+'<br> Tanggal : '+day+', '+date+' '+bulan[month]+' '+year+', '+curr_hour+":"+curr_min+":"+curr_sec;
	}
	function checkTime(i) {
		if (i<10) {
			i="0" + i;
		}
		return i;
	}
	setInterval(startTime, 500);


	// initialise plugins menu
	jQuery(function(){
		//supersubs dijalankan sblm superfish
//		$("ul.sf-menu").supersubs({
//			minWidth:    12,   // minimum width of sub-menus in em units
//			maxWidth:    27,   // maximum width of sub-menus in em units
//			extraWidth:  1     // extra width can ensure lines don't sometimes turn over
//							   // due to slight rounding differences and font-family
//		});
//		//superfish dijalankan setelah supersubs
		jQuery('ul.sf-menu').superfish({
			//animation: {opacity: 'show'},
			//animationOut: {opacity: 'hide'},
			delay:500, //800 default
			speed: 'fast',
			speedOut: 'fast',
			cssArrows: true,
			useClick: true
		});		
	});

	$(document).ready(function(){
//		// initialise plugin
//		var example = $('#example').superfish({
//			//add options here if required
//		});

		//Open - Form Change Profile
		$('#902').click(function(){
			window.location.assign("regisEdit.php")
		});


		//Open - Form Dialog About
		$('#903').click(function(){
			//utk ganti isi about
			//$('#about').text("ini isi dialog yg di ganti");
			$("#about").show();
			$('#about').dialog('open');
		});


		//mengisi info komputer client
		$("#jqueryversion").text("JQUERY Version: "+ $.fn.jquery);
		//sumber => http://www.quirksmode.org/js/detect.html
		$("#platform").text("Platform: "+ navigator.platform);
		//$("#appCodeName").text("appCodeName: "+navigator.appCodeName);
	
	});
</script>

</head>
<body>


<?php
//letakan set lokasi pada saat menampilkan jam di php
//date_default_timezone_set('Asia/Jakarta');

//aktifkan session
//@ob_start();
//session_start();
//if(!isset($_SESSION)){session_start();}
if(!isset($_SESSION['f_user'])){$fuserx="Guest";$ffullnamex="";}else {$fuserx = $_SESSION['f_user'];$ffullnamex=$_SESSION['f_fullname'];}
if(!isset($_SESSION['f_pass'])){$f_pass="";}else{$f_pass = $_SESSION['f_pass'];}
if(!isset($_SESSION['f_keterangan'])){$f_keteranganx="";}else{$f_keteranganx = $_SESSION['f_keterangan'];}

//Source datagrid    => http://www.jeasyui.com/tutorial/datagrid/datagrid2.php , http://www.jeasyui.com/tutorial/
//Source menu easyui => https://www.jeasyui.com/forum/index.php?topic=5830.0
include ('connect-DB.php');

/*//----- hanya di buka jika di perlukan utk merubah menu -----
//------------------------- insert menu ----------------------------------------
// Cek table Menu
$ketemu=false;
$result = db2_tables($conn_db2, NULL, "DB2ADMIN");
while ($row = db2_fetch_array($result) and !($ketemu)) {
	if (strtoupper($row[2]=="MENUSTX"))
	{$ketemu=true;}
}

//bisa di tutup kl proses insert sdh jalan
if (true) {
	//hapus table
	$delete = 'DROP TABLE MENUSTX';
	//delete isi table
	//$delete = 'DELETE FROM STXOUTSTANDINGAR';
	$result = db2_exec($conn_db2, $delete);
	//die();
	$ketemu=false;
}

//jika table menu tidak ada maka buatlah
if ( !($ketemu) ){
	//jika tabel STXOUTSTANDINGAR hilang maka buat baru
	//create table
	$create = 'CREATE TABLE MENUSTX (id decimal(4,0), parent_id decimal(4,0), title char(50), url char(50), menu_order decimal(4,0) )';
	$result = db2_exec($conn_db2, $create);
	//initial query
	$query  = array();
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (1,0,'Home','#',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (2,0,'Transaksi','#',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (3,0,'Laporan','#',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (5,3,'Lap. Cust / suplier','sup_cust.php',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (6,3,'Lap. ArInv-Datatex','arinvdtx.php',4)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (7,3,'Lap. Inv-Datatex','invdtx.php',5)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (8,3,'Lap. Shipment cossacc-Datatex','ShipmentCostAcc.php',2)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (4,0,'About','#',1)";
	//old=> $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (6,3,'Lap. Oracle2Db2','invoracle2db2.php',2)";
	//old=> $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (7,3,'Lap. ArInv-Oracle','arinv.php',3)";
	for ($i=0;$i<count($query);$i++){
		$result = db2_exec($conn_db2, $query[$i]) or die("ERROR.. gagal insert NEW data");
	}
}
//------------------------- end insert menu ----------------------------------------
*/

$ketemu=false;
//$dbname="sritex3";

$dbname = $datalogin;

//$sql = "SHOW TABLES FROM $dbname";
//$result = mysql_query($sql);
//while ($row = mysql_fetch_row($result)) {
//	if (strtoupper($row[0])=="MENUSTX")
//	{$ketemu=true;}
//}


////bisa di tutup kl proses insert sdh jalan
////if ($ketemu) {
//	//hapus table
//	$delete = 'DROP TABLE IF EXISTS MENUSTX';
//	//delete isi table
//	//$delete = 'DELETE FROM MENUSTX';
//	$result = mysqli_query($conn_login,$delete);
////	$ketemu=false;
////}


//jika table menu tidak ada maka buatlah
//if ( !$ketemu ){
	//jika tabel MENUSTX hilang maka buat baru
	//create table
	$create = 'CREATE TABLE IF NOT EXISTS MENUSTX (id numeric(4,0), parent_id numeric(4,0), title char(50), url char(50), menu_order numeric(4,0) )';
	$result = mysqli_query($conn_login,$create);// or die("ERROR.. gagal buat table MENUSTX");

	//hapus table
	$delete = 'DELETE FROM MENUSTX';
	$result = mysqli_query($conn_login,$delete);
	
	//initial query dalam array
	$query  = array();
	//Root
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (1 ,0,'Master','#',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (2 ,0,'Transaksi','#',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (3 ,0,'Laporan','#',1)";

	//Root-1 Master
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (4  ,1,'Barang','barang.php',1)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (5  ,1,'Suplier','suplier.php',2)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (6  ,1,'Customer','customer.php',3)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (9  ,1,'Stok Gdg' ,'stokgd.php',7)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (10 ,1,'Stok Toko','stoktk.php',8)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (4 ,1,'(1000)Data Nasabah','1000.php',4)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (6 ,1,'Item Barang','item.php',4)";
	////Transaksi
	////PO di bikin sub	
////	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (7 ,2,'Transaksi PO','#',1)";
////	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (15 ,7,'PO','pom.php',1)";
    //// 20150910, di tutup krn ganti yg baru =>	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (16 ,7,'PO Detail','pod.php',2)";
	////Gudang
	//// 20160414, ditutup => $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (8,2,'Transaksi Gudang /w BC','icm.php',3)"; //
	////$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (12,2,'Transaksi Gudang-Detail','icd.php',4)";
    //// 20150910, di tutup krn ganti yg baru => $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (9,2,'Transaksi Hutang-Pembelian','mbbm.php',5)";
    //// 20150910, di tutup krn ganti yg baru => $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (10,2,'Transaksi AR','tran.php',6)"; 
	
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (10,2,'AX AP BAYAR (LPP)','axaplppbyr.php',6)"; //$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (10,2,'AX AP BAYAR (LPP)','axapbayar.php',6)"; 
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (11,2,'Transaksi Beacukai (AX)','axbcm.php',7)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (15,2,'Pengajuan Beacukai (AX)','ajuanm.php',8)";

	////UPDATE di bikin sub	// 20160414, ditutup karena ini hanya utk program lama clipper
	//// 20160414, ditutup => $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (12,2,'Update','#',8)";
	//// 20160414, ditutup => $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (13,12,'Update Beacukai Detail','updbcdetail.php',1)";
	//// 20160414, ditutup => $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (14,12,'Update Kurs (Jual Beacukai)','kursjual.php',2)";

	//Root-2 Transaksi
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (16,2,'Beli','beligd.php',1)";					//dr suplier ke gudang
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (17,2,'Jual putus','jualgd.php',2)";		//dr gudang langsung jual
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (18,2,'Konsinyasi','',3)";							//titip
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (19,18,'Kirim toko','kirimtk.php',1)";	//dr gudang ke toko
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (20,18,'Jual Toko' ,'jualtk.php',2)";		//stok toko diakui sbg terjual
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (21,18,'Retur Toko','returtk.php',3)";	//dr toko ke gudang


	//Root-3 Laporan
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (21  ,3,'Harga Beli Terakhir','hargabeli.php',4)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (22  ,3,'Harga Jual Terakhir','hargajual.php',5)";
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (23  ,3,'Harga Kirim Terakhir','hargatk.php',6)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (40000,3,'Absen Summary','absensum.php',1)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (40010,3,'Laporan Tabungan','#',2)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (48205,40010,'(8205) Laporan nominatif tabungan','8205.php',1)";
	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (40001,3,'Laporan Deposito','#',3)";

	//$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (11,2,'Transaksi LPP','lpp.php',8)";
	//Root-ABOUT
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (901,0,'About','#',1)";
  $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (902,901,'Edit Profile','#',1)";
  $query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (903,901,'About','#',2)";
  //Root-LOGOUT
	$query[]= "INSERT INTO MENUSTX (id, parent_id, title, url, menu_order) VALUES (999,0,'Logout','keluar.php',1)";

	//simpan
	for ($i=0;$i<count($query);$i++){
		$result = mysqli_query($conn_login,$query[$i]) or die("ERROR.. gagal insert NEW data");
	}
//}

//function ini berisi rumus utk buat menu
function get_menu($data, $parent = 0, $satux = 0) {
	static $i = 1;
	$tab = str_repeat("\t\t", $i);
	if (isset($data[$parent])) {
		$html ="";		
		if ($satux==0) {			
			$html .= "\n$tab<ul class='sf-menu' id='example'>";	
			$satux=1;
		}
		else{$html .= "\n$tab<ul>";}
		$i++;
		foreach ($data[$parent] as $v) {
			$child = get_menu($data, $v->id,$satux);
			$html .= "\n\t$tab<li id='".trim($v->id)."'>";
			$html .= '<a href="'.trim($v->url).'" >'.trim($v->title).'</a>';
			//$html .= '<a id="'.trim($v->ID).'" href="'.trim($v->URL).'" >'.trim($v->TITLE).'</a>';
			//menurut superfish (cek lagi)
			//$html .= "\n\t$tab<li class='current'>";
			//$html .= '<a class="'.'sf-with-ul" href="'.$v->URL.'">'.$v->TITLE.'</a>';
			if ($child) {
				$i--;
				$html .= $child;
				$html .= "\n\t$tab";
			}
			$html .= '</li>';
		}
		$html .= "\n$tab </ul>";
		return $html;
	} else {
		return false;
	}
}

//buat isi data menu
$sql = "SELECT * FROM MENUSTX";
$result = mysqli_query($conn_login,$sql);
while ($row = mysqli_fetch_object($result)) {
	$data[$row->parent_id][] = $row;
}
//release memory $result
mysqli_free_result($result);
//kirim data menu ke function
$menu = get_menu($data);

//cetak logo
$logox ="";
$logox .="<img src=\"./gambar/LogoHeader.gif\" />";

//cetak login user
$logox .="<div id=\"LoginUser\" >
			Login user : $fuserx - $ffullnamex<br>
			Lokasi	   : $f_keteranganx
		  </div>";
$logox .="<div id=\"Info\"></div>";

//cetak garis
//$logox .="<hr align=left width=900px>";
$logox .="<hr id='Garis'>";
echo $logox;

//cetak menu
echo $html ="<div id='isiMenu'>".$menu."</div><br>";

?>

<!-- Menampilkan Dialog - About -->

<div id="about" class="easyui-dialog" title="About Program Web BPR"  
	data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true"
	style="width:480px;height:420px;padding:5px;top:100px;left:300px;" hidden>

	<h1>History :</h1>
	<p>
	<u>Change log - v2021.08.28</u><br>
	- Initial on server <br>
	</p>
	<?php 
	  echo "<br><hr>";
	  //echo "Server OS: ".php_uname().PHP_OS."<br><br>";
	  echo 'Current PHP version: ' . phpversion();
	  printf("<br><br>MySQL server version: %s\n", mysqli_get_server_info($conn_login));
	?>
	<br><br><div id="jqueryversion"></div>
	<!--br><div id="platform"></div -->
	<br><?php echo "Browser client: ".$_SERVER['HTTP_USER_AGENT']; ?> <br>

    <hr>
   <center>
     <p><a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#about').dialog('close')">Close</a></p>    
   </center>   
	<div align="center"><span class="createdby">Created by : <a href="mailto:hendro@sritex.co.id">Hendro Pranata</a></span></div>
</div>  

<!--
Penggunaan link ke hp/bb/android, sumber => http://copygocopy.blogspot.co.id/2014/02/membuat-HTML-link-langsung-menuju-SMS-dan-Telepon.html
semua ini akan aktif jika masuk ke HP
-------------------------------------
sharing text ke whatsapp
<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>
sharing text ke sms
<a href="sms:088827">sms</a>
<a href="sms:?&body=Pesan di tubuh body disini">Link menuju sms body terisi</a>
sharing to call (telp)
<a href="tel:088827">Link telepon</a>
contoh penggunaan :
<script type='text/javascript'>
if( /Opera Mini|BlackBerry|Android|webOS|iPhone|iPad|IEMobile/i.test(navigator.userAgent) ) {
   document.write('<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>');
}
</script>

sharing ke BBM, sumber => http://copygocopy.blogspot.co.id/2015/11/Berbagi-lamanWeb-diBrowser-android-dan-link-menuju-BBM.html
--------------
<a href="bbmi://api/share?message=pesan-bagi&userCustomMessage=yang-ingin-dibagikan">text link ke Apl BBM</a>
Atau begini
<a href="bbmi://api/share?userCustomMessage=URL - Tambah string text"> text link ke Apl BBM</a>
Dan link ke BBM untuk invite PIN atau mulai ngobrol dengan temannya adalah:
<a href="bbmi://NO_PIN_BBM">Mulai obrolan atau Invite PIN saya</a>

-->

</body>
</html>
