<?php
$sql="select * from web_SideBar where [group]=1 and degree=1 and active=1 and Separator is not null order by Sortorder";
$result=odbc_exec($connection,$sql) or die(odbc_error().$sql);
$Sep="";
//print_r(odbc_fetch_array($result));
while($row=odbc_fetch_array($result))
{
	$SideBarID=$row['SideBarID'];
$SideBarPicture=$row['SideBarPicture'];
	if($SideBarPicture!=null)
	{
		$Icon=$SideBarPicture;
	}
	else	
	{
		$Icon='icon-menu-alt icon-sidebar';
	}	
	$Separator=$row['Separator'];
 $name=$row['SideBarName'];
	$link=$row['URLLink'];//./viewdealers.php
$permission=userrights($Userid,$SideBarID,'Display',$connection);
if($permission==1)
{	
	if($Separator!=$Sep)
	{

 echo $data='<li>
<div class="sidebar-title">'.$Separator.'</div>';
	$Sep=$Separator;
        
	}

$data ='<li>
<a href="<?php echo SITEURL;?>#" class="sidebar-header">
           <i class="'.$Icon.'"></i><span class="sub-header-title">'.$name.'</span>
           <i class="fa fa-angle-right pull-right"></i>
        </a>        <ul class="sidebar-submenu">';
//pages here 
        $sql1="select * from web_SideBar where [group]=0 and degree>1 and active=1 and under=$SideBarID order by Sortorder";
        $result1=odbc_exec($connection,$sql1);
		while($row1=odbc_fetch_array($result1))
		{
$SideBarID1=$row1['SideBarID'];
$name1=$row1['SideBarName'];
	$link1=$row1['URLLink'];//./viewdealers.php
	$Flag=$row1['Flag'];
	if($Flag==null)$Flag="";

	$SideBarPicture=$row1['SideBarPicture'];
	if($SideBarPicture!=null)
	{
		$Icon=$SideBarPicture;
	}
	else	
	{
		$Icon='fa fa-address-card';
	}

$permission=userrights($Userid,$SideBarID1,'Display',$connection);
if($permission==1)
{
 $data .='<li><a href="#" onclick="javascript: navigateTo(this, &#39;'.$link1.'&#39;, &#39;'.$name1.'&#39;, &#39;'.$SideBarID1.'&#39;, &#39;'.$Flag.'&#39; )"><i class="'.$Icon.'" aria-hidden="true"></i>'.$name1.'</a></li>';			
}
		}//end while 
      echo $data .='</ul></li>';  
}//end permission
}//end while 


?>