211 lines
7.3 KiB
PHP
211 lines
7.3 KiB
PHP
<?php
|
|
include('pop_up_top.php');
|
|
$TABLENAME='role_master';
|
|
$TABLENAME2='assign_menu';
|
|
$this_script='role_master.php';
|
|
?>
|
|
<?php
|
|
if(isset($acn) && $acn=='delete')
|
|
{
|
|
if($Role_id)
|
|
{
|
|
mysqli_query($conn,"DELETE FROM $TABLENAME WHERE role_id='".$Role_id."'");
|
|
$sql = "Delete from $TABLENAME2 where role_id='".$Role_id."'";
|
|
$res=mysqli_query($conn,$sql);
|
|
}
|
|
}
|
|
if(isset($hid) && $hid=='1')
|
|
{
|
|
|
|
$result_max=mysqli_query($conn,"select max(role_id)as max from $TABLENAME ");
|
|
|
|
$row = mysqli_fetch_assoc($result_max);
|
|
|
|
|
|
|
|
if($frmacn=="Add")
|
|
{
|
|
$max= $row['max']+1;}
|
|
else {
|
|
$max=$Role_id;
|
|
}
|
|
|
|
$query_main=" SET role_id='$max' ,role_name ='".addslashes($Role_Name)."',role_description='".addslashes($Role_Description)."', modified_by='".$_SESSION['user_id']."'";
|
|
if($frmacn=="Update")
|
|
{
|
|
$query_prefix='UPDATE ';
|
|
$query_suffix=" WHERE role_id='".$Role_id."'";
|
|
$query_additional="";
|
|
$msg="Role Updated Successfully";
|
|
$sql=$query_prefix.$TABLENAME.$query_main.$query_additional.$query_suffix;
|
|
$res=@mysqli_query($conn,$sql);
|
|
}
|
|
elseif($frmacn=="Add")
|
|
{
|
|
$query_prefix='INSERT INTO ';
|
|
$query_suffix="";
|
|
$query_additional="";
|
|
$msg="Role Added Successfully";
|
|
$sql = "select * FROM $TABLENAME where role_name ='".addslashes($Role_Name)."'";
|
|
$res=mysqli_query($conn,$sql);
|
|
$num=mysqli_num_rows($res);
|
|
if($num<=0)
|
|
{
|
|
$sql=$query_prefix.$TABLENAME.$query_main.$query_additional.$query_suffix;
|
|
$res=@mysqli_query($conn,$sql);
|
|
if(!$res){
|
|
$msg="Error adding/updating role. Please make sure the role does not already exist.";
|
|
}
|
|
}
|
|
}
|
|
//echo "<script>location.replace('$this_script?msg=$msg')</script>";
|
|
|
|
}
|
|
|
|
?>
|
|
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
|
|
|
|
|
|
<tr>
|
|
<td style="padding:10px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
<tr>
|
|
<td><fieldset class="bdr1" >
|
|
|
|
|
|
<center>
|
|
|
|
<?php if($acn=='add' || $acn=='update' || $acn=='view') { ?>
|
|
<?php
|
|
if($acn=='update' || $acn=='view')
|
|
{
|
|
$sql=@mysqli_query($conn,"SELECT * FROM $TABLENAME WHERE role_id='".$Role_id."'");
|
|
$row=@mysqli_fetch_array($sql);
|
|
@extract($row);
|
|
}
|
|
?>
|
|
<form name="f1" method="post" action="#" onsubmit="return validateForm();">
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bdr_table">
|
|
<tr>
|
|
<td colspan="2" align="center" class="bg2">
|
|
<span class="txt">
|
|
<?php
|
|
if($msg)
|
|
echo $msg;
|
|
?>
|
|
</span></td>
|
|
</tr>
|
|
<tr>
|
|
|
|
</tr>
|
|
<tr>
|
|
<!-- <td width="50%" align="right" class="bg3">Role Name </td> -->
|
|
|
|
<td align="left" class="bdr_td"><input placeholder="ROLE NAME" type="text" class="textbox1" name="Role_Name" size="45" value="<?php echo stripslashes($role_name)?>" style="width:200px;"></td>
|
|
</tr>
|
|
<tr>
|
|
<!--<td width="50%" align="right" class="bg3">Role Description:</td>-->
|
|
<td align="left" class="bdr_td">
|
|
<input placeholder="ROLE DESCRIPTION" type="text" class="textbox1" name="Role_Description" value="<?php echo stripslashes($role_description)?>" style="width:200px;"/></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="50%" align="right" class="bg3">
|
|
<input type="hidden" name="hid" value="1">
|
|
<input type="hidden" name="Role_id" value="<?php echo $role_id?>">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td width="50%" align="left" class="bdr_td">
|
|
<?php if($acn=='update') { ?>
|
|
<input type="submit" name="frmacn" value="Update" class="submitbutton" style="background-color:#CCFF33;">
|
|
<?php } else if($acn=='add') { ?>
|
|
<input type="submit" name="frmacn" value="Add" class="submitbutton" style="background-color:#CCFF33;">
|
|
<?php } ?>
|
|
<input type="button" value="Close" onclick="window.close();" class="submitbutton" style="background-color:#FF5C33;">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</form>
|
|
<?php } else { ?>
|
|
<script>location.href='role_list.php';</script>
|
|
<form name="f1" method="post" action="<?php echo $this_script?>">
|
|
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bdr_table">
|
|
<tr class="bg2">
|
|
<td colspan="9" align="center"><font color="maroon"><?php echo $msg?></font></td>
|
|
</tr>
|
|
<tr class="bg2">
|
|
<td align="left" ><strong>S.No.</strong></td>
|
|
<td align="center"><strong>Role Id</strong></td>
|
|
<td align="center"><strong>Role Name</strong></td>
|
|
<td align="center" width="300"><strong>Role Description</strong></td>
|
|
<td align="center"><strong>View</strong></td>
|
|
<td align="center"><strong>Edit</strong></td>
|
|
<td align="center"><strong>Delete</strong></td>
|
|
<td align="center"><strong>Assign menu</strong></td>
|
|
</tr>
|
|
<?php
|
|
$sql="SELECT * FROM $TABLENAME ";
|
|
$result = mysqli_query($conn,$sql);
|
|
$num_rows=@mysqli_num_rows($result);
|
|
$page=new Page();
|
|
$page->set_page_data($this_script,$num_rows,$records_per_page=100000,$scroll_num=0,$show_prev_next=true,$show_scroll_prev_next=true,$show_first_last=true);
|
|
$page->set_qry_string("");
|
|
$page_order_result=@mysqli_query($conn,$page->get_limit_query($sql));
|
|
$num=@mysqli_num_rows($page_order_result);
|
|
if($num>0)
|
|
{
|
|
$pageon=$_GET['page'];
|
|
$pageon=($pageon)*100000;
|
|
$count=$pageon+1;
|
|
while($row=@mysqli_fetch_array($page_order_result))
|
|
{
|
|
extract($row);
|
|
?>
|
|
<tr class="bdr_td">
|
|
<td align="left" class="bdr_td"><?php echo $count?></td>
|
|
<td align="center" class="bdr_td"> <?php echo $role_id?></td>
|
|
<td align="center" class="bdr_td"> <?php echo $role_name?></td>
|
|
<td align="center" class="bdr_td"> <?php echo stripslashes($row['role_description'])?></td>
|
|
<td align="center" class="bdr_td"> <a href="javascript:void(0);" onclick="javascript:sendpage('<?php echo $this_script?>?acn=view&Role_id=<?php echo $row['role_id']?>');"><img src='images/view.jpg' border="0" /></a></td>
|
|
<td align="center" class="bdr_td"> <a href="javascript:void(0);" onclick="javascript:sendpage('<?php echo $this_script?>?acn=update&Role_id=<?php echo $row['role_id']?>');"><img src='images/edit.png' border="0" /></a></td>
|
|
<td align="center" class="bdr_td"><?php if($role_id!=2){?> <a href="javascript:void(0);" onclick="javascript:deleterecord('<?php echo $this_script?>?acn=delete&Role_id=<?php echo $row['role_id']?>');"><img src='images/drop.png' border="0" /></a><?php }else{ echo "Protected";}?></td>
|
|
<td align="center" class="bdr_td"> <a href="javascript:void(0);" onclick="javascript:sendpage('assign_menu.php?Role_id=<?php echo $row['role_id']?>&Role_Name=<?php echo $row['role_name']?>');"><img src='images/view.jpg' border="0" /></a></td>
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
} ?>
|
|
<tr class='bg2'><td colspan='9'><div style="margin-right:10px; ">Page <?php echo "<br>".$page->get_page_nav();?></div></td></tr>
|
|
<?php }
|
|
else
|
|
{
|
|
echo "<tr><td align='center' colspan='9' class='bdr_td'><strong>No Record Found</strong></td></tr>";
|
|
}
|
|
?>
|
|
|
|
<tr><td colspan="9" align="right"><input type="button" onclick="window.location.href='role_master.php?acn=add'" value="Add New"></td></tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
<?php } ?>
|
|
</center>
|
|
</fieldset>
|
|
</td>
|
|
</tr>
|
|
</table></td>
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
var fieldArray = new Array(
|
|
new Array('Role_Name'), new Array('Please enter role name.'));
|
|
|
|
function validateForm(){
|
|
|
|
return checkform('f1',fieldArray);
|
|
}
|
|
</script>
|