<?php
	/*
		[Office 515158] (C) 2009-2012 天生创想 Inc.
		$Id: lmenu.php 1209087 2012-01-08 08:58:28Z baiwei.jiang $
	*/
	define('IN_ADMIN',True);
	require_once('../include/common.php');
	if ( !$_USER->id ) {
		show_msg('你还没有登录，请先登录', 'login.php', 1000);
	}
	if(getGP('menuid','G','int')){
		$muid=getGP('menuid','G','int');
	}
	global $_CACHE;
	get_cache(DB_JT.'menu');
	function _Nmenu($muid,$type=0){
	global $_CACHE;
	get_cache(DB_JT.'menu');
	foreach ( $_CACHE[DB_JT.'menu'] as $row) {
		if($row['fatherid']==$muid){
				if(crm_menu_view($row["menuid"])){
					if($row[menutype]!='1'){
						if($row[keytable]!=''){
							if(is_superadmin() || check_purview($row[keytable])){
							echo '<li class="pcoded-hasmenu">';
							echo '<a href="javascript:void(0)">';
							echo '<span class="pcoded-micon"><i class="ti-minus"></i><b></b></span>';
							echo '<span class="pcoded-mtext">'.$row[menuname].'</span>';
							echo '<span class="pcoded-mcaret"></span></a>';
							echo '<ul class="pcoded-submenu">';
							_Nmenu($row[menuid]);
							
							echo '</ul>';
							echo '</li>';
								
							}
						}else{
							echo '<li class="pcoded-hasmenu">';
							echo '<a href="javascript:void(0)">';
							echo '<span class="pcoded-micon"><i class="ti-minus"></i><b></b></span>';
							echo '<span class="pcoded-mtext">'.$row[menuname].'</span>';
							echo '<span class="pcoded-mcaret"></span></a>';
							echo '<ul class="pcoded-submenu">';
							_Nmenu($row[menuid]);
							
							echo '</ul>';
							echo '</li>';
							
						}
					}
				}else{
					if($row[menutype]!='1'){
						if($row[keytable]!=''){
							if(is_superadmin() || check_purview($row[keytable])){
								echo '<li class=" ">';
								echo '<a href="';
								echo 'javascript:_M('.$row[menuid].',';
								echo "'".$row[menuurl]."')";
								echo '" ><span class="pcoded-micon"><i class="ti-minus"></i><b></b></span>
								<span class="pcoded-mtext">';
								echo $row[menuname].'</span><span class="pcoded-mcaret"></span></a>';
								echo '</li> ';
							}
						}else{
							echo '<li class=" ">';
								echo '<a href="';
								echo 'javascript:_M('.$row[menuid].',';
								echo "'".$row[menuurl]."')";
								echo '" ><span class="pcoded-micon"><i class="ti-minus"></i><b></b></span>
								<span class="pcoded-mtext">';
								echo $row[menuname].'</span><span class="pcoded-mcaret"></span></a>';
								echo '</li> ';
						}
					}
				}
		}
	}
}
?>
<li class="active ">
<a href="javascript:_M('0','home.php?file=text')">
<span class="pcoded-micon"><i class="ti-home"></i></span>
<span class="pcoded-mtext">个人桌面</span>
<span class="pcoded-mcaret"></span></a>
</li>
<?php
foreach ( $_CACHE[DB_JT.'menu'] as $row) {
if($row['fatherid']==$muid && $row[menutype]!='1'){
if($row[keytable]){
	if(is_superadmin() || check_purview($row[keytable])){
		if(crm_menu_view($row["menuid"])){
	?>
	<li class="pcoded-hasmenu">
	<a href="javascript:f(<?php echo trim($row[menuid]);?>)" >
	<span class="pcoded-micon"><i class="ti-angle-right"></i><b></b></span>
	<span class="pcoded-mtext"><?php echo $row[menuname]?></span>
	<!--<span class="pcoded-badge label label-danger">100+</span> -->
	<span class="pcoded-mcaret"></span></a>
	<ul class="pcoded-psubmenu" id="<?php echo trim($row[menuid]);?>">

<?php _Nmenu($row[menuid]);?>
</ul>
	</li>
		<?php }else{?>
		
		<li class="">
	<a href="javascript:_M('<?php echo $row[menuid];?>','<?php echo $row[menuurl];?>')" >
	<span class="pcoded-micon"><i class="ti-angle-right"></i><b></b></span>
	<span class="pcoded-mtext"><?php echo $row[menuname]?></span>
	<!--<span class="pcoded-badge label label-danger">100+</span> -->
	<span class="pcoded-mcaret"></span></a>
	</li>
		
		
	<?php
	 }
	}
}else{
if(crm_menu_view($row["menuid"])){
?>
<li class="pcoded-hasmenu">
	<a href="javascript:f(<?php echo trim($row[menuid]);?>)" >
	<span class="pcoded-micon"><i class="ti-angle-right"></i><b></b></span>
	<span class="pcoded-mtext"><?php echo $row[menuname]?></span>
	<!--<span class="pcoded-badge label label-danger">100+</span> -->
	<span class="pcoded-mcaret"></span></a>
	<ul class="pcoded-psubmenu" id="<?php echo trim($row[menuid]);?>">

<?php _Nmenu($row[menuid]);?>
</ul>
	</li>
<?php }else{?>
<li class="">
<a href="javascript:_M('<?php echo $row[menuid];?>','<?php echo $row[menuurl];?>')">
<span class="pcoded-micon"><i class="ti-angle-right"></i><b></b></span>
<span class="pcoded-mtext"><?php echo $row[menuname]?></span>
<span class="pcoded-mcaret"></span></a>
</li>
<?php
}
}
}
}
?>
<script>
function f(str){
var sub_menu = document.getElementById(str);
var dis_v = sub_menu.style.display;
if(dis_v == "none")
sub_menu.style.display = "block";
else
sub_menu.style.display = "none";
}
</script>
