<?php
    class MENUCONFIG_NEW extends MENUCONFIG
    {     
        public function menuconfig_new_javainit()
        {
            
        } 
        
        public function fn_new_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);}}
            
            //echo $task." re";return false;
            switch($task)
            {                  
                case "default":
                    $this->fn_default_new();
                break;
                
                case $task:
                    $task="fn_".$task;
                    if(method_exists($this,$task)){$this->$task();}
                break;

//                case "loadheader":
//                    $this->fn_loadheader();
//                break;

//                case "savemenu":
//                    $this->fn_savemenu();
//                break;

//                case "updateuser":
//                    $this->fn_savemenu(true);
//                break;
//                
//                case "getordermenu":
//                    $this->fn_getordermenu();
//                break;
//                
//                case "geticons":
//                    $this->fn_geticons();
//                break;
                
                default:
                    //if($_SESSION['nikx']!=='9999'){echo $this->under_construction();}
                    $this->fn_default_new();                    
                break;
            }
        }
                           
        public function fn_default_new()
        {
            echo $this->FN_CREATEHEADER();
            echo "<script>  
                       var myForm; 
                       function initObject()
                       {";
                           $formdata=array(
                                             array("type"=>"settings","position"=>"label-left","labelWidth"=>"130","inputWidth"=>"120"),
                                             array("type"=>"block","width"=>"1020",
                                                     "list"=>array(
                                                                      array("type"=>"label","label"=>"<u>Kolom 1</u>"),  
                                                                      array("type"=>"combo","name"=>"cbocategory","label"=>"Kategori","required"=>"true","info"=>"true",
                                                                                  "tooltip"=>"Masukkan Kategori terlebih dahulu","inputWidth"=>"220"),
                                                                      array("type"=>"combo","name"=>"cbomenutype","label"=>"Tipe","required"=>"true","info"=>"true",
                                                                                  "tooltip"=>"Pilih Jenis Menu terlebih dahulu","inputWidth"=>"220"),
                                                                      array("type"=>"combo","name"=>"cbomenugroupproject","label"=>"Group Project","required"=>"true","info"=>"true",
                                                                                  "tooltip"=>"Pilih Menu Group Project terlebih dahulu","inputWidth"=>"220"),
                                                                      array("type"=>"combo","name"=>"cbomenuheader","label"=>"Header","info"=>"true",
                                                                                  "tooltip"=>"Pilih Menu Header Project terlebih dahulu","inputWidth"=>"220"),
                                                                                  
                                                                      array("type"=>"input","name"=>"txtmenuid","label"=>"Menu Id","required"=>"true","info"=>"true","inputWidth"=>"260",
                                                                                          "tooltip"=>"Masukkan Id Menu terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","className"=>"txtleft"),
                                                                      array("type"=>"input","name"=>"txtmenutext","label"=>"Nama Menu","required"=>"true","info"=>"true","inputWidth"=>"260",
                                                                                          "tooltip"=>"Masukkan Nama Menu terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","className"=>"txtleft"),
                                                                      array("type"=>"input","name"=>"txtmenudesc","label"=>"Keterangan","required"=>"true","info"=>"true","inputWidth"=>"260",
                                                                                          "tooltip"=>"Masukkan Deskripsi Menu terlebih dahulu. TERIMA KASIH","validate"=>"NotEmpty","className"=>"txtleft"),
                                                                      array("type"=>"combo","name"=>"cbomenuimg","label"=>"Icons","info"=>"true","comboType"=>"image",
                                                                                  "tooltip"=>"Pilih Icons Bila ada","inputWidth"=>"220"),
                                                                      array("type"=>"input","name"=>"txtobjoption","label"=>"Nama Option","required"=>"true","info"=>"true","inputWidth"=>"220",
                                                                                          "tooltip"=>"Masukkan Object Option terlebih dahulu. TERIMA KASIH","className"=>"txtleft"),
                                                                      
                                                                      array("type"=>"newcolumn"),
                                                                      array("type"=>"label","label"=>"<u>Kolom 2</u>"),
                                                                      array("type"=>"input","name"=>"txtobjname","label"=>"Nama Object","required"=>"true","info"=>"true","inputWidth"=>"220",
                                                                                          "tooltip"=>"Masukkan Nama Object terlebih dahulu. TERIMA KASIH","className"=>"txtleft","offsetLeft"=>20),
                                                                      array("type"=>"input","name"=>"txttask","label"=>"Task","required"=>"true","info"=>"true","inputWidth"=>"220",
                                                                                          "tooltip"=>"Masukkan Task/Case terlebih dahulu. TERIMA KASIH","className"=>"txtleft","offsetLeft"=>20),
                                                                      array("type"=>"combo","name"=>"cbotarget","label"=>"Target","info"=>"true","readonly"=>"0","offsetLeft"=>20,
                                                                                          "tooltip"=>"Pilih Target Terlebih dahulu","inputWidth"=>"220"),
                                                                      array("type"=>"checkbox","name"=>"chkaktif","label"=>"Aktifkan","checked"=>1,"offsetLeft"=>20),
                                                                      array("type"=>"input","name"=>"txtmenuorder","label"=>"Order / Urutan","required"=>"true","info"=>"true","inputWidth"=>"30",
                                                                                          "tooltip"=>"Masukkan Order/Urutan terlebih dahulu. TERIMA KASIH","className"=>"txtcenter",
                                                                                          "validate"=>"^[0-9]","offsetLeft"=>20),
                                                                      array("type"=>"combo","name"=>"cbomenugroup","label"=>"Group","info"=>"true","readonly"=>"0","offsetLeft"=>20,
                                                                                  "tooltip"=>"Pilih Menu Group User Terlebih dahulu","inputWidth"=>"220"),
                                                                      array("type"=>"combo","name"=>"cbotable","label"=>"Setting Ke Table","info"=>"true","readonly"=>"0","offsetLeft"=>20,
                                                                                  "tooltip"=>"Pilih Setting Ke Table Terlebih dahulu","inputWidth"=>"220"),
                                                                      
                                                                      array("type"=>"checkbox","label"=>"Ya, Yakin Ingin disimpan","position"=>"label-right","offsetLeft"=>"20","offsetTop"=>"10","checked"=>1,"labelWidth"=>330,
                                                                                               "list"=>array(
                                                                                                                array("type"=>"button","name"=>"btnsave","value"=>"Save","className"=>"button_update","offsetLeft"=>"50","offsetTop"=>"10"),
                                                                                                                array("type"=>"newcolumn"),
                                                                                                                array("type"=>"button","name"=>"btncancel","value"=>"Cancel","className"=>"button_cancel","offsetLeft"=>"8","offsetTop"=>"10")
                                                                                               )
                                                                                                        
                                                                      )
                                                                  )
                                             )
                                           );


                            $this->FN_DHTMLXFORMDOCUMENT("myForm","document.body",$formdata);
                            $arrerror=array("cbocategory"=>"Error Found : Harap Pilih <b>Kategori</b> terlebih dahulu.TERIMA KASIH",
                                             "cbomenutype"=>"Error Found : Harap Isikan Pilih <b>Jenis Menu</b> terlebih dahulu.TERIMA KASIH",
                                             "cbomenugroupproject"=>"Error Found : Harap Pilih <b>Group Project</b> terlebih dahulu.TERIMA KASIH",
                                             "cbomenuheader"=>"Error Found : Harap Pilih <b>Header</b> terlebih dahulu.TERIMA KASIH",
                                             "txtmenuid"=>"Error Found : Harap Masukkan <b>Menu Id</b> terlebih dahulu.TERIMA KASIH",
                                             "txtmenutext"=>"Error Found : Harap Masukkan <b>Nama Menu</b> terlebih dahulu.TERIMA KASIH",
                                             "txtmenudesc"=>"Error Found : Harap Masukkan <b>Keterangan Menu</b> terlebih dahulu.TERIMA KASIH",
                                             "txtobjoption"=>"Error Found : Harap Masukkan <b>Object Option</b> terlebih dahulu.TERIMA KASIH",
                                             "txtobjname"=>"Error Found : Harap Masukkan <b>Nama Object</b> terlebih dahulu.TERIMA KASIH",
                                             "txttask"=>"Error Found : Harap Masukkan <b>Task</b> terlebih dahulu.TERIMA KASIH",
                                             "cbotarget"=>"Error Found : Harap Pilih <b>Target</b> terlebih dahulu.TERIMA KASIH",
                                             "txtmenuorder"=>"Error Found : Harap Masukkan <b>Order Menu</b> terlebih dahulu.TERIMA KASIH",
                                             "cbomenugroup"=>"Error Found : Harap Pilih <b>Group User</b> terlebih dahulu.TERIMA KASIH"
                                           );
                            $this->FN_DHTMLXFORMVALIDATIONERROR("myForm",$arrerror);
 
                            //  === Init Object
                            $arrcategory=array("options"=>array(
                                                                   array("value"=>"","text"=>""),array("value"=>"tree","text"=>"TreeMenu") 
                                                          )
                                         );
                            $this->FN_DHTMLXNEWCOMBOWITHARRAY("myForm","cbocategory",$arrcategory);
                            
                            $arrmenutype=array("options"=>array(
                                                                   array("value"=>"","text"=>""),array("value"=>"H","text"=>"Header"), 
                                                                   array("value"=>"S","text"=>"SubHeader"),array("value"=>"D","text"=>"Detail") 
                                                          )
                                         );
                            $this->FN_DHTMLXNEWCOMBOWITHARRAY("myForm","cbomenutype",$arrmenutype);

                            $arrmenuheader=array("options"=>array(
                                                                   array("value"=>"","text"=>"")
                                                          )
                                         );
                            $this->FN_DHTMLXNEWCOMBOWITHARRAY("myForm","cbomenuheader",$arrmenuheader);

                            $arrtarget=array("options"=>array(
                                                                   array("value"=>"","text"=>""),array("value"=>"_self","text"=>"_self"), 
                                                                   array("value"=>"_blank","text"=>"_blank") 
                                                          )
                                         );
                            $this->FN_DHTMLXNEWCOMBOWITHARRAY("myForm","cbotarget",$arrtarget);
                            
                            $urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("getmenugroup")."');";
                            $this->FN_DHTMLXNEWCOMBO("myForm","cbomenugroup",$urlcbo);

                            $urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("gettables")."');";
                            $this->FN_DHTMLXNEWCOMBO("myForm","cbotable",$urlcbo);
                            
                            $urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_controller")."','obj=".$this->enc("-")."&task=".$this->enc("dhtmlxaddcombo")."&tableobj=tbl_menu_groupproject|id,groupname')";
                            $this->FN_COMBOVALIDATIONVALUE2("myForm","cbomenugroupproject","tbl_menu_groupproject",$urlcbo,"");
 
                            $urlcbo="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("geticons")."');";
                            $this->FN_DHTMLXNEWCOMBOIMAGE("myForm","cbomenuimg",$urlcbo,"themes/icons/");
                            
                            // === Form Event
                            $arrayControls=array(
                                                  "txt_tgltra"=>date("Y-m-d"),"txt_nominal"=>"0","txt_bankfrom"=>"","txt_cabangbankfrom"=>"",
                                                  "cbo_idbankto"=>"","txt_rekeningfrom"=>"","txt_bankaccountfrom"=>"","txt_keterangan"=>""
                                           );
                            $onchangecbomenugroupproject="var menutype=myForm.getCombo(\"cbomenutype\").getSelectedValue();
                                                          var cbomenuheader=myForm.getCombo('cbomenuheader');
                                                          if(val==null){myForm.getCombo('cbomenugroupproject').setComboText('');}
                                                          cbomenuheader.setComboText('');
                                                          cbomenuheader.clearAll();//alert(menutype);
                                                          if(menutype!=='H')
                                                          {
                                                              url=fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("loadheader")."&kategory='+myForm.getCombo(\"cbocategory\").getSelectedValue()+'&idgroupproject='+val);
                                                              cbomenuheader.load(url);//alert('f');
                                                          }
                                                          //else                                                
                                                          //{myform_setmenuorder();}
                                                          myform_setmenuorder();";
                            
                            $onchangecbomenutype="if(val==null){myForm.getCombo('cbomenutype').setComboText('');}
                                                  myForm.getCombo('cbomenuheader').setComboText('');
                                                  myForm.getCombo('cbomenuheader').clearAll();";
                            
                            //$onkeydowntxtmenutext="alert(myForm.getCombo('cbomenutype').getComboText());";
                            $onkeydowntxtmenutext="if(ev.keyCode==13)";
                            $onkeydowntxtmenutext.="{";
                            $onkeydowntxtmenutext.="    myForm.setItemValue('txtobjoption','');";
                            $onkeydowntxtmenutext.="    myForm.setItemValue('txtobjname','');";
                            $onkeydowntxtmenutext.="    myForm.setItemValue('txttask','');";
                            $onkeydowntxtmenutext.="    if(myForm.getItemValue('cbomenutype')=='H')";
                            $onkeydowntxtmenutext.="    {";
                            $onkeydowntxtmenutext.="        myForm.setItemValue('txtobjoption','-');";
                            $onkeydowntxtmenutext.="        myForm.setItemValue('txtobjname','-');";
                            $onkeydowntxtmenutext.="        myForm.setItemValue('txttask','-');";
                            $onkeydowntxtmenutext.="    }";
                            $onkeydowntxtmenutext.="}";
                            
                            $onbuttonclickbtnsave="if(myForm.validate())
                                                   {";
                                                        $params="'obj=".$this->enc("menuconfig_new")."&task=".$this->enc("savemenu")."'";    
                                                        $onbuttonclickbtnsave.="url=fn_dhtmlxsenddata('".$this->enc("obj_menuconfig")."',$params);
                                                        myForm.send(url,\"get\",function(loader, response){
                                                            var sp=trim(response).split('|');
                                                            //alert(response);
                                                            if(sp[0]=='ok')
                                                            {
                                                                fn_dhtmlxmessage('','Menu <b>'+myForm.getItemValue('txtmenutext')+'</b> sudah berhasil ditambahkan');
                                                                myform_clear();
                                                            }
                                                            else if(sp[0]=='failed')
                                                            {fn_dhtmlxmessage('error','Error Found : '+sp[1]);}
                                                            else
                                                            {fn_dhtmlxmessage('error','Error Found : '+response);}
                                                            
                                                        });
                                                    }";
                            $arrevent=array(
                                                array("eventname"=>"onbuttonclick","eventparam"=>"id,val",
                                                                    "switch"=>array(
                                                                                      "btnsave"=>"$onbuttonclickbtnsave",
                                                                                      "btncancel"=>"myform_clear();"
                                                                                   )
                                                ),
                                                array("eventname"=>"onchange","eventparam"=>"id,val",
                                                                    "switch"=>array(
                                                                                      "cbomenugroupproject"=>"$onchangecbomenugroupproject",
                                                                                      "cbomenutype"=>"$onchangecbomenutype",
                                                                                      "cbomenuheader"=>"myform_setmenuorder();"
                                                                                   )
                                                ),
                                                array("eventname"=>"onkeydown","eventparam"=>"inp,ev,id,val",
                                                                    "switch"=>array("txtmenutext"=>"$onkeydowntxtmenutext")
                                                )
                                      );
                                      
                            $this->FN_DHTMLXFORMEVENT("myForm",$arrevent);
            echo "     }
                       
                       function myform_setmenuorder()
                       {
                           var getmenuorder=ajaxuridhtmlx('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("getordermenu")."&menutype='+myForm.getCombo(\"cbomenutype\").getSelectedValue()+'&idheader='+myForm.getCombo(\"cbomenuheader\").getSelectedValue()+'&kategory='+myForm.getCombo(\"cbocategory\").getSelectedValue());
                           //alert(getmenuorder);
                           myForm.setItemValue('txtmenuorder',getmenuorder);
                       }
                       
                       function myform_clear()
                       {
                           myForm.setItemValue(\"cbomenutype\",'');
                           myForm.setItemValue(\"cbomenuheader\",'');
                           myForm.setItemValue(\"txtmenuid\",'');
                           myForm.setItemValue(\"txtmenutext\",'');
                           myForm.setItemValue(\"txtmenudesc\",'');
                           myForm.setItemValue(\"cbomenuimg\",'');
                           myForm.setItemValue(\"txtobjoption\",'');
                           myForm.setItemValue(\"txtobjname\",'');
                           myForm.setItemValue(\"txttask\",'');
                           myForm.setItemValue(\"cbotarget\",'');
                           myForm.setItemValue(\"chkaktif\",true);
                           myForm.setItemValue(\"txtmenuorder\",'');
                           myForm.setItemValue(\"cbomenugroup\",'');
                           myForm.setItemValue(\"cbomenugroupproject\",'');
                           myForm.setItemFocus(\"cbomenutype\");
                       }           
                  </script>";
            echo $this->FN_CLOSEHEADER();
            echo $this->FN_CREATEBODY("e8f1ff");
            echo $this->FN_CREATEFOOTER();
        }
        
        public function fn_savemenu($isupdate=null)
        {
            $menuid=$_REQUEST['txtmenuid'];
            $menutype=$_REQUEST['cbomenutype'];//echo $menutype;return true;
            $menuheader=$_REQUEST['cbomenuheader'];
            $menutext=$_REQUEST['txtmenutext'];
            $menudesc=$_REQUEST['txtmenudesc'];
            $menuimg=$_REQUEST['cbomenuimg'];
            $objoption=$_REQUEST['txtobjoption'];
            $objname=$_REQUEST['txtobjname'];
            $task=$_REQUEST['txttask'];
            $target=$_REQUEST['cbotarget'];
            $menuorder=$_REQUEST['txtmenuorder'];
            $menugroup=$_REQUEST['cbomenugroup'];
            $tables=$_REQUEST['cbotables'];
            $idmenugroupproject=$_REQUEST['cbomenugroupproject'];
            $menuactivated=$_REQUEST['chkaktif'];
            $kategory=$_REQUEST['cbocategory'];
            $ajaxurl="ajax=0&sec=1&option=".$this->enc($objoption)."&obj=".$this->enc($objname)."&task=".$this->enc($task);
            if($menutype=='H'||$menutype=='S'){$objoption="";$objname="";$task="";$ajaxurl="";$target="";}
            //"$('#uri').val('ajax=1&sec=1&option=01fc812f36899c1ee4d748105ff6db23&obj=e6e61859e95f78646b67a1cc96d270fa&task=de7eb57f52fc4d8a6fef759e7bb0844b');$('#fm').submit();";

            if($menutype=='D'){if(!$this->CREATE_ROOT($objoption,$objname,$task,$tables)){echo 'failed|'.$this->getErrMsg();return false;};}
            
            //return false;
            $qry="insert into ".DB_APORTIL.".tbl_".$kategory."menu 
                  set menuid='$menuid',menutype='$menutype',menuheader='$menuheader',menutext='$menutext',menudesc='$menudesc',
                      menuimg='$menuimg',objoption='$objoption',objname='$objname',objtask='$task',objtarget='$target',
                      menuorder='$menuorder',menugroup='$menugroup',id_menu_groupproject='$idmenugroupproject',menuactivated='$menuactivated',
                      iby='".$_SESSION['nik']."',idt=now()";
            //echo $menuheader;return false;
            //echo "failed|$idmenugroupproject";
            //echo "failed|Object $objoption sudah pernah ditambahkan.TERIMA KASIH";
//            if($this->fn_row_isexists("select objoption from ".DB_APORTIL.".tbl_menu where objoption='$objoption' and isdeleted=0"))
//            {
//                echo "failed|Object $objoption sudah pernah ditambahkan.TERIMA KASIH";return false;
//            }
            $qrychkmenuid="select menuid from ".DB_APORTIL.".tbl_treemenu where menuid='$menuid'";
            if($this->fn_row_isexists($qrychkmenuid)){echo "failed|Mohon maaf menu $menuid sudah pernah didaftarkan.TERIMA KASIH";return false;}
            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_getordermenu()
        {
            
            $kategory=$_POST['kategory'];
            $menutype=$_POST['menutype'];
            //$menutype=$_POST['menutype'];
            $qry="select menuorder from ".DB_APORTIL.".tbl_".$kategory."menu where menutype='$menutype' order by id desc limit 1";
            //echo $qry;return false;
            $menuorder=$this->fn_get_fieldvalue("menuorder",$qry);
            if($menutype=='H'){$newmenuorder=$menuorder+1;}
            else
            {
                $idheader=$_POST['idheader'];
                $qry="select menuorder from ".DB_APORTIL.".tbl_".$kategory."menu where menuheader='$idheader' order by id desc limit 1";
                //echo $qry;
                $menuorder=$this->fn_get_fieldvalue("menuorder",$qry);
                $newmenuorder=$menuorder+1;
                //$lastmenuorder=substr($menuorder,strlen($menuorder)-1,1);
                //if($lastmenuorder==1){$newmenuorder=$menuorder."0";}else{$newmenuorder=$menuorder+1;}
            }
            echo $newmenuorder;
//            $arrprop=array("style="=>"\"width:3%;height:17px;text-align:center;\"","maxlength="=>"\"3\"",
//                           "onKeyDown="=>"\"nextfocus('txtmenuorder','cbotarget')\"","value="=>"\"$newmenuorder\"");
//            echo $this->CREATE_INPUT_OBJECT("text","txtmenuorder","cbomenugroup","",$arrprop);

        }
        
        
        public function fn_geticons()
        {
             $qry="select imgname,imgname imagename from ".DB_APORTIL.".tbl_menu_img where isdeleted=0 order by id asc";
             if($this->fn_row_isexists($qry))
             {
                 $rs=$this->selectquery($qry);
                 if($rs)
                 {
                     $imgjson=array();
                     while($rw=$this->data_row_array($rs))
                     {
                         array_push($imgjson,array("value"=>$rw[0],"text"=>$rw[1],"img"=>$rw[1]));
                         //echo("<option value=\"".$rw[0]."\" img_src=\"".$rw[1]."\">".$rw[1]."</option>"); 
                         //echo("<option value=\"".$rw[0]."\">".$rw[1]."</option>"); 
                     }
                 }
                 $this->clearrecordset($rs);
                 $arrresult=array("options"=>$imgjson);
                 print(json_encode($arrresult));
             }
        }
        
        public function fn_loadheader()
        {
            header("Content-type:text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            echo("<complete>");
                    echo "<option value=\"\"></option>";
                    $kategory=$_REQUEST['kategory'];
                    $idgroupproject=$_REQUEST['idgroupproject'];
                    $qry="select id,concat(id,' - ',menutext) menutext from ".DB_APORTIL.".tbl_".$kategory."menu where menutype<>'D' and menuactivated=1 and id_menu_groupproject='$idgroupproject' order by id asc";
                    $rs=$this->selectquery($qry);
                    if($rs)
                    {
                        while($rw=$this->data_row_object($rs))
                        {
                            echo "<option value=\"".$rw->id."\">".$rw->menutext."</option>";
                        }
                    }
                    $this->clearrecordset($rs);
            echo("</complete>");
        }

        public function fn_getmenugroup()
        {
            header("Content-type:text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            echo("<complete>");
                    echo "<option value=\"\"></option>";
                    $qry="select groupuser grp,groupuser from ".DB_APORTIL.".tbl_usergroup where isdeleted=0 order by id asc";
                    $rs=$this->selectquery($qry);
                    if($rs)
                    {
                        while($rw=$this->data_row_object($rs))
                        {
                            echo "<option value=\"".$rw->grp."\">".$rw->groupuser."</option>";
                        }
                    }
                    $this->clearrecordset($rs);
            echo("</complete>");
        }
        
        public function fn_gettables()
        {
            header("Content-type:text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            echo("<complete>");
                    echo("<option value=\"\"></option>");
                     $qry="select distinct table_name from information_schema.columns where table_schema='".DB_APORTIL."'";
                     if($this->fn_row_isexists($qry))
                     {
                         $rs=$this->selectquery($qry);
                         if($rs)
                         {
                             while($rw=$this->data_row_array($rs))
                             {
                                 echo("<option value=\"".$rw[0]."\">".$rw[0]."</option>"); 
                             }
                         }
                         $this->clearrecordset($rs);                         
                     }
            echo("</complete>");
        }
        
    }
?>
