331 lines
22 KiB
PHP
331 lines
22 KiB
PHP
<?php
|
|
class USER_AUTH extends USER
|
|
{
|
|
public function user_auth_javainit()
|
|
{
|
|
|
|
}
|
|
|
|
public function fn_auth_init()
|
|
{
|
|
if(isset($_REQUEST['task'])){$task=trim(strtolower($_REQUEST['task']));}
|
|
if(isset($_POST['task'])){$task=trim(strtolower($_POST['task']));}
|
|
if($_REQUEST||$_POST){if($_REQUEST['sec']||$_POST['sec']){$task=$this->dec($task);}}
|
|
switch($task)
|
|
{
|
|
case "default":
|
|
$this->fn_default_auth();
|
|
break;
|
|
|
|
case $task:
|
|
$task="fn_".$task;
|
|
if(method_exists($this,$task)){$this->$task();}
|
|
break;
|
|
|
|
default:
|
|
$this->fn_default_auth();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function fn_default_auth()
|
|
{
|
|
echo $this->FN_CREATEHEADER();
|
|
// echo "<style>
|
|
// .besidepassword {margin-left:92px;margin-top:-5px;position:absolute;z-index:0}
|
|
// </style>";
|
|
echo "<script>
|
|
var myFormsearch;var dguserauth;
|
|
function initObject()
|
|
{";
|
|
// ===== FOrm Search
|
|
$formdata=array(
|
|
array("type"=>"settings","position"=>"label-left","labelWidth"=>"160","inputWidth"=>"120"),
|
|
array("type"=>"fieldset","width"=>"950","label"=>"User Authentifikasi",
|
|
"list"=>array(
|
|
array("type"=>"hidden","name"=>"txtmenuid"),
|
|
array("type"=>"combo","name"=>"cbonik","label"=>"Masukkan/Pilih Kode User","required"=>"true","info"=>"true","inputWidth"=>"180",
|
|
"tooltip"=>"Pilih Kode User terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","maxLength"=>"","className"=>"txtleft"),
|
|
array("type"=>"newcolumn"),
|
|
array("type"=>"combo","name"=>"cbotipemenu","required"=>"true","info"=>"true","offsetLeft"=>"10",
|
|
"tooltip"=>"Pilih Tipe Menu terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","maxLength"=>"","className"=>"txtleft"),
|
|
array("type"=>"newcolumn"),
|
|
array("type"=>"combo","name"=>"cbogroupproject","info"=>"true","offsetLeft"=>"10","width"=>"190",
|
|
"tooltip"=>"Pilih Group Project Menu terlebih dahulu. TERIMA KASIH","maxLength"=>"","className"=>"txtleft"),
|
|
array("type"=>"newcolumn"),
|
|
array("type"=>"button","name"=>"btnloadmenu","value"=>"Load Menu","className"=>"button_load","offsetLeft"=>"10","offsetTop"=>"0","disabled"=>"1"),
|
|
array("type"=>"newcolumn"),
|
|
array("type"=>"button","name"=>"btnupdatemenu","value"=>"Update","className"=>"button_update","offsetLeft"=>"10","offsetTop"=>"0","disabled"=>"1")
|
|
)
|
|
)
|
|
);
|
|
$this->FN_DHTMLXFORM("myFormsearch","divformsearch",$formdata);
|
|
$arrval=array(array(value=>"",text=>""),array(value=>"",text=>"Menu"),array(value=>"tree",text=>"TreeMenu"));
|
|
$this->FN_COMBOVALIDATIONVALUEARRAY("myFormsearch","cbotipemenu",$arrval);
|
|
|
|
$exp="&exp=nik|9999";
|
|
if($_SESSION['nik']=='9999'){$exp="";}
|
|
|
|
$urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("dhtmlxaddcombo")."&tableobj=tbl_employee_accessibility|id,nik,employeename:nik,employeename".$exp."')";
|
|
$this->FN_COMBOVALIDATIONVALUENEW("myFormsearch","cbonik","tbl_employee_accessibility","$urlcbo","");
|
|
|
|
$urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("dhtmlxaddcombo")."&tableobj=tbl_employee_accessibility|id,nik,employeename:nik,employeename".$exp."')";
|
|
$urlother="myFormsearch.getCombo('cbogroupproject').clearAll();myFormsearch.getCombo('cbogroupproject').setComboText('');";
|
|
$urlother.="var groupproject=ajaxuridhtmlx('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("getfieldvalue")."&tableobj=tbl_employee_accessibility&getfield=menuidgroupproject&swhere=id|'+val);";
|
|
$urlother.="var url=fn_dhtmlxloadobject('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("dhtmlxaddcombo")."&tableobj=tbl_menu_groupproject|id,groupname,groupdescription:id,groupname&in=id|'+groupproject+'&sort=id');";
|
|
$urlother.=$this->FN_COMBOVALIDATIONVALUE2("myFormsearch","cbogroupproject","tbl_menu_groupproject","url","",true);
|
|
$this->FN_COMBOVALIDATIONVALUENEW("myFormsearch","cbonik","tbl_employee_accessibility","$urlcbo","$urlother");
|
|
|
|
// === Form Event
|
|
$onchangecbotipemenu="myFormsearch.enableItem('btnloadmenu');";
|
|
$onchangecbotipemenu.="myFormsearch.setItemFocus('btnloadmenu');";
|
|
|
|
$onclickbtnloadmenu="var menuid=ajaxuridhtmlx('".$this->enc("obj_user")."','obj=".$this->enc("user_auth")."&task=".$this->enc("getmenuid")."&tipemenu='+myFormsearch.getCombo('cbotipemenu').getSelectedValue()+'&idnik='+myFormsearch.getCombo('cbonik').getSelectedValue());";
|
|
$onclickbtnloadmenu.="myFormsearch.setItemValue('txtmenuid',menuid);";
|
|
$onclickbtnloadmenu.="url=fn_dhtmlxloadobject('".$this->enc("obj_user")."','obj=".$this->enc("user_auth")."&task=".$this->enc("loadmenu")."&idnik='+myFormsearch.getCombo('cbonik').getSelectedValue()+'&tipemenu='+myFormsearch.getCombo('cbotipemenu').getSelectedValue()+'&idgroupproject='+myFormsearch.getItemValue('cbogroupproject'));";
|
|
//$onclickbtnloadmenu.="alert(url);";
|
|
$onclickbtnloadmenu.="dguserauth.clearAndLoad(url);";
|
|
$onclickbtnloadmenu.="myFormsearch.enableItem('btnupdatemenu');";
|
|
|
|
$eventupdatemenu="dhtmlx.confirm({";
|
|
$eventupdatemenu.=" title:'Konfirmasi',text:'Data sudah benar dan ingin diupdate?',type:'confirm',";
|
|
$eventupdatemenu.=" callback:function(result){";
|
|
$eventupdatemenu.=" if(result)";
|
|
$eventupdatemenu.=" {";
|
|
$eventupdatemenu.=" var res=ajaxuridhtmlx('".$this->enc("obj_user")."','obj=".$this->enc("user_auth")."&task=".$this->enc("updatemenuid")."&idnik='+myFormsearch.getItemValue('cbonik')+'&menuid='+myFormsearch.getItemValue('txtmenuid')+'&tipemenu='+myFormsearch.getItemValue('cbotipemenu'));";
|
|
$eventupdatemenu.=" var spres=res.split('|');";
|
|
$eventupdatemenu.=" if(spres[0]=='ok'){fn_dhtmlxmessage('','Menu sudah berhasil diupdate.TERIMA KASIH');}";
|
|
$eventupdatemenu.=" else{fn_dhtmlxmessage('error','Error Found : '+spres[1]);}";
|
|
$eventupdatemenu.=" fn_myform_clear();dguserauth.clearAll();".$this->FN_DHTMLXWINDOWSHIDEPROGRESS();
|
|
$eventupdatemenu.=" }else{".$this->FN_DHTMLXWINDOWSHIDEPROGRESS()."}";
|
|
$eventupdatemenu.=" }";
|
|
$eventupdatemenu.="});";
|
|
$onclickbtnupdatemenu=$this->FN_DHTMLXWINDOWSHOWPROGESS($eventupdatemenu);
|
|
|
|
$arrevent=array(
|
|
array("eventname"=>"onbuttonclick","eventparam"=>"id,val",
|
|
"switch"=>array(
|
|
"btnloadmenu"=>"$onclickbtnloadmenu",
|
|
"btnupdatemenu"=>"$onclickbtnupdatemenu"
|
|
)
|
|
),
|
|
array("eventname"=>"onchange","eventparam"=>"id,val",
|
|
"switch"=>array(
|
|
"cbotipemenu"=>"$onchangecbotipemenu",
|
|
"cbogroupproject"=>"myFormsearch.setItemFocus('btnloadmenu')"
|
|
)
|
|
)
|
|
);
|
|
|
|
$this->FN_DHTMLXFORMEVENT("myFormsearch",$arrevent);
|
|
|
|
// === Form Event
|
|
|
|
//echo " dguserauth=new dhtmlXGridObject(\"divdgsearch\");
|
|
// dguserauth.setSkin(\"dhx_skyblue\");
|
|
// dguserauth.setImagePath(\"".PATH_THEME."/codebase/imgs/\");
|
|
// dguserauth.setHeader(\"C,Id,Tipe,Menu Text,Keterangan,Group Project\");
|
|
// dguserauth.setColTypes(\"ch,ro,ro,ro,ro,ro\"); // ro => Read Only, ed => Edit
|
|
// dguserauth.attachHeader(\"#rspan,#rspan,#combo_filter,#rspan,#rspan,#combo_filter\");
|
|
// dguserauth.setInitWidths(\"40,30,80,210,320,*\");
|
|
// dguserauth.setColAlign(\"center,left,center,left,left,left\");
|
|
// dguserauth.setColSorting(\"int,int,str,str,str,str\");
|
|
//
|
|
// dguserauth.setDateFormat(\"%Y-%m-%d %H:%i:%s\");
|
|
// dguserauth.enablePaging(true,".PAGE_LIMIT.",null,\"divdgsearchpaging\",true,\"recInfoArea\");
|
|
// dguserauth.setPagingSkin(\"toolbar\",\"dhx_skyblue\");
|
|
// dguserauth.setPagingSkin(\"bricks\");
|
|
// dguserauth.enableTooltips(\"false,false,false,false,false\");
|
|
// dguserauth.attachFooter(\"<a href='javascript:void(0)' style='color:blue' onClick='fn_checkall(1)'>Check All</a> <a href='javascript:void(0)' style='color:blue' onClick='fn_checkall(0)'>Uncheck all</a>,#cspan,#cspan,#cspan,#cspan,#cspan\",[\"text-align:left;\"]);
|
|
// dguserauth.init();";
|
|
$grdinit=array("gridname"=>"dguserauth","divtarget"=>"divdgsearch","divpaging"=>"divpagingarea","paginglimit"=>PAGE_LIMIT,"skin"=>"modern",
|
|
"showloader"=>"true","setcolumnhidden"=>"false,false,false,false,false,false",
|
|
"attachheader"=>"#rspan,#rspan,#combo_filter,#rspan,#rspan,#combo_filter",
|
|
"enableheadermenu"=>true);
|
|
$gridproperties=array("C"=>"center,ch,40,center,int,false",
|
|
"ID. "=>"left,ro,30,left,str,false",
|
|
"Menu Type"=>"left,ro,110,left,str,false",
|
|
"Menu Text"=>"left,ed,180,left,str,false",
|
|
"Menu Description"=>"left,ro,200,left,str,false",
|
|
"Group Project"=>"center,combo,110,center,str,false");
|
|
$this->FN_DHTMLXGRIDVIEW($grdinit,$gridproperties,"bricks",true,"");
|
|
// === data grid attach Event
|
|
//echo " dguserauth.attachEvent(\"onXLE\",function(){
|
|
// var rwcount=dguserauth.getRowsNum();
|
|
// var menuid=myFormsearch.getItemValue(\"txtmenuid\");
|
|
// if(menuid)
|
|
// {
|
|
// spmenuid=menuid.split(',');
|
|
// for(i=1;i<=rwcount;i++)
|
|
// {
|
|
// var id=dguserauth.cells(i,1).getValue();
|
|
// for(j=0;j<spmenuid.length;j++)
|
|
// {
|
|
// if(trim(spmenuid[j])==trim(id))
|
|
// {
|
|
// dguserauth.cells(i,0).setValue(1);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// });
|
|
//
|
|
// dguserauth.attachEvent(\"onEditCell\",function(stage,rowid,colid){
|
|
// stage 2 is edit closed
|
|
// if(colid==0&&stage==1){fn_getmenuid();}
|
|
//alert(colid);
|
|
// return true;
|
|
// });";
|
|
echo " }
|
|
|
|
function fn_checkall(chkvalue)
|
|
{
|
|
var rwcount=dguserauth.getRowsNum();
|
|
if(rwcount<=0){fn_dhtmlxmessage('error','Mohon maaf data tidak ada / belum query');return false;}
|
|
//alert(rwcount);
|
|
for(i=1;i<=rwcount;i++)
|
|
{
|
|
dguserauth.cells(i,0).setValue(chkvalue);
|
|
//alert(i+' '+dguserauth.cells(i,0).getValue(chkvalue));
|
|
}
|
|
if(chkvalue==1){fn_getmenuid();}
|
|
}
|
|
|
|
function fn_getmenuid()
|
|
{
|
|
var rwcount=dguserauth.getRowsNum();
|
|
var varmenuid='';
|
|
for(i=1;i<=rwcount;i++)
|
|
{
|
|
var id=dguserauth.cells(i,0).getValue();
|
|
if(id==1){varmenuid=varmenuid+dguserauth.cells(i,1).getValue()+',';}
|
|
}
|
|
varmenuid=varmenuid.substring(0,varmenuid.length-1);
|
|
myFormsearch.setItemValue(\"txtmenuid\",varmenuid);
|
|
//alert(myFormsearch.getItemValue(\"txtmenuid\"));
|
|
}
|
|
|
|
function fn_myform_clear()
|
|
{
|
|
myFormsearch.getCombo(\"cbonik\").setComboValue('');
|
|
myFormsearch.getCombo(\"cbonik\").setComboText('');
|
|
myFormsearch.getCombo(\"cbotipemenu\").setComboValue('');
|
|
myFormsearch.getCombo(\"cbotipemenu\").setComboText('');
|
|
myFormsearch.disableItem(\"btnloadmenu\");
|
|
myFormsearch.disableItem(\"btnupdatemenu\");
|
|
myFormsearch.setItemFocus(\"cbonik\");
|
|
|
|
}
|
|
</script>";
|
|
echo $this->FN_CLOSEHEADER();
|
|
echo $this->FN_CREATEBODY("e8f1ff");
|
|
echo " <table width=\"100%\" border=\"0\">
|
|
<tr>
|
|
<td valign=\"top\">
|
|
<div id=\"divformsearch\" style=\"width:100%\"></div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<div id=\"divdgsearch\" style=\"height:420px;width:948px;overflow:hidden\"></div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>
|
|
<div id=\"divdgsearchpaging\" style=\"width:830px;margin-top:1px\"></div>
|
|
</td>
|
|
</tr>
|
|
</table>";
|
|
echo $this->FN_CREATEFOOTER();
|
|
}
|
|
|
|
public function fn_updatemenuid()
|
|
{
|
|
$id=$_REQUEST['idnik'];
|
|
$menuid=$_REQUEST['menuid'];//echo $menutype;return true;
|
|
$tipemenu=$_REQUEST['tipemenu'];//echo $menutype;return true;
|
|
//return false;
|
|
$qry="update ".DB_APORTIL.".tbl_employee_accessibility
|
|
set ".$tipemenu."menuid='$menuid',uby='".$_SESSION['nik']."',udt=now()
|
|
where id='$id'";
|
|
if($this->executequery($qry))
|
|
{
|
|
echo 'ok|';
|
|
//$msg="Menu baru <b>".strtoupper("$nmuser")."</b> sudah berhasil ditambahkan<br/>";
|
|
//$msg.="Klik ".$this->CREATE_LINK($this->fn_url_home(),"disini","javascript:void(0)","_self","Penambahan Menu Baru");
|
|
//$msg.=" untuk Penambahan Menu Baru. TERIMA KASIH";
|
|
//echo $this->SHOWMESSAGE($msg);
|
|
}else{echo "failed|".$this->getErrorQuery();}
|
|
}
|
|
|
|
public function fn_loadmenu()
|
|
{
|
|
$id=$_REQUEST["idnik"];
|
|
$tipemenu=$_REQUEST["tipemenu"];
|
|
$idgroupproject=$_REQUEST["idgroupproject"];
|
|
$sp=$this->fn_get_fieldsvalues("menuidgroupproject,groupuser","select menuidgroupproject,groupuser from ".DB_APORTIL.".tbl_employee_accessibility where id='$id'");
|
|
//echo "select menuidgroupproject,groupuser from ".DB_APORTIL.".tbl_employee_accessibility where nik='$nik'";return false;
|
|
$menuidgroupproject=$sp[0];$groupuser=$sp[1];
|
|
//include XML Header (as response will be in xml format)
|
|
header("Content-type: text/xml");
|
|
//encoding may be different in your case
|
|
echo('<?xml version="1.0" encoding="utf-8"?>');
|
|
//start output of data
|
|
echo "<rows id=\"0\">";
|
|
//if(!$menuidgroupproject){$menuidgroupproject=0;}
|
|
if(!$menuidgroupproject){$menuidgroupproject=0;}
|
|
$swhere="and t.id_menu_groupproject in($menuidgroupproject)";
|
|
if($idgroupproject){$swhere="and t.id_menu_groupproject='$idgroupproject'";}
|
|
if($nik=='9999'||$nik=='9292'||$groupuser=='SU'&&!$idgroupproject){$swhere="";}
|
|
|
|
$qry="select t.id,t.menutype,t.menutext,t.menudesc,0 ischecked,m.groupname
|
|
from ".DB_APORTIL.".tbl_".$tipemenu."menu t inner join ".DB_APORTIL.".tbl_menu_groupproject m on m.id=t.id_menu_groupproject
|
|
where t.isdeleted=0 and t.menuactivated=1 $swhere
|
|
order by t.id asc limit ".TBL_PAGE_LIMIT;
|
|
//echo $qry;
|
|
$rs=$this->selectquery($qry);
|
|
if($rs)
|
|
{
|
|
$i=1;
|
|
while($row=$this->data_row_array($rs))
|
|
{
|
|
//create xml tag for grid's row
|
|
echo ("<row id='".$i."'>");
|
|
print("<cell><![CDATA[".$row["ischecked"]."]]></cell>");
|
|
print("<cell><![CDATA[".$row["id"]."]]></cell>");
|
|
print("<cell><![CDATA[".$row["menutype"]."]]></cell>");
|
|
print("<cell><![CDATA[".$row["menutext"]."]]></cell>");
|
|
print("<cell><![CDATA[".$row["menudesc"]."]]></cell>");
|
|
print("<cell><![CDATA[".$row["groupname"]."]]></cell>");
|
|
echo ("</row>");
|
|
$i+=1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//error occurs
|
|
echo mysql_errno().": ".mysql_error()." at ".__LINE__." line in ".__FILE__." file<br>";
|
|
}
|
|
echo "</rows>";
|
|
|
|
}
|
|
|
|
public function fn_getnik()
|
|
{
|
|
$nik=$_REQUEST["nik"];
|
|
$getnik=$this->fn_get_fieldvalue("nik","select nik from ".DB_APORTIL.".tbl_employee_accessibility where nik='$nik' and isdeleted=0");
|
|
echo $getnik;
|
|
}
|
|
|
|
public function fn_getmenuid()
|
|
{
|
|
$id=$_REQUEST["idnik"];
|
|
$tipemenu=$_REQUEST["tipemenu"];
|
|
$menuid=$this->fn_get_fieldvalue($tipemenu."menuid","select ".$tipemenu."menuid from ".DB_APORTIL.".tbl_employee_accessibility where id='$id'");
|
|
echo $menuid;
|
|
|
|
}
|
|
}
|
|
|
|
?>
|