Make tables:
CREATE TABLE IF NOT EXISTS `sys_menu` (
`id` int(3) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE latin1_general_ci NOT NULL,
`name_alias` varchar(50) COLLATE latin1_general_ci NOT NULL,
`descrip` text COLLATE latin1_general_ci,
`links` varchar(100) COLLATE latin1_general_ci NOT NULL,
`target` varchar(20) COLLATE latin1_general_ci NOT NULL,
`folder_name` varchar(50) COLLATE latin1_general_ci NOT NULL,
`modules` varchar(50) COLLATE latin1_general_ci NOT NULL,
`dependency` int(1) NOT NULL,
`dependency_to` varchar(100) COLLATE latin1_general_ci NOT NULL,
`access_mode` int(2) NOT NULL,
`access_type` varchar(25) COLLATE latin1_general_ci NOT NULL,
`admin_sort` int(3) NOT NULL,
`_sort` int(3) NOT NULL,
`_show` int(1) NOT NULL,
`_group` varchar(20) COLLATE latin1_general_ci NOT NULL,
`_date_time` datetime NOT NULL,
`_subid` int(3) NOT NULL,
`_referto` int(3) NOT NULL,
`_group_level` int(3) NOT NULL,
`_mainid` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=152 ;
CREATE TABLE IF NOT EXISTS `sys_menu` (
`id` int(3) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE latin1_general_ci NOT NULL,
`name_alias` varchar(50) COLLATE latin1_general_ci NOT NULL,
`descrip` text COLLATE latin1_general_ci,
`links` varchar(100) COLLATE latin1_general_ci NOT NULL,
`target` varchar(20) COLLATE latin1_general_ci NOT NULL,
`folder_name` varchar(50) COLLATE latin1_general_ci NOT NULL,
`modules` varchar(50) COLLATE latin1_general_ci NOT NULL,
`dependency` int(1) NOT NULL,
`dependency_to` varchar(100) COLLATE latin1_general_ci NOT NULL,
`access_mode` int(2) NOT NULL,
`access_type` varchar(25) COLLATE latin1_general_ci NOT NULL,
`admin_sort` int(3) NOT NULL,
`_sort` int(3) NOT NULL,
`_show` int(1) NOT NULL,
`_group` varchar(20) COLLATE latin1_general_ci NOT NULL,
`_date_time` datetime NOT NULL,
`_subid` int(3) NOT NULL,
`_referto` int(3) NOT NULL,
`_group_level` int(3) NOT NULL,
`_mainid` int(3) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=152 ;
INSERT INTO `sys_menu` (`id`, `name`, `name_alias`, `descrip`, `links`, `target`, `folder_name`, `modules`, `dependency`, `dependency_to`, `access_mode`, `access_type`, `admin_sort`, `_sort`, `_show`, `_group`, `_date_time`, `_subid`, `_referto`, `_group_level`, `_mainid`) VALUES
(1, 'Configuration', '', NULL, '#', '', '', '', 0, '', 0, '', 0, 1, 1, 'main', '0000-00-00 00:00:00', 0, 0, 0, 0),
(2, 'Company Add/ View', '', NULL, '../gc/company_list.php?mode=', '', '', '', 0, '', 0, '', 0, 1, 1, 'sub', '0000-00-00 00:00:00', 138, 0, 0, 0)
CREATE TABLE IF NOT EXISTS `user_level` (
`levelid` int(11) NOT NULL AUTO_INCREMENT,
`level` varchar(150) COLLATE latin1_general_ci NOT NULL,
`levelgroupid` int(2) NOT NULL,
`processing_type` int(2) NOT NULL,
`menugroup` varchar(200) COLLATE latin1_general_ci NOT NULL,
`menuid` varchar(250) COLLATE latin1_general_ci NOT NULL,
`approval` int(1) NOT NULL,
PRIMARY KEY (`levelid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci ROW_FORMAT=DYNAMIC AUTO_INCREMENT=106 ;
INSERT INTO `user_level` (`levelid`, `level`, `levelgroupid`, `processing_type`, `menugroup`, `menuid`, `approval`) VALUES
(1, 'General User GC', 1, 0, '7,8,9,95', '0', 0),
(2, 'Advance User GC', 1, 0, '1,7,8,9,95', '5', 0),
(103, 'General User WT', 3, 0, '', '', 0),
(104, 'Advance User WT', 3, 0, '', '', 0),
(100, 'Administrator', 100, 100, '1,7,8,9,95,101,116,122', '2,3,4,5,6,93,94,97,100,102,103,104106,107,108,109,110,111,112,113,114,117,118,119,120,121,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140, 142, 147,148, 149, 150, 151', 0),
(101, 'General User PT', 2, 0, '101', '106,107,108,109,110', 0),
(102, 'Advance User PT', 2, 0, '1,7,101', '102,103,104,106,107,108,109,110,111,112,113,114', 0);
PHP CODE:
function getMenu() {
$target = "";
$user = getUser();
$emp_row = find("select ul.menugroup, ul.menuid, ul.level from user u
left join user_level ul on ul.levelid=u.userlevel where u.username='$user'
");
$menugroup = $emp_row->menugroup;
$menuid = $emp_row->menuid;
$level = $emp_row->level;
echo "<ul>";
$q = mysql_query("Select id, name, links, dependency, dependency_to, target from sys_menu where _group like '%main%' and _show = 1 and id in($menugroup) order by _sort") or trigger_error(mysql_error(), E_USER_ERROR);
//$q = mysql_query("Select id, name, links, dependency, dependency_to, target from sys_menu where _group like '%main%' and _show = 1 order by _sort") or trigger_error(mysql_error(), E_USER_ERROR);
while ($d = mysql_fetch_object($q)) {
if ($d->dependency !=1) {
if ($d->target !="") {
$target = "target = $d->target";
}
$links = "$d->links";
echo "<li><a href='$links' $target>$d->name</a>";
$q_sub = mysql_query("Select id, name, links, target from sys_menu where _subid = $d->id and _show = 1 and id in($menuid) order by _sort") or trigger_error(mysql_error(), E_USER_ERROR);
//$q_sub = mysql_query("Select id, name, links, target from sys_menu where _subid = $d->id and _show = 1 order by _sort") or trigger_error(mysql_error(), E_USER_ERROR);
if (mysql_num_rows($q_sub) !=0 ) {
echo "<ul>";
while ($d_sub = mysql_fetch_object($q_sub)){
$links = "$d_sub->links";
echo "<li><a href='$links'>» $d_sub->name</a>";
//-------------sub_sub menu begain here--------------
$q_sub_sub = mysql_query("Select id, name, links, target from sys_menu where _subid = $d_sub->id and _show = 1 and id in($menuid) order by _sort") or trigger_error(mysql_error(), E_USER_ERROR);
if (mysql_num_rows($q_sub_sub) !=0)
{
echo "<ul>";
while($d_sub_sub = mysql_fetch_object($q_sub_sub))
{
$links = "$d_sub_sub->links";
echo "<li><a href='$links'>» $d_sub_sub->name</a></li>";
}
echo "</ul>";
} else {
echo "</li>";
}
//end-------------------------------
}
echo "</ul>";
} else {
echo "</li>";
}
} else {
$links = "$d->links";
echo "<li><a href='$links'/>$d->name</a>
<ul>";
$qq = mysql_query("Select id, category_name from $d->dependency_to where _group like '%main%' order by _sort ") or trigger_error(mysql_error(), E_USER_ERROR);
while($dd = mysql_fetch_object($qq)) {
$links = "$d->links";
echo "<li>Please generate</li>";
}
echo "</ul>
</li>";
}
}
echo "<li><a href='../common/modules.php?logout=true' onClick='return log_out()'>Sign out</a></li>";
echo "</ul>";
}
<div class="grid_16">
<div id="myslidemenu" class="jqueryslidemenu">
<?php getMenu(); // call the getMenu() Function ?>
</div>
</div>
No comments:
Post a Comment