Viewing file: umPermission.php (5.85 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
include_once("pagebody.php");
pageHeader();
$pageTitle="กำหนดสิทธิ์การใช้รายคน"; // $UsID";
?>
<table width=100% class="pageTitleBgColor" align="center">
<tr><td align=center><? echo $pageTitle; ?></td></tr>
</table>
<!--your code here-------------------------------------------------------------------------->
<br>
<?
include_once("clsUmSystem.php");
include_once("clsUmGroup.php");
include_once("clsUmUserGroup.php");
include_once("clsUmMenu.php");
include_once("clsUmGPermission.php");
include_once("clsUmPermission.php");
include_once("clsUmUser.php");
$oC = new clsConnection($GLOBALS['HOST'], $GLOBALS['DB'], $GLOBALS['USER'], $GLOBALS['PASSWORD']);
$oSt = new umsystem($oC);
$oGp = new umgroup($oC);
$oUg = new umusergroup($oC);
$oMnT = new ummenu($oC);
$oMn = new umMenu($oC);
$oGPm = new umgpermission($oC);
$oPm = new umpermission($oC);
$oUs = new umuser($oC);
//get groups are assigned to user
$oUg->RSgroupByUs($UsID);
if ($oUg->GetRowSelected()>0){
while ($oUg->GetRecord()){
//get group info
$oGp->SearchByKey ($oUg->UgGpID);
$oGp->GetRecord();
//get app info
$oSt->SearchByKey($oGp->GpStID);
$oSt->GetRecord();
$StName = $oSt->StNameT;
//create table
echo "<form name=form".$oGp->GpID." method=post action=processUmPermission.php>\n";
echo "<input type=hidden name=UsID value=$UsID>\n";
echo "<input type=hidden name=GpID value=$oGp->GpID>\n";
echo "<input type=hidden name=GpStID value=$oGp->GpStID>\n";
$oT = new clsTable();
$oT->bgColor="#eeeeee";
$oT->headerBgColor="#dddddd";
$oT->align="center";
$oT->rowStart();
$oT->addCell("<b>ระบบ ".$oSt->StNameT,"<b>","",7);
$oT->rowEnd();
$oT->rowStart();
$oT->addCell(" <b>กลุ่มงาน ".$oGp->GpNameT,"<b>","",7);
$oT->rowEnd();
$oT->rowStart("",$oT->headerBgColor);
//$oT->addCell("");
$oT->addCell("<b>เมนู</b>","center");
$oT->addCell("<b>X</b>","center");
$oT->addCell("<b>C</b>","center");
$oT->addCell("<b>R</b>","center");
$oT->addCell("<b>U</b>","center");
$oT->addCell("<b>D</b>","center");
$oT->rowEnd();
$oMnT->RSMainMenuBySt($oGp->GpStID);
while ($oMnT->GetRecord()){
ShowmenuP($oGp->GpID, $oMnT->MnID, $UsID);
}
$oT->rowStart("","#dddddd");
//$oT->addCell("");
$oT->addCell("");
$oT->addCell("<input type=submit name=check value=บันทึก>",'','','5');
$oT->rowEnd();
echo $oT->output();
echo "<form>\n";
echo "<p> </p>";
} //end while
//reset all permission
echo "<form name=form".$oGp->GpID." method=post action=processUmPermission.php>\n";
echo "<input type=hidden name=UsID value=$UsID>\n";
echo "<input type=hidden name=GpID value=$oGp->GpID>\n";
echo "<input type=hidden name=GpStID value=$oGp->GpStID>\n";
$oT = new clsTable();
$oT->bgColor="#eeeeee";
$oT->headerBgColor="#dddddd";
$oT->align="center";
$oT->rowStart();
$oT->addCell("<input type=submit name=resetall value=\"Reset All\">");
$oT->rowEnd();
echo $oT->output();
}else{
echo "<p align=center>";
echo "Not assigned any groups to this user yet !!!";
echo "</p>";
}
//////////////////////////////////////////
function ShowMenuP($GpID, $MnID, $UsID){
global $oC;
global $oT;
global $Str;
global $oGPm;
global $oPm;
global $rw;
include_once("../class/clsDB.php");
$oMn = new ummenu($oC);
$oMn->SearchByKey($MnID);
$oMn->GetRecord();
if ($oMn->MnLevel==0){
$bs="<b>";
$be="</b>";
}
$lv = $oMn->MnLevel+1;
$checkX= "checked";
$checkC= "checked";
$checkR= "checked";
$checkU= "checked";
$checkD= "checked";
$oT->rowStart();
//$oT->addCell("<input type=\"hidden\" name=mnid[] value=$oMn->MnID>");
$oT->addCell("<input type=\"hidden\" name=mnid[] value=$oMn->MnID>" . str_pad("",10*6*$oMn->MnLevel, " ", STR_PAD_RIGHT).$bs.$oMn->MnNameT.$be);
//find in UmPermission
$oPm->SearchByKey($UsID, $oMn->MnID);
if ($oPm->GetRowSelected()>0){
//found in umPermission
$oPm->GetRecord();
if ($oPm->pmX==0) $checkX="";
if ($oPm->pmC==0) $checkC="";
if ($oPm->pmR==0) $checkR="";
if ($oPm->pmU==0) $checkU="";
if ($oPm->pmD==0) $checkD="";
}else{
$oGPm->SearchByKey($GpID, $oMn->MnID);
if ($oGPm->GetRowSelected()>0){
//found in umGPermission
$oGPm->GetRecord();
if ($oGPm->gpX==0) $checkX="";
if ($oGPm->gpC==0) $checkC="";
if ($oGPm->gpR==0) $checkR="";
if ($oGPm->gpU==0) $checkU="";
if ($oGPm->gpD==0) $checkD="";
}
}
$oT->addCell("<input type=checkbox name=\"_".$oMn->MnID."x\" $checkX>");
$oT->addCell("<input type=checkbox name=\"_".$oMn->MnID."c\" $checkC>");
$oT->addCell("<input type=checkbox name=\"_".$oMn->MnID."r\" $checkR>");
$oT->addCell("<input type=checkbox name=\"_".$oMn->MnID."u\" $checkU>");
$oT->addCell("<input type=checkbox name=\"_".$oMn->MnID."d\" $checkD>");
$oT->rowEnd();
//show column header
$rw++;
if ($rw % 15 == 0){
$oT->rowStart("",$oT->headerBgColor);
//$oT->addCell("");
$oT->addCell("<b>เมนู</b>","center");
$oT->addCell("<b>X</b>","center");
$oT->addCell("<b>C</b>","center");
$oT->addCell("<b>R</b>","center");
$oT->addCell("<b>U</b>","center");
$oT->addCell("<b>D</b>","center");
$oT->rowEnd();
}
//show column header
$oMn->RSmenuByParentMn($oMn->MnID);
while ($oMn->GetRecord()){
ShowMenuP($GpID, $oMn->MnID, $UsID);
}
}
?>
<br>
<!--------------------------------------------------------------------->
<?
pageFooter();
?>
<!--------------------------------------------------------------------->
<!--put javascript here-->
<script language="javascript">
function doEditMenu(StID, MnID){
window.location="umEditMenu.php?MnStID=" + StID + "&MnID=" + MnID;
}
function doDelete(f, txt, StID, MnID){
if (confirm('ต้องการลบเมนู ' + txt + ' ใช่หรือไม่') ) {
window.location="processUmMenu.php?method=delete&MnStID=" + StID + "&MnID=" + MnID;
}
}
</script>
|