<?php
    if (preg_match("/libhtml.php/i", $_SERVER['PHP_SELF'])){header("location: index.php");die;}
    require_once("controller/libdhtmlx.php");
    require_once("controller/libgendix.php");
    class MY_HTML extends MY_LIBRARY
    {
        var $MSG;var $errMsg;
        public function __construct()
        {
            //echo "test";return false;
            $this->MSG=new LIBMSG();    
            //if(!isset($_SESSION['nik'])){$this->mosRedirect("D.H.T.M.L.X");}
            $spip=explode(".",$_SERVER["HTTP_HOST"]);
            if(count($spip)>0)
            {
                //if($spip[0]=='172'||$spip[0]=='10'){header("location: http://portal.telkomcel.tl");die;}
            }
            //echo $this->get_client_ip();
            //if($spip[0]=='172'){header("location: http://portal.telkomcel.tl");die;}
        }
        
          //echo get_client_ip();
   
         public function get_client_ip() {
            $ipaddress = '';
            if (getenv('HTTP_CLIENT_IP'))
                $ipaddress = getenv('HTTP_CLIENT_IP');
            else if(getenv('HTTP_X_FORWARDED_FOR'))
                $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
            else if(getenv('HTTP_X_FORWARDED'))
                $ipaddress = getenv('HTTP_X_FORWARDED');
            else if(getenv('HTTP_FORWARDED_FOR'))
                $ipaddress = getenv('HTTP_FORWARDED_FOR');
            else if(getenv('HTTP_FORWARDED'))
               $ipaddress = getenv('HTTP_FORWARDED');
            else if(getenv('REMOTE_ADDR'))
                $ipaddress = getenv('REMOTE_ADDR');
            else
                $ipaddress = 'UNKNOWN';
            return $ipaddress;
        }
        
        public function initjq() // used for pop window
        {
?>
            <script src="<?php echo $this->HANDLE_VIEWSOURCE(560); ?>themes/js/<?php echo $this->HANDLE_VIEWSOURCE(560); ?>initjq.js"></script>
<?php
        }

        
        public function FN_CREATEHEADER()
        {
            echo "<!DOCTYPE html>
                    <html>
                    <head>
                    <title>".PROJECTID."</title>
                    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>
                    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>
                    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>
                    <!--<link rel=\"stylesheet\" type=\"text/css\" href=\"types/ftypes.css\"/>-->
                    <link rel=\"stylesheet\" type=\"text/css\" href=\"".PATH_THEME."/codebase/fonts/font_roboto/roboto.css\"/>
                    <link rel=\"stylesheet\" type=\"text/css\" href=\"".PATH_THEME."/codebase/dhtmlx.css\"/>
                    <!--<link rel=\"stylesheet\" type=\"text/css\" href=\"".PATH_THEME."/skins/terrace/dhtmlx.css\"/>-->
                    <link rel=\"stylesheet\" type=\"text/css\" href=\"".PATH_THEME."/skins/web/dhtmlx.css\"/>
                    <link rel=\"stylesheet\" href=\"".PATH_THEME."/font/font-awesome.min.css\">
                    <script src=\"".PATH_THEME."/codebase/dhtmlx.js\"></script>

                    <script src=\"".PATH_THEME."/js/".$this->HANDLE_VIEWSOURCE(123091)."jquery.js\"></script>
                    
                    <!--<script type=\"text/javascript\" src=\"types/ftypes.js\"></script>-->
                    <style>
                        html, body {
                            width: 100%;
                            height: 100%;
                            overflow: hidden;
                            margin-left: 30px;margin-top:5px;
                            /*background-color: #fff;*/
                        }
                        .intro {
                            margin: 30px;
                            font-family: Tahoma;
                            font-size: 12px;
                        }
                        div.image_preview {
                            position: relative;
                            width: 100%;
                            height: 100%;
                            padding: 0px;
                            margin: 0px;
                            background-position: center center;
                            background-repeat: no-repeat;
                            overflow: hidden;
                        }
                        
                        div.preview_tpl {
                            position: relative;
                            float: left;
                            border-radius: 2px;
                            box-shadow: 0 0 3px rgba(0, 0, 0, 0.10);
                            background-color: #fefefe;
                            font-size: 13px;
                            font-family: Roboto, Arial, Helvetica;
                            color: #404040;
                            font-size: 14px;
                            border: 1px solid #dfdfdf;
                        }
                        div.preview_tpl div.header_tpl {
                            position: absolute;
                            border-radius: 2px;
                            background-color: #fff;
                            border: 1px solid #dfdfdf;
                            padding: 4px 14px;
                            left: 10px;
                            top: -14px;
                            box-shadow: 0 -1px 1px rgba(0, 0, 0, 0.05);
                            cursor: default;
                        }
                        div.preview_tpl table {
                            margin: 10px 10px;
                        }
                        div.preview_tpl td {
                            font-family: Roboto, Arial, Helvetica;
                            color: #404040;
                            font-size: 14px;
                            padding: 2px 20px 2px 5px;
                        }
                        div.preview_tpl tr.tr_hdr_tpl td {
                            border-bottom: 1px solid #c0c0c0;
                            padding-bottom: 8px;
                        }
                        div.preview_tpl tr.first_row_tpl td {
                            padding-top: 7px;
                        }
                        .txtcenter input{text-align:center;}
                        .txtright input{text-align:right;}
                        
                        input[type=text]:focus {background-color:#fdf79b;}                                  
                        input.dhxcombo_input[type=text]:focus {background-color:#fdf79b;box-shadow:2px 4px 4px 24px #fdf79b;}                       
                    </style>
                    <script>
                        //var myTabbar;
                        var dhxwin;
                        function fn_dhtmlxaddtabbar(tabid,url,headertext,widthheader,activated,eventwhenclick)
                        {
                            // ==== Check Tab is already Exists
                            var isTabCreated=false;
                            myTabbar.forEachCell(function(cell){
                                    var id = cell.getId();
                                    if(id==tabid){isTabCreated=true;}
                            });
                            //tabid=tabid+1;
                            //alert(tabid);
                            if(!isTabCreated)
                            {
                                myTabbar.addTab(tabid, headertext, widthheader+\"px\",\"true\",activated);
                                myTabbar.cells(tabid).progressOn();
                                myTabbar.cells(tabid).attachURL(url);
                                myTabbar.attachEvent(\"onContentLoaded\",function(id){
                                    myTabbar.cells(id).progressOff();
                                });
                                myTabbar.attachEvent(\"onTabClick\",function(id,lastid){
                                    if(id==tabid)
                                    {
                                        
                                    }
                                });

                            }
                        }
                    </script>";
        }
        
        public function FN_GETMONTHNAME($i)
        {
            $arrmonth=array("1"=>"Januari","2"=>"Februari","3"=>"Maret","4"=>"April","5"=>"Mei","6"=>"Juni","7"=>"Juli",
                            "8"=>"Agustus","9"=>"September","10"=>"Oktober","11"=>"November","12"=>"Desember");
            return $arrmonth[$i];
        }
        
        public function FN_CLOSEHEADER()
        {
            echo "</head>";
        }
        
        public function FN_CREATEBODY($bgcolor=null)
        {
            if($bgcolor){$bgcolor="background-color:#$bgcolor;";}
            $bgcolor="white";
            //if(!$bgcolor){$bgcolor="background-color:#e8f1ff;";}
            echo "<body onLoad=\"initObject();\" onContextMenu=\"\"  style=\"width:100%; height:100%; margin-left:-10px;overflow:hidden;$bgcolor\">                    
                    <form ".$this->HANDLE_VIEWSOURCE(97890)."id=\"fmpreview\" name=\"fmpreview\" target=\"_blank\" ".$this->HANDLE_VIEWSOURCE(12890)."method=\"POST\" ".$this->HANDLE_VIEWSOURCE(11890)."action=\"?".$this->dec("2304f0e32dd0e041231c536c971ebaab")."\">
                    </form".$this->HANDLE_VIEWSOURCE(19890).">";    
        }
        
        public function FN_CREATEFOOTER()
        {
            echo $this->initjq();
            echo "</body>
                  </html>";    

        }
        
        public function URLHOME()
        {
            return "$('#uri').val('ajax=0&sec=1&option=".$this->enc("obj_home")."&obj=&task=".$this->enc("layoutgraph")."');$('#fm').prop('target','_self');$('#fm').submit();";
        }
        
        public function SHOWMESSAGE($msginfo)
        {
            echo "<p class=\"alert alert-info\">$msginfo</p>";
        }

        public function SHOWMESSAGEWAIT($msginfo,$counttmr,$int,$url=null,$withalertformat=null)
        {
            $jvtmr="<script>";
            $jvtmr.="   tmr=setTimeout(function(){fn_timewait();},$int);";
            $jvtmr.="   var tmval=$counttmr;
                        function fn_timewait()";
            $jvtmr.="   {";
            $jvtmr.="       tmval=tmval-1;";
            $jvtmr.="       $('#sptmr').html(tmval);";
            $jvtmr.="       if(tmval<=1){clearTimeout(tmr);$url;return false;}";
            $jvtmr.="       tmr=setTimeout(function(){fn_timewait();},$int);";
            $jvtmr.="   }";
            $jvtmr.="</script>";
            
            echo $jvtmr;
            $msginfo.="&nbsp...<span id=\"sptmr\">$counttmr</span>";
            if($withalertformat){echo "<p class=\"alert alert-info\">$msginfo</p>";}
            else
            {echo $msginfo;}
            
        }
        
        public function SHOWMESSAGETOVARIABLE($msginfo)
        {
            return "<p class=\"alert alert-info\">$msginfo</p>";
        }

        public function initial_css_style() // used for pop window
        {
            echo "<link href=\"".PATH_THEME."/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />
                  <link href=\"".PATH_THEME."/css/table-style.css\" rel=\"stylesheet\" type=\"text/css\" />";
        }
        
        public function SET_PAGE_TITLE($titlepage)
        {
            echo "<table width=\"100%\" style=\"height:30px;\">
                     <tr>
                         <td align=\"left\" style=\"font-size:16px;font-weight:bold;\" valign=\"top\"><u>$titlepage</u></td>
                     </tr>
                 </table>";
        }

        public function SIDEBAR()
        {
            $x="<!-- sidebar -->
                  <ul id=\"sidebar\" class=\"nav nav-pills nav-stacked\">
                    <!--<li class=\"avatar hidden-phone\">
                        <a href=\"#\">
                            <img src=\"".PATH_THEME."/library/images/100/06.png\" />
                                <span>Geunevere Calista</span>
                        </a>
                        </li>-->
                        <li class=\"active\">
                            <a href=\"index.html\">
                                <i class=\"micon-screen\"></i>
                                <!--<span class=\"hidden-phone\">Dashboard</span>-->
                            </a>
                        </li>
                        <li class=\"dropdown\">
                            <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">
                                <i class=\"micon-gift\"></i>
                                <!--<span class=\"hidden-phone\">UI</span>-->
                            </a>
                            <ul class=\"dropdown-menu\">
                                <li>
                                    <a href=\"typography.html\">
                                        <i class=\"icon-large icon-underline\"></i> Typography
                                    </a>
                                </li>                                    
                                </li>
                                <li>
                                    <a href=\"tables.html\">
                                        <i class=\"icon-large icon-table\"></i> Tables
                                    </a>
                                </li>
                                <li>
                                    <a href=\"buttons.html\">
                                        <i class=\"icon-large icon-th\"></i> Buttons
                                    </a>
                                </li>
                                <li>
                                    <a href=\"icons.html\">
                                        <i class=\"icon-large icon-check-empty\"></i> Icons
                                    </a>
                                </li>
                                <li>
                                    <a href=\"dropdowns.html\">
                                        <i class=\"icon-large icon-sort\"></i> Dropdowns
                                    </a>
                                </li>
                                <li>
                                    <a href=\"tabs.html\">
                                        <i class=\"icon-large icon-columns\"></i> Tabs
                                    </a>
                                </li>
                                <li>
                                    <a href=\"breadcrumbs-paginations.html\">
                                        <i class=\"icon-large micon-loop\"></i> Breadcrums & Paginations
                                    </a>
                                </li>
                                <li>
                                    <a href=\"alerts.html\">
                                        <i class=\"icon-large micon-bell\"></i> Alerts
                                    </a>
                                </li>
                                <li>
                                    <a href=\"progress-bars.html\">
                                        <i class=\"icon-large micon-paragraph-left\"></i> Progress Bars
                                    </a>
                                </li>
                                <li>
                                    <a href=\"pickers-sliders.html\">
                                        <i class=\"icon-large micon-equalizer\"></i> Pickers & Sliders
                                    </a>
                                </li>
                                <li>
                                    <a href=\"modals.html\">
                                        <i class=\"icon-large micon-copy\"></i> Modals
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href=\"charts.html\">
                                <i class=\"micon-stats-up\"></i>
                                <!--<span class=\"hidden-phone\">Charts</span>-->
                            </a>
                        </li>
                        <li>
                            <a href=\"maps.html\">
                                <i class=\"micon-location\"></i>
                                <!--<span class=\"hidden-phone\">Maps</span>-->
                            </a>
                        </li>
                        <li class=\"dropdown\">
                            <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">
                                <i class=\"micon-checkbox\"></i>
                                <!--<span class=\"hidden-phone\">Form</span>-->
                            </a>
                            <ul class=\"dropdown-menu\">
                                <li>
                                    <a href=\"form-elements.html\">
                                        <i class=\"icon-large icon-th-large\"></i> Form elements
                                    </a>
                                </li>
                                <li>
                                    <a href=\"form-input-sizes.html\">
                                        <i class=\"icon-large icon-th-large\"></i> Input Size
                                    </a>
                                </li>
                                <li>
                                    <a href=\"form-control-states.html\">
                                        <i class=\"icon-large icon-th-large\"></i> Form control states
                                    </a>
                                </li>
                                <li>
                                    <a href=\"wysiwyg.html\">
                                        <i class=\"icon-large icon-th-large\"></i> WYSIWYG
                                    </a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href=\"widgets.html\">
                                <i class=\"micon-lab\"></i>
                                <!--<span class=\"hidden-phone\">Widgets</span>-->
                            </a>
                        </li>
                        <li>
                            <a href=\"widgets.html\">
                                <i class=\"micon-lab\"></i>
                                <!--<span class=\"hidden-phone\">Widgets</span>-->
                            </a>
                        </li>
                        <li>
                            <a href=\"widgets.html\">
                                <i class=\"micon-lab\"></i>
                                <!--<span class=\"hidden-phone\">Widgets</span>-->
                            </a>
                        </li>
                   </ul>
                   <!-- end sidebar -->";
            return $x;
        }
        
        //public function 
        
        public function GET_PATH()
        {
            $uripath=$_SERVER["REQUEST_URI"] ;
            $spuripath=explode("/",$uripath);
            $realpath="";
            for($i=0;$i<count($spuripath)-1;$i++)
            {
                $realpath.=$spuripath[$i]."/";
            }             
            $docroot="http://".$_SERVER["HTTP_HOST"] ; 
            return $docroot.$realpath;
        }
        
        public function GET_DBFPATH()
        {
            $rtn=getenv("DOCUMENT_ROOT")."/kismis/dokumen";
            $sproot=explode("/",getenv("DOCUMENT_ROOT"));
            $baseroot=$sproot[0];
            if($baseroot=='D:')
            {
                $rtn=getenv("DOCUMENT_ROOT")."/project/kismis/dokumen";
            }
            return $rtn;
        }

        public function RELINK_PAGE($arruri)
        {                         
            echo "<ul class=\"breadcrumb breadcrumb-main\">";
                    $i=0;
                    foreach($arruri as $lnk=>$lnkvalue)
                    {                          
                        if($lnkvalue=='disabled'){echo "<li class=\"text-info\"><i>".$lnk."</i><span class=\"divider\"></span></li>";}
                        else
                        {
                            $title="";$onClick="";$prop="";
                            $spuri=explode("|",$lnkvalue);
                            $title=$spuri[2];
                            if($spuri[0]=='ajax')
                            {
                                $onClick="onClick=\"".$spuri[1]."\"";
                                $lnkvalue="javascript:void(0)";
                            }
                            
                            if($spuri[0]=='ahref')
                            {
                                $onClick="";
                                $lnkvalue=$spuri[1];
                                $prop=$spuri[3];
                            }
                            //if(isset($spuri))
                            //if(is_array($arrurititle)){$title=$arrurititle[$i][1];}echo $title;
                            $span="<span class=\"divider\"><i class=\"icon-caret-right\"></i></span>";
                            if($i==count($arruri)-1){$span="";}
                            echo "<li><a href=\"$lnkvalue\" $prop $onClick title=\"$title\">$lnk</a> $span</li>";
                        }
                        $i+=1;
                    } 
            echo "</ul>";
        }
                
        public function LINK_BACKTOPAGE($ajaxurl='',$url='#',$width='0px')
        {
            return "<div id=\"div_linkbacktopage\"><a href=\"$url\" title=\"Klik disini untuk kembali\" onClick=\"$ajaxurl\">BACK</a></div>";
        }
        
        public function CREATE_IMAGE($img,$width=null,$height=null,$prop=null,$url=null)
        {
            if($width){$pagewidth="width=\"".$width."px\"";}
            if($height){$pageheight="height=\"".$height."px\"";}
            $path=PATH_THEME;
            if($url){$path=$url;}
            return "<img src=\"".$path."/images/$img\" border=\"0\" $pagewidth $pageheight style=\"$prop\"/>";
        }
        
        
        public function CREATE_LINK_IMG_HOVER($url,$event,$img,$imghover,$title=null)
        {
            $sp=explode(".",$img);
            if(count($sp)<=1){$img.=".png";}            
            //echo $sp[1];
            return "<a href=\"$url\" title=\"$title\" style=\"text-decoration:none;\">
                        <img src=\"".PATH_THEME."/images/$img\" onClick=\"$event;\" 
                            onmouseover=\"this.src='".PATH_THEME."/images/$imghover';\" 
                            onmouseout=\"this.src='".PATH_THEME."/images/$img';\" border=\"0\" />
                    </a>";
        }
        
        //public function CREATE_LINK($ajaxurl='',$linktext='',$url='javascript:void(0)',$target='_self',$title='',$color='',$properties='')
//        {
//            if($ajaxurl){$ajaxurl.=";return false;";}
//            if(!$color){$color='blue';}
//            return "<a href=\"$url\" target=\"$target\" title=\"$title\" style=\"color:$color;$properties\" onClick=\"$ajaxurl\">$linktext</a>";
//        }
        
        public function CREATE_LINK($ajaxurl='',$linktext='',$url='javascript:void(0)',$target='_self',$title='',$color='',$style='',$properties='')
        {
            if($ajaxurl){$ajaxurl.=";return false;";}
            if(!$color){$color='blue';}
            return "<a href=\"$url\" target=\"$target\" title=\"$title\" style=\"color:$color;$style\" $properties onClick=\"$ajaxurl\">$linktext</a>";
        }

        
        public function MULTIPLE_LINK($linkarray)
        {
            $linkvalue="";$separator="";
            //$h=array("r"=>"1","b"=>"2");
            foreach($linkarray as $lnk=>$lnkvalue)
            {
                if($linkvalue!==""){$separator="&nbsp;&nbsp;".$this->CREATE_IMAGE("arrowright.png","","","")."&nbsp;&nbsp;";}
                if($lnkvalue)
                {
                    $sppipe=explode("|",$lnkvalue);
                    $fnvalue=$sppipe[0];$prop=$sppipe[1];
                    $linkvalue.="$separator".$this->CREATE_LINK($fnvalue,$lnk,"javascript:void(0)","_self","","","font-size:14px;",$prop);
                }
                else
                {$linkvalue.="$separator".$this->CREATE_LINK("",$lnk,"javascript:void(0)","_self","","","color:gray;text-decoration:none;font-style:italic;font-size:14px;","");}
                
            }    
            $rtn="<table><tr><td>$linkvalue</td></tr></table>";
            return $rtn;
        }
        
        public function CREATE_UNLINK($linktext="")
        {
            return "<a href=\"javascript:void(0);\" target=\"_self\" title=\"disabled\" style=\"color:gray;\">$linktext</a>";
        }
        
        public function CREATE_INPUT_OBJECT($type,$id,$name,$event,$properties)
        {
            $OBJ_PROPERTIES="";
            if(is_array($properties))
            {
                foreach($properties as $arr=>$arrvalue)
                {
                    $OBJ_PROPERTIES.=$arr.$arrvalue." ";
                }                
            }
            else
            {$OBJ_PROPERTIES=$properties;}
            //echo $OBJ_PROPERTIES;
            return "<input type=\"$type\" id=\"$id\" name=\"$name\"  $event $OBJ_PROPERTIES />";    
        }
        
        public function CREATE_INPUT_OBJECT_WITHSHADOW($type,$id,$name,$shadowvalue,$event,$properties)
        {
            if(is_array($properties))
            {
                foreach($properties as $arr=>$arrvalue)
                {
                    $OBJ_PROPERTIES.=$arr.$arrvalue." ";
                }                
            }
            else
            {$OBJ_PROPERTIES=$properties;}
            //echo $OBJ_PROPERTIES;
            return "<input type=\"$type\" id=\"$id\" name=\"$name\"  $event $OBJ_PROPERTIES />
                    <input type=\"hidden\" id=\"".$id."1\" name=\"".$name."1\"  value=\"$shadowvalue\"/>";    
        }
        
        public function CREATE_BUTTON($text,$id,$name,$event,$properties)
        {
            if(is_array($properties))
            {
                foreach($properties as $arr=>$arrvalue)
                {
                    $OBJ_PROPERTIES.=$arr.$arrvalue." ";
                }                
            }
            else
            {$OBJ_PROPERTIES=$properties;}
            return "<button type=\"submit\" class=\"btn btn-primary\" id=\"$id\" name=\"$name\" $event $OBJ_PROPERTIES>$text</button>";
        }
        
        public function FN_SERVERDOWNTIMETEXT()
        {
            echo "You Server Has Been <font color=\"red\"> Turn Off</font>&nbsp;THANK YOU.";
        }
        
        public function FN_DHTMLXCONFIRM($title,$text,$event)
        {
            return "dhtmlx.confirm({
                        title: '$title',
                        type:'confirm',
                        text: '$text',
                        callback: function(result){if(result){".$event."}}
                    });";
        }
        
        public function FN_DHTMLXMESSAGE($type,$msg)
        {
            $rtn="dhtmlx.message({";
            if($type){$rtn.="type: '$type',";}
            $rtn.="text: '$msg'});";
            return $rtn;
        }
        
        
        public function FN_DHTMLXFORMOld($formname,$formheadertext,$formheaderwidth,$tabbarid,$arrelement)
        {
            $jvform="<link rel=\"stylesheet\" type=\"text/css\" href=\"".PATH_THEME."/codebase/dhtmlx.css\"/>";
            $jvform.="<script type=\"text/javascript\" src=\"".PATH_THEME."/codebase/dhtmlx.js\"></script>";
            $jvform.="<script>";
            $jvform.="formData = new dhtmlXForm(\"myForm\",[";
            $jvform.="{type: \"settings\", position: \"label-left\", labelWidth: 130, inputWidth: 120},";
            $jvform.="{type: \"fieldset\", label: \"Welcome\", inputWidth: 340, list:[";
            $jvform.="      {type: \"radio\", name: \"type\", label: \"Already have account\", labelWidth: \"auto\", position: \"label-right\", checked: true, list:[";
            $jvform.="      {type: \"input\", label: \"Login\", value: \"p_rossi\"},";
            $jvform.="      {type: \"password\", label: \"Password\", value: \"123\"},";
            $jvform.="      {type: \"checkbox\", label: \"Remember me\", checked: true}";
            $jvform.="]},";
            $jvform.="      {type: \"radio\", name: \"type\", label: \"Not registered yet\", labelWidth: \"auto\", position: \"label-right\", list:[";
            $jvform.="      {type: \"input\", label: \"Full Name\", value: \"Patricia D. Rossi\"},";
            $jvform.="      {type: \"input\", label: \"E-mail Address\", value: \"p_rossi@example.com\"},";
            $jvform.="      {type: \"input\", label: \"Login\", value: \"p_rossi\"},";
            $jvform.="      {type: \"password\", label: \"Password\", value: \"123\"},";
            $jvform.="      {type: \"password\", label: \"Confirm Password\", value: \"123\"},";
            $jvform.="      {type: \"checkbox\", label: \"Subscribe on news\"}";
            $jvform.="]},";
            $jvform.="      {type: \"radio\", name: \"type\", label: \"Guest login\", labelWidth: \"auto\", position: \"label-right\", list:[";
            $jvform.="      {type: \"select\", label: \"Account type\", options:[";
            $jvform.="      {text: \"Admin\", value: \"admin\"},";
            $jvform.="      {text: \"Organiser\", value: \"org\"},";
            $jvform.="      {text: \"Power User\", value: \"poweruser\"},";
            $jvform.="      {text: \"User\", value: \"user\"}";
            $jvform.="]},";
            $jvform.="      {type: \"checkbox\", label: \"Show logs window\"}";
            $jvform.="]},";
            $jvform.="  {type: \"button\", value: \"Proceed\"}";
            $jvform.="]}";
            $jvform.="]);";
            //$jvform.="myTabbar.cells('tabmenusetting').attachForm(formData);";
            $jvform.="</script>";

            return $jvform;
            //return  "<script></script>";
            //return "TETS";
//            echo "<script language=\"javascript\">";
//                      $myelement=json_encode($arrelement);
//            echo "    $formname=[{type:\"settings\",position:\"label-left\",labelWidth:130,inputWidth:120},
//                                 {type:\"fieldset\",label:\"$formheadertext\",inputWidth:$formheaderwidth,list:
//                                    [
//                                        $myelement
//                                    ] 
//                                ]
//                      myTabbar.cells('$tabbarid').attachForm($formname);";
//            echo "</script>";
            
        }
        
        public function FN_DHTMLXLOADOBJECTx($option,$task)
        {
            return "?ajax=1&sec=1&option=".$option."&".$task;
        }
        
        public function FN_DHTMLXGRIDCONTEXTMENU()
        {
            header("Content-type: text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 
            echo("<menu id=\"0\">");
            echo("   <item text=\"Delete Row\" img=\"close.gif\"  id=\"contextmenu_deleted\" />");
            echo("</menu>");
        }
        
        public function FN_DHTMLXGRIDCONTEXTMENU2()
        {
            $mnuprop=$_REQUEST['mnuprop'];
            $spmnuprop=explode(",",$mnuprop);
            
            header("Content-type: text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 
            echo("<menu id=\"0\">");
                for($i=0;$i<count($spmnuprop);$i++)
                {
                    $sp=explode("|",$spmnuprop[$i]);
                    $mnutext=$sp[0];$mnugif=$sp[1];$mnuid=$sp[2];
                    echo("<item text=\"$mnutext\" img=\"$mnugif\"  id=\"$mnuid\" />");
                }
            
            echo("</menu>");
        }
        
        public function FN_DHTMLXADDCOMBO($DBNAME=null)
        {
            if(!$DBNAME){$DBNAME=DB_APORTIL;}
            // === param request tablename|col1,col2
            $tableobj=$_REQUEST['tableobj'];
            //echo $tableobj;
            $sp=explode("|",$tableobj);
            
            $table=$sp[0];
            $spcol=explode(",",$sp[1]);
            $col1=$spcol[0];$col2=$spcol[1];

            //echo $table;
            $multicol=false;
            // === Check The MultiColumn
            $spfield=explode(":",$sp[1]);
            if(count($spfield)>1)
            {
                $multicol=true;
                $spcol=explode(",",$spfield[0]);
                $col1=$spcol[0];$col2=$spcol[1];$col3=$spcol[2];
                
                $spview=explode(",",$spfield[1]);
                $view1=$spview[0];$view2=$spview[1];
            }
            
            $swhere="";
            if(isset($_REQUEST['exp']))//&&$_SESSION['nik']!=='9999'
            {
                //$spexp=explode("|",$_REQUEST['exp']);
                //$exp="and ".$spexp[0]."<>'".$spexp[1]."'";
                $spexp=explode(",",$_REQUEST['exp']);
                if(count($spexp)>0)
                {
                    for($i=0;$i<count($spexp);$i++)
                    {
                        $spcriteria=explode("|",$spexp[$i]);    
                        $swhere.="and ".$spcriteria[0]."<>'".$spcriteria[1]."' ";
                    }
                }
                else
                {
                    $spcriteria=explode("|",$spexp[$i]);
                    $swhere="and ".$spcriteria[0]."<>'".$spcriteria[1]."'";
                }
                
            }
            
            if(isset($_REQUEST['and']))//&&$_SESSION['nik']!=='9999'
            {
                //$spexp=explode("|",$_REQUEST['exp']);
                //$exp="and ".$spexp[0]."<>'".$spexp[1]."'";
                $spexp=explode(",",$_REQUEST['and']);
                if(count($spexp)>0)
                {
                    for($i=0;$i<count($spexp);$i++)
                    {
                        $spcriteria=explode("|",$spexp[$i]);    
                        $swhere.="and ".$spcriteria[0]."='".$spcriteria[1]."' ";
                    }
                }
                else
                {
                    $spcriteria=explode("|",$spexp[$i]);
                    $swhere="and ".$spcriteria[0]."='".$spcriteria[1]."'";
                }
                
            }
            if(isset($_REQUEST['in']))//&&$_SESSION['nik']!=='9999'
            {
                //$spexp=explode("|",$_REQUEST['exp']);
                //$exp="and ".$spexp[0]."<>'".$spexp[1]."'";
                $spexp=explode("|",$_REQUEST['in']);
                $swhere="and ".$spexp[0]." in (".$spexp[1].")";
                
            }
            
            $captionnulltext="";
            if(isset($_REQUEST['withallcaption'])){$captionnulltext="ALL";}
            $mask=$_REQUEST['mask'];
            header("Content-type: text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 
            echo("<complete add=\"true\">"); 
            echo("<template>");
            
            echo("<input><![CDATA[#$col2#]]></input>");
            if($multicol)
            {echo("<option><![CDATA[<div style='width:490px;'>#$view1# - #$view2#</div>]]></option>");}
            else
            {echo("<option><![CDATA[<div style='width:490px;'>#$col2#</div>]]></option>");}
            
            
            echo("</template>");
                     //echo("<option value=\"\">$captionnulltext</option>");
                     $sort=$col2;
                     if($_REQUEST['sort']){$sort=$_REQUEST['sort'];}
                     $qry="select distinct $col1,$col2 from ".$DBNAME.".$table where isdeleted=0 $swhere and ($col2<>'') order by $sort asc limit 100";
                     if($mask)
                     {
                        $qry="select distinct $col1,$col2 from ".$DBNAME.".$table where isdeleted=0 $swhere and $col2 like '%$mask%' and ($col2<>'') order by $sort asc limit 20";
                        if($multicol)
                        {
                            $qry="select distinct $col1,$col2,$col3 from ".$DBNAME.".$table 
                                  where isdeleted=0 $swhere and ($col2 like '%$mask%' and ($col2<>'')) or ($col3 like '%$mask%' and ($col3<>'')) order by $sort,$col3 asc limit 20";
                        }
                     }
                     echo $qry;
                     if($this->fn_row_isexists($qry))
                     {
                         $rs=$this->selectquery($qry);
                         if($rs)
                         {
                             $option="";
                             while($rw=$this->data_row_array($rs))
                             {
                                 //echo("<option value=\"".$rw->img."\" img_src=\"".$rw->imgname."\">".$rw->imgname."</option>"); 
                                 //echo("<option value=\"".str_replace("&","&amp;",$rw[0])."\">".str_replace("&","&amp;",$rw[1])."</option>"); 
                                 $option="<option value=\"".str_replace("&","&amp;",$rw[0])."\">";
                                 $option.="<text>";
                                    $option.="<$col1>".str_replace("&","&amp;",$rw[0])."</$col1>";
                                    $option.="<$col2>".str_replace("&","&amp;",$rw[1])."</$col2>";
                                    if($multicol)
                                    {
                                        $option.="<$col3>".str_replace("&","&amp;",$rw[2])."</$col3>";    
                                    }
                                 $option.="</text>";
                                 $option.="</option>";
                                 echo($option); 
                             }
                         }
                         $this->clearrecordset($rs);                         
                     }
            echo("</complete>"); 
        }
        
        public function FN_DHTMLXADDCOMBOOLD($DBNAME=null)
        {
            // === param request tablename|col1,col2
            $tableobj=$_REQUEST['tableobj'];
            //echo $tableobj;
            $sp=explode("|",$tableobj);
            
            $table=$sp[0];
            //echo $table;
            $spcol=explode(",",$sp[1]);
            $col1=$spcol[0];$col2=$spcol[1];
            
            $exp="";
            if(isset($_REQUEST['exp']))//&&$_SESSION['nik']!=='9999'
            {
                //$spexp=explode("|",$_REQUEST['exp']);
                //$exp="and ".$spexp[0]."<>'".$spexp[1]."'";
                $spexp=explode(",",$_REQUEST['exp']);
                if(count($spexp)>0)
                {
                    for($i=0;$i<count($spexp);$i++)
                    {
                        $spcriteria=explode("|",$spexp[$i]);    
                        $exp.="and ".$spcriteria[0]."<>'".$spcriteria[1]."' ";
                    }
                }
                else
                {
                    $spcriteria=explode("|",$spexp[$i]);
                    $exp="and ".$spcriteria[0]."<>'".$spcriteria[1]."'";
                }
                
            }
            
            if(isset($_REQUEST['and']))//&&$_SESSION['nik']!=='9999'
            {
                //$spexp=explode("|",$_REQUEST['exp']);
                //$exp="and ".$spexp[0]."<>'".$spexp[1]."'";
                $spexp=explode(",",$_REQUEST['and']);
                if(count($spexp)>0)
                {
                    for($i=0;$i<count($spexp);$i++)
                    {
                        $spcriteria=explode("|",$spexp[$i]);    
                        $swhere.="and ".$spcriteria[0]."='".$spcriteria[1]."' ";
                    }
                }
                else
                {
                    $spcriteria=explode("|",$spexp[$i]);
                    $swhere="and ".$spcriteria[0]."='".$spcriteria[1]."'";
                }
                
            }
            
            //$expression=$_REQUEST['expression'];$cboexp="";
//            if(isset($_REQUEST['expression']))
//            {
//                $spexp=explode("|",$expression);
//                for($j=0;$j<count($spexp);$j++)
//                {
//                    $cboexp.=html_entity_decode($spexp[$j])." and ";
//                }
//                $cboexp=substr($cboexp,0,strlen($cboexp)-strlen(" and "));
//                if($exp){$cboexp=" and ".$exp;}
//            }
            
//            $expression=$_REQUEST['expression'];$cboexp="";
//            if(isset($_REQUEST['expression']))
//            {
//                $spexp=explode("|",$expression);
//                for($j=0;$j<count($spexp);$j++)
//                {
//                    $cboexp.=html_entity_decode($spexp[$j])." and ";
//                }
//                $cboexp=substr($cboexp,0,strlen($cboexp)-strlen(" and "));
//                if($exp){$cboexp=" and ".$exp;}
//            }
            
            header("Content-type: text/xml");
            echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); 
            echo("<complete>"); 
                     echo("<option value=\"\"></option>");
                     $qry="select $col1,$col2 from ".DB_APORTIL.".$table where isdeleted=0 $exp $cboexp order by id asc";
                     if($DBNAME){$qry="select $col1,$col2 from $DBNAME.$table where isdeleted=0 $exp $cboexp order by id asc";}
                     if($this->fn_row_isexists($qry))
                     {
                         $rs=$this->selectquery($qry);
                         if($rs)
                         {
                             while($rw=$this->data_row_array($rs))
                             {
                                 //echo("<option value=\"".$rw->img."\" img_src=\"".$rw->imgname."\">".$rw->imgname."</option>"); 
                                 echo("<option value=\"".htmlspecialchars($rw[0])."\">".htmlspecialchars($rw[1])."</option>"); 
                             }
                         }
                         $this->clearrecordset($rs);                         
                     }
            echo("</complete>"); 
        }
        
        public function FN_DHTMLXACCORDION()
        {
            echo "myAccordion=myLayout.cells(\"a\").attachAccordion();";
                  if($_SESSION['menuidgroupproject'])
                  {
                      $qry="select id,groupname from ".DB_APORTIL.".tbl_menu_groupproject where id in(".$_SESSION['menuidgroupproject'].") and isdeleted=0 order by id asc";
                      //echo $qry;return false;
                      $rs=$this->selectquery($qry);
                      if($rs)
                      {
                          $i=1;
                          while($rw=$this->data_row_object($rs))
                          {
                              $firstactive="";
                              if($i==1){$firstactive=",true";}
                              $expandcollapse="&nbsp;<a href='javascript:void(0)' onClick='myTree".$rw->id.".closeAllItems(0);' style='color:white;text-decoration:none'>(+)</a>&nbsp;&nbsp;<a href='javascript:void(0)' onClick='myTree".$rw->id.".openAllItems(0);' style='color:white;text-decoration:none'>(-)</a>";
                              //$expandcollapse="&nbsp;<a id='atreecollapse".$rw->id."' href='javascript:void(0)' onClick='fn_treeexpand(myTree".$rw->id.")' style='color:white;text-decoration:none' >(+)</a>";
                              //$urlexcol="var img=document.getElementById('imgexcol');";
                              //$urlexcol="alert(\'test\');";//"imgexp='\'".PATH_THEME."/images/expand.png'\';";//myTree".$rw->id.".closeAllItems(0);
                              //$urlexcol.="imgcol='\'".PATH_THEME."/images/collapse.png'\';";//myTree".$rw->id.".closeAllItems(0);
                              //$urlexcol.="this.src=imgcol;";//myTree".$rw->id.".closeAllItems(0);
                              //$expandcollapse="&nbsp;<a id='lnktree' href='javascript:void(0)' style='text-decoration:none;margin-left:-3px'><img id='imgexcol' src='".PATH_THEME."/images/expand.png' onClick='alert(\'test\')' /></a>";
                              //echo "myAccordion.addItem(\"a".$rw->id."\", \"$expandcollapse&nbsp;&nbsp;".$rw->groupname."\" $firstactive);"; 
                              echo "myAccordion.addItem(\"a".$rw->id."\", \"".$rw->groupname."&nbsp;$expandcollapse\" $firstactive);"; 
                              $i+=1;
                          }
                      }
                      $this->clearrecordset($rs);
                      // === Create My TREE
                      //if($this->fn_row_isexists("select id from ".DB_APORTIL.".tbl_treemenu where isdeleted=0 and id_menu_groupproject in(".$_SESSION['menuidgroupproject'].") order by id asc limit 1")>0)
                      if($_SESSION['menuidgroupproject'])
                      {
                          $spid=explode(",",$_SESSION['menuidgroupproject']);
                          for($i=0;$i<count($spid);$i++)
                          {
                               //$qry="select id_menu_groupproject from ".DB_APORTIL.".tbl_treemenu where id_menu_groupproject='".$spid[$i]."' and isdeleted=0 order by id asc limit 1";
                               $qry="select m.id_menu_groupproject from ".DB_APORTIL.".tbl_menu_groupproject p inner join ".DB_APORTIL.".tbl_treemenu m on p.id=m.id_menu_groupproject
                                     where p.id='".$spid[$i]."' and p.isdeleted=0 order by m.menuorder asc limit 1";
                               //echo $qry;return false;
                               if($this->fn_row_isexists($qry))
                               {
                                   //skins/web/imgs/dhxtree_web/
                                   echo "myTree".$spid[$i]."= myAccordion.cells(\"a".$spid[$i]."\").attachTree();
                                         myTree".$spid[$i].".setImagePath(\"themes/skins/web/imgs/dhxtree_web/\");
                                         myTree".$spid[$i].".enableTreeLines(true);
                                         url=fn_dhtmlxloadobject('".$this->enc("obj_home")."','obj=".$this->enc("-")."&task=".$this->enc("treemenu")."&id_menu_groupproject=".$spid[$i]."');
                                         //alert(url);
                                         myTree".$spid[$i].".loadXML(url);
                                         myTree".$spid[$i].".attachEvent(\"onClick\",function(e){
                                            switch (myTree".$spid[$i].".getSelectedItemId())
                                            {";
                                                if($_SESSION['treemenuid'])
                                                {
                                                    $qry="select objoption,objname,objtask,menutext,menuid,url from ".DB_APORTIL.".tbl_treemenu 
                                                          where id in(".$_SESSION['treemenuid'].") and menutype='D' and isdeleted=0 and menuactivated=1 and id_menu_groupproject='".$spid[$i]."'
                                                          order by menuorder asc";
                                                    $rseventmnu=$this->selectquery($qry);
                                                    if($rseventmnu)
                                                    {
                                                        if($this->REC_ROWS_COUNT($rseventmnu)>0)
                                                        {
                                                            while($rwevent=$this->data_row_object($rseventmnu))
                                                            {
                                                                echo "case '".$rwevent->menuid."':";
                                                                           $url="fn_dhtmlxloadobject('".$this->enc($rwevent->objoption)."','obj=".$this->enc($rwevent->objname)."&task=".$this->enc($rwevent->objtask)."&tabid=tab".$rwevent->menuid."')";
                                                                           if($rwevent->url){$url="'".$rwevent->url."'";}
                                                                echo "     fn_dhtmlxaddtabbar('tab".$rwevent->menuid."',$url,'".$rwevent->menutext."',220,true);
                                                                      break;";
                                                            }                                                
                                                        }
                                                        else
                                                        {
                                                            echo "case 'mc0':";
                                                                       $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("default")."&tabid=tab0')";
                                                            echo "     fn_dhtmlxaddtabbar('tab0',$url,'Penambahan Menu',150,true);
                                                                  break;";
                                                                  
                                                            echo "case 'mc1':";
                                                                       $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_list")."&task=".$this->enc("default")."&tabid=tab1')";
                                                            echo "     fn_dhtmlxaddtabbar('tab1',$url,'Pencarian Menu',150,true);
                                                                  break;";
                                                        }
                                                    }
                                                    $this->clearrecordset($rseventmnu);
                                                } 
                                                else if($_SESSION['nik']=='82010')
                                                {
                                                    echo "case 'mc0':";
                                                               $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("default")."&tabid=tab0')";
                                                    echo "     fn_dhtmlxaddtabbar('tab0',$url,'Penambahan Menu',150,true);
                                                          break;";
                                                          
                                                    echo "case 'mc1':";
                                                               $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_list")."&task=".$this->enc("default")."&tabid=tab1')";
                                                    echo "     fn_dhtmlxaddtabbar('tab1',$url,'Pencarian Menu',150,true);
                                                          break;";
                                                }                                 
                                   echo "   };
                                         });"; 
                                         
                               }                           
                          }
                      }
                      else
                      {
                          $idmyAccadmin=$this->fn_get_fieldvalue("id","select id from ".DB_APORTIL.".tbl_menu_groupproject where isadministrator=1 and isdeleted=0");
                          echo "myTree".$idmyAccadmin."= myAccordion.cells(\"a".$idmyAccadmin."\").attachTree();                      
                                myTree".$idmyAccadmin.".setImagePath(\"themes/skins/web/imgs/dhxtree_web/\");
                                myTree".$idmyAccadmin.".enableTreeLines(true);
                                url=fn_dhtmlxloadobject('".$this->enc("obj_home")."','obj=".$this->enc("-")."&task=".$this->enc("treemenuadmin")."');
                                //alert(url);
                                myTree".$idmyAccadmin.".loadXML(url);
                                // === Attach Event MyTree
                                myTree".$idmyAccadmin.".attachEvent(\"onClick\",function(e){
                                    switch (myTree".$idmyAccadmin.".getSelectedItemId())
                                    {";
                                        if($_SESSION['nik']=='82010')
                                        {
                                            echo "case 'mc0':";
                                                       $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("default")."&tabid=tab0')";
                                            echo "     fn_dhtmlxaddtabbar('tab0',$url,'Penambahan Menu',220,true);
                                                  break;";
                                                  
                                            echo "case 'mc1':";
                                                       $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_list")."&task=".$this->enc("default")."&tabid=tab1')";
                                            echo "     fn_dhtmlxaddtabbar('tab1',$url,'Pencarian Menu',220,true);
                                                  break;";
                                            echo "case 'mc2':";
                                                       $url="fn_dhtmlxloadobject('".$this->enc("obj_user")."','obj=".$this->enc("user_new")."&task=".$this->enc("default")."&tabid=tab2')";
                                            echo "     fn_dhtmlxaddtabbar('tab2',$url,'Penambahan User',220,true);
                                                  break;";
                                                  
                                            echo "case 'mc3':";
                                                       $url="fn_dhtmlxloadobject('".$this->enc("obj_user")."','obj=".$this->enc("user_auth")."&task=".$this->enc("default")."&tabid=tab3')";
                                            echo "     fn_dhtmlxaddtabbar('tab3',$url,'Authentifikasi User',250,true);
                                                  break;";
                                        }                                 
                          echo "    };
                                });";      
                      }
                  }
                  else
                  {
                      $idmyAccadmin=$this->fn_get_fieldvalue("id","select id from ".DB_APORTIL.".tbl_menu_groupproject where isadministrator=1 and isdeleted=0");
                      echo "myAccordion.addItem(\"a".$idmyAccadmin."\", \"Konfigurasi&nbsp;$expandcollapse\" $firstactive);
                            myTree".$idmyAccadmin."= myAccordion.cells(\"a".$idmyAccadmin."\").attachTree();
                            myTree".$idmyAccadmin.".setImagePath(\"themes/skins/web/imgs/dhxtree_web/\");
                            myTree".$idmyAccadmin.".enableTreeLines(true);  
                            url=fn_dhtmlxloadobject('".$this->enc("obj_home")."','obj=".$this->enc("-")."&task=".$this->enc("treemenuadmin")."');
                            //alert(url);
                            myTree".$idmyAccadmin.".loadXML(url);
                            // === Attach Event MyTree
                            myTree".$idmyAccadmin.".attachEvent(\"onClick\",function(e){
                                switch (myTree".$idmyAccadmin.".getSelectedItemId())
                                {";
                                    if($_SESSION['nik']=='82010')
                                    {
                                        echo "case 'mc0':";
                                                   $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_new")."&task=".$this->enc("default")."&tabid=tab0')";
                                        echo "     fn_dhtmlxaddtabbar('tab0',$url,'Penambahan Menu',220,true);
                                              break;";
                                              
                                        echo "case 'mc1':";
                                                   $url="fn_dhtmlxloadobject('".$this->enc("obj_menuconfig")."','obj=".$this->enc("menuconfig_list")."&task=".$this->enc("default")."&tabid=tab1')";
                                        echo "     fn_dhtmlxaddtabbar('tab1',$url,'Pencarian Menu',220,true);
                                              break;";
                                        echo "case 'mc2':";
                                                   $url="fn_dhtmlxloadobject('".$this->enc("obj_user")."','obj=".$this->enc("user_new")."&task=".$this->enc("default")."&tabid=tab2')";
                                        echo "     fn_dhtmlxaddtabbar('tab2',$url,'Penambahan User',220,true);
                                              break;";
                                              
                                        echo "case 'mc3':";
                                                   $url="fn_dhtmlxloadobject('".$this->enc("obj_user")."','obj=".$this->enc("user_auth")."&task=".$this->enc("default")."&tabid=tab3')";
                                        echo "     fn_dhtmlxaddtabbar('tab3',$url,'Authentifikasi User',150,true);
                                              break;";
                                    }                                 
                      echo "    };
                            });";      
                  }
            
            
            
//            echo "myAccordion.addItem(\"a1\", \"Main Page\", true);
//                  myAccordion.addItem(\"a2\", \"Site Navigation\");
//                  myAccordion.addItem(\"a3\", \"Support & Feedback\");";
        }
        
        public function FN_DHTMLXTOOLBAR()
        {
            $mymenu="<?xml version='1.0' encoding='UTF-8'?>";
            $mymenu.="<toolbar>";
            $mymenu.="   <item id='toolbarexit' type='button' text='Exit' img='exit.png' imgDis='exit.png'/>";
            $mymenu.="   <item id='sep1' type='separator'/>";
            $mymenu.="   <item id='toolbarwelcome' type='buttonSelect' text='Welcomes Mr/Mrs &lt;b&gt;".$_SESSION["employeename"]."&lt;/b&gt;' openAll='true' renderSelect='false'>";
            $mymenu.="      <item id='subtoolbarchgpass' text='Change Your Password' type='button'  img='72.png' imgDis='72.png'/>";
            $mymenu.="   </item>";
            $mymenu.="   <item id='sep1' type='separator'/>";
            $mymenu.="   <item id='toolbarreload' type='button' text='Refresh' img='reload.png' imgDis='reload.png'/>";
            $mymenu.="   <item id='sep1' type='separator'/>";
            $mymenu.="   <item id='toolbartreeview' type='buttonSelect' text='Treeview Shown&amp;nbsp;' openAll='true' renderSelect='false' img='2.png' imgDis='2.png'>";
            $mymenu.="      <item id='subtoolbartreeviewhide' text='Hide".str_repeat("&amp;nbsp;",18)."' type='button' img='59.gif' imgDis='59.gif'/>";
            $mymenu.="      <item id='subtoolbartreeviewunhide' text='Unhide".str_repeat("&amp;nbsp;",18)."' type='button'  img='60.gif' imgDis='60.gif'/>";
            $mymenu.="   </item>";
            $mymenu.="   <item id='sep1' type='separator'/>";
                        $spanhour="&lt;span id=&quot;h&quot; style=&quot;font-family:dseg7modernregular;font-size:16pt;&quot;&gt;00&lt;/span&gt;";
                        $spanseparator="&lt;span style=&quot;font-size:16pt;&quot;&gt;:&lt;/span&gt;";
                        $spanminute="&lt;span id=&quot;m&quot; style=&quot;font-family:dseg7modernregular;font-size:16pt;&quot;&gt;00&lt;/span&gt;";
                        $spanseparator="&lt;span style=&quot;font-size:16pt;&quot;&gt;:&lt;/span&gt;";
                        $spansecond="&lt;span id=&quot;s&quot; style=&quot;font-family:dseg7modernregular;font-size:16pt;&quot;&gt;00&lt;/span&gt;";
                        //$spanspacedate="&lt;span style=&quot;font-size:16pt;&quot;&gt;&nbsp;&lt;/span&gt;";
                        //$date="&lt;span id=&quot;h&quot; style=&quot;font-family:arial;font-size:10pt;&quot;&gt;".strtoupper(date("d M Y"))."&lt;/span&gt;";
//            $mymenu.="   <item id='toolbarservice' type='buttonSelect' text='Download&amp;nbsp;' openAll='true' renderSelect='false' img='load.png' imgDis='load.png'>";
//            $mymenu.="      <item id='subtoolbarserviceprint' text='&lt;a href=&quot;lib/DMSD.exe&quot;&gt;Print Service&lt;/a&gt;".str_repeat("&amp;nbsp;",18)."' type='button' img='print.gif' imgDis='print.gif'/>";
//            $mymenu.="      <item id='subtoolbarserviceadobereader' text='&lt;a href=&quot;lib/Adobe.exe&quot;&gt;Adobe Reader&lt;/a&gt;".str_repeat("&amp;nbsp;",18)."' type='button'  img='pdf.png' imgDis='pdf.png'/>";
//            $mymenu.="   </item>";
//            $mymenu.="   <item id='toolbardmsd' type='text' text='&lt;a href=&quot;lib/DMSD.exe&quot;&gt;&lt;span style=&quot;font-family:arial;font-size:8pt&quot;&gt;Download Print Services&lt;/span&gt;&lt;/a&gt;'/>";//&lt;span id=&quot;h&quot; style&gt;00&lt;/span&gt;
//            $mymenu.="   <item id='toolbardmsd' type='text' text='&lt;a href=&quot;lib/DMSD.exe&quot;&gt;&lt;span style=&quot;font-family:arial;font-size:8pt&quot;&gt;&lt;img src=&quot;themes/icons/pdf.png&quot;/&gt; Adobe Reader&lt;/span&gt;&lt;/a&gt;'/>";//&lt;span id=&quot;h&quot; style&gt;00&lt;/span&gt;
            $mymenu.="   <item id='toolbartime' type='text' text='&lt;span style=&quot;font-family:arial;font-size:8pt&quot;&gt;TIME&lt;/span&gt; $spanhour$spanseparator$spanminute$spanseparator$spansecond'/>";//&lt;span id=&quot;h&quot; style&gt;00&lt;/span&gt;
            //$mymenu.="   <item id='toolbarwelcome' type='text' text='Selamat Datang Mr/Mrs &lt;b&gt;".$_SESSION["employeename"]."&lt;/b&gt;' />";
            
            $mymenu.="   <item id='sep1' type='separator'/>";
            $mymenu.="   <item id='toolbaripinfo' type='text' text='&lt;span style=&quot;font-family:arial;font-size:10pt&quot;&gt;Your IP Address :&lt;/span&gt; &lt;span style=&quot;font-family:arial;font-size:14pt&quot;&gt;".$this->get_client_ip()."&lt;/span&gt;'/>";//&lt;span id=&quot;h&quot; style&gt;00&lt;/span&gt;
            
            $mymenu.="</toolbar>";                           

            echo "// === Create toolbar Menu
                  myToolbar = myLayout.attachToolbar({
                      icons_size: 24,
                      icons_path: \"themes/icons/toolbar/\",
                      xml: \"$mymenu\"
                  });
                  
                  myToolbar.attachEvent(\"onClick\",function(id){
                      switch(id)
                      {
                          case 'toolbarexit':";                      
                              $event="document.getElementById('uri').value='ajax=0&sec=0&option=".$this->enc("r/out")."';";
                              $event.="document.getElementById('fm').submit();";
                              echo $this->FN_DHTMLXCONFIRM("Konfirmasi","Anda ingin Keluar?",$event);
            echo "        break;
                          case 'toolbarreload':
                              myTabbar.forEachCell(function(cell){
                                    var id = cell.getId();
                                    if(myTabbar.tabs(id).isActive()){myTabbar.cells(id).reloadURL();}
                              });

                          break;
                          case 'subtoolbarchgpass':";
                              $url="fn_dhtmlxloadobject('".$this->enc("obj_user")."','obj=".$this->enc("user_pass")."&task=".$this->enc("default")."')";  
            echo "            fn_dhtmlxaddtabbar('subtoolbarchgpass',$url,'Change Password',190,true);
                          break;
                          
                          case 'subtoolbartreeviewhide':
                              myLayout.cells(\"a\").undock();
                              myLayout.dhxWins.window(\"a\").hide();
                          break;
                          
                          case 'subtoolbartreeviewunhide':
                              myLayout.cells(\"a\").dock();
                          break;
                          
                      }
                  });
                  //myLayout.dhxWins.window(\"a\").hide();
                  fn_timeschedule();";              
            
        }
        
        public function FN_DHTMLXMENU()
        {            
            $mymenu="<?xml version='1.0' encoding='UTF-8'?>";
            $mymenu.="<menu>";
            $mymenu.="   <item id='mnubantuan' text='Bantuan' img='help.gif'></item>";
            $mymenu.="</menu>";                           

            echo "// === Create Menu Header
                    myMenu = myLayout.attachMenu({
                        icons_path: \"themes/icons/\",
                        xml: \"$mymenu\"
                    });"; 
                    
            echo "  myMenu.attachEvent(\"onClick\", function(id)
                        {                                        
                            switch(id)
                            {
                                case 'submnuclose':";                      
                                    $event="document.getElementById('uri').value='ajax=0&sec=0&option=".$this->enc("r/out")."';";
                                    $event.="document.getElementById('fm').submit();";
                                    echo $this->FN_DHTMLXCONFIRM("Konfirmasi","Anda ingin Keluar?",$event);
            echo "              break;
                                case 'mnubantuan':
                                    
                                break;";
            echo "          }
                        });";

        }
        
        public function FN_DHTMLXROWISEXIST()
        {
            $object=$_REQUEST['object'];
            $validationvalue=trim($_REQUEST['validationvalue']);
            $sp=explode("|",$object);
            $qry="select ".$sp[1]." from ".DB_APORTIL.".".$sp[0]." where ".$sp[1]."='$validationvalue' and isdeleted=0 order by id asc limit 1";
            $value=$this->fn_get_fieldvalue($sp[1],$qry);
            if($value)
            {
                echo "failed|Data <b>".$validationvalue."</b> sudah pernah di tambahkan";
            }

        }
        
        public function FN_DHTMLXFORMVALIDATIONERROR($myform,$arrvalidateerror,$resulttovariable=null)
        {
            $rtn=$myform.".attachEvent(\"onValidateError\",function(id,value,result){
                    var msg='';
                    switch(id)
                    {";
                        foreach($arrvalidateerror as $obj => $valerror)
                        {
                            $rtn.="case '$obj':
                                      msg='$valerror';";
                            $rtn.="break;";
                        }
            $rtn.="  }";
            $rtn.="  if(msg){fn_dhtmlxmessage('error',msg);}";
            $rtn.="});";
            if($resulttovariable){return $rtn;}else{echo $rtn;}
        }
        
        public function CREATE_TEXTAREA($id,$name,$event,$properties)
        {
            if(is_array($properties))
            {
                foreach($properties as $arr=>$arrvalue)
                {
                    $OBJ_PROPERTIES.=$arr.$arrvalue." ";
                }                
            }
            else
            {$OBJ_PROPERTIES=$properties;}
            return "<textarea id=\"$id\" name=\"$name\" $event $OBJ_PROPERTIES></textarea>";                            
            //echo "<textarea class=\"span8\" rows=\"3\" style></textarea>";
        }
        
        public function CREATE_EDIT_ICON_BUTTON($event,$title=null)
        {
            return "<a href=\"#\" title=\"$title\" style=\"text-decoration:none;\">
                        <img src=\"".PATH_THEME."/images/edit.png\" onClick=\"$event\" border=\"0\" />
                    </a>";
        }
        
        public function CREATE_PRINT_ICON_BUTTON($event,$title=null)
        {
            return "<a href=\"#\" title=\"$title\" style=\"text-decoration:none;\">
                        <img src=\"".PATH_THEME."/images/print.gif\" onClick=\"$event\" border=\"0\" />
                    </a>";
        }
        
        public function getErrMsg()
        {
            return $this->errMsg;
        }

        public function CREATE_ROOT($option,$obj_name,$defaulttask)
        {
            // === check Validation $option &obj_name
            $msgvalidation="";
            //echo preg_match("/^_/i",$option);
            if(!preg_match("/_/i",$option)){$msgvalidation="Isikan Kolom Option dengan tanda separator \"_\" contoh obj_test.TERIMA KASIH.";}
            //if(!preg_match("/_/i",$obj_name)){if($msgvalidation){$msgvalidation.="<br/>";}$msgvalidation.="Isikan Kolom Obj Name dengan tanda separator \"_\" contoh test_new.<br/>TERIMA KASIH.";}
            
            //if($msgvalidation){echo $this->SHOWMESSAGE($msgvalidation);return false;}
            if($msgvalidation){$this->errMsg=$msgvalidation; return false;}
            // === CREATE ROOT AND STRUCTURE
            
            if(!is_dir(PATH_OBJECT."/$option"))
            {
                mkdir(PATH_OBJECT."/$option");
                $spfile=explode("_",$option);
                $basefile=$spfile[1];
                // ==== Create $basefile.php
                $fl=fopen(PATH_OBJECT."/$option/$basefile.php","w");
                // ==== Write $basefile.php
                $strbasefile="<?php\n";
                $strbasefile.=str_repeat(chr(32),4)."require_once(".chr(36)."pg.\".html.php\");\n";   
                $strbasefile.=str_repeat(chr(32),4)."class ".strtoupper($basefile)." extends ".strtoupper($basefile)."_HTML\n";   
                $strbasefile.=str_repeat(chr(32),4)."{\n\n\n";   
                $strbasefile.=str_repeat(chr(32),4)."}\n\n";   
                $strbasefile.=str_repeat(chr(32),4)."".chr(36)."cl=new ".strtoupper($basefile)."();\n\n";   
                $strbasefile.=str_repeat(chr(32),4)."if(isset(".chr(36)."_REQUEST['task'])){".chr(36)."case=".chr(36)."_REQUEST['task'];}\n";   
                $strbasefile.=str_repeat(chr(32),4)."if(isset(".chr(36)."_POST['task'])){".chr(36)."case=".chr(36)."_POST['task'];}\n";   
                $strbasefile.=str_repeat(chr(32),4)."if(isset(".chr(36)."_REQUEST['obj'])){".chr(36)."obj=".chr(36)."_REQUEST['obj'];}\n";   
                $strbasefile.=str_repeat(chr(32),4)."if(isset(".chr(36)."_POST['obj'])){".chr(36)."obj=".chr(36)."_POST['obj'];}\n\n";   
                //if($_REQUEST){if($_REQUEST['sec']){$case=$this->dec($case);$obj=$this->dec($obj);}}
                $strbasefile.=str_repeat(chr(32),4)."if(".chr(36)."_REQUEST){if(".chr(36)."_REQUEST['sec']){".chr(36)."case=".chr(36)."cl->dec(".chr(36)."case);".chr(36)."obj=".chr(36)."cl->dec(".chr(36)."obj);}}\n\n";   
                $strbasefile.=str_repeat(chr(32),4)."if(file_exists(PATH_OBJECT.\"/".chr(36)."option/".chr(36)."obj.php\"))\n";   
                $strbasefile.=str_repeat(chr(32),4)."{\n";   
                $strbasefile.=str_repeat(chr(32),8)."require_once(\"".chr(36)."obj.php\");\n";   
                $strbasefile.=str_repeat(chr(32),8)."".chr(36)."className=strtoupper(".chr(36)."obj);\n";   
                $strbasefile.=str_repeat(chr(32),8)."".chr(36)."clfile=new ".chr(36)."className();\n";   
                $strbasefile.=str_repeat(chr(32),8)."".chr(36)."fn_init_java=".chr(36)."className.\"_javainit\";\n";   
                $strbasefile.=str_repeat(chr(32),8)."".chr(36)."init_java=trim(".chr(36)."_REQUEST['init_java']);if(".chr(36)."init_java){".chr(36)."clfile->".chr(36)."fn_init_java();}\n\n";   
                $strbasefile.=str_repeat(chr(32),8)."".chr(36)."case=".chr(36)."obj;\n";   
                $strbasefile.=str_repeat(chr(32),4)."}\n\n";   
                $strbasefile.=str_repeat(chr(32),4)."if(!".chr(36)."case){".chr(36)."case=".chr(36)."obj;if(!file_exists(PATH_OBJECT.\"/".chr(36)."option/".chr(36)."obj.php\")){".chr(36)."cl->under_construction();}}\n";   
                $strbasefile.=str_repeat(chr(32),4)."".chr(36)."sptask=explode(\"_\",".chr(36)."case);".chr(36)."modulename=".chr(36)."sptask[1];".chr(36)."fn_module_init=\"fn_\".".chr(36)."modulename.\"_init\";\n\n";   
                $strbasefile.=str_repeat(chr(32),4)."switch(".chr(36)."case)\n";   
                $strbasefile.=str_repeat(chr(32),4)."{\n";   
                $strbasefile.=str_repeat(chr(32),8)."case \"".$basefile."_".chr(36)."modulename\":\n";   
                $strbasefile.=str_repeat(chr(32),10)."".chr(36)."clfile->".chr(36)."fn_module_init();\n";   
                $strbasefile.=str_repeat(chr(32),8)."break;\n";   
                $strbasefile.=str_repeat(chr(32),4)."}\n\n";   
                $strbasefile.="?>";   
                
                fwrite($fl,$strbasefile);
                fclose($fl);

                // === Create and write $basefile_html.php
                $basefilehtml=$basefile.".html";
                $fl=fopen(PATH_OBJECT."/$option/".$basefilehtml.".php","w");
                $strbasefile="<?php\n";
                $strbasefile.=str_repeat(chr(32),4)."class BASE_".strtoupper($basefile)." extends MY_DHTMLX\n";   
                $strbasefile.=str_repeat(chr(32),4)."{\n";   
                $strbasefile.=str_repeat(chr(32),8)."public function fn_page_construct()\n";   
                $strbasefile.=str_repeat(chr(32),8)."{\n\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n";   
                $strbasefile.=str_repeat(chr(32),4)."}\n\n";   
                
                $strbasefile.=str_repeat(chr(32),4)."class ".strtoupper($basefile)."_HTML extends BASE_".strtoupper($basefile)."\n";   
                $strbasefile.=str_repeat(chr(32),4)."{\n";   
                $strbasefile.=str_repeat(chr(32),8)."public function fn_page_home()\n";   
                $strbasefile.=str_repeat(chr(32),8)."{\n\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n";
                $strbasefile.=str_repeat(chr(32),8)."public function fn_url_home()\n";   
                $strbasefile.=str_repeat(chr(32),8)."{\n";  
                $strbasefile.=str_repeat(chr(32),12)."return \"".chr(36)."('#uri').val('');".chr(36)."('#fm').prop('target','_self');".chr(36)."('#fm').submit();\";\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n\n";
                $strbasefile.=str_repeat(chr(32),8)."public function fn_url_$obj_name()\n";   
                $strbasefile.=str_repeat(chr(32),8)."{\n";  
                $strbasefile.=str_repeat(chr(32),12)."return \"".chr(36)."('#uri').val('ajax=0&sec=1&option=".$this->enc("$option")."&obj=".$this->enc($obj_name)."&task=".$this->enc($defaulttask)."');".chr(36)."('#fm').prop('target','_self');".chr(36)."('#fm').submit();\";\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n";
                $strbasefile.=str_repeat(chr(32),4)."}\n\n";   
                $strbasefile.="?>";   
                fwrite($fl,$strbasefile);
                fclose($fl);
                
                // === Create and write $obj_name.php
                $spsuffix=explode("_",$obj_name);
                $suffixobjname=$spsuffix[1];
                $fl=fopen(PATH_OBJECT."/$option/".$obj_name.".php","w");
                $strbasefile="<?php\n";
                $strbasefile.=str_repeat(chr(32),4)."class ".strtoupper($obj_name)." extends ".strtoupper($basefile)."\n";   
                $strbasefile.=str_repeat(chr(32),4)."{\n";   
                $strbasefile.=str_repeat(chr(32),8)."public function ".$obj_name."_javainit()\n";   
                $strbasefile.=str_repeat(chr(32),8)."{\n\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n\n";   
                
                $strbasefile.=str_repeat(chr(32),8)."public function fn_".$suffixobjname."_init()\n";   
                $strbasefile.=str_repeat(chr(32),8)."{\n";   
                $strbasefile.=str_repeat(chr(32),12)."if(isset(".chr(36)."_REQUEST['task'])){".chr(36)."task=trim(strtolower(".chr(36)."_REQUEST['task']));}\n";   
                $strbasefile.=str_repeat(chr(32),12)."if(isset(".chr(36)."_POST['task'])){".chr(36)."task=trim(strtolower(".chr(36)."_POST['task']));}\n";   
                $strbasefile.=str_repeat(chr(32),12)."if(".chr(36)."_REQUEST||".chr(36)."_POST){if(".chr(36)."_REQUEST['sec']||".chr(36)."_POST['sec']){".chr(36)."task=".chr(36)."this->dec(".chr(36)."task);}}\n\n";   
                $strbasefile.=str_repeat(chr(32),12)."switch(".chr(36)."task)\n";   
                $strbasefile.=str_repeat(chr(32),12)."{\n";   
                //$strbasefile.=str_repeat(chr(32),16)."case \"save$suffixobjname\":\n\n";   
                $strbasefile.=str_repeat(chr(32),16)."case \"default\":\n";
                $strbasefile.=str_repeat(chr(32),20)."".chr(36)."this->fn_default_$suffixobjname();\n";      
                $strbasefile.=str_repeat(chr(32),16)."break;\n\n";   
                $strbasefile.=str_repeat(chr(32),16)."case ".chr(36)."task:\n";
                $strbasefile.=str_repeat(chr(32),20)."".chr(36)."task=\"fn_\".".chr(36)."task;\n";      
                $strbasefile.=str_repeat(chr(32),20)."if(method_exists(".chr(36)."this,".chr(36)."task)){".chr(36)."this->".chr(36)."task();}\n";      
                $strbasefile.=str_repeat(chr(32),16)."break;\n\n";   
                $strbasefile.=str_repeat(chr(32),16)."default:\n";   
                $strbasefile.=str_repeat(chr(32),20)."".chr(36)."this->fn_default_$suffixobjname();\n";   
                $strbasefile.=str_repeat(chr(32),16)."break;\n";   
                $strbasefile.=str_repeat(chr(32),12)."}\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n";
                
                $strbasefile.=str_repeat(chr(32),8)."public function fn_default_".$suffixobjname."()\n";      
                $strbasefile.=str_repeat(chr(32),8)."{\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CREATEHEADER();\n\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo \"<style>\n";   
                $strbasefile.=str_repeat(chr(32),12)."          .besidebtnsave {margin-left:104px;margin-top:-6px;position:absolute;}\n";   
                $strbasefile.=str_repeat(chr(32),12)."          .besidebtnupdate {margin-left:198px;margin-top:-6px;position:absolute;}\n";   
                $strbasefile.=str_repeat(chr(32),12)."          .besidebtndelete {margin-left:288px;margin-top:-6px;position:absolute;}\n";   
                $strbasefile.=str_repeat(chr(32),12)."      </style>\";\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo \"<script>\n";   
                $strbasefile.=str_repeat(chr(32),12)."           var myForm,myFormsearch,dgtra;\n";   
                $strbasefile.=str_repeat(chr(32),12)."           function initObject()\n";   
                $strbasefile.=str_repeat(chr(32),12)."           {\";\n\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo \"     }\n\n";   
                $strbasefile.=str_repeat(chr(32),12)."           function fn_grid_loaddata()\n";   
                $strbasefile.=str_repeat(chr(32),12)."           {\";\n\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo \"     }\n";   
                $strbasefile.=str_repeat(chr(32),12)."       </script>\";\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CLOSEHEADER();\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CREATEBODY(\"e8f1ff\");\n\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo \"Your Module is <font color='red'>still underconstruction.</font>\";\n";   
                $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CREATEFOOTER();\n\n";   
                $strbasefile.=str_repeat(chr(32),8)."}\n";
                
                $strbasefile.=str_repeat(chr(32),4)."}\n";   
                $strbasefile.="?>";   
                fwrite($fl,$strbasefile);
                fclose($fl);

                return true;
            }
            else
            {
                if(!file_exists(PATH_OBJECT."/$option/$obj_name.php"))
                {
                    $spfile=explode("_",$option);
                    $basefile=$spfile[1];
                    // === Create and write $obj_name.php
                    $spsuffix=explode("_",$obj_name);
                    $suffixobjname=$spsuffix[1];
                    $fl=fopen(PATH_OBJECT."/$option/".$obj_name.".php","w");
                    $strbasefile="<?php\n";
                    $strbasefile.=str_repeat(chr(32),4)."class ".strtoupper($obj_name)." extends ".strtoupper($basefile)."\n";   
                    $strbasefile.=str_repeat(chr(32),4)."{\n";   
                    $strbasefile.=str_repeat(chr(32),8)."public function ".$obj_name."_javainit()\n";   
                    $strbasefile.=str_repeat(chr(32),8)."{\n\n";   
                    $strbasefile.=str_repeat(chr(32),8)."}\n\n";   
                    
                    $strbasefile.=str_repeat(chr(32),8)."public function fn_".$suffixobjname."_init()\n";   
                    $strbasefile.=str_repeat(chr(32),8)."{\n";   
                    $strbasefile.=str_repeat(chr(32),12)."if(isset(".chr(36)."_REQUEST['task'])){".chr(36)."task=trim(strtolower(".chr(36)."_REQUEST['task']));}\n";   
                    $strbasefile.=str_repeat(chr(32),12)."if(isset(".chr(36)."_POST['task'])){".chr(36)."task=trim(strtolower(".chr(36)."_POST['task']));}\n";   
                    $strbasefile.=str_repeat(chr(32),12)."if(".chr(36)."_REQUEST||".chr(36)."_POST){if(".chr(36)."_REQUEST['sec']||".chr(36)."_POST['sec']){".chr(36)."task=".chr(36)."this->dec(".chr(36)."task);}}\n\n";   
                    $strbasefile.=str_repeat(chr(32),12)."switch(".chr(36)."task)\n";   
                    $strbasefile.=str_repeat(chr(32),12)."{\n";   
                    //$strbasefile.=str_repeat(chr(32),16)."case \"save$suffixobjname\":\n\n";   
                    $strbasefile.=str_repeat(chr(32),16)."case \"default\":\n";
                    $strbasefile.=str_repeat(chr(32),20)."".chr(36)."this->fn_default_$suffixobjname();\n";      
                    $strbasefile.=str_repeat(chr(32),16)."break;\n\n";   
                    $strbasefile.=str_repeat(chr(32),16)."case ".chr(36)."task:\n";
                    $strbasefile.=str_repeat(chr(32),20)."".chr(36)."task=\"fn_\".".chr(36)."task;\n";      
                    $strbasefile.=str_repeat(chr(32),20)."if(method_exists(".chr(36)."this,".chr(36)."task)){".chr(36)."this->".chr(36)."task();}\n";      
                    $strbasefile.=str_repeat(chr(32),16)."break;\n\n";   
                    $strbasefile.=str_repeat(chr(32),16)."default:\n";   
                    $strbasefile.=str_repeat(chr(32),20)."".chr(36)."this->fn_default_$suffixobjname();\n";   
                    $strbasefile.=str_repeat(chr(32),16)."break;\n";   
                    $strbasefile.=str_repeat(chr(32),12)."}\n";   
                    $strbasefile.=str_repeat(chr(32),8)."}\n";
                    
                    $strbasefile.=str_repeat(chr(32),8)."public function fn_default_".$suffixobjname."()\n";      
                    $strbasefile.=str_repeat(chr(32),8)."{\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CREATEHEADER();\n\n";
                    $strbasefile.=str_repeat(chr(32),12)."echo \"<style>\n";   
                    $strbasefile.=str_repeat(chr(32),12)."          .besidebtnsave {margin-left:104px;margin-top:-6px;position:absolute;}\n";   
                    $strbasefile.=str_repeat(chr(32),12)."          .besidebtnupdate {margin-left:198px;margin-top:-6px;position:absolute;}\n";   
                    $strbasefile.=str_repeat(chr(32),12)."          .besidebtndelete {margin-left:288px;margin-top:-6px;position:absolute;}\n";   
                    $strbasefile.=str_repeat(chr(32),12)."      </style>\";\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo \"<script>\n";   
                    $strbasefile.=str_repeat(chr(32),12)."           var myForm,myFormsearch,dgtra;\n";   
                    $strbasefile.=str_repeat(chr(32),12)."           function initObject()\n";   
                    $strbasefile.=str_repeat(chr(32),12)."           {\";\n\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo \"     }\n\n";   
                    $strbasefile.=str_repeat(chr(32),12)."           function fn_grid_loaddata()\n";   
                    $strbasefile.=str_repeat(chr(32),12)."           {\";\n\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo \"     }\n";   
                    $strbasefile.=str_repeat(chr(32),12)."       </script>\";\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CLOSEHEADER();\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CREATEBODY(\"e8f1ff\");\n\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo \"Your Module is <font color='red'>still underconstruction.</font>\";\n";   
                    $strbasefile.=str_repeat(chr(32),12)."echo ".chr(36)."this->FN_CREATEFOOTER();\n\n";   
                    $strbasefile.=str_repeat(chr(32),8)."}\n";   
                    $strbasefile.=str_repeat(chr(32),4)."}\n";   
                    $strbasefile.="?>";   
                    fwrite($fl,$strbasefile);
                    fclose($fl);    
                    return true;
                }
                else
                {
                    $msg="Mohon maaf Module <b>$obj_name</b> sudah tersedia tidak bisa ditambahkan.<br/>TERIMA KASIH";
                    //echo "dhtmlx.message({type:'error',text:'$msg'})";
                    $this->errMsg=$msg;
                    return false;                                    
                }
            }

        }
        
        public function SHOW_INFO_UPDATED($infomsg,$imginfo,$widthinfo)
        {
             if(!preg_match("/%/i",$widthinfo)){$widthinfo.="px";}
             echo "<table id=\"tb_fs_input\" style=\"width:".$widthinfo.";\">
                      <thead>
                           <tr>
                               <th colspan=\"2\">INFO UPDATED</th>
                           </tr>
                      </thead>
                      <tbody>
                           <tr>
                               <td width=\"2%\">";
                                   echo $this->CREATE_IMAGE($imginfo);  // test
             echo "            </td>
                               <td>";
                                   echo $infomsg; 
             echo "            </td> 
                           </tr>
                      </tbody>  
                  </table>";
        }
        
        public function SHOW_POPUP_REMARK($url,$init=null)
        {
            // ***** Popup Window **************************************************** -->
            echo "<div class=\"sample_popup\" id=\"popup$init\" style=\"display: none;\">
                        <div class=\"menu_form_header\" id=\"popup_drag$init\" style=\"width:400px;background-color:blue;\">
                            <img class=\"menu_form_exit\" id=\"popup_exit$init\" src=\"./themes/css/form_exit.png\" alt=\"\" />";
            echo "          &nbsp;&nbsp;&nbsp;Mohon masukkan remark terlebih dahulu!
                        </div>
                        <div class=\"menu_form_body\" style=\"width:400px;background-color:white;\">
                        <table border=\"0\">
                            <tr>
                                <td align=\"center\">";
                                    echo $this->CREATE_INPUT_OBJECT("text","txtremark$init","txtremark$init","onKeyPress=\"if(event.keyCode==13){btnset$init.click();}\"","style=\"width:98%;\"");
            echo "              </td>
                            </tr>
                            <tr>
                                <td align=\"right\">";
                                    $event="if(txtremark$init.value==''){alert('Beri tanda (-) bila ingin dikosongkan TERIMA KASIH');txtremark$init.focus();return false;}";
                                    $event.="if(confirm('Data ingin di update?')){".$url.";popup$init.style.display='none';}";
                                    echo $this->CREATE_INPUT_OBJECT("button","btnset$init","btnset$init","onClick=\"$event\"","value=\"    SET    \"");
            echo "              </td>
                            </tr>
                        </table>
                        </div>
                  </div>";
            // ***** Info ************************************************************ -->
        }
        
        public function CREATE_ICON_BUTTON_MODAL($event,$img,$title=null,$prop=null)
        {
            $sp=explode(".",$img);
            if(count($sp)<=1){$img.=".png";}            
            //echo $sp[1];
            return "<a href=\"#divmodal\" title=\"$title\" style=\"text-decoration:none;\" $prop >
                        <img src=\"".PATH_THEME."/images/$img\" onClick=\"$event;return false;\" border=\"0\" />
                    </a>";
        }

        public function CREATE_ICON_BUTTON($event,$img,$title=null,$prop=null)
        {
            $sp=explode(".",$img);
            if(count($sp)<=1){$img.=".png";}            
            //echo $sp[1];
            return "<a href=\"javascript:void(0)\" title=\"$title\" style=\"text-decoration:none;\" $prop >
                        <img src=\"".PATH_THEME."/images/$img\" onClick=\"$event;return false;\" border=\"0\" />
                    </a>";
        }

        public function CREATE_ICON_BUTTON2($event,$img,$id,$name,$title=null)
        {
            $sp=explode(".",$img);
            if(count($sp)<=1){$img.=".png";}            
            //echo $sp[1];
            return "<a href=\"javascript:void(0)\" title=\"$title\" style=\"text-decoration:none;\">
                        <img src=\"".PATH_THEME."/images/$img\" id=\"$id\" name=\"$name\" onClick=\"$event;return false;\" border=\"0\" />
                    </a>";
        }
        
        public function CREATE_EXECUTE_BUTTON($event,$btntext,$title=null)
        {
            if(!$btntext){$btntext="Save";}
            return "<a href=\"#\" title=\"$title\" style=\"text-decoration:none;\" onClick=\"$event\" class=\"btnexecute\">
                        $btntext
                    </a>";
        }
        
        public function INFO_RECORD_NOT_FOUND($errmsg=null)
        {
            $msg="Record Not Found!";
            if($errmsg){$msg=$errmsg;}
            return "<font color=\"red\">$msg</font>";
        }
        
        public function ANNOUNCEMENT()
        {   
            $rtn='';
            $qry="select tgltayang,pengumuman from ".DB_APORTIL.".tbl_pengumuman where isactivated=1 and isdeleted=0 order by id asc";
            $rsann=$this->selectquery($qry);
            if($rsann)
            {
                $pengumuman="Mohon Maaf Pengumuman <span class=\"textblink\" style=\"color:#4531e1;font-weight:bold;\">Belum Tersedia</span>. TERIMA KASIH";
                if($this->REC_ROWS_COUNT($rsann)>0)
                {
                    $tgltayang="";$content="";$pengumuman="";
                    while($rw=$this->data_row_object($rsann))
                    {
                        $tgltayang=date("Y-m-d H:i:s",strtotime($rw->tgltayang));
                        $content=addslashes($rw->pengumuman);
                        $pengumuman.="<b>".$tgltayang."</b>&nbsp".$content.str_repeat("&nbsp;",10);
                    }                    
                }
                $rtn="<div id=\"scroller\" class=\"navbar navbar-fixed-top\" style=\"background-color:#7a7091;\">
                          <span id=\"static-text\" style=\"margin-top:-1px;\">Pengumuman :</span>
                          <div class=\"scrollingtext\">
                              <span class=\"review\">
                                  $pengumuman
                              </span>
                          </div>
                      </div>";  

            }
            $this->clearrecordset($rsann);
            return $rtn;
        }
        
        public function PAGING_TABLE($COMBO_PAGE_NAME,$EVENT,$LIMIT_PAGE,$TOTAL_ROWS,$PAGE_SELECTED=null,$ARRPROP="",$aliasobj=null)
        {            
            //$nameobjnext="a_next";$nameobjprev="a_prev";
//            $namedivpaging="div_paging";
//            $namepagecount="txtpagecount";
//            $nameimgnext="imgnext";
//            $nameimgprev="imgprev";
            $nameobjnext="a_next".$aliasobj;$nameobjprev="a_prev".$aliasobj;
            $namedivpaging="div_paging".$aliasobj;
            $namepagecount="txtpagecount".$aliasobj;
            $nameimgnext="imgnext".$aliasobj;
            $nameimgprev="imgprev".$aliasobj;
            if(is_array($ARRPROP))
            {
                //$i;return false;
                foreach($ARRPROP as $NAMES=>$VALUES)
                {                    
                    if(strtolower($NAMES)=='name_next'){$nameobjnext=$VALUES;}
                    if(strtolower($NAMES)=='name_prev'){$nameobjprev=$VALUES;}
                    if(strtolower($NAMES)=='name_divpaging'){$namedivpaging=$VALUES;}                    
                    if(strtolower($NAMES)=='name_pagecount'){$namepagecount=$VALUES;}                    
                    if(strtolower($NAMES)=='name_imgnext'){$nameimgnext=$VALUES;}                    
                    if(strtolower($NAMES)=='name_imgprev'){$nameimgprev=$VALUES;}                    
                }
            }
            $LAST_PAGE=0;
            if($LIMIT_PAGE!==0&&$TOTAL_ROWS!==0){$LAST_PAGE=ceil($TOTAL_ROWS/$LIMIT_PAGE);}
            // ============ set url prev and next button
            $url_prev=str_replace("this.value","$COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex-1].value",$EVENT);
            //$url_prev=str_replace("this.value","$COMBO_PAGE_NAME.options[$('select[name='$COMBO_PAGE_NAME'] option:selected').index()-1].value",$EVENT);
            $url_prev.=";$COMBO_PAGE_NAME.selectedIndex=$COMBO_PAGE_NAME.selectedIndex-1;pagesymbolview($COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex].text,'$nameobjnext','$nameobjprev','$namepagecount','$nameimgnext','$nameimgprev');";
            
            //$("select[name='CCards'] option:selected").index()
            $url_next=str_replace("this.value","$COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex+1].value",$EVENT);
            //$url_next=str_replace("this.value","$COMBO_PAGE_NAME.options[$('select[name='$COMBO_PAGE_NAME'] option:selected').index()+1].value",$EVENT);
            //$url_next.=";$COMBO_PAGE_NAME.selectedIndex=$COMBO_PAGE_NAME.selectedIndex+1;pagesymbolview($COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex].text,'$nameobjnext','$nameobjprev','$namepagecount','$nameimgnext','$nameimgprev');";
            $url_next.=";$COMBO_PAGE_NAME.selectedIndex=$COMBO_PAGE_NAME.selectedIndex+1;pagesymbolview($COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex].text,'$nameobjnext','$nameobjprev','$namepagecount','$nameimgnext','$nameimgprev');";
            // ============  filter Selected page 
            if($PAGE_SELECTED==0||!$PAGE_SELECTED){$PAGE_SELECTED=1;}
            else
            {$PAGE_SELECTED=($PAGE_SELECTED/$LIMIT_PAGE)+1;}
                        
            //echo $EVENT;                        
            echo "<div id=\"$namedivpaging\" style=\"margin-top:2px;\">
                     Page&nbsp;";
                     $disabledprevious="disabled";
                     if($PAGE_SELECTED>1 && $PAGE_SELECTED<=$LAST_PAGE){$disabledprevious="";} // ===== symbol <<
                     echo "<a id=\"$nameobjprev\" href=\"javascript:void(0);\" onClick=\"if(!this.disabled){".$url_prev.";return false;}\" title=\"Disabled\" style=\"text-decoration:none;\" $disabledprevious>
                               <img src=\"".PATH_THEME."/images/application_previous_disabled.png\" border=\"0\" id=\"$nameimgprev\" /> 
                           </a>";
            //echo $EVENT; 
            echo "   <select id=\"$COMBO_PAGE_NAME\" name=\"$COMBO_PAGE_NAME\" style=\"width:60px;\" onChange=\"$EVENT;pagesymbolview(this.options[this.selectedIndex].text,'$nameobjnext','$nameobjprev','$namepagecount','$nameimgnext','$nameimgprev');\">";
                        $j=0;
                        if($LAST_PAGE>0)
                        {
                            for($i=1;$i<=$LAST_PAGE;$i++)
                            {
                                $s="";
                                if($i==$PAGE_SELECTED){$s="selected";}
                                echo "<option value=\"$j\" $s>$i</option>";
                                $j+=$LIMIT_PAGE;
                            }
                            $i-=1;                            
                        }
                        else
                        {
                            echo "<option value=\"\"></option>";
                        }
            echo "   </select>&nbsp;<input type=\"hidden\" id=\"$namepagecount\" value=\"$i\" />";
                     $disablednext="disabled";$imgnext="application_next_disabled.png";$titlenext="Disabled";
                     if($PAGE_SELECTED==1&&$i>1){$disablednext="";$imgnext="application_next_active.png";$titlenext="Next";} // ===== symbol >>
                     echo "<a id=\"$nameobjnext\" href=\"javascript:void(0);\" onClick=\"if(!this.disabled){".$url_next.";return false;}\" title=\"$titlenext\" style=\"text-decoration:none;\" $disablednext>
                               <img src=\"".PATH_THEME."/images/$imgnext\" border=\"0\" style=\"margin-left:-3px;\" id=\"$nameimgnext\" />
                           </a>&nbsp;of ".$LAST_PAGE;
            echo "</div>";                
        }
        
        //public function PAGING_TABLE($COMBO_PAGE_NAME,$EVENT,$LIMIT_PAGE,$TOTAL_ROWS,$PAGE_SELECTED=null)
        //{
           // echo "<script language=\"javascript\">
//                       function pagesymbolview(page)
//                       {
//                            var prev=document.getElementById('a_prev');
//                            var imgprev=document.getElementById('imgprev');
//                            var picprev='application_previous_disabled.png';
//                            prev.disabled=true;prev.title='Disabled';
//                            var next=document.getElementById('a_next');
//                            var imgnext=document.getElementById('imgnext');
//                            var picnext='application_next_active.png';
//                            next.disabled=false;next.title='Next';
//                            
//                            var pagecount=document.getElementById('txtpagecount').value;
//                            if(page>1){prev.disabled=false;prev.title='Previous';picprev='application_previous_active.png';}
//                            if(page==pagecount){next.disabled=true;next.title='Disabled';picnext='application_next_disabled.png';}
//                            
//                            imgprev.src='".PATH_THEME."/images/'+picprev;
//                            imgnext.src='".PATH_THEME."/images/'+picnext;
//                       } 
//                  </script>";
//            $LAST_PAGE=0;
//            if($LIMIT_PAGE!==0&&$TOTAL_ROWS!==0){$LAST_PAGE=ceil($TOTAL_ROWS/$LIMIT_PAGE);}
            // ============ set url prev and next button
//            $url_prev=str_replace("this.value","$COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex-1].value",$EVENT);
//            $url_prev.=";$COMBO_PAGE_NAME.selectedIndex=$COMBO_PAGE_NAME.selectedIndex-1;pagesymbolview($COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex].text);";
//            
//            $url_next=str_replace("this.value","$COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex+1].value",$EVENT);
//            $url_next.=";$COMBO_PAGE_NAME.selectedIndex=$COMBO_PAGE_NAME.selectedIndex+1;pagesymbolview($COMBO_PAGE_NAME.options[$COMBO_PAGE_NAME.selectedIndex].text);";
            // ============  filter Selected page 
//            if($PAGE_SELECTED==0||!$PAGE_SELECTED){$PAGE_SELECTED=1;}
//            else
//            {$PAGE_SELECTED=($PAGE_SELECTED/$LIMIT_PAGE)+1;}
//                        
//            echo "<div id=\"div_paging\" style=\"margin-top:2px;\">
//                     Page&nbsp;";
//                     $disabledprevious="disabled";
//                     if($PAGE_SELECTED>1 && $PAGE_SELECTED<=$LAST_PAGE){$disabledprevious="";} // ===== symbol <<
//                     echo "<a id=\"a_prev\" href=\"javascript:void(0);\" onClick=\"if(!this.disabled){".$url_prev.";return false;}\" title=\"Disabled\" style=\"text-decoration:none;\" $disabledprevious>
//                               <img src=\"".PATH_THEME."/images/application_previous_disabled.png\" border=\"0\" id=\"imgprev\" /> 
//                           </a>";
            //echo $EVENT;
//            echo "   <select id=\"$COMBO_PAGE_NAME\" name=\"$COMBO_PAGE_NAME\" style=\"font-size:10px;\" onChange=\"$EVENT;pagesymbolview(this.options[this.selectedIndex].text);\">";
//                        $j=0;
//                        if($LAST_PAGE>0)
//                        {
//                            for($i=1;$i<=$LAST_PAGE;$i++)
//                            {
//                                $s="";
//                                if($i==$PAGE_SELECTED){$s="selected";}
//                                echo "<option value=\"$j\" $s>$i</option>";
//                                $j+=$LIMIT_PAGE;
//                            }
//                            $i-=1;                            
//                        }
//                        else
//                        {
//                            echo "<option value=\"\"></option>";
//                        }
//            echo "   </select>&nbsp;<input type=\"hidden\" id=\"txtpagecount\" value=\"$i\" />";
//                     $disablednext="disabled";$imgnext="application_next_disabled.png";$titlenext="Disabled";
//                     if($PAGE_SELECTED==1&&$i>1){$disablednext="";$imgnext="application_next_active.png";$titlenext="Next";} // ===== symbol >>
//                     echo "<a id=\"a_next\" href=\"javascript:void(0);\" onClick=\"if(!this.disabled){".$url_next.";return false;}\" title=\"$titlenext\" style=\"text-decoration:none;\" $disablednext>
//                               <img src=\"".PATH_THEME."/images/$imgnext\" border=\"0\" style=\"margin-left:-3px;\" id=\"imgnext\" id=\"imgnext\" /> 
//                           </a>of ".$LAST_PAGE;
//            echo "</div>";                
//        }
        
        public function SHOW_TEXTRUPIAHS($xpos,$ypos)
        {
            echo "<div id=\"div_rupiahs\" style=\"position:absolute;margin-top:".$xpos."px;margin-left:".$ypos."px;width:300px;visibility:hidden;z-index:0;\">
                       <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
                            <tr>
                                <td>
                                    <table id=\"rounded-rupiah\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
                                        <thead>
                                           <tr>
                                               <th class=\"rounded-rpleft\" width=\"5%\">&nbsp;</th>
                                               <th>Rupiah's Separator</th>
                                               <th class=\"rounded-rpright\" width=\"7%\">
                                                   <a href=\"javascript:void(0);\" style=\"border:0px;\" onClick=\"hidemaskingrupiah();\">
                                                      <img src=\"".PATH_THEME."/css/table-images/closerp.png\" border=\"0\"/>
                                                   </a>
                                               </th>
                                           </tr>
                                        </thead> 
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td> 
                                    <table id=\"rounded-rupiah\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
                                       <tbody>
                                           <tr>
                                               <td>
                                                   <table style=\"width:100%;height:60px;background-color:white;border-color:#a7c942;border-collapse:collapse;margin-top:-1px;\" border=\"0\">
                                                       <tr>
                                                           <td valign=\"middle\" align=\"center\">
                                                                <div id=\"lblrupiahs\" style=\"color:gray;font-size:24px;font-weight:bold;width:100%;\">0.00</div>
                                                           </td>
                                                       </tr>                           
                                                   </table> 
                                               </td>
                                           </tr>
                                       </tbody>
                                    </table>
                                </td>
                             </tr>
                        </table>
                  </div>";
        }
        
        public function SHOW_POPUPTEXT($xpos,$ypos,$objdisplay)
        {            
            echo "<div id=\"div_popup\" style=\"position:absolute;margin-top:".$xpos."px;margin-left:".$ypos."px;width:300px;visibility:hidden;\">
                       <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
                            <tr>
                                <td>
                                    <table id=\"rounded-rupiah\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
                                        <thead>
                                           <tr>
                                               <th class=\"rounded-rpleft\" width=\"5%\">&nbsp;</th>
                                               <th>Set Text To Popup</th>
                                               <th class=\"rounded-rpright\" width=\"7%\">
                                                   <a href=\"javascript:void(0);\" style=\"border:0px;\" onClick=\"closeobj('div_popup','txtpopup');\">
                                                      <img src=\"".PATH_THEME."/css/table-images/closerp.png\" border=\"0\"/>
                                                   </a>
                                               </th>
                                           </tr>
                                        </thead> 
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td> 
                                    <table id=\"rounded-rupiah\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
                                       <tbody>
                                           <tr>
                                               <td>
                                                   <table style=\"width:100%;height:60px;background-color:white;border-color:#a7c942;border-collapse:collapse;margin-top:-1px;\" border=\"0\">
                                                       <tr>
                                                           <td valign=\"top\" align=\"left\">
                                                                <div id=\"div_text\" style=\"color:gray;font-size:24px;font-weight:bold;width:100%;\">";
                                                                    $arrprop=array("style="=>"width:100%;height:40px;");
                                                                    echo $this->CREATE_INPUT_OBJECT("text","txtpopup","txtpopup","",$arrprop);                                                      
            echo "                                              </div>";
                                                                $arrprop=array("value="=>"\"Set\"","style="=>"\"width:80px;\"");
                                                                $event="if(document.getElementById('$objdisplay').tagName=='DIV')";
                                                                $event.="{";
                                                                $event.="   document.getElementById('$objdisplay').innerHTML=txtpopup.value;";
                                                                $event.="}";
                                                                $event.="else";
                                                                $event.="{";
                                                                $event.="   document.getElementById('$objdisplay').value=txtpopup.value;";                                                                
                                                                $event.="}";
                                                                echo $this->CREATE_INPUT_OBJECT("button","btnset","btnset","onClick=\"$event;closeobj('div_popup','txtpopup');\"",$arrprop);
            echo "                                         </td>
                                                       </tr>                           
                                                   </table> 
                                               </td>
                                           </tr>
                                       </tbody>
                                    </table>
                                </td>
                             </tr>
                        </table>
                  </div>";
        }
        
        public function CREATE_COMBOSTRAP($comboname,$arr_or_query,$event,$withoutindex1=null,$valselected=null,$propertyonARRAY=null)
        {
            $styleprop="";
            if($propertyonARRAY)
            {
                foreach($propertyonARRAY as $arr=>$arrvalue)
                {
                    $styleprop.=$arr.$arrvalue." ";
                }
            }
            $withclass=false;
            if(preg_match("/^class/",$styleprop)){$withclass=true;}
            $rtn="<select id=\"".$comboname."\" name=\"".$comboname."\" onChange=\"$event\" $styleprop>";
            if(is_null($withoutindex1)||$withoutindex1=='')
            {
                if($withclass)
                {$rtn.="<option value=\"\" />";}
                else
                {$rtn.="<option value=\"\"></option>";}
                
            }
            if(is_array($arr_or_query))
            {
               while(list($val,$opt)=each($arr_or_query))
               {
                   $s="";
                   if($valselected==$val){$s="selected";}
                   if($withclass)
                   {$rtn.="<option value=\"$val\" $s />$opt";}
                   else
                   {$rtn.="<option value=\"$val\" $s>$opt</option>";}
               }
            }
            else
            {
                 $rsqry=$this->selectquery($arr_or_query);
                 if($rsqry)
                 {
                     while($rw=$this->data_row_array($rsqry))
                     {
                         $s="";
                         if($valselected==$rw[0]){$s="selected";}
                         if($withclass)
                         {$rtn.="<option value=\"".$rw[0]."\" $s />".$rw[1];}
                         else
                         {$rtn.="<option value=\"".$rw[0]."\" $s>".$rw[1]."</option>";}
                         
                     }
                 }
                 $this->clearrecordset($rsqry);
            }
            $rtn.="</select>";
            return $rtn;
        }

        public function CREATE_COMBO($comboname,$arr_or_query,$event,$withoutindex1=null,$valselected=null,$propertyonARRAY=null)
        {
            $styleprop="";
            if($propertyonARRAY)
            {
                foreach($propertyonARRAY as $arr=>$arrvalue)
                {
                    $styleprop.=$arr.$arrvalue." ";
                }
            }
            $rtn="<select id=\"".$comboname."\" name=\"".$comboname."\" onChange=\"$event\" $styleprop>";
            if(is_null($withoutindex1)||$withoutindex1==''){$rtn.="<option />";}
            if($arr_or_query)
            {
                if(is_array($arr_or_query))
                {
                   while(list($val,$opt)=each($arr_or_query))
                   {
                       $s="";
                       if($valselected==$val){$s="selected";}
                       $rtn.="<option value=\"$val\" $s>$opt</option>";   
                   }
                }
                else
                {
                     $rsqry=$this->selectquery($arr_or_query);
                     if($rsqry)
                     {
                         while($rw=$this->data_row_array($rsqry))
                         {
                             $s="";
                             if($valselected==$rw[0]){$s="selected";}
                             //echo $valselected.' '.$rw[0];
                             //$rtn.="<option value=\"".$rw[0]."\" $s>".$rw[1]."</option>";
                             $rtn.="<option value=\"".$rw[0]."\" $s>".$rw[1]."</option>";
                         }
                     }
                     $this->clearrecordset($rsqry);
                }                
            }
            $rtn.="</select>";
            return $rtn;
        }
        
        public function CONVEDATETOMYSQL($datevalue)
        {
            $dtsplit=explode("/",$datevalue);
            return $dtsplit[2]."-".$dtsplit[1]."-".$dtsplit[0]; //conversi date format d/m/Y ke YYYY-mm-dd
        }
        
        public function mosRedirect($url, $msg='' )
        {
            if(trim($msg))
            {
                if(strpos($url, '?' ))
                {$url.= "&mosmsg=$msg";} 
                else
                {$url.= "?mosmsg=$msg";}
            }
            if(headers_sent())
            {echo "<script>document.location.href='$url';</script>\n";}
            else
            {header("Location: $url" );}
            exit();
        }
        
    }
?>
