195 lines
6.3 KiB
PHP
195 lines
6.3 KiB
PHP
|
<?php
|
||
|
include('pop_up_top.php');
|
||
|
$TABLENAME='report_master';
|
||
|
$TABLENAME2='assign_report';
|
||
|
$this_script='assign_report_master.php';
|
||
|
?>
|
||
|
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
|
||
|
|
||
|
<?php
|
||
|
|
||
|
if(isset($acn) && $acn=='view')
|
||
|
{
|
||
|
$sql = "select report_id, report_name FROM $TABLENAME ";
|
||
|
$res=mysqli_query($conn,$sql);
|
||
|
}
|
||
|
elseif($hid=="1")
|
||
|
{
|
||
|
if($count_menu>=1 AND $Role_id!='')
|
||
|
{
|
||
|
$sql = "Delete from $TABLENAME2 where role_id='".$Role_id."'";
|
||
|
$res=mysqli_query($conn,$sql);
|
||
|
$msg="Menu assigned Successfully";
|
||
|
//$qery ="";
|
||
|
|
||
|
for($i=0;$i<$count_menu;$i++)
|
||
|
{
|
||
|
$suffix=$i;
|
||
|
|
||
|
$query_prefix='INSERT INTO ';
|
||
|
$query_suffix="";
|
||
|
if(isset(${"report_id$suffix"}) && ${"report_id$suffix"}!=''){
|
||
|
$query_main="(role_id, report_id,access_level,modified_by) values('".$Role_id."','".${"report_id$suffix"}."','".${"accesslevel$suffix"}."','".$_SESSION['user_id']."')";
|
||
|
|
||
|
$sql=$query_prefix.$TABLENAME2.$query_main.$query_additional.$query_suffix;
|
||
|
//$qery.=$sql;
|
||
|
$res=@mysqli_query($conn,$sql);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
//echo $qery;
|
||
|
//echo "<script>location.replace('role_master.php?msg=$msg')</script>";
|
||
|
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
<tr>
|
||
|
<td height="350" valign="top" style="padding:10px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
||
|
<tr>
|
||
|
|
||
|
<td><fieldset class="bdr1" >
|
||
|
|
||
|
<legend class="heading1">Assign Menues </legend>
|
||
|
<center>
|
||
|
|
||
|
<form name="f1" method="post" action="<?php echo $this_script?>">
|
||
|
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bdr_table">
|
||
|
<tr>
|
||
|
<td colspan="4" align="center" class="bg2">
|
||
|
<span class="txt">
|
||
|
<?php
|
||
|
if($msg)
|
||
|
echo $msg;
|
||
|
?>
|
||
|
</span></td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td width="50%" align="right" class="bg3" colspan="3">Role Name</td>
|
||
|
<td width="50%" align="left" class="bg3">
|
||
|
<input type="hidden" name="Role_id" value="<?php echo $Role_id?>">
|
||
|
<?php
|
||
|
$sql = "select report_id FROM $TABLENAME2 where role_id='".$Role_id."'";
|
||
|
$res=mysqli_query($conn,$sql);
|
||
|
while($row=@mysqli_fetch_array($res))
|
||
|
{
|
||
|
$menuIDs[]=$row['report_id'];
|
||
|
}
|
||
|
$role_name = getTableFieldValue('role_master','role_name','role_id',$Role_id);
|
||
|
echo $role_name;
|
||
|
//print "$Role_Name";
|
||
|
?>
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
<table width="100%" border="1" cellspacing="0" cellpadding="4" class="bdr_table" bordercolor="#eeeeee">
|
||
|
<tr>
|
||
|
<td align="center" class="bg3" colspan="4">Menu Items</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td align="center" class="bg3">Select All <input name="selectall1" value="Select All" onclick="CheckAll(this)" type="checkbox">
|
||
|
</td>
|
||
|
<td align="center" class="bg3">Report ID</td>
|
||
|
<td align="center" class="bg3">Report Name</td>
|
||
|
<td align="center" class="bg3">Report Type</td>
|
||
|
<td align="center" class="bg3">Report Code</td>
|
||
|
<td align="center" class="bg3">Access Level</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
$sql = "select * FROM $TABLENAME order by report_id+0 ";
|
||
|
$res=mysqli_query($conn,$sql);
|
||
|
$count=0;
|
||
|
while($menu_rows = mysqli_fetch_array($res)){
|
||
|
@extract($menu_rows);
|
||
|
$mm = number_format($menu_rows['report_id'],2);
|
||
|
?>
|
||
|
<tr>
|
||
|
<td align="center"><input type="checkbox" name="report_id<?php echo $count?>" id="report_id<?php echo $count?>" value="<?php echo $menu_rows['report_id']?>" <?php if(is_array($menuIDs)){ if(in_array($menu_rows['report_id'],$menuIDs)) echo 'checked'; }?> onclick="checkParent(<?php echo $count?>);"></td>
|
||
|
<td align="center"><?php echo $menu_rows['report_id']?><input type="hidden" name="parent_id<?php echo $count?>" id="parent_id<?php echo $count?>" value="<?php echo $menu_rows['parent_id']?>" class="textbox1">
|
||
|
<input type="hidden" name="menu<?php echo $count?>" id="menu<?php echo $count?>" value="<?php echo $mm?>" class="textbox1">
|
||
|
</td>
|
||
|
<td align="center"><?php echo $menu_rows['report_name']?></td>
|
||
|
<td align="center"><?php echo $menu_rows['report_type']?></td>
|
||
|
<td align="center"><?php echo $menu_rows['report_code']?></td>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<?php
|
||
|
$sql2 = "select access_level FROM $TABLENAME2 where role_id='".$Role_id."' and report_id='".$menu_rows['report_id']."' ";
|
||
|
$res2=mysqli_query($conn,$sql2);
|
||
|
if($row2=@mysqli_fetch_array($res2))
|
||
|
{
|
||
|
|
||
|
|
||
|
}
|
||
|
//print "$Role_Name";
|
||
|
//print "$access_level";
|
||
|
$accesslevel=$row2['access_level'];
|
||
|
?>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<td align="center">
|
||
|
Access Level:<?php echo $accesslevel?>
|
||
|
<input type="radio" name="accesslevel<?php echo $count?>" value="R" <?php if($accesslevel=="R"){?> checked<?php }?>/>
|
||
|
Read
|
||
|
<input type="radio" name="accesslevel<?php echo $count?>" value="W" <?php if($accesslevel=="W"){?> checked<?php }?> />
|
||
|
Write
|
||
|
<input type="radio" name="accesslevel<?php echo $count?>" value="E" <?php if($accesslevel=="E"){?> checked<?php }?> />
|
||
|
Execute
|
||
|
</td>
|
||
|
</tr>
|
||
|
<?php
|
||
|
$count++;
|
||
|
|
||
|
}?>
|
||
|
</table>
|
||
|
<table width="100%" align="center">
|
||
|
<input type="hidden" name="hid" value="1"/>
|
||
|
<input type="hidden" name="hid2" value="1"/>
|
||
|
<input type="hidden" name="count_menu" value="<?php echo $count?>" id="count_menu"/>
|
||
|
<tr class="bg2" >
|
||
|
<td align="center"><input type="submit" name="submit" class="submitbutton" value="Assign Menus" onclick="document.f1.count_menu.value=document.f1.report_id.length;" /></td>
|
||
|
<td align="center"><input type="submit" name="" value="Close" onclick="window.close();" /></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
</form>
|
||
|
|
||
|
|
||
|
<script>
|
||
|
function CheckAll(chk)
|
||
|
{for(var i=0;i<document.f1.elements.length;i++)
|
||
|
{var e=document.f1.elements[i];if(e.type=="checkbox")
|
||
|
{e.checked=chk.checked;}}}
|
||
|
|
||
|
function checkParent(count){
|
||
|
//alert(count);
|
||
|
var menu_name = document.getElementById('menu'+count).value;
|
||
|
//alert(menu_name);
|
||
|
var parent_name = document.getElementById('parent_id'+count).value;
|
||
|
//alert(parent_name);
|
||
|
var report_id = document.getElementById('report_id'+count).checked;
|
||
|
var totalCount = document.getElementById('count_menu').value;
|
||
|
for(var i = 0 ; i< totalCount ; i++){
|
||
|
var checkParent = document.getElementById('menu'+i).value;
|
||
|
|
||
|
if(parent_name==checkParent){
|
||
|
//alert('test');
|
||
|
if(report_id==true){
|
||
|
document.getElementById('report_id'+i).checked=true;
|
||
|
}
|
||
|
if(report_id==false){
|
||
|
document.getElementById('report_id'+i).checked=false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|