<?php
if (!defined("root")) {
	define("root", $_SERVER['DOCUMENT_ROOT']);
}
require(root."/___simple_config.php");
session_start();
require(root."/".adminFolder."/_common.php");
require(root."/".adminFolder."/_lib/db.php");
require(root."/".adminFolder."/_lib/main.php");
require(root."/".adminFolder."/_lib/auth.php");
require(root."/".adminFolder."/_lib/bootstraps.php");
$pageSubOf = "pages";
$pageName = "fakes";
$pageTitle = "Fakes";
$thisUrl = "fakes";
$ajax_page = "ajax_fakes.php";
$pageUrl = "/".adminFolder."/$thisUrl";
$a = cekpost(cleanQuery($_GET["a"]), "");
$err = "";
if ($a=="section_main") {
	cout('<div class="row">');
		$rsd=array(); $qd="SELECT * FROM fake_depo ORDER BY cretime DESC";
		callRS($rsd, $qd);
		cout('<div class="col-sm-6">');
			if (count($rsd)!=0) {
				cout('<table class="table table-striped table-bordered">');
					cout('<thead>');
						cout('<tr>');
							cout('<th colspan="4" class="text-center alert alert-success">Fake Deposits</th>');
						cout('</tr>');
						cout('<tr>');
							cout('<th class="text-center">#</th>');
							cout('<th class="text-center">USERNAME</th>');
							cout('<th class="text-center">NOMINAL</th>');
							if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
								cout('<th class="text-center">By</th>');
							}
						cout('</tr>');
					cout('</thead>');
					cout('<tbody>');
						for ($i=0;$i<count($rsd);$i++) {
							cout('<tr class="tr-data'.$kdmember.'">');
								cout('<td class="text-center">'.($i+1).'</td>');
								cout('<td class="text-center">'.$rsd[$i]["userid"].'</td>');
								cout('<td class="text-right">'.number_format($rsd[$i]["jumlah"],0).'</td>');
								if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
									$creby = isset($rsd[$i]["creby"])?$rsd[$i]["creby"]:'';
									$cretime = isset($rsd[$i]["cretime"])?date('l', $rsd[$i]["cretime"]).'<br/>'.date('d M Y H:i:s', $rsd[$i]["cretime"]):'';
									cout('<td class="text-center">'.$creby.' - '.$cretime.'</td>');
								}
							cout('</tr>');
						}
					cout('</tbody>');
				cout('</table>');
			} else {
				cout('<div class="alert alert-info" role="alert">');
					cout('<strong>No data available.</strong> Please add new data for display.');
				cout('</div>');
			}
		cout('</div>');
		
		$rsw=array(); $qw="SELECT * FROM fake_wd ORDER BY cretime DESC";
		callRS($rsw, $qw);
		cout('<div class="col-sm-6">');
			if (count($rsw)!=0) {
				cout('<table class="table table-striped table-bordered">');
					cout('<thead>');
						cout('<tr>');
							cout('<th colspan="4" class="text-center alert alert-warning">Fake Withdraws</th>');
						cout('</tr>');
						cout('<tr>');
							cout('<th class="text-center">#</th>');
							cout('<th class="text-center">USERNAME</th>');
							cout('<th class="text-center">NOMINAL</th>');
							if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
								cout('<th class="text-center">By</th>');
							}
						cout('</tr>');
					cout('</thead>');
					cout('<tbody>');
						for ($i=0;$i<count($rsw);$i++) {
							cout('<tr class="tr-data'.$kdmember.'">');
								cout('<td class="text-center">'.($i+1).'</td>');
								cout('<td class="text-center">'.$rsw[$i]["userid"].'</td>');
								cout('<td class="text-right">'.number_format($rsw[$i]["jumlah"],0).'</td>');
								if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
									$creby = isset($rsw[$i]["creby"])?$rsw[$i]["creby"]:'';
									$cretime = isset($rsw[$i]["cretime"])?date('l', $rsw[$i]["cretime"]).'<br/>'.date('d M Y H:i:s', $rsw[$i]["cretime"]):'';
									cout('<td class="text-center">'.$creby.' - '.$cretime.'</td>');
								}
							cout('</tr>');
						}
					cout('</tbody>');
				cout('</table>');
			} else {
				cout('<div class="alert alert-info" role="alert">');
					cout('<strong>No data available.</strong> Please add new data for display.');
				cout('</div>');
			}
		cout('</div>');
		
	cout('</div>');
	
	$act_ket = "Fakes: Main List";
	if ($swhere!="") { $act_ket .= ": ".cleanQuery($swhere).""; }
	updateUserActivities($act_ket);
}

if ($a=="do_save_wd") {
	$kirim = cekpost(cleanQuery($_REQUEST["kirim"]), "");
	if ($kirim==1) {
		#$qd = "DELETE FROM fake_wd";
		#execRS($qd);
		$creby = $_SESSION["user"]["inisial"];
		$cretime = time();
		for ($i=0;$i<20;$i++) {
			$kdf = cekpost(cleanQuery($_REQUEST["kdf$i"]), "");
			$userid = cekpost(cleanQuery($_REQUEST["userid$i"]), "");
			$jumlah = cekpost(cleanQuery($_REQUEST["jumlah$i"]), "0");
			if ($userid!="" && $jumlah!="" && $jumlah!="0") {
				$rscek = array(); $qcek = "SELECT * FROM fake_wd WHERE userid='$userid' AND jumlah='$jumlah'";
				callRS($rscek, $qcek);
				if (count($rscek)!=0) {
					#$qd = "DELETE FROM fake_wd WHERE kdfdepo = '".$rscek[0]["kdfwd"]."'";
					#execRS($qd);
				} else {
					$kdfwd = getID("fake_wd", "kdfwd");
					$qi = "INSERT INTO fake_wd (kdfwd, userid, jumlah, creby, cretime) VALUES ('$kdfwd', '$userid', '$jumlah', '$creby', '$cretime')";
					execRS($qi);
				}
				
			} else {
				$qd = "DELETE FROM fake_wd WHERE kdfwd = '".$kdf."'";
				execRS($qd);
			}
		}
		cout('<script type="text/javascript">parent.window.location="'.$pageUrl.'/";</script>');
	}
}
if ($a=="section_withdraw") {
	cout('<form method="post" target="quick_iframe" action="/'.adminFolder.'/_ajax/'.$ajax_page.'?a=do_save_wd" role="form">');
		cout('<input type="hidden" name="kirim" id="kirim" value="1" />');
		cout('<div class="row">');
			$rsd=array(); $qd="SELECT * FROM fake_wd ORDER BY cretime DESC";
			callRS($rsd, $qd);
			cout('<div class="col-sm-8">');
				cout('<button class="btn btn-primary" type="submit">Save</button>');
				cout('<table class="table table-striped table-bordered">');
					cout('<thead>');
						cout('<tr>');
							cout('<th colspan="5" class="text-center alert alert-warning">Fake Withdraw</th>');
						cout('</tr>');
						cout('<tr>');
							cout('<th class="text-center">#</th>');
							cout('<th class="text-center">USERNAME</th>');
							cout('<th class="text-center">NOMINAL</th>');
							if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
								cout('<th class="text-center">By</th>');
							}
							cout('<th class="text-center"></th>');
						cout('</tr>');
					cout('</thead>');
					cout('<tbody>');
						for ($i=0;$i<20;$i++) {
							cout('<tr class="tr-data'.$kdmember.'">');
								cout('<td class="text-center">'.($i+1).'<input name="kdf'.$i.'" id="kdf'.$i.'" type="hidden" value="'.$rsd[$i]["kdfwd"].'" /></td>');
								cout('<td class="text-center"><input class="form-control" name="userid'.$i.'" id="userid'.$i.'" type="text" value="'.$rsd[$i]["userid"].'" /></td>');
								cout('<td class="text-center"><input class="form-control" name="jumlah'.$i.'" id="jumlah'.$i.'" type="text" value="'.$rsd[$i]["jumlah"].'" /></td>');
								if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
									$creby = isset($rsd[$i]["creby"])?$rsd[$i]["creby"]:'';
									$cretime = isset($rsd[$i]["cretime"])?date('l', $rsd[$i]["cretime"]).'<br/>'.date('d M Y H:i:s', $rsd[$i]["cretime"]):'';
									cout('<td class="text-center">'.$creby.' - '.$cretime.'</td>');
								}
								cout('<td class="text-center"><a href="#" onclick="resetFieldDPWD('.$i.');return false;">Delete</a></td>');
							cout('</tr>');
						}
					cout('</tbody>');
				cout('</table>');
				cout('<button class="btn btn-primary" type="submit">Save</button>');
			cout('</div>');
		cout('</div>');
	cout('</form>');
	$viewFrame = 0;
	if ($viewFrame==1) {
		cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="100" style="overflow:;border:1px red solid;" visibility="" scrolling="yes" frameborder="1"></iframe>');
	} else {
		cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="11" style="overflow:hidden;" visibility="hidden" scrolling="no" frameborder="0"></iframe>');
	}
	$act_ket = "Fakes: Editing Withdraw...";
	updateUserActivities($act_ket);
	exit;
}
if ($a=="do_save_dp") {
	$kirim = cekpost(cleanQuery($_REQUEST["kirim"]), "");
	if ($kirim==1) {
		#$qd = "DELETE FROM fake_depo";
		#execRS($qd);
		$creby = $_SESSION["user"]["inisial"];
		$cretime = time();
		for ($i=0;$i<20;$i++) {
			$kdf = cekpost(cleanQuery($_REQUEST["kdf$i"]), "");
			$userid = cekpost(cleanQuery($_REQUEST["userid$i"]), "");
			$jumlah = cekpost(cleanQuery($_REQUEST["jumlah$i"]), "0");
			if ($userid!="" && $jumlah!="" && $jumlah!="0") {
				$rscek = array(); $qcek = "SELECT * FROM fake_depo WHERE userid='$userid' AND jumlah='$jumlah'";
				callRS($rscek, $qcek);
				if (count($rscek)!=0) {
				} else {
					$kdfdepo = getID("fake_depo", "kdfdepo");
					$qi = "INSERT INTO fake_depo (kdfdepo, userid, jumlah, creby, cretime) VALUES ('$kdfdepo', '$userid', '$jumlah', '$creby', '$cretime')";
					execRS($qi);
				}
			} else {
				$qd = "DELETE FROM fake_depo WHERE kdfdepo = '".$kdf."'";
				execRS($qd);
			}
		}
		cout('<script type="text/javascript">parent.window.location="'.$pageUrl.'/";</script>');
	}
}
if ($a=="section_deposit") {
	cout('<form method="post" target="quick_iframe" action="/'.adminFolder.'/_ajax/'.$ajax_page.'?a=do_save_dp" role="form">');
		cout('<input type="hidden" name="kirim" id="kirim" value="1" />');
		cout('<div class="row">');
			$rsd=array(); $qd="SELECT * FROM fake_depo ORDER BY cretime DESC";
			callRS($rsd, $qd);
			cout('<div class="col-sm-8">');
				cout('<button class="btn btn-primary" type="submit">Save</button>');
				cout('<table class="table table-striped table-bordered">');
					cout('<thead>');
						cout('<tr>');
							cout('<th colspan="5" class="text-center alert alert-success">Fake Deposits</th>');
						cout('</tr>');
						cout('<tr>');
							cout('<th class="text-center">#</th>');
							cout('<th class="text-center">USERNAME</th>');
							cout('<th class="text-center">NOMINAL</th>');
							if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
								cout('<th class="text-center">By</th>');
							}
							cout('<th class="text-center"></th>');
						cout('</tr>');
					cout('</thead>');
					cout('<tbody>');
						for ($i=0;$i<20;$i++) {
							cout('<tr class="tr-data'.$kdmember.'">');
								cout('<td class="text-center">'.($i+1).'<input name="kdf'.$i.'" id="kdf'.$i.'" type="hidden" value="'.$rsd[$i]["kdfdepo"].'" /></td>');
								cout('<td class="text-center"><input class="form-control" name="userid'.$i.'" id="userid'.$i.'" type="text" value="'.$rsd[$i]["userid"].'" /></td>');
								cout('<td class="text-center"><input class="form-control" name="jumlah'.$i.'" id="jumlah'.$i.'" type="text" value="'.$rsd[$i]["jumlah"].'" /></td>');
								if ($_SESSION["user"]["kduser"]=="0" || $_SESSION["user"]["kduser"]=="1") {
									$creby = isset($rsd[$i]["creby"])?$rsd[$i]["creby"]:'';
									$cretime = isset($rsd[$i]["cretime"])?date('l', $rsd[$i]["cretime"]).'<br/>'.date('d M Y H:i:s', $rsd[$i]["cretime"]):'';
									cout('<td class="text-center">'.$creby.' - '.$cretime.'</td>');
								}
								cout('<td class="text-center"><a href="#" onclick="resetFieldDPWD('.$i.');return false;">Delete</a></td>');
							cout('</tr>');
						}
					cout('</tbody>');
				cout('</table>');
				cout('<button class="btn btn-primary" type="submit">Save</button>');
			cout('</div>');
		cout('</div>');
	cout('</form>');
	$viewFrame = 0;
	if ($viewFrame==1) {
		cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="100" style="overflow:;border:1px red solid;" visibility="" scrolling="yes" frameborder="1"></iframe>');
	} else {
		cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="11" style="overflow:hidden;" visibility="hidden" scrolling="no" frameborder="0"></iframe>');
	}
	$act_ket = "Fakes: Editing Deposit...";
	updateUserActivities($act_ket);
	exit;
}
if ($a=="chactive") {
	$kd = cekpost(cleanQuery($_REQUEST["kd"]), "");
	$ca = cekpost(cleanQuery($_REQUEST["ca"]), "");
	$kd = (trim($kd)=="undefined")?'':$kd;
	$ca = (trim($ca)=="undefined")?'':$ca;
	if ($kd!="" && $kd!=0 && $ca!="") {
		$na = $ca==0?1:0;
		$modby = $_SESSION["user"]["inisial"];
		$modtime = time();
		$qu = "UPDATE banks SET isactive='$na', modby='$modby', modtime='$modtime' WHERE kdbank='$kd'";
		execRS($qu);
		$act_ket = "Banks: Ch. Active [kd: $kd][from Act: $ca][to Act: $na]";
		updateUserActivities($act_ket);
		if (intval($na)==0) {
			$isactive = '<a href="#" title="Activate" onclick="chActive(\''.$pageName.'\', '.$kd.', '.$na.');return false;">Non-Active</a>';
		} else {
			$isactive = '<a href="#" title="Deactivate" onclick="chActive(\''.$pageName.'\', '.$kd.', '.$na.');return false;">Active</a>';
		}
		echo $isactive;
	}
}
if ($a=="chbankonoff") {
	$kd = cekpost(cleanQuery($_REQUEST["kd"]), "");
	$ca = cekpost(cleanQuery($_REQUEST["ca"]), "");
	$kd = (trim($kd)=="undefined")?'':$kd;
	$ca = (trim($ca)=="undefined")?'':$ca;
	if ($kd!="" && $kd!=0 && $ca!="") {
		$na = $ca==0?1:0;
		$modby = $_SESSION["user"]["inisial"];
		$modtime = time();
		$qu = "UPDATE banks SET ison='$na', modby='$modby', modtime='$modtime' WHERE kdbank='$kd'";
		execRS($qu);
		$act_ket = "Banks: Ch. On/Off-Line [kd: $kd][from On-Off: $ca][to On-Off: $na]";
		updateUserActivities($act_ket);
		if (intval($na)==0) {
			$isactive = '<a href="#" title="Set Online" onclick="chBankOnOff(\''.$pageName.'\', '.$kd.', '.$na.');return false;">OFF line</a>';
		} else {
			$isactive = '<a href="#" title="Set Offline" onclick="chBankOnOff(\''.$pageName.'\', '.$kd.', '.$na.');return false;">ON line</a>';
		}
		echo $isactive;
	}
}
if ($a=="section_view") {
	if (!authorizedModule("banks_view", $ses_kduser)) {
		unAuthorizedAccess("banks_view");
	} else {
		$id = cekpost(cleanQuery($_GET["id"]), "0");
		$rs=array(); $q="SELECT a.* FROM banks a WHERE kdbank='$id'";
		callRS($rs, $q);
		if (intval($rs[0]["isactive"])==0) {
			$isactive = '<a href="#" title="Activate" onclick="chActive(\''.$pageName.'\', '.$rs[0]["kdbank"].', '.$rs[0]["isactive"].');return false;">Non-Active</a>';
		} else {
			$isactive = '<a href="#" title="Deactivate" onclick="chActive(\''.$pageName.'\', '.$rs[0]["kdbank"].', '.$rs[0]["isactive"].');return false;">Active</a>';
		}
		$creby = (trim($rs[0]["creby"])!=""?'By: <strong>'.$rs[0]["creby"].'</strong>':'By: &lt;<em>no data</em>&gt;').(trim($rs[0]["cretime"])?' ('.date('d M Y, H:i:s A', $rs[0]["cretime"]).')':' &lt;<em>no data</em>&gt;');
		$modby = (trim($rs[0]["modby"])!=""?'By: <strong>'.$rs[0]["modby"].'</strong>':'By: &lt;<em>no data</em>&gt;').(trim($rs[0]["modtime"])?' ('.date('d M Y, H:i:s A', $rs[0]["modtime"]).')':' &lt;<em>no data</em>&gt;');
		cout('<dl class="dl-horizontal dldata">');
			if (authorizedModule("banks_element_name", $ses_kduser)) {
				cout('<dt>Bank Name</dt>');
				cout('<dd>'.$rs[0]["namabank"].'</dd>');
			}
			if (authorizedModule("banks_element_initial", $ses_kduser)) {
				cout('<dt>Initial</dt>');
				cout('<dd>'.$rs[0]["inisial"].'</dd>');
			}
			if (authorizedModule("banks_element_active", $ses_kduser)) {
				cout('<dt>Active Status</dt>');
				cout('<dd class="isactive'.$rs[0]["kd"].'">'.$isactive.'</dd>');
			}
			if (authorizedModule("banks_element_creation", $ses_kduser)) {
				cout('<dt>Created</dt>');
				cout('<dd>'.$creby.'</dd>');
			}
			if (authorizedModule("banks_element_modification", $ses_kduser)) {
				cout('<dt>Modified</dt>');
				cout('<dd>'.$modby.'</dd>');
			}
		cout('</dl>');
		
		$act_ket = "Banks: View: [kdbank: ".$rs[0]["kdbank"]."][namabank: ".$rs[0]["namabank"]."][inisial: ".$rs[0]["inisial"]."]";
		updateUserActivities($act_ket);
		exit;
	}
}
if ($a=="do_delete") {
	$kirim = cekpost(cleanQuery($_REQUEST["kirim"]), "");
	if ($kirim=="1") {
		$delby = $_SESSION["user"]["inisial"];
		$deltime = time();
		$kdbank = cekpost(cleanQuery($_POST["kdbank"]), "0");
		$rs=array(); $q="SELECT * FROM banks WHERE kdbank='$kdbank'";
		callRS($rs, $q);
		
		$q = "DELETE FROM banks WHERE kdbank='$kdbank'";
		execRS($q);
		$act_ket = "Banks: Delete: Deleted [kdbank: $kdbank][namabank: ".$rs[0]["namabank"]."][inisial: ".$rs[0]["inisial"]."][isactive: ".$rs[0]["isactive"]."]";
		updateUserActivities($act_ket);
		cout('<script type="text/javascript">parent.window.location="'.$pageUrl.'/";</script>');
		exit;
	}
}
if ($a=="section_delete") {
	if (!authorizedModule("banks_delete", $ses_kduser)) {
		unAuthorizedAccess("banks_delete");
	} else {
		$id = cekpost(cleanQuery($_GET["id"]), "0");
		$rs=array(); $q="SELECT * FROM banks WHERE kdbank='$id'";
		callRS($rs, $q);
		
		cout('<form method="post" target="quick_iframe" action="/'.adminFolder.'/_ajax/'.$ajax_page.'?a=do_delete" role="form">');
			cout('<input type="hidden" name="kirim" id="kirim" value="1" />');
			cout('<input type="hidden" name="kdbank" id="kdbank" value="'.$rs[0]["kdbank"].'" />');
			cout('<dl class="dl-horizontal dldata">');
				if (authorizedModule("banks_element_name", $ses_kduser)) {
					cout('<dt>Bank Name</dt>');
					cout('<dd>'.$rs[0]["namabank"].'</dd>');
				}
				if (authorizedModule("banks_element_initial", $ses_kduser)) {
					cout('<dt>Initial</dt>');
					cout('<dd>'.$rs[0]["inisial"].'</dd>');
				}
				cout('<dt></dt>');
				cout('<dd><button class="btn btn-primary" type="submit">Delete</button></dd>');
			cout('</dl>');
		cout('</form>');
		$viewFrame = 0;
		if ($viewFrame==1) {
			cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="100" style="overflow:;border:1px red solid;" visibility="" scrolling="yes" frameborder="1"></iframe>');
		} else {
			cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="11" style="overflow:hidden;" visibility="hidden" scrolling="no" frameborder="0"></iframe>');
		}
		$act_ket = "Banks: Deleting... [kd: ".$rs[0]["kd"]."][nama: ".$rs[0]["nama"]."]";
		updateUserActivities($act_ket);
		exit;
	}
}
if ($a=="do_edit") {
	$kirim = cekpost(cleanQuery($_REQUEST["kirim"]), "");
	$err = "";
	if ($kirim=="1") {
		$kdbank = cekpost(cleanQuery($_REQUEST["kdbank"]), "0");
		$namabank = cekpost(cleanQuery($_REQUEST["namabank"]), "");
		$inisial = cekpost(cleanQuery($_REQUEST["inisial"]), "");
		$isactive = cekpost(cleanQuery($_REQUEST["isactive"]), 0);
		if ($namabank=="") { $err.= BSErrorMessage('Bank Name must be filled'); }
		if ($inisial=="") { $err.= BSErrorMessage('Initial must be filled'); }
		if ($err=="") {
			$modby = $_SESSION["user"]["inisial"];
			$modtime = time();
			$q = "UPDATE banks SET namabank='$namabank', inisial='$inisial', isactive='$isactive', modby='$modby', modtime='$modtime' 
				WHERE kdbank='$kdbank'";
			execRS($q);
			$act_ket = "Banks: Edit: Updated [kdbank: $kdbank][judul: $judul][tanggal: $tanggal][isi: $isi][isactive: $isactive]";
			updateUserActivities($act_ket);
			cout('<script type="text/javascript">parent.window.location="'.$pageUrl.'/view/'.$kdbank.'/";</script>');
		} else {
			cout('<script type="text/javascript">parent.showError(\''.$err.'\');</script>');
		}
		exit;
	}
	exit;
}
if ($a=="section_edit") {
	if (!authorizedModule("banks_edit", $ses_kduser)) {
		unAuthorizedAccess("banks_edit");
	} else {
		$id = cekpost(cleanQuery($_GET["id"]), "0");
		$rs=array(); $q="SELECT * FROM banks WHERE kdbank='$id'";
		callRS($rs, $q);
		cout('<form method="post" target="quick_iframe" action="/'.adminFolder.'/_ajax/'.$ajax_page.'?a=do_edit" role="form">');
			cout('<input type="hidden" name="kirim" id="kirim" value="1" />');
			cout('<input type="hidden" name="kdbank" id="kdbank" value="'.$rs[0]["kdbank"].'" />');
			cout('<dl class="dl-horizontal dldata">');
				if (authorizedModule("banks_element_name", $ses_kduser)) {
					cout('<dt><label for="namabank">Bank Name</label></dt>');
					cout('<dd><input class="form-control" type="text" name="namabank" id="namabank" value="'.$rs[0]["namabank"].'" /></dd>');
				}
				if (authorizedModule("banks_element_initial", $ses_kduser)) {
					cout('<dt><label for="inisial">Initial</label></dt>');
					cout('<dd><input class="form-control" type="text" name="inisial" id="inisial" value="'.$rs[0]["inisial"].'" /></dd>');
				}
				if (authorizedModule("banks_element_active", $ses_kduser)) {
					$isactive0 = intval($rs[0]["isactive"])==0?'selected="selected"':'';
					$isactive1 = intval($rs[0]["isactive"])==1?'selected="selected"':'';
					cout('<dt><label for="isactive">Active Status</label></dt>');
					cout('<dd>
						<select name="isactive" id="isactive" class="form-control">
							<option value="0" '.$isactive0.'>Non-Active</option>
							<option value="1" '.$isactive1.'>Active</option>
						</select>
					</dd>');
				}
				
				cout('<dt></dt>');
				cout('<dd class="err"></dd>');
				
				cout('<dt></dt>');
				cout('<dd><button class="btn btn-primary" type="submit">Update</button></dd>');
			cout('</dl>');
		cout('</form>');
		cout('<script>parent.bindDatePicker(\'.tanggal\');</script>');
		$viewFrame = 0;
		if ($viewFrame==1) {
			cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="100" style="overflow:;border:1px red solid;" visibility="" scrolling="yes" frameborder="1"></iframe>');
		} else {
			cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="11" style="overflow:hidden;" visibility="hidden" scrolling="no" frameborder="0"></iframe>');
		}
		$act_ket = "Banks: Editing... [kd: ".$rs[0]["kd"]."][nama: ".$rs[0]["nama"]."]";
		updateUserActivities($act_ket);
		exit;
	}
}
if ($a=="do_add") {
	$kirim = cekpost(cleanQuery($_REQUEST["kirim"]), "");
	$err = "";
	if ($kirim=="1") {
		$namabank = cekpost(cleanQuery($_REQUEST["namabank"]), "");
		$inisial = cekpost(cleanQuery($_REQUEST["inisial"]), "");
		$isactive = cekpost(cleanQuery($_REQUEST["isactive"]), 0);
		if ($namabank=="") { $err.= BSErrorMessage('Bank Name must be filled'); }
		if ($inisial=="") { $err.= BSErrorMessage('Initial must be filled'); }
		if ($err=="") {
			$creby = $_SESSION["user"]["inisial"];
			$cretime = time();
			$kdbank = getID("banks", "kdbank");
			$q = "INSERT INTO banks (kdbank, namabank, inisial, isactive, creby, cretime) 
				VALUES ('$kdbank', '$namabank', '$inisial', '$isactive', '$creby', '$cretime')";
			execRS($q);
			$act_ket = "Banks: Add [kd: $kd][namabank: $namabank][inisial: $inisial][isactive: $isactive]";
			updateUserActivities($act_ket);
			cout('<script type="text/javascript">parent.window.location="'.$pageUrl.'/view/'.$kdbank.'/";</script>');
		} else {
			cout('<script type="text/javascript">parent.showError(\''.$err.'\');</script>');
		}
		exit;
	}
	exit;
}
if ($a=="section_add") {
	if (!authorizedModule("banks_add", $ses_kduser)) {
		unAuthorizedAccess("banks_add");
	} else {
		cout('<form method="post" target="quick_iframe" action="/'.adminFolder.'/_ajax/'.$ajax_page.'?a=do_add" role="form">');
			cout('<input type="hidden" name="kirim" id="kirim" value="1" />');
			cout('<dl class="dl-horizontal dldata">');
				cout('<dt><label for="namabank">Bank Name</label></dt>');
				cout('<dd><input class="form-control" type="text" name="namabank" id="namabank" /></dd>');
				
				cout('<dt><label for="inisial">Initial</label></dt>');
				cout('<dd><input class="form-control" type="text" name="inisial" id="inisial" /></dd>');
				
				cout('<dt><label for="isactive">Active Status</label></dt>');
				cout('<dd>
					<select name="isactive" id="isactive" class="form-control">
						<option value="0">Non-Active</option>
						<option value="1">Active</option>
					</select>
				</dd>');
				
				cout('<dt></dt>');
				cout('<dd class="err"></dd>');
				
				cout('<dt></dt>');
				cout('<dd><button class="btn btn-primary" type="submit">Add</button></dd>');
			cout('</dl>');
		cout('</form>');
		cout('<script>parent.bindDatePicker(\'.tanggal\');</script>');
		$viewFrame = 0;
		if ($viewFrame==1) {
			cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="100" style="overflow:;border:1px red solid;" visibility="" scrolling="yes" frameborder="1"></iframe>');
		} else {
			cout('<iframe name="quick_iframe" id="quick_iframe" src="/'.adminFolder.'/_ajax/index.php" width="300" height="11" style="overflow:hidden;" visibility="hidden" scrolling="no" frameborder="0"></iframe>');
		}
		$act_ket = "Banks: Adding...";
		updateUserActivities($act_ket);
		exit;
	}
}
?>