<?php
# Baca Variabel Form
$message = array();
$Act	 	 		= isset($_REQUEST['Act']) ? $_REQUEST['Act'] : '';
$Act_Det 	 		= isset($_REQUEST['Act_Det']) ? $_REQUEST['Act_Det'] : '';
$jurnal_id 	 		= isset($_REQUEST['jurnal_id']) ? $_REQUEST['jurnal_id'] : '';
$jurnal_type		= isset($_REQUEST['jurnal_type']) ? $_REQUEST['jurnal_type'] : '';
$jurnal_no			= isset($_REQUEST['jurnal_no']) ? $_REQUEST['jurnal_no'] : get_jurnalno();
$jurnal_date  		= isset($_REQUEST['jurnal_date']) ? $_REQUEST['jurnal_date'] : '';
$jurnal_iddept		= isset($_REQUEST['jurnal_iddept']) ? $_REQUEST['jurnal_iddept'] : '';
$cust_id			= isset($_REQUEST['cust_id']) ? $_REQUEST['cust_id'] : '';
$cust_name			= isset($_REQUEST['cust_name']) ? $_REQUEST['cust_name'] : '';
$sup_id			 	= isset($_REQUEST['sup_id']) ? $_REQUEST['sup_id'] : '';
$sup_name		 	= isset($_REQUEST['sup_name']) ? $_REQUEST['sup_name'] : '';
$jurnal_ptype		= isset($_REQUEST['jurnal_ptype']) ? $_REQUEST['jurnal_ptype'] : '';
$jurnal_idbank		= isset($_REQUEST['jurnal_idbank']) ? $_REQUEST['jurnal_idbank'] : '';
$jurnal_invno		= isset($_REQUEST['jurnal_invno']) ? $_REQUEST['jurnal_invno'] : '';
$jurnal_currency	= isset($_REQUEST['jurnal_currency']) ? $_REQUEST['jurnal_currency'] : '';
$jurnal_duedate		= isset($_REQUEST['jurnal_duedate']) ? $_REQUEST['jurnal_duedate'] : '';
$jurnal_chequeno	= isset($_REQUEST['jurnal_chequeno']) ? $_REQUEST['jurnal_chequeno'] : '';
$jurnal_girono		= isset($_REQUEST['jurnal_girono']) ? $_REQUEST['jurnal_girono'] : '';
$jurnal_rate		= isset($_REQUEST['jurnal_rate']) ? $_REQUEST['jurnal_rate'] : 0;
$total				= isset($_REQUEST['total']) ? $_REQUEST['total'] : '';
$rate				= get_rate($jurnal_currency,$jurnal_date);
$npwp      			= isset($_REQUEST['npwp']) ? $_REQUEST['npwp'] : '';
#detail
$id_det				= isset($_REQUEST['id_det']) ? $_REQUEST['id_det'] : '';
$id_deth			= isset($_REQUEST['id_deth']) ? $_REQUEST['id_deth'] : '';
$jurnald_acctno     = isset($_REQUEST['acctno']) ? $_REQUEST['acctno'] : '';
$jurnald_desc   	= isset($_REQUEST['acctdesc']) ? $_REQUEST['acctdesc'] : '';
$acctamount 		= isset($_REQUEST['acctamount']) ? $_REQUEST['acctamount'] : '';
$jurnald_status     = isset($_REQUEST['acctstatus']) ? $_REQUEST['acctstatus'] : '';
$pilih2			    = isset($_REQUEST['pilih2']) ? $_REQUEST['pilih2'] : 0;
$jurnal_amount      = isset($_REQUEST['tdebit']) ? $_REQUEST['tdebit'] : 0;
$jurnal_amount_usd  = isset($_REQUEST['tdebit_usd']) ? $_REQUEST['tdebit_usd'] : 0;
$supcust_code		= isset($_REQUEST['supcust_code']) ? $_REQUEST['supcust_code'] : 0;
$jurnal_trcid		= isset($_REQUEST['jurnal_trcid']) ? $_REQUEST['jurnal_trcid'] : 0;
$fromdate	 		= isset($_REQUEST['fromdate']) ? $_REQUEST['fromdate'] : $date;
$todate     		= isset($_REQUEST['todate']) ? $_REQUEST['todate'] : $date; 
$jurnal_nofaktur	= isset($_REQUEST['jurnal_nofaktur']) ? $_REQUEST['jurnal_nofaktur'] : '';
$hdr_id				= isset($_REQUEST['hdr_id']) ? $_REQUEST['hdr_id'] : '';
$tipe				= isset($_REQUEST['tipe']) ? $_REQUEST['tipe'] : '';
$tipe_del			= isset($_REQUEST['tipe_del']) ? $_REQUEST['tipe_del'] : '';
$jurnal_menu		= isset($_REQUEST['jurnal_menu']) ? $_REQUEST['jurnal_menu'] : '';
if($jurnal_currency=="IDR"){
	if(!empty($jurnal_rate)){
		$jurnald_amount_usd = $acctamount / $jurnal_rate;
	}else{
		$jurnald_amount_usd =0;
	}
	$jurnald_amount     = $acctamount;
}else{
	$jurnald_amount_usd = $acctamount;
	$jurnald_amount     = $acctamount * $jurnal_rate;
}
if($Act =="SEL_SUP"){
	$data=mysql_fetch_array(mysql_query("SELECT a.id, a.kode, a.nama, snpwp, CONCAT_WS(' - ', a.kode, a.nama) codename, a.tipe FROM
								(SELECT id, sup_code kode, sup_name nama, sup_npwp snpwp, 'SUP' tipe FROM supplier WHERE sup_status=10
								UNION
								SELECT id, cust_code kode, cust_name nama, cust_npwp snpwp, 'CUS' tipe FROM customer WHERE cust_status=10) a WHERE a.kode='$supcust_code'"));
	$npwp = $data['snpwp'];		
	$supcust_code = $data['kode'];	
	$sup_id = $data['id'];
	$sup_name = $data['nama'];
}
#cek jurnal no
$cekno = mysql_fetch_array(mysql_query("SELECT jurnal_no FROM jurnal WHERE jurnal_no='$jurnal_no'"));
if(!empty($cekno['jurnal_no']) && empty($jurnal_id)){
	$jrn = "NO";
}else{
	$jrn = "OK";
}
if($Act =="SAVE"){	
	if($jrn=="NO"){
		echo "<font color='red'>Nomor Jurnal sudah ada silakan isi nomor jurnal yang baru</font><br>";
		#reload
		require_once "add_jurnal_referensi.php";
		exit;
	}else{
		if(count($message)==0){	
			if(empty($jurnal_id)){
				$qrySave=mysql_query("INSERT INTO jurnal SET jurnal_type='$jurnal_type', jurnal_no='$jurnal_no', jurnal_date='$jurnal_date', jurnal_iddept='$jurnal_iddept', 
								  jurnal_idcust='$cust_id', jurnal_idsupp='$sup_id', jurnal_ptype='$jurnal_ptype', jurnal_idbank='$jurnal_idbank', jurnal_invno='$jurnal_invno',
								  jurnal_currency='$jurnal_currency', jurnal_duedate='$jurnal_duedate', jurnal_chequeno='$jurnal_chequeno', jurnal_girono='$jurnal_girono', 	
								  jurnal_rate='$jurnal_rate', jurnal_amount='$jurnal_amount', jurnal_amount_usd='$jurnal_amount_usd', jurnal_idpemasok='$npwp',
								  jurnal_suppname='$sup_name', jurnal_custname='$cust_name', jurnal_inputby='$user_id', jurnal_inputdate='$datetime', jurnal_status=20,
								  jurnal_menu='BCALL', jurnal_nofaktur='$jurnal_nofaktur', jurnal_supcustcode='$supcust_code'") 
								  or die ("Gagal query".mysql_error());
				if($qrySave){
					$query = mysql_query("SELECT * FROM jurnal_temp WHERE jurnald_inputby='$user_id' AND jurnald_status IN(10,20) ORDER BY id ASC");
					while($dt=mysql_fetch_object($query)){
						mysql_query("INSERT INTO jurnal_detail SET jurnal_no='$jurnal_no', jurnald_acctno='$dt->jurnald_acctno', jurnald_status='$dt->jurnald_status',
									 jurnald_desc='".mysql_real_escape_string($dt->jurnald_desc)."', jurnald_amount='$dt->jurnald_amount', jurnald_inputby='$user_id', jurnald_inputdate='$datetime',
									 jurnald_inchid='$dt->jurnald_inchid', jurnald_invno_acct='$dt->jurnald_invno_acct', jurnald_amount_usd='$dt->jurnald_amount_usd'");
					}
					mysql_query("DELETE FROM jurnal_temp WHERE jurnald_inputby='$user_id' AND jurnald_status IN(10,20)");
				}	
				#Insert History User
				mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Menambahkan transaksi jurnal No. $jurnal_no', user_date='$date', user_time='$time'");
							  
			}elseif(!empty($jurnal_id) && ($Act_Det <> "ADD_DET")){
				foreach($id_det as $i => $id){
					$j_acctno		= $_REQUEST['j_acctno'][$id];
					$jurnald_desc	= $_REQUEST['jurnald_desc'][$id];
					$debit_usd		= $_REQUEST['debit_usd'][$id];
					$debit			= $_REQUEST['debit'][$id];
					$kredit_usd		= $_REQUEST['kredit_usd'][$id];
					$kredit			= $_REQUEST['kredit'][$id];
					$jurnald_status = $_REQUEST['jurnald_status'][$id];
					if($jurnald_status==10){
						$jurnal_amount  = $debit; 
						$jurnal_amount_usd = $debit_usd;
						mysql_query("UPDATE jurnal_detail SET jurnald_acctno='$j_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$debit', jurnald_amount_usd='$debit_usd' WHERE id='$id' ");
					}else{
						mysql_query("UPDATE jurnal_detail SET jurnald_acctno='$j_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$kredit', jurnald_amount_usd='$kredit_usd' WHERE id='$id' ");
					}
				}
				$qrySave=mysql_query("UPDATE jurnal SET jurnal_type='$jurnal_type', jurnal_no='$jurnal_no', jurnal_date='$jurnal_date', jurnal_iddept='$jurnal_iddept', 
								  jurnal_idcust='$cust_id', jurnal_idsupp='$sup_id', jurnal_ptype='$jurnal_ptype', jurnal_idbank='$jurnal_idbank', jurnal_invno='$jurnal_invno',
								  jurnal_currency='$jurnal_currency', jurnal_duedate='$jurnal_duedate', jurnal_chequeno='$jurnal_chequeno', jurnal_girono='$jurnal_girono', jurnal_rate='$jurnal_rate', jurnal_amount='$jurnal_amount', jurnal_amount_usd='$jurnal_amount_usd', jurnal_idpemasok='$npwp',
								  jurnal_suppname='$sup_name', jurnal_custname='$cust_name', jurnal_status=20, jurnal_nofaktur='$jurnal_nofaktur', jurnal_supcustcode='$supcust_code' WHERE id='$jurnal_id'") or die ("Gagal query".mysql_error());
				#Insert History User
				mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Mengubah transaksi jurnal No. $jurnal_no', user_date='$date', user_time='$time'");
		}				
			if($qrySave){
				$message[] = "Data Sukses tersimpan";	
				$status = "OK";
				
			}
		}
	}
}		
if($Act =="SAVE2"){	
	if($jrn=="NO"){
		echo "<font color='red'>Nomor Jurnal sudah ada silakan isi nomor jurnal yang baru</font><br>";
		#reload
		require_once "add_jurnal_referensi.php";
		exit;
	}else{
		if(count($message)==0){	
			if(!empty($jurnal_id)){
				#Update Detail
				foreach($id_det as $i => $id){
					$j_acctno		= $_REQUEST['j_acctno'][$id];
					$jurnald_desc	= $_REQUEST['jurnald_desc'][$id];
					$debit_usd		= $_REQUEST['debit_usd'][$id];
					$debit			= $_REQUEST['debit'][$id];
					$kredit_usd		= $_REQUEST['kredit_usd'][$id];
					$kredit			= $_REQUEST['kredit'][$id];
					$jurnald_status = $_REQUEST['jurnald_status'][$id];					
					if($jurnald_status==10){
						$jurnal_amount  = $debit; 
						$jurnal_amount_usd = $debit_usd;
						mysql_query("UPDATE jurnal_detail SET jurnald_acctno='$j_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$debit', jurnald_amount_usd='$debit_usd' WHERE id='$id' ");
					}else{						
						mysql_query("UPDATE jurnal_detail SET jurnald_acctno='$j_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$kredit', jurnald_amount_usd='$kredit_usd' WHERE id='$id' ");
					}
				}
				$qrySave=mysql_query("UPDATE jurnal SET jurnal_date='$jurnal_date', jurnal_iddept='$jurnal_iddept', jurnal_idsupp='$sup_id', jurnal_invno='$jurnal_invno',
								  jurnal_currency='$jurnal_currency', jurnal_amount='$jurnal_amount', jurnal_amount_usd='$jurnal_amount_usd', jurnal_suppname='$sup_name', 
								  jurnal_idsupp='$sup_id', jurnal_idcust='$cust_id', jurnal_custname='$cust_name', jurnal_status=20, jurnal_nofaktur='$jurnal_nofaktur',jurnal_idpemasok='$npwp',
								  jurnal_duedate='$jurnal_duedate', jurnal_chequeno='$jurnal_chequeno', jurnal_girono='$jurnal_girono' WHERE id='$jurnal_id'") or die ("Gagal query".mysql_error());
				if($qrySave){				
					#Insert History User
					mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Mengubah transaksi jurnal No. $jurnal_no', user_date='$date', user_time='$time'");
				}							  
			}				
			if($qrySave){
				$message[] = "Data Sukses tersimpan";	
				$status = "OK";
				
			}
		}
	}
}	
if($Act =="DETAIL"){
	$qd = mysql_query("SELECT a.*,d.dept_name, e.mb_bank FROM jurnal a
					   LEFT JOIN departement d ON d.id=a.jurnal_iddept
					   LEFT JOIN master_bank e ON e.id=a.jurnal_idbank					   	   
					   WHERE a.id='$jurnal_id'");
	$dd=mysql_fetch_array($qd);		
	$jurnal_id 			= $dd['id'];			
	$jurnal_type		= $dd['jurnal_type'];
	$jurnal_no 			= $dd['jurnal_no'];
	$jurnal_date		= $dd['jurnal_date'];
	$jurnal_iddept  	= $dd['jurnal_iddept'];
	$cust_id			= $dd['jurnal_idcust'];
	$cust_name			= $dd['jurnal_custname'];
	$sup_id			    = $dd['jurnal_idsupp'];
	$sup_name		    = $dd['jurnal_suppname'];
	$jurnal_ptype		= $dd['jurnal_ptype'];
	$jurnal_idbank		= $dd['jurnal_idbank'];
	$jurnal_invno		= $dd['jurnal_invno'];
	$jurnal_currency	= $dd['jurnal_currency'];
	$jurnal_duedate		= $dd['jurnal_duedate'];
	$jurnal_chequeno	= $dd['jurnal_chequeno'];
	$jurnal_girono		= $dd['jurnal_girono'];
	$jurnal_rate		= $dd['jurnal_rate'];
	$tdebit			    = $dd['jurnal_amount'];
	$tdebit_usd			= $dd['jurnal_amount_usd'];
	$npwp				= $dd['jurnal_idpemasok'];
	$jurnal_trcid		= $dd['jurnal_trcid'];
	$jurnal_nofaktur	= $dd['jurnal_nofaktur'];
	$jurnal_menu		= $dd['jurnal_menu'];		
	$data=mysql_fetch_array(mysql_query("SELECT a.id, a.kode, a.nama, snpwp, CONCAT_WS(' - ', a.kode, a.nama) codename, a.tipe FROM
								(SELECT id, sup_code kode, sup_name nama, sup_npwp snpwp, 'SUP' tipe FROM supplier WHERE sup_status=10
								UNION
								SELECT id, cust_code kode, cust_name nama, cust_npwp snpwp, 'CUS' tipe FROM customer WHERE cust_status=10) a WHERE a.kode='$dd[jurnal_supcustcode]'"));		
	$supcust_code = $data['kode'];
}
if($Act == "DELETE"){
	#header
	mysql_query("UPDATE jurnal SET jurnal_status=100, jurnal_nodel='$jurnal_no', jurnal_no='DELETE' WHERE id='$jurnal_id'");
	#detail
	mysql_query("UPDATE jurnal_detail SET jurnal_nodel='$jurnal_no', jurnal_no='DELETE' WHERE jurnal_no='$jurnal_no'");
	#dari inbox dan outbox
	$cek = mysql_fetch_array(mysql_query("SELECT jurnal_type, jurnal_menu, jurnal_trcid FROM jurnal WHERE id='$jurnal_id'"));
	if(($cek['jurnal_type']=="HT" && $cek['jurnal_menu']=="BC" ) || $cek['jurnal_menu']=="BCINC"){
		mysql_query("UPDATE incoming SET inch_paytype='', inch_invno_acct='', inch_invdate_acct='',
			inch_debit='', inch_kredit='', inch_jurnalno='', inch_jurnaldate='',inch_ajd_nidr='', inch_ajd='' WHERE id='$cek[jurnal_trcid]'");
	}elseif(($cek['jurnal_type']=="PT" && $cek['jurnal_menu']=="BC") || $cek['jurnal_menu']=="BCOUT"){
		mysql_query("UPDATE outgoing SET outh_paytype='', outh_invno_acct='', outh_invdate_acct='',
			outh_debit='', outh_kredit='', outh_jurnalno='', outh_jurnaldate='', outh_ajd_nidr='', outh_ajd='' WHERE id='$cek[jurnal_trcid]'");
	}
	#Insert History User
	$itemp = mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Menghapus transaksi jurnal No. $jurnal_no', user_date='$date', user_time='$time'");
	$message[] = "Data Sukses terhapus !";	
	$status = "OK";
}
if($Act == "DELETEJLL"){
	if($tipe_del=="INC"){
		$qd = mysql_query("UPDATE incoming SET inch_paytype='' WHERE id='$hdr_id'");
		if($qd){
			#Insert History User
			$itemp = mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Menghapus transaksi jurnal lain-lain ID INC. $hdr_id', user_date='$date', user_time='$time'");
			$message[] = "Data Sukses terhapus !";	
			$status = "OK";
		}
	}else{
		$qd = mysql_query("UPDATE outgoing SET outh_paytype='' WHERE id='$hdr_id'");
		if($qd){
			#Insert History User
			$itemp = mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Menghapus transaksi jurnal lain-lain ID OUT. $hdr_id', user_date='$date', user_time='$time'");
			$message[] = "Data Sukses terhapus !";	
			$status = "OK";
		}
	}
}
if($Act == "POSTING"){
	#Update status menjadi posting
	$qd = mysql_query("UPDATE jurnal SET jurnal_status=20 WHERE id='$jurnal_id'");
	#Insert History User
	$itemp = mysql_query("INSERT INTO user_activity SET user_id='$user_id', user_act='Posting transaksi jurnal No. $jurnal_no', user_date='$date', user_time='$time'");
	$message[] = "Data Sukses diposting !";	
	$status = "OK";
}
if(($Act_Det == "ADD_DET") && (empty($jurnal_id))){ 
	mysql_query("INSERT INTO jurnal_temp SET jurnald_acctno='$jurnald_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$jurnald_amount',
	jurnald_amount_usd='$jurnald_amount_usd', jurnald_inputby='$user_id', jurnald_inputdate='$datetime', jurnald_status='$jurnald_status'");
}elseif(($Act_Det == "ADD_DET") && (!empty($jurnal_id))){
	mysql_query("INSERT INTO jurnal_detail SET jurnal_no='$jurnal_no', jurnald_acctno='$jurnald_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$jurnald_amount',
	jurnald_amount_usd='$jurnald_amount_usd', jurnald_inputby='$user_id', jurnald_inputdate='$datetime', jurnald_status='$jurnald_status'");
}elseif(($Act_Det == "ADD_DET2") && (empty($jurnal_id))){ 
	foreach($pilih2 as $i => $id){
		$jurnald_acctno2		= $_REQUEST['jurnald_acctno2'][$id];
		$jurnald_desc2			= $_REQUEST['jurnald_desc2'][$id];
		$acctamount2			= $_REQUEST['jurnald_amount2'][$id];
		$jurnald_status2		= $_REQUEST['jurnald_status2'][$id];
		$jurnald_invno_acct2	= $_REQUEST['jurnald_invno_acct2'][$id]; 
		if($jurnal_currency=="IDR"){
			if(!empty($jurnal_rate)){
				$jurnald_amount_usd2 = $acctamount2 / $jurnal_rate;
			}else{
				$jurnald_amount_usd2 =0;
			}
			$jurnald_amount2     = $acctamount2;
		}else{
			$jurnald_amount_usd2 = $acctamount2;
			$jurnald_amount2     = $acctamount2 * $jurnal_rate;
		}
		if($jurnald_amount2 > 0){
			mysql_query("INSERT INTO jurnal_temp SET jurnald_acctno='$jurnald_acctno2', jurnald_desc='".mysql_real_escape_string($jurnald_desc2)."', jurnald_amount='$jurnald_amount2',
			jurnald_inputby='$user_id', jurnald_inputdate='$datetime', jurnald_status='$jurnald_status2', jurnald_inchid='$id', jurnald_invno_acct='$jurnald_invno_acct2',
			jurnald_amount_usd='$jurnald_amount_usd2'");
		}
	}
}

if(($Act_Det == "DELETE_DET") && (empty($jurnal_id))){
	mysql_query("DELETE FROM jurnal_temp WHERE id='$id_deth'");
}elseif(($Act_Det == "DELETE_DET") && (!empty($jurnal_id))){
	mysql_query("DELETE FROM jurnal_detail WHERE id='$id_deth'");
}
if(($Act_Det == "UPDATE_DET") && (empty($jurnal_id))){
	foreach($id_det as $i => $id){
		$j_acctno		= $_REQUEST['j_acctno'][$id];
		$jurnald_desc	= $_REQUEST['jurnald_desc'][$id];
		$debit_usd		= $_REQUEST['debit_usd'][$id];
		$debit			= $_REQUEST['debit'][$id];
		$kredit_usd		= $_REQUEST['kredit_usd'][$id];
		$kredit			= $_REQUEST['kredit'][$id];
		$jurnald_status = $_REQUEST['jurnald_status'][$id];
		if($id_deth==$id){
			if($jurnald_status==10){
				mysql_query("UPDATE jurnal_temp SET jurnald_acctno='$j_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$debit', jurnald_amount_usd='$debit_usd' WHERE id='$id_deth' ");
			}else{
				mysql_query("UPDATE jurnal_temp SET jurnald_acctno='$j_acctno', jurnald_desc='".mysql_real_escape_string($jurnald_desc)."', jurnald_amount='$kredit', jurnald_amount_usd='$kredit_usd' WHERE id='$id_deth' ");
			}
		}
	}					
}
if($Act == "ADD" || $Act == "DETAIL" || $Act_Det == "ADD_DET" || $Act_Det == "DELETE_DET" || $Act == "SEL_SUP" || $Act_Det == "ADD_DET2" || $Act == "JTC" || $Act_Det == "UPDATE_DET"){
	require_once "add_jurnal_referensi.php";
}
if($Act == "CLOSE"){
	echo "<meta http-equiv='refresh' content='0; url=?page=Data-Jurnal-Ref&fromdate=$fromdate&todate=$todate'>";
}
if (! count($message)==0 ){
	?>
		<script language="javascript">
			var pesan ='<?php 
							$Num=0;
							foreach ($message as $indeks=>$pesan_tampil){ 
								$Num++;
								echo $Num.'. '.$pesan_tampil.'\n';
							}
						?>';
			var status ='<?=$status;?>';			
			alert(pesan);
			//if(status == "SIMPAN"){
				//openwindow5('<?=$jurnal_id;?>');
			//}else{
				//self.history.back();
			//}
		</script>			
	<?php  
	if ($status=="OK"){	
		echo "<meta http-equiv='refresh' content='0; url=?page=Data-Jurnal-Ref&fromdate=$fromdate&todate=$todate'>";	
		exit;
	}
}	
?>