<?php
$PageSecurity = 11;
//echo $_SERVER['QUERY_STRING'];exit;
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
include('includes/Class_www_users.php');
include('includes/Class_Emp.php');
include('includes/session.inc');
	 $q=$_GET['q']; 
	 
		 $pcode= $rolepid;
		
		function CategoryShow1($pcode, $PcateID, $dashVal,$data8)
		{
		   $data10='';
		   $v='';
		   
			global $db;
			 $dashVal = $dashVal . "&nbsp;&nbsp;&nbsp;&nbsp;";
			   $sqlCate = "select * from securityroles  where  rolepid  = '".$PcateID."'";
			$rsCate  = DB_query($sqlCate,$db);	
			 
			if(DB_num_rows($rsCate)>0)
			{
				while($rowCate = DB_fetch_array($rsCate))
				{
					 $sqlCateSel = "select * from securityroles where rolepid =".$rowCate['rolepid']." ";
					$rsCateSel	= DB_query($sqlCateSel,$db);
					$px='';
					 if($rowCate['secroleid']==$pcode)
					 $px="selected";			
				     $data12="<option value=".$rowCate['secroleid'].">".$dashVal.".".$rowCate['role_name']."</option>";
				     $data14= $data8.$data12.CategoryShow1($pcode,$rowCate['secroleid'], $dashVal,$data12='');					 
				} 
				
				return  $data14;	
			}
		 	
		} 
		
		$dashVal = "&nbsp;&nbsp;&nbsp;";
		$query=DB_query("select * from securityroles where rolepid=0 and companyid ='".$q."'",$db);
		?> 
            <?php
			
			$data2='';
			$data3='';
		
		if(DB_num_rows($query)>0){
		  $data1='';
		  while($row=DB_fetch_array($query))
		  {		  
		  	$p='';
			if($row['secroleid']==$rolepid)
			{
			   $p="selected";
			}
		 
                $data1="<option value=".$row['secroleid']." ".$p." >".$row['role_name']."</option>";            
		   $data9= CategoryShow1($rolepid,$row['secroleid'], $dashVal,$data1);
		}
		} 
		
		  $data2.="<option value=''>Select</option>";
		 $sql=DB_query("select * from zone_master where CompanyId='".$q."'",$db);
		while($row1=DB_fetch_array($sql))
		{
		  $data2.="<option value=".$row1['id']." ".($area_code==$row1['id']?'selected':'').">".$row1['ZoneTitle']."</option>";
		
	     } 
		 
		
	  $sql1=DB_query("select * from locations where exciable='Y' and mst_companyid='".$q."' ",$db);
	    $data3.="<option value=''>Select</option>";
	  while($row1=DB_fetch_array($sql1))
	  {
	  
	    $data3.="<option value=".$row1['loccode']."".($default_dispatch_excisable==$row1['loccode']?"selected":"") .">".$row1['locationname']."</option>";
	  
	   } 
	   
	     $data4.="<option value='0'>Select</option>";
	  $sql1=DB_query("select * from locations where non_exciable='Y' and mst_companyid='".$q."'",$db);
	  while($row1=DB_fetch_array($sql1))
	  {
	    
	     $data4.="<option value=".$row1['loccode']."".($default_dispatch_nonexcisable==$row1['loccode']?"selected":"") .">".$row1['locationname']."</option>";
	  
	 }
	 
	    echo $data=$data9."__".$data2."__".$data3."__".$data4; 
	
	 
	 ?>
	
	
	
	
		
		
		
		
		
		
		
		
		
		
       
		