	<?php
	$usermenu = array();
	$sql7 = 
	" SELECT * FROM user_akses ".
	" WHERE user = ".$edit.
	" ORDER BY menu, akses_id ";
	if ($hasil7 = mysql_query($sql7)) {
		while ($data7 = mysql_fetch_array($hasil7)) {
			$usermenu[] = $data7["menu"];
		}
	}
	//var_dump($usermenu);
	
	function listUserMenu($thisPage, $curPage1, $menusIDParent, &$menuName='', $subLevel, $parent=0) {
		global $usermenu;
		$sql7 = 
		' SELECT * FROM user_menu '.
		' WHERE menusActive  <> 0 '.
		' AND menusIDParent="'.$parent.'" '.
		' ORDER BY menusOrder ';
		if ($hasil7 = mysql_query($sql7)) {
			if (mysql_num_rows($hasil7) > 0) {
				while ($data7 = mysql_fetch_array($hasil7)) {
					$padd = $checked = '';
					if ($data7["menusIDParent"] == 0) {
						if ($data7["target_page"] == '#') {
							if ($data7["menu_id"] > 1) {
								$padd = ' style = " padding:12px 0px 3px 0px; " ';	
							}
							$menuName .= '
							<div '.$padd.'>
								<strong>'.$data7["nama_menu"].'</strong>
							</div>';
						} else {
							$padd = ' style = " padding:10px 0px 0px 0px; " ';	
						}
					}
					if ($data7["target_page"] != '#' && $data7["menu_id"] != 1 && $data7["menu_id"] != 4) {
						foreach ($usermenu as $arr) {
							if ($arr == $data7["menu_id"]) {
								$checked = 'checked';
							}
						}
						$menuName .= '
						<div '.$padd.'>
							<input type="checkbox" '.$checked.' name="menu[]" value="'.$data7["menu_id"].'">'.$data7["nama_menu"].'</input>
						</div>';
					}
					listUserMenu($thisPage, $curPage1, $menusIDParent, $menuName, '', $data7["menu_id"]);
				}
			}
		}
	}

	$bgClr = 'style="background-color:#e4e4e4;"';
	$htbl  = 'style="height:25px;"';
	
	echo '
	<p style="padding:20px 0px 10px 0px; margin:0"><strong>Edit User</strong></p>
	<form name="formUser" id="formUser" class="form" action="'.$thisPage.'adm1n/'.$curPage1.'" onsubmit="return validate(this)" method="post">
		<table width="100%" cellpadding="10" cellspacing="1" border="0" bgcolor="#999999">
			<tr '.$bgClr.'>
				<td width="20%" '.$bgClr.'>
					<strong>User name</strong>
				</td>
				<td '.$bgClr.'>
					<input type="text" name="username" size="55" value="'.$username.'" '.$htbl.' />
				</td>
			</tr>
			<tr '.$bgClr.' valign="top">
				<td '.$bgClr.'>
					<strong>User role</strong>
				</td>
				<td '.$bgClr.'>';
					$sql7 = ' SELECT * FROM user_roles ';
					if ($hasil7 = mysql_query($sql7)) {
						while ($data7 = mysql_fetch_array($hasil7)) {
							$checked = ($data7["rolesID"] == $user_roles ? 'checked' : '');
							if ($data7["rolesName"] == 'Others') {
								$Others = '
								<div style="margin:0; padding: 0px 0px 8px 0px">
									<input name="user_roles" '.$checked.' class="radio" type="radio" value="'.$data7["rolesID"].'" /> 
									<span>'.$data7["rolesName"].'</span>
								</div>';
							} else {
								echo '
								<div style="margin:0; padding: 0px 0px 8px 0px">
									<input name="user_roles" '.$checked.' class="radio" type="radio" value="'.$data7["rolesID"].'" /> 
									<span>'.$data7["rolesName"].'</span>
								</div>';
							}
						}
					}
					echo $Others.'
				</td>
			</tr>
			<tr '.$bgClr.' valign="top">
				<td '.$bgClr.'>
					<strong>User menu</strong>
				</td>
				<td '.$bgClr.'>';
					$menuName = $subLevel = $menuName = '';
					listUserMenu($thisPage, $curPage1, (isset($menusIDParent) ? $menusIDParent : ''), $menuName, $subLevel, 0);
					if ($menuName) echo $menuName;
					echo '
				</td>
			</tr>
			<tr valign="top" bgcolor="#e4e4e4">
				<td align="center" colspan="2">
					<div style="margin:20px 0px" align="center">
						<div onclick="goBack()" class="hvr-sweep-to-right" style="padding:10px 30px; cursor:pointer;">
							<font style="color:#ffffff; text-align:center">
								<< Back
							</font>
						</div>
						<div onclick="submitFormUser()" class="hvr-sweep-to-right" style="padding:10px 30px; cursor:pointer;">
							<font style="color:#ffffff; text-align:center">
								Submit >>
							</font>
						</div>
						
						<input type="hidden" name="action" id="action" value="'.(isset($button_label) ? $button_label : "").'" />
						<input type="hidden" name="button_event" id="button_event" value="'.(isset($button_event) ? $button_event : "").'" />
						<input type="hidden" name="header_id" id="header_id" value="'.(isset($header_id) ? $header_id : "").'" />
						
						<input type="hidden" name="users"  id="users"  value="users" />
						<input type="hidden" name="pass"   id="pass"   value="'.(isset($_REQUEST["pass"]) ? $_REQUEST["pass"] : null).'" />
						<input type="hidden" name="edit"   id="edit"   value="'.(isset($_REQUEST["edit"]) ? $_REQUEST["edit"] : null).'" />
						<input type="hidden" name="delete" id="delete" value="'.(isset($_REQUEST["delete"]) ? $_REQUEST["delete"] : null).'" />
					</div>
				</td>
			</tr>
		</table>
	</form>
	<br><br>';
	?>