<?php

class settings {

    var $pagename = 'index.php?module=settings'; // Attribute of Page Name
    var $int_glcode;   // KEY ATTR. WITH AUTOINCREMENT
    var $var_title;
    var $var_alias;   // (normal Attribute)
    var $var_introtext;
    var $var_meta_title;
    var $var_meta_keyword;
    var $var_meta_description;
    var $var_commanmetatags;
    var $int_hits;
    var $int_displayorder;
    var $dt_startdate;
    var $dt_expiredate;
    var $dt_createddate;
    var $chr_read;
    var $chr_star;
    var $chr_publish;
    var $intdisplayorder;   // (normal Attribute)
    var $chr_delete = 'Y';   // (normal Attribute)
    var $dt_createdate;   // (normal Attribute)
    var $dt_modifydate;   // (normal Attribute)
    var $var_advertisepath;
    var $chr_advertisetype;
    var $var_link;
    var $var_text;
    var $var_description;
    var $oldintdisplayorder; // Attribute of Old Displayorder
    var $numofrows; // Attribute of Num Of Rows In Result
    var $numofpages; // Attribute of Num Of Pages In Result
    var $orderby = 'int_glcode'; // Attribute of Deafult Order By
    var $ordertype = 'desc'; // Attribute of Deafult Order By
    var $searchby = '0'; // Attribute of Search By
    var $searchtxt; // Attribute of Search Text
    var $start = 1; // Attribute of Start For Paging
    var $pagesize = DEFAULT_PAGESIZE; // Attribute of Pagesize For Paging
    var $pagenumber = '1'; // Attribute of Page Number For Paging
    var $lastinsertid; // Attribute of Last Inserid
    var $urlwithpara = ''; // Attribute of URL With parameters
    var $hurlwithpara = ''; // Attribute of URL With parameters
    var $urlwithpoutsearch = ''; // Attribute of URL With parameters without searh
    var $urlwithoutsort = ''; // Attribute of URL With parameters without sort
    var $urlwithoutpaging = ''; // Attribute of URL With parameters without paging
    var $configObj;
    var $filterby = '0';
    var $urlwithoutfilter = '';
    var $display_limit_array = array(5, 10, 15, 30);
    var $varpostdata = array();
    var $file;
    var $a = array();
    var $d = array();

    function settings($configObj) {
        $this->sortvar = '<img alt="sorting" src="' . GLOBAL_ADMIN_IMAGES_PATH . 'arrow-up.png" style="vertical-align:middle;">';
        $this->configObj = $configObj;
    }

    // **********************
    // Intitialize METHOD
    // **********************
    function initialize($view) {
        if (!empty($_REQUEST['history'])) {
            $this->configObj->glLibraryObj->hintitialize($this);
            return;
        }
        $this->chr_action = ($_REQUEST['chr_action'] != '' || $_REQUEST['chr_action'] != '0') ? $_REQUEST['chr_action'] : '';
        $this->modval = ($_REQUEST['modval'] != '' || $_REQUEST['modval'] != '0') ? $_REQUEST['modval'] : '';
        $_REQUEST['searchtxt'] = ($_REQUEST['type'] == 'autosearch') ? $_REQUEST['term'] : $_REQUEST['searchtxt'];
        $this->searchby = (isset($_REQUEST['searchby'])) ? $_REQUEST['searchby'] : $this->searchby;
        $this->searchbyVal = (isset($_REQUEST['searchbyVal'])) ? $_REQUEST['searchbyVal'] : $this->searchbyVal;
        $this->searchtxt = (isset($_REQUEST['searchtxt'])) ? urldecode($_REQUEST['searchtxt']) : '';
        $this->searchtxtjs = (isset($_REQUEST['searchtxt'])) ? urlencode($_REQUEST['searchtxt']) : '';
        $this->orderby = (isset($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : $this->orderby;
        $this->ordertype = (isset($_REQUEST['ordertype'])) ? $_REQUEST['ordertype'] : $this->ordertype;
        $this->filterby = (isset($_REQUEST['filterby'])) ? $_REQUEST['filterby'] : $this->filterby;

        if (isset($_REQUEST['sorting'])) {
            if ($this->ordertype == "asc") {  // This is for sort image
                $this->ordertype = "desc";
                $this->sortvar = "<img alt=\"sorting\" src=\"" . GLOBAL_ADMIN_IMAGES_PATH . "arrow-down.png\" style=\"vertical-align:middle;\">";
            } else if ($this->ordertype == "desc") {   // This is for sort image
                $this->ordertype = "asc";
                $this->sortvar = "<img alt=\"sorting\" src=\"" . GLOBAL_ADMIN_IMAGES_PATH . "arrow-up.png\" style=\"vertical-align:middle;\">";
            }
        }
        if ($view == "templates") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_template();
        } else if ($view == "modules") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_modules();
        } else if ($view == "positions") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_positions();
        } else if ($view == "logmanager") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_logmanager();
        } else if ($view == "emails") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_emails();
        } else if ($view == "features") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_features();
        } else if ($view == "highlight") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_highlight();
        } else if ($view == "rating") {
            $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->CountRows_rating();
        }

        $this->pagesize = (isset($_REQUEST['pagesize'])) ? $_REQUEST['pagesize'] : $this->pagesize;

        $this->pagenumber = (isset($_REQUEST['pagenumber'])) ? $_REQUEST['pagenumber'] : $this->pagenumber;

        $this->noofpages = intval($this->numofrows / $this->pagesize);

        $this->noofpages = (($this->numofrows % $this->pagesize) > 0) ? ($this->noofpages + 1) : ($this->noofpages);

        $this->start = ($this->pagenumber - 1 ) * $this->pagesize;
    }

    // **********************
    // SELECTALL METHOD / LOAD
    // **********************
    function CountRows_template() {
        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_themename like '%$this->searchtxt%'" : " and $this->searchby like '%$this->searchtxt%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);

            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }
        $sqlCountPages = "select count(1) as total from " . DB_PREFIX . "themes where chr_delete = 'N' $whereclause ";

        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountPages);

        $this->numofrows = $rs['total'];

        return $rs['total'];
    }

    function CountRows_modules() {
        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_modulename like '%$this->searchtxt%'" : " and $this->searchby like '%$this->searchtxt%'";
        }



        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);

            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $sqlCountPages = "select count(1) as total from " . DB_PREFIX . "modules where chr_delete = 'N' $whereclause ";

        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountPages);

        $this->numofrows = $rs['total'];

        return $rs['total'];
    }

    function CountRows_positions() {
        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_positionname like '%$this->searchtxt%'" : " and $this->searchby like '%$this->searchtxt%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);

            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $sqlCountPages = "select count(1) as total from " . DB_PREFIX . "positions where chr_delete = 'N' $whereclause ";

        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountPages);

        $this->numofrows = $rs['total'];

        return $rs['total'];
    }

    function CountRows_logmanager() {

        if (trim($this->searchtxt) != '') {

            $whereclause .= ($this->searchby == '0') ? " and($this->searchbyVal like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%') " : " and $this->searchby like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%'";
        }

        if ($this->modval != '0' && $this->modval != '') {
            $filtermodule = explode('-', $this->modval);
            if ($filtermodule[1] == 'm') {
                $whereclause .=" and FIND_IN_SET('" . $filtermodule[0] . "',fk_modulename) and chr_custom='N'";
            } else {
                $whereclause .=" and FIND_IN_SET('" . $filtermodule[0] . "',fk_modulename) and chr_custom='Y'";
            }
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }
        if ($this->configObj->glSessionObj->value('chr_user') == 'A') {
            $whereclause.="and var_fname!='Netclues' ";
        }
        if ($this->chr_action != '0' && $this->chr_action != '') {
            $whereclause .=" and var_operation ='" . $_REQUEST['chr_action'] . "'";
        }
        if ($this->configObj->glSessionObj->value('admin_id') != '1' && $this->configObj->glSessionObj->value('chr_user') != 'A') {
            $admin = '"' . ADMIN_NAME . '"';
            $whereclause.="and var_fname=" . $admin . " ";
        }

        $sqlCountPages = "select count(1) as total from " . DB_PREFIX . "logmanager where chr_publish = 'Y' $whereclause ";
        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountPages);
        $this->numofrows = $rs['total'];
        return $rs['total'];
    }

    function CountRows_emails() {
        $whereclause = " where e.chr_delete = 'N' ";
        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and et.var_type like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%'" : " and $this->searchby like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        if ($_REQUEST['modval'] != '0' && $_REQUEST['modval'] != '') {
            $whereclause .=" and fk_emailtype = '" . $_REQUEST['modval'] . "'";
        }
        $sqlCountPages = "select count(1) as total from " . DB_PREFIX . "emails as e left join " . DB_PREFIX . "emailtype as et on e.fk_emailtype = et.int_glcode $whereclause ";
        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountPages);
        $this->numofrows = $rs['total'];

        return $rs['total'];
    }

    function CountRows_features() {
        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_tablename like '%$this->searchtxt%'" : " and $this->searchby like '%$this->searchtxt%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);

            $whereclause .=" and mf." . $filterarray[0] . " = '$filterarray[1]'";
        }

        $sqlCountPages = "select count(1) as total from " . DB_PREFIX . "modules_features mf join " . DB_PREFIX . "modules m  on mf.fk_module=m.int_glcode" . $whereclause;

        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountPages);

        $this->numofrows = $rs['total'];

        return $rs['total'];
    }

    // **********************
    // SELECTALL METHOD / LOAD
    // **********************

    function selectall_templates() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'themes');
        $this->configObj->glDbObj->addColumn('*');
        $whereclause = "chr_delete = 'N'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_themename like '%" . mysql_real_escape_string($this->searchtxt) . "%' " : " and $this->searchby  like '%" . mysql_real_escape_string($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    function select_default_templates() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'themes');
        $this->configObj->glDbObj->addColumn('int_glcode');
        $whereclause = "chr_delete = 'N' and chr_publish='Y'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_themename like '%" . mysql_real_escape_string($this->searchtxt) . "%' " : " and $this->searchby  like '%" . mysql_real_escape_string($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    function selectall_modules() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules');
        $this->configObj->glDbObj->addColumn('*');
        $whereclause = "chr_delete = 'N'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_modulename like '%" . mysql_real_escape_string($this->searchtxt) . "%' " : " and $this->searchby  like '%" . mysql_real_escape_string($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    function selectall_positions() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'positions');
        $this->configObj->glDbObj->addColumn('*');
        $whereclause = "chr_delete = 'N'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and var_positionname like '%" . mysql_real_escape_string($this->searchtxt) . "%' " : " and $this->searchby  like '%" . mysql_real_escape_string($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    function selectall_systemsettings() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');
        $this->configObj->glDbObj->addColumn('*');
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $row = $this->configObj->glDbObj->get_sql_row($this->configObj->glDbObj->buildQuery());
        return $row;
    }

    function notused_selectall_youtubevideo() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'videos');
        $this->configObj->glDbObj->addColumn('*');
        $whereclause = "chr_delete = 'N' and chr_publish = 'Y'";


        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    function selectall_logmanager() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'logmanager');
        $this->configObj->glDbObj->addColumn('*,dt_operationdate as date');

        $whereclause = "chr_publish = 'Y'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and($this->searchbyVal like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%') " : " and $this->searchby like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%'";
        }

        if ($this->modval != '0' && $this->modval != '') {
            $filtermodule = explode('-', $this->modval);

            if ($filtermodule[1] == 'm') {
                $whereclause .=" and FIND_IN_SET('" . $filtermodule[0] . "',fk_modulename) and chr_custom='N'";
            } else {
                $whereclause .=" and FIND_IN_SET('" . $filtermodule[0] . "',fk_modulename) and chr_custom='Y'";
            }
        }

        if ($this->chr_action != '0' && $this->chr_action != '') {
            $whereclause .=" and var_operation ='" . $_REQUEST['chr_action'] . "'";
        }

        if ($this->configObj->glSessionObj->value('chr_user') == '2') {
            $whereclause.="and var_fname!='Netclues' ";
        }
        $admin = '"' . ADMIN_NAME . '"';
        if ($this->configObj->glSessionObj->value('admin_id') != '1' && $this->configObj->glSessionObj->value('chr_user') != 'A') {
            $whereclause.="and var_fname='" . ADMIN_NAME . "' ";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);



        if ($_REQUEST['type'] == 'autosearch') {

            if (empty($this->searchbyVal)) {
                
            } else {
                $selectField = $this->searchbyVal;
                $querysearch = "select distinct $selectField as AutoVal FROM " . DB_PREFIX . "logmanager where $whereclause $searchbyVal group by $selectField $orderby";
            }
            $orderby = (isset($_REQUEST['orderby'])) ? 'order by ' . $this->orderby . ' ' . $this->ordertype : 'order by int_displayorder';
            $searchbyVal = (!empty($this->searchbyVal)) ? " chr_publish = 'Y' and {$this->searchbyVal} like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%' " : "$whereclause";
            $autoSearchQry = $querysearch;

            $this->configObj->glLibraryObj->GetAutoSearch($autoSearchQry);
        }

        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    // **********************
    // Generate URL
    // **********************

    function Generateurl() {

        if ($_REQUEST['view'] != '') {
            $view = '&view=' . $_REQUEST['view'];
        }
        $this->urlwithpara = $this->pagename . '&' . 'pagesize=' . $this->pagesize . '&numofrows=' . $this->numofrows . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&searchby=' . $this->searchby . '&searchtxt=' . $this->searchtxtjs . '&pagenumber=' . $this->pagenumber . '&filterby=' . $this->filterby . '&modval=' . $this->modval . '&chr_action=' . $this->chr_action . $view;

        $this->hurlwithpara = $this->pagename . '&' . 'hpagesize=' . $this->pagesize . '&hnumofrows=' . $this->numofrows . '&horderby=' . $this->orderby . '&hordertype=' . $this->ordertype . '&hsearchby=' . $this->searchby . '&hsearchtxt=' . $this->searchtxtjs . '&hpagenumber=' . $this->pagenumber . '&modval=' . $this->modval . '&hfilterby=' . $this->filterby . '&history=T' . '&chr_action=' . $this->chr_action . $view;

        $this->urlwithpoutsearch = $this->pagename . '&' . 'pagesize=' . $this->pagesize . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&filterby=' . $this->filterby . '&modval=' . $this->modval . '&chr_action=' . $this->chr_action . $view;

        $this->urlwithoutsort = $this->pagename . '&' . 'pagesize=' . $this->pagesize . '&numofrows=' . $this->numofrows . '&searchby=' . $this->searchby . '&searchtxt=' . $this->searchtxtjs . '&pagenumber=' . $this->pagenumber . '&ordertype=' . $this->ordertype . '&filterby=' . $this->filterby . '&modval=' . $this->modval . '&chr_action=' . $this->chr_action . $view;

        $this->urlwithoutpaging = $this->pagename . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&searchby=' . $this->searchby . '&searchtxt=' . $this->searchtxtjs . '&filterby=' . $this->filterby . '&modval=' . $this->modval . '&chr_action=' . $this->chr_action . $view;

        $this->urlwithoutfilter = $this->pagename . '&' . 'pagesize=' . $this->pagesize . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&searchby=' . $this->searchby . '&searchtxt=' . $this->searchtxtjs . '&modval=' . $this->modval . '&chr_action=' . $this->chr_action . $view;

        $this->urlwithoutmoduleid = $this->pagename . '&pagesize=' . $this->pagesize . '&numofrows=' . $this->numofrows . '&chr_action=' . $this->chr_action .
                '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&searchby=' . $this->searchby .
                '&searchtxt=' . $this->searchtxt . '&pagenumber=' . $this->pagenumber . '&filterby=' . $this->filterby . '&modval=' . $this->modval . $view;
        $this->configObj->AutoSearchUrl = $this->urlwithpara . "&type=autosearch&searchbyVal=" . $this->searchbyVal . '&chr_action=' . $this->chr_action . $view;
    }

    function org_generateParam($view = '', $actionurl = '', $searcharray = array("var_themename" => "Template"), $tablename = "", $position = 'top') {

        $filterPos = ($position == 'top') ? 'FT' : 'FB';
        if ($view != "Emails") {
            if ($position == 'top' && $_REQUEST['view'] == 'emails') {
                $modcmb = $this->emailtype();
            } else if ($position == 'top') {
                $modcmb = $this->Bindmodule();
                $actioncmb = $this->getoperationcmb();
            }
        }

        if ($this->configObj->glSessionObj->value('admin_id') == '1') {
            $filterstar = array('filterarray' => array('chr_read-Y' => 'Read Only',
                    'chr_read-N' => 'Unread Only',
                    'chr_star-Y' => 'Star Only',
                    'chr_star-N' => 'Unstar Only'
                ),
                'filterurl' => $this->urlwithoutfilter,
                'filterposition' => $filterPos,
                'filterby' => $this->filterby
            );
        } else {

            $filterstar = array();
        }

        return array('pageurl' => $this->pagename,
            'heading' => $view,
            'listImage' => 'add-new-user-icon.png',
            'tablename' => $tablename,
            'position' => $position,
            'actionImage' => 'add-new-button-blue.gif',
            'actionImageHover' => 'add-new-button-blue-hover.gif',
            'actionUrl' => $actionurl,
            'search' => array('searchArray' => $searcharray,
                'searchBy' => $this->searchby,
                'searchText' => $this->searchtxt,
                'searchUrl' => $this->urlwithpoutsearch
            ),
            'filter' => $filterstar,
            'paging' => array('pagenumber' => $this->pagenumber,
                'noofpages' => $this->noofpages,
                'numofrows' => $this->numofrows,
                'pagingurl' => $this->urlwithpara
            ),
            'display' => array('displayurl' => $this->urlwithoutpaging,
                'pagesize' => $this->pagesize,
                'limitarray' => $this->display_limit_array,
            ),
            'modcmb' => $modcmb,
            'actioncmb' => $actioncmb,
        );
    }

    // **********************
    // Update Display
    // **********************

    function update_default() {  // To set the Display Falg Yes of No
        $this->configObj->glDbObj->resetfields();
        $this->configObj->glDbObj->setQueryType('update');
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'themes');

        // Set the Columns

        $this->configObj->glDbObj->addColumn('chr_publish');
        $this->configObj->glDbObj->addColumn('dt_modifydate');

        // Set the Values

        $this->configObj->glDbObj->addValue($this->defaultflag);
        $this->configObj->glDbObj->addValue('NOW()');

        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->newdefaultid);

        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());

        // For old default theme

        $this->configObj->glDbObj->addColumn('chr_publish');
        $this->configObj->glDbObj->addColumn('dt_modifydate');

        // Set the Values

        $this->configObj->glDbObj->addValue('N');
        $this->configObj->glDbObj->addValue('NOW()');

        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->olddefaultid);
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
    }

    function update_display() {  // To set the Display Falg Yes of No
        $this->configObj->glDbObj->resetfields();
        $this->configObj->glDbObj->setQueryType('update');
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules');

        // Set the Columns

        $this->configObj->glDbObj->addColumn('chr_publish');
        $this->configObj->glDbObj->addColumn('dt_modifydate');

        // Set the Values

        $this->configObj->glDbObj->addValue($this->displayflag);
        $this->configObj->glDbObj->addValue('NOW()');

        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->displayid);
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
    }

    function update_display_position() {  // To set the Display Falg Yes of No
        $this->configObj->glDbObj->resetfields();
        $this->configObj->glDbObj->setQueryType('update');
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'positions');

        // Set the Columns

        $this->configObj->glDbObj->addColumn('chr_publish');
        $this->configObj->glDbObj->addColumn('dt_modifydate');

        // Set the Values

        $this->configObj->glDbObj->addValue($this->displayflag);
        $this->configObj->glDbObj->addValue('NOW()');

        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->displayid);
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
    }

    function update_cache() {  // To set the Display Falg Yes of No
        $this->configObj->glDbObj->resetfields();
        $this->configObj->glDbObj->setQueryType('update');
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules');

        // Set the Columns

        $this->configObj->glDbObj->addColumn('chr_cached');
        $this->configObj->glDbObj->addColumn('dt_modifydate');

        // Set the Values

        $this->configObj->glDbObj->addValue($this->cacheflag);
        $this->configObj->glDbObj->addValue('NOW()');

        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->cacheid);
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
    }

    //***********
    //Load Page
    //***********


    function load_templates() {
        $this->update_display_order($upidsarray, $upvalsarray, $upoldvalsarray);
        $this->configObj->glTplObj->set('numofrows', $this->numofrows);
        $result = $this->selectall_templates();
        $result1 = $this->select_default_templates();
        $this->pagename = "index.php?module=settings&view=templates";
        $this->configObj->glTplObj->set('result', $result);
        $this->configObj->glTplObj->set('result1', $result1);
        $this->Generateurl();
        $view = 'Template';
        $tablename = DB_PREFIX . 'themes';
        $searcharray = array("var_themename" => "Template");
        $parmas = $this->org_generateParam($view, $searcharray, $tablename);



        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas, 'no'));
        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));
        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->org_generateParam($view, $searcharray, $tablename, 'bottom')));

        $tmpsetsortvar = 'setsortimg' . $this->orderby;
        $$finalsortvar = $tmpsetsortvar;
        $this->configObj->glTplObj->set($$finalsortvar, $this->sortvar);



        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('template.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('template.tpl.php');
        }
    }

    function load_landingpage() {

        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('web-design-development-services-html.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('web-design-development-services-html.tpl.php');
        }
    }

    function rem_special_chars($string) {
        $string = stripslashes($string);
        $string = eregi_replace("'", "&#039;", $string);
        $string = eregi_replace('"', '&quot;', $string);
        return $string;
    }

    function save_file($file_path, $file_content) {
        global $settingsObj;

        (string) $display_output = null;

        $file_content = $settingsObj->add_special_chars($file_content);

        if (is_writable($file_path)) {
            $fp = fopen($file_path, 'w');

            if (!$fp) {
                $display_output = GMSG_CANNOT_OPEN_FILE . ' [ ' . $file_path . ' ]';
            } else if (!fwrite($fp, $file_content)) {
                $display_output = GMSG_FILE_NOT_EDITABLE . ' [ ' . $file_path . ' ]';
            } else {
                $display_output = GMSG_FILE_UPDATED . ' [ ' . $file_path . ' ]';
            }

            fclose($fp);
        } else {
            $display_output = GMSG_FILE_NOT_WRITABLE . ' [ ' . $file_path . ' ]';
        }
        return $display_output;
    }

    function gettabledataData($tablename) {
        $selectids = $_REQUEST['chkids'];

        $selectarray = explode(',', $selectids);
        $totaldeletedrecords = count($selectarray);
        $exportarry = array();
        for ($i = 0; $i < $totaldeletedrecords; $i++) {
            $data = "select var_fname from " . DB_PREFIX . $tablename . " where int_glcode = '" . $selectarray[$i] . "'";
            $result = $this->configObj->glDbObj->query($data);
            //echo chr_delivered; exit; 
            if ($tablename == 'logmanager') {

//                  $sel="SELECT aoa_downloadfiles.*,aoa_emails.*,aoa_doc_gallery.*,aoa_doc_gallery.*,aoa_emailtype.*,aoa_faq.*,aoa_financial_category.*,aoa_forms.*,aoa_homebanner.*,aoa_link.*,aoa_news.*,aoa_newslatterleads.*,aoa_pagephoto.*,aoa_pages.*,aoa_polices.*,aoa_pressrelease.*,aoa_reports.*,aoa_reports_category.*,aoa_servicefeedback.*,aoa_team.*,aoa_logmanager.* FROM join_o left JOIN aoa_logmanager ON join_o.id=aoa_logmanager.fk_modulename";


                if ($_REQUEST['chkids'] != '') {

// two table join query

                    $sql = "select int_glcode as No, var_modulename as Module_Name, var_name as Name, var_fname as User_Name, DATE_FORMAT(dt_operationdate,'%m-%d-%Y') as Date,DATE_FORMAT(dt_operationdate,'%I:%i:%s %p') as Time, var_ipaddress as Ip_Address, case when var_operation='D' then 'Delete' when var_operation='I' then 'Insert' when var_operation='U' then 'Update' end as Operation from ecl_logmanager  where  int_glcode IN($selectids)";
                } else {

                    $sql = "select int_glcode as No,var_modulename as Module_Name,var_name  as Name,var_fname as User_Name,DATE_FORMAT(dt_operationdate,'%m-%d-%Y') as Date,DATE_FORMAT(dt_operationdate,'%I:%i:%s %p') as Time,var_ipaddress as Ip_Address,case when var_operation='D' then 'Delete' when var_operation='I' then 'Insert' when var_operation='U' then 'Update' end as Operation from ecl_logmanager";
                }
            }
        }
        return $sql;
    }

    function add_special_chars($string, $no_quotes = FALSE) {
        $pattern = "/(?i)<img.+\.php/";

        $string = eregi_replace("&amp;", "&", $string);

        if (!$no_quotes)
            $string = eregi_replace("&#039;", "'", $string);

        $string = eregi_replace('&quot;', '"', $string);
        $string = eregi_replace('&lt;', '<', $string);
        $string = eregi_replace('&gt;', '>', $string);
        $string = eregi_replace('&nbsp;', ' ', $string);

        $string = (preg_match($pattern, $string)) ? strip_tags($string, '<br>') : $string;

        return $string;
    }

    function GetMessagebox($message, $cssclass = "confirmation-div") {
        return "<div class=\"$cssclass\"><strong>$message</strong></div>";
    }

    //fetures start

    function load_features() {
        $this->configObj->glTplObj->set('numofrows', $this->numofrows);
        $result = $this->getFeatures();
        $this->pagename = "index.php?module=settings&view=features";
        $this->configObj->glTplObj->set('result', $result);
        $this->Generateurl();
        $view = 'Received Change(s)';
        $tablename = DB_PREFIX . 'modules_features';
        $searcharray = array();
        $parmas = $this->org_generateParam($view, $searcharray, $tablename);

        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas, 'no'));
        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));
        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->org_generateParam($view, $searcharray, $tablename, 'bottom')));

        $tmpsetsortvar = 'setsortimg' . $this->orderby;
        $$finalsortvar = $tmpsetsortvar;
        $this->configObj->glTplObj->set($$finalsortvar, $this->sortvar);



        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('features.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('features.tpl.php');
        }
    }

    function getFeatures() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules_features mf join ' . DB_PREFIX . 'modules m on mf.fk_module=m.int_glcode');
        $this->configObj->glDbObj->addColumn('mf.*,mf.int_glcode as int_glcode,m.var_modulename');
        $whereclause = "mf.chr_delete = 'N'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and mf.var_name like '%" . mysql_real_escape_string($this->searchtxt) . "%' " : " and $this->searchby  like '%" . mysql_real_escape_string($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and mf.$filterarray[0] = '$filterarray[1]'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy('mf.int_glcode desc');
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());

        return $rs;
    }

    function load_modules() {

        $this->configObj->glTplObj->set('numofrows', $this->numofrows);
        $result = $this->selectall_modules();
        $this->pagename = "index.php?module=settings&view=modules";
        $this->configObj->glTplObj->set('result', $result);
        $this->Generateurl();

        $view = 'Module';
        $tablename = DB_PREFIX . 'modules';
        $searcharray = array("var_modulename" => "Module");

        $parmas = $this->org_generateParam($view, $searcharray, $tablename);


        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas, 'no'));
        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));
        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->org_generateParam($view, $searcharray, $tablename, 'bottom')));

        $tmpsetsortvar = 'setsortimg' . $this->orderby;
        $$finalsortvar = $tmpsetsortvar;
        $this->configObj->glTplObj->set($$finalsortvar, $this->sortvar);

        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('module.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('module.tpl.php');
        }
    }

    function load_position() {

        $this->configObj->glTplObj->set('numofrows', $this->numofrows);
        $result = $this->selectall_positions();
        $this->pagename = "index.php?module=settings&view=positions";
        $this->configObj->glTplObj->set('result', $result);
        $this->Generateurl();
        $view = 'Position';
        $tablename = DB_PREFIX . 'positions';
        $searcharray = array("var_positionname" => "Position");

        $parmas = $this->org_generateParam($view, $searcharray, $tablename);


        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas, 'no'));
        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));
        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->org_generateParam($view, $searcharray, $tablename, 'bottom')));


        $tmpsetsortvar = 'setsortimg' . $this->orderby;
        $$finalsortvar = $tmpsetsortvar;
        $this->configObj->glTplObj->set($$finalsortvar, $this->sortvar);



        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('position.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('position.tpl.php');
        }
    }

    function load_systemsettings() {
        $this->pagename = "index.php?module=settings&view=system";
        $row = $this->selectall_systemsettings();
        $this->configObj->glTplObj->set('row', $row);

        $this->Generateurl();
        $gridtabarray = array(array("General", "$settingsObj->urlwithoutmoduleid" . "&p=gen", "gen"),
            array("SMTP", "$settingsObj->urlwithoutmoduleid" . "&p=ser", "ser"),
            array("Currency", "$settingsObj->urlwithoutmoduleid" . "&p=cur", "cur"),
            array("SEO", "$settingsObj->urlwithoutmoduleid" . "&p=seo", "seo")
        );

        if ($_REQUEST['msg']) {
            if ($_REQUEST['msg'] == 'add') {
                $messagebox = $this->configObj->glLibraryObj->message("Congrats! Data Successfully Saved!");
                $this->configObj->glTplObj->set('messagebox', $messagebox);
            } else if ($_REQUEST['msg'] == 'edit') {
                $messagebox = $this->configObj->glLibraryObj->message("Congrats! The data has been successfully edited and saved.");
                $this->configObj->glTplObj->set('messagebox', $messagebox);
            }
        }

        if ($this->configObj->isAjaxSet) {
            $p = $_REQUEST['p'];
            $this->configObj->glTplObj->set('p', $p);
            $this->configObj->glTplObj->set("gridtabs", $this->GetGridTabs($gridtabarray, $p, true));
            echo $this->configObj->glTplObj->process('systemsettings.tpl.php');
            exit;
        } else {
            $this->configObj->glTplObj->set("gridtabs", $this->GetGridTabs($gridtabarray, $p, true));
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('systemsettings.tpl.php');
        }
    }

    function get_fk_modules($module) {
        $sql = "SELECT int_glcode from " . DB_PREFIX . "modules WHERE var_modulename='$module' and chr_publish='Y' and chr_delete='N'";
        $rs = $this->configObj->glDbObj->get_sql_row($sql);
        $fk_tml_modules = 0;
        $fk_tml_modules = $rs['int_glcode'];
        return $fk_tml_modules;
    }

    function load_logmanager() {
        ///
        $this->loadCount('CountRows_logmanager');
        $this->pagename = "index.php?module=settings&view=logmanager";
        $this->configObj->glTplObj->set('result', $this->selectall_logmanager());
        $this->Generateurl();
        //

        $this->CountRows_logmanager();
        $this->configObj->glTplObj->set('numofrows', $this->numofrows);
        $result = $this->selectall_logmanager();
        $this->pagename = "index.php?module=settings&view=logmanager";
        $this->configObj->glTplObj->set('result', $result);
        $this->Generateurl();

        $view = 'Log Manager';
        $tablename = DB_PREFIX . 'logmanager';
        $searcharray = array("var_modulename" => "Module Name", "var_name" => "Name", "var_fname" => "User Name", "var_ipaddress" => "Ip Address");


        $parmas = $this->org_generateParam($view, $actionurl, $searcharray, $tablename);

        $actionurl = 'index.php?module=settings&view=' . $_REQUEST['view'];
        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas, 'no'));
        ////echo $configObj->glLibraryObj->generatePagingPannel($parmas);exit;
        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));
        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->org_generateParam($view, $actionurl, $searcharray, $tablename, 'bottom')));
        $notemessagebox = $this->configObj->glLibraryObj->notemessage("Note : ", "Please take a note that the records which are 60 days older will be automatically deleted from the database and will not be available later on into the PowerPanel.");
        $this->configObj->glTplObj->set('notemessagebox', $notemessagebox);
        $tmpsetsortvar = 'setsortimg' . $this->orderby;
        $$finalsortvar = $tmpsetsortvar;
        $this->configObj->glTplObj->set($$finalsortvar, $this->sortvar);

        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('logmanager.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('logmanager.tpl.php');
        }
    }

    function is_logused($fk_modules) {

        $deleteids = $_REQUEST['dids'];
        $deletearray = explode(',', $deleteids);
        $totaldeletedrecords = count($deletearray);
        //echo "<pre>";
        //print_r($deletearray);
        //exit;
        for ($i = 0; $i < $totaldeletedrecords; $i++) {

            $sql = "Update " . DB_PREFIX . "logmanager set chr_publish='N' where int_glcode='$deletearray[$i]'";
            //echo $sql;
            $this->configObj->glDbObj->query($sql);
        }
        $this->initialize($_REQUEST['view']);
        $this->load_logmanager();
        exit;
    }

    function GetGridTabs($arrtab, $activeident, $display = true, $filterbyuser = '') {

        if (!$display)
            return "";
        $str = "<div class='grid-tab-box'>";

        $activeleftcurv = GLOBAL_ADMIN_IMAGES_PATH . "tab-active-left-curv.jpg";
        $activerightcurv = GLOBAL_ADMIN_IMAGES_PATH . "tab-active-right-curv.jpg";
        $activeclass = "grid-tab-current";

        $leftcurv = GLOBAL_ADMIN_IMAGES_PATH . "tab-left-curv.jpg";
        $rightcurv = GLOBAL_ADMIN_IMAGES_PATH . "tab-right-curv.jpg";
        $class = "grid-tab";

        foreach ($arrtab as $arr) {
            // echo"<pre>";
            //print_r($arr);
            $abarray = array('SEO', '.Htaccess', 'Maintenance');
            if ($this->configObj->glSessionObj->value('chr_user') == 'A' && in_array($arr[0], $abarray)) {
                $flag = 'false';
            } else {
                $flag = 'true';
            }

            if ($flag == 'true') {
                $sendGridFunction = "SendGridBindRequest('$arr[1]','gridbody','tab','','','$arr[2]')";
                if ($arr[2] == $activeident) {
                    $str .= "<div style='float:left'><img src='" . $activeleftcurv . "' width='7' height='26' alt='teb left curv' /></div>
            <div class='" . $activeclass . "'><a id='" . $arr[2] . "' href=\"javascript:;\" onclick=\"$sendGridFunction\">" . $arr[0] . "</a></div>
            <div style='float:left;  margin-right:2px;'><img src='" . $activerightcurv . "' width='7' height='26' alt='teb left curv' /></div>";
                } else {
                    $str .= "<div style='float:left'><img src='" . $leftcurv . "' width='7' height='26' alt='teb left curv' /></div>
            <div class='" . $class . "'><a id='" . $arr[2] . "' href=\"javascript:;\" onclick=\"$sendGridFunction\">" . $arr[0] . "</a></div>
            <div style='float:left;  margin-right:2px;'><img src='" . $rightcurv . "' width='7' height='26' alt='teb left curv' /></div>";
                }
            }
        }


        $str .= "</div>";
        if ($filterbyuser != '') {
            $str .="<div class=\"by-user\">$filterbyuser</div>";
        }

        return $str;
    }

    // End of the grid tab binding
    function GetGridusercombo($filterbyuser = '') {
        $str = "<div class='grid-tab-box'>";

        if ($filterbyuser != '') {
            $str .="<div class=\"by-user\" style=\"padding-bottom:5px;\">$filterbyuser</div></div>";
        }
        return $str;
    }

    function delbrochure() {
        $this->configObj->glDbObj->resetfields();
        $this->configObj->glDbObj->setQueryType('update');
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');
        $this->configObj->glDbObj->addColumn('var_brochure');
        $this->configObj->glDbObj->addValue('');
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
    }

    function getYoutubeThumb($url, $dst_img, $dst_path, $dst_w, $dst_h, $dst_quality) {

        //echo $url."<br>";
        $img_name = $dst_img;

        $src_embed = $this->get_youtubevideo($url, $dst_w, $dst_h);

        //  echo $src_embed;
        preg_match('~http://[^/]+/v/([^&/]+)~', $src_embed, $match);
        $youtube_id = $match[1];

        $YouTubeThumbURL = 'http://img.youtube.com/vi/';

        $src_cpl = $YouTubeThumbURL . $youtube_id . '/default.jpg';

        $dst_cpl = $dst_path . "/" . basename($dst_img);

        // echo $src_cpl;exit;
        // echo $dst_cpl;exit;
        try {
            if (!$src_cpl) {
                throw new Exception("No such file or directory");
            } else {
                list($src_w, $src_h) = getimagesize($src_cpl);
                $src_img = imagecreatefromjpeg($src_cpl);
                // throw new TestException();
            }
        } catch (Exception $e) {
            echo 'Message: ' . $e->getMessage();
        }

        // exit;
        //Get heights and width so the image keeps its ratio.
        $x_ratio = $dst_w / $src_w;
        $y_ratio = $dst_h / $src_h;

        if ((($x_ratio > 1) || ($y_ratio > 1)) && ($x_ratio > $y_ratio)) {
            //If one of the sizes of the image is smaller than the destination (normal: more height than width).
            $dst_w = ceil($y_ratio * $src_w);
            $dst_h = $dst_h;
        } elseif ((($x_ratio > 1) || ($y_ratio > 1)) && ($y_ratio > $x_ratio)) {
            //If one of the sizes of the image is smaller than the destination (landscape: more width than height).
            $dst_w = $dst_w;
            $dst_h = ceil($x_ratio * $src_h);
        } elseif (($x_ratio * $src_h) < $dst_h) {
            //if the image is landscape (more width than height).
            $dst_h = ceil($x_ratio * $src_h);
            $dst_w = $dst_w;
        } elseif (($x_ratio * $src_h) > $dst_h) {
            //if the image is normal (more height than width).
            $dst_h = ceil($x_ratio * $src_h);
            $dst_w = $dst_w;
        } else {
            //if the image is normal (more height than width).
            $dst_w = ceil($y_ratio * $src_w);
            $dst_h = $dst_h;
        }

        // Creating the resized image.
        $dst_img = imagecreatetruecolor($dst_w, $dst_h);

        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_w, $dst_h, $src_w, $src_h);

        // Saving the resized image.
        imagejpeg($dst_img, $dst_cpl, $dst_quality);

        // Cleaning the memory.
        imagedestroy($src_img);
        imagedestroy($dst_img);
        //echo $img_name;
        return $img_name;
    }

    function get_youtubevideo($url, $height, $width) { //To get youtube video link Sanjay 120310
        preg_match("/v=([^&]+)/i", $url, $matches);

        $id = $matches[1];

        $YouTubeVideoURL = 'http://www.youtube.com/v/';
        $code = '<object width="' . $width . '" height="' . $height . '">';
        $code .= '<param name="movie" value="' . $YouTubeVideoURL . '{id}&hl=en_US&fs=1&" ></param>';
        $code .='<param name="allowFullScreen" value="true" ></param>';
        $code .='<param name="allowscriptaccess" value="always"></param>';
        $code .='<embed src="' . $YouTubeVideoURL . '{id}&hl=en_US&fs=1&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '">';

        $code .='</embed></object>';

        $code = str_replace('{id}', $id, $code);

        return $code;
    }

    function video_display($id) {
        $video_data = $this->select_video_gallery($id);
        $youtube_url = $video_data['var_youtubelink'];
        $embdcode = $this->get_youtubevideo($youtube_url, '400', '550');

        echo $embdcode;
    }

    function select_video_gallery($id) {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'videos');
        $this->configObj->glDbObj->addColumn('*');
        $this->configObj->glDbObj->setWhere('int_glcode =' . $id);

        $row = $this->configObj->glDbObj->get_sql_row($this->configObj->glDbObj->buildQuery());

        return $row;
    }

    function edit_systemsettings() {
        //echo'<pre>';print_r($_REQUEST);exit;
//          echo 'arfwsdf';die;
        if ($_POST['p'] == "gen") {
            //echo'<pre>';print_r($_REQUEST);exit;
            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setQueryType('update');
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');
            // Set the Columns
            $this->configObj->glDbObj->addColumn('var_sitename');
            $this->configObj->glDbObj->addColumn('var_sitepath');
            $this->configObj->glDbObj->addColumn('var_pagesize');
            $this->configObj->glDbObj->addColumn('var_facebook_link');
            $this->configObj->glDbObj->addColumn('var_forgote_mail');
            $this->configObj->glDbObj->addColumn('chr_facebook');

            $this->configObj->glDbObj->addColumn('var_twitter_link');
            $this->configObj->glDbObj->addColumn('chr_twitter');
            $this->configObj->glDbObj->addColumn('var_tripadvisor_link');
            $this->configObj->glDbObj->addColumn('chr_tripadvisor');
            $this->configObj->glDbObj->addColumn('chr_passengerpicks');
            $this->configObj->glDbObj->addColumn('var_passengerpicks');
            $this->configObj->glDbObj->addColumn('var_youtube_link');
            $this->configObj->glDbObj->addColumn('chr_youtube');
            $this->configObj->glDbObj->addColumn('chr_google_plus_link');
            $this->configObj->glDbObj->addColumn('chr_google_plus');
            $this->configObj->glDbObj->addColumn('chr_pinterest_link');
            $this->configObj->glDbObj->addColumn('chr_pinterest');
            $this->configObj->glDbObj->addColumn('chr_instagram_link');
            $this->configObj->glDbObj->addColumn('chr_instagram');
            $this->configObj->glDbObj->addColumn('chr_location_link');
            $this->configObj->glDbObj->addColumn('chr_location');

            $this->configObj->glDbObj->addColumn('var_mailbottom_text');
            $this->configObj->glDbObj->addColumn('var_mailbottom_textlink');
            $this->configObj->glDbObj->addColumn('var_dateformat');
            $this->configObj->glDbObj->addColumn('var_frontdateformat');
            $this->configObj->glDbObj->addColumn('chr_seo_flag');
            $this->configObj->glDbObj->addColumn('chr_alias_flag');
            $this->configObj->glDbObj->addColumn('var_note');

            // Set the Values

            $this->configObj->glDbObj->addValue($this->varpostdata['var_sitename']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_sitepath']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_pagesize']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_facebook_link']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_forgote_mail']);
            if ($this->varpostdata['chr_facebook'] == "on")
                $chr_facebook = "Y";
            else
                $chr_facebook = "N";
            $this->configObj->glDbObj->addValue($chr_facebook);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_twitter_link']);

            if ($this->varpostdata['chr_twitter'] == "on")
                $chr_twitter = "Y";
            else
                $chr_twitter = "N";
            $this->configObj->glDbObj->addValue($chr_twitter);


            $this->configObj->glDbObj->addValue($this->varpostdata['var_tripadvisor_link']);

            if ($this->varpostdata['chr_tripadvisor'] == "on")
                $chr_trip = "Y";
            else
                $chr_trip = "N";
            $this->configObj->glDbObj->addValue($chr_trip);



            if ($this->varpostdata['chr_passengerpicks'] == "on")
                $chr_pass = "Y";
            else
                $chr_pass = "N";
            $this->configObj->glDbObj->addValue($chr_pass);

            $this->configObj->glDbObj->addValue($this->varpostdata['var_passengerpicks']);

            $this->configObj->glDbObj->addValue($this->varpostdata['var_youtube_link']);

            if ($this->varpostdata['chr_youtube'] == "on")
                $chr_you = "Y";
            else
                $chr_you = "N";
            $this->configObj->glDbObj->addValue($chr_you);



            $this->configObj->glDbObj->addValue($this->varpostdata['chr_google_plus_link']);

            if ($this->varpostdata['chr_google_plus'] == "on")
                $chr_plus = "Y";
            else
                $chr_plus = "N";
            $this->configObj->glDbObj->addValue($chr_plus);


            $this->configObj->glDbObj->addValue($this->varpostdata['chr_pinterest_link']);

            if ($this->varpostdata['chr_pinterest'] == "on")
                $chr_pnt = "Y";
            else
                $chr_pnt = "N";
            $this->configObj->glDbObj->addValue($chr_pnt);

            $this->configObj->glDbObj->addValue($this->varpostdata['chr_instagram_link']);

            if ($this->varpostdata['chr_instagram'] == "on")
                $chr_intst = "Y";
            else
                $chr_intst = "N";
            $this->configObj->glDbObj->addValue($chr_intst);

            $this->configObj->glDbObj->addValue($this->varpostdata['chr_location_link']);
            if ($this->varpostdata['chr_location'] == "on")
                $chr_lcn = "Y";
            else
                $chr_lcn = "N";
            $this->configObj->glDbObj->addValue($chr_lcn);



            $this->configObj->glDbObj->addValue($this->varpostdata['var_mailbottom_text']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_mailbottom_textlink']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_dateformat']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_frontdateformat']);
            $this->configObj->glDbObj->addValue($this->varpostdata['chr_seo_flag']);
            $this->configObj->glDbObj->addValue($this->varpostdata['chr_alias_flag']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_note']);
            // echo $this->configObj->glDbObj->buildQuery();
            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        }

        else if ($_POST['p'] == "ser") {

            //echo "in ser";exit;
            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setQueryType('update');
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');
            // related fields

            $this->configObj->glDbObj->addColumn('var_smtpserver');
            $this->configObj->glDbObj->addColumn('var_smtpusername');
            $this->configObj->glDbObj->addColumn('var_smtppassword');
            $this->configObj->glDbObj->addColumn('chr_smtpauthentication');
            $this->configObj->glDbObj->addColumn('var_smtpport');
            $this->configObj->glDbObj->addColumn('var_emailfrom');
            $this->configObj->glDbObj->addColumn('var_mailer');
            $this->configObj->glDbObj->addColumn('var_adminmailid');
//            $this->configObj->glDbObj->addValue($this->varpostdata['var_email_signature']);
            $this->configObj->glDbObj->addColumn('var_email_signature');

            $this->configObj->glDbObj->addValue($this->varpostdata['var_smtpserver']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_smtpusername']);


            $cryptpwd = $this->configObj->glLibraryObj->cryptPass($this->varpostdata['var_smtppassword']);

            $this->configObj->glDbObj->addValue($cryptpwd);
            $this->configObj->glDbObj->addValue($this->varpostdata['chr_smtpauthentication']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_smtpport']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_emailfrom']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_mailer']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_adminmailid']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_email_signature']);

            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        } else if ($_POST['p'] == "map") {


            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setQueryType('update');
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');
            // related fields
            $this->configObj->glDbObj->addColumn('var_geocode');
            $this->configObj->glDbObj->addColumn('var_googlemapapikey');
            $this->configObj->glDbObj->addColumn('var_yahoomapapikey');

            $this->configObj->glDbObj->addValue($this->varpostdata['var_geocode']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_googlemapapikey']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_yahoomapapikey']);

            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        } else if ($_POST['p'] == "cur") {
            // related fields

            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setQueryType('update');
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');

            $this->configObj->glDbObj->addColumn('var_currency');
            $this->configObj->glDbObj->addColumn('var_currencysymbol');

            $this->configObj->glDbObj->addValue($this->varpostdata['var_currency']);
            $this->configObj->glDbObj->addValue($this->varpostdata['var_currencysymbol']);

            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        } else if ($_POST['p'] == "seo") {
            if ($this->varpostdata['chr_urlrewriting'] == "on")
                $chr_urlrewriting = "Y";
            else
                $chr_urlrewriting = "N";


            //			echo "<pre>";
            //                print_r($this->varpostdata);
            //            echo "</pre>";
            //            echo exit;


            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setQueryType('update');
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');
            // related fields
            $this->configObj->glDbObj->addColumn('var_googleanalyticcode');
            $this->configObj->glDbObj->addColumn('var_metatitle');
            $this->configObj->glDbObj->addColumn('var_metakeywords');
            $this->configObj->glDbObj->addColumn('var_metadescription');
            $this->configObj->glDbObj->addColumn('var_commanmetatags');
            $this->configObj->glDbObj->addColumn('chr_urlrewriting');

            $this->configObj->glDbObj->addValue(trim($this->varpostdata['var_googleanalyticcode']));
            $this->configObj->glDbObj->addValue(trim($this->varpostdata['var_metatitle']));
            $this->configObj->glDbObj->addValue(trim($this->varpostdata['var_metakeywords']));
            $this->configObj->glDbObj->addValue(trim($this->varpostdata['var_metadescription']));
            $this->configObj->glDbObj->addValue(trim($this->varpostdata['var_commanmetatags']));
            $this->configObj->glDbObj->addValue($chr_urlrewriting);

            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        }
        else if ($_REQUEST['p'] == "uman") {
            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setQueryType('update');
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'general_settings');

            $this->configObj->glDbObj->addColumn('chr_maintenance');
            $this->configObj->glDbObj->addColumn('var_main_description');

            if (isset($this->varpostdata['chr_maintenance'])) {
                $chr_maintenance = $this->varpostdata['chr_maintenance'];
                $var_main_description = $this->varpostdata['main_description'];
            } else {
                $chr_maintenance = 'N';
                $var_main_description = '';
            }
            $this->configObj->glDbObj->addValue($chr_maintenance);
            $this->configObj->glDbObj->addValue($var_main_description);

            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        } else if ($_REQUEST['p'] == "htaccess") {
            //print '<pre>';
            //print_r($_REQUEST);exit;
            //$file = file_get_contents ('../.htaccess');exit;

            $myFile = "../.htaccess";
            $fh = fopen($myFile, 'w') or die("can't open file");
            $stringData = $_REQUEST['htaccesscode'];
            fwrite($fh, $stringData);
            fclose($fh);
            //exit;
            if ($_REQUEST['backup'] == 'Y') {
                $this->getBackupOfFile();
            }


            //exit;
        }

        return true;
    }

    function getDisplayFiles() {
        $dir = "htaccessbackup/";
        $dateFileArray = array();
        // Open a known directory, and proceed to read its contents
        $i = 0;
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    $fname = explode('.', $file);
                    $fcount = count($fname);
                    $fextension = $fname[$fcount - 1];
                    //echo $fcount;echo '<br/>'; 
                    if ($fextension == 'htaccess') {
                        $dateFileArray[$i]['filename'] = $file;
                        $dateFileArray[$i]['displayname'] = 'htaccess_' . $fname[0];
                        $dateFileArray[$i]['filetime'] = date('F d Y H:i:s', filemtime($dir . $file));
                        //echo "filename: $file : filetype: " . date('F d Y H:i:s',filemtime($dir . $file)) . "<br/>";
                        $i++;
                    }
                }
                closedir($dh);
            }
        }
        //print '<pre>';
        //print_r($dateFileArray);
        return $dateFileArray;
    }

    function getBackupOfFile() {


        $dir = "htaccessbackup/";
        $dateFileArray = array();
        // Open a known directory, and proceed to read its contents
        $i = 0;
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    $fname = explode('.', $file);
                    $fcount = count($fname);
                    $fextension = $fname[$fcount - 1];
                    //echo $fcount;echo '<br/>'; 
                    if ($fextension == 'htaccess') {
//                        $dateFileArray[$i]['filename']=$file;
//                        $dateFileArray[$i]['filetime']=date('F d Y H:i:s',filemtime($dir . $file));
                        $FileArray[$i] = $file;
                        $TimeFileArray[$i] = date('F d Y H:i:s', filemtime($dir . $file));
                        //echo "filename: $file : filetype: " . date('F d Y H:i:s',filemtime($dir . $file)) . "<br/>";
                        $i++;
                    }
                }
                closedir($dh);
            }
        }

        if (!empty($TimeFileArray)) {
            asort($TimeFileArray);
        }

        if ($i == 5) {
            $k = 0;
            foreach ($TimeFileArray as $key => $value) {
                if ($k == 0) {
                    $filekey = $key;
                    $firstfilename = $FileArray[$key];
                } else {
                    
                }
                $k++;
            }
            //echo '<br/>';
            //echo $firstfilename;exit;
            $delFilename = $dir = "htaccessbackup/" . $firstfilename;
            unlink($delFilename);
        }
        //exit;

        $filename = '../.htaccess';
        $copyname = 'htaccessbackup/' . date('Y-m-d-h-i-s-A') . '.htaccess';
        if ($file = @fopen($copyname, 'x')) {
            if (!@fclose($file)) {
                return false;
            }

            if (!@copy($filename, $copyname)) {
                //unlink($copyname);
            }
        }
    }

    function publishcombo($tabindex) {

        $displayoutput = "<select name='publishcombo' id='publishcombo' tabindex='$tabindex' onchange='display_positions();'>
          <option>-All-</option>";
        $displayoutput.=
                "<option value='Y' >Publish</option>
          <option value='N'> Unpublish</option>
      </select>";
        return $displayoutput;
    }

    function select_profile($id) {
        $sql = "select * from " . DB_PREFIX . "users where int_glcode = " . $id . "";
        $exec = $this->configObj->glDbObj->get_sql_row($sql);
        //$rows = $this->configObj->glDbObj->fetch_array($exec);
        return $exec;
    }

    function select_emailid($id) {
        $sql = "select var_careeremail,var_newslattermail,var_bookanappointmentmail ,var_contactusmail,var_reviewapplication,var_commentemail,var_phone,var_celno,var_coaddress,var_rescelno,var_tollfreeno  from " . DB_PREFIX . "general_settings ";
        $exec = $this->configObj->glDbObj->get_sql_row($sql);
        //$rows = $this->configObj->glDbObj->fetch_array($exec);
        return $exec;
    }

    function edit_Userprofile($id) {
        if ($_REQUEST['pwdpassword'] != '') {
            $sql = "Update " . DB_PREFIX . "users set var_fname = '" . $this->configObj->glDbObj->addSlashes($_POST['txtfname']) . "',var_lname = '" . $this->configObj->glDbObj->addSlashes($_POST['txtlname']) . "',var_emailid = '" . $_POST['txtemail'] . "',var_emailid1 = '" . $_POST['txtemail1'] . "',var_emailid2 = '" . $_POST['txtemail2'] . "',var_password = '" . $this->configObj->glLibraryObj->cryptPass($_POST['pwdpassword']) . "',var_address1='" . $this->configObj->glDbObj->addSlashes($_POST['var_address1']) . "' where int_glcode = " . $id;
            $exec = $this->configObj->glDbObj->query($sql);
        } else {
            $sql = "Update " . DB_PREFIX . "users set var_fname = '" . $this->configObj->glDbObj->addSlashes($_POST['txtfname']) . "',var_lname = '" . $this->configObj->glDbObj->addSlashes($_POST['txtlname']) . "',var_emailid = '" . $_POST['txtemail'] . "',var_emailid1 = '" . $_POST['txtemail1'] . "',var_emailid2 = '" . $_POST['txtemail2'] . "',var_address1='" . $this->configObj->glDbObj->addSlashes($_POST['var_address1']) . "' where int_glcode = " . $id;

            $exec = $this->configObj->glDbObj->query($sql);
        }

        $gencosql = "Update " . DB_PREFIX . "general_settings set var_phone='" . $_POST['var_phone'] . "', var_coaddress = '" . $this->configObj->glDbObj->addSlashes($_POST['var_coaddress']) . "' , var_celno = '" . $_POST['var_celno'] . "', var_rescelno = '" . $_POST['var_rescelno'] . "', var_tollfreeno = '" . $_POST['var_tollfreeno'] . "' where int_glcode = 1";

        $this->configObj->glDbObj->query($gencosql);

        if ($this->configObj->glSessionObj->value('admin_id') == '1' || $this->configObj->glSessionObj->value('chr_user') == 'A' || $this->configObj->glSessionObj->value('admin_id') == '3' || $this->configObj->glSessionObj->value('admin_id') == '4') {
            $gensql = "Update " . DB_PREFIX . "general_settings set var_newslattermail= '" . $_POST['var_newslattermail'] . "',var_bookanappointmentmail = '" . $_POST['var_bookanappointmentmail'] . "',var_contactusmail = '" . $_POST['var_contactusmail'] . "',var_reviewapplication = '" . $_POST['var_reviewapplication'] . "'  where int_glcode = 1";
            $this->configObj->glDbObj->query($gensql);
        }
    }

    function getEmailDetails($id) {

        $sql = "select * from " . DB_PREFIX . "emails where int_glcode = " . $id . "";
        $exec = $this->configObj->glDbObj->get_sql_row($sql);
        $to = explode(",", $exec['txt_to']);
        $to1 = '';
        for ($i = 0; $i < count($to); $i++) {
            $to1.= $to[$i] . "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        }
        $body = ' <table class="test"><tr><td align="left" ><strong>From : </strong>' . $exec['var_from'] . ' </td></tr>
                  <tr><td align="left" ><strong>To : </strong>' . $to1 . ' </td></tr>
                  <tr><td align="left" ><strong>subject : </strong>' . $exec['txt_subject'] . ' </td></tr>
                  <tr><td align="left" ><strong>Date : </strong>' . $exec['dt_createdate'] . ' </td></tr>
                  <tr><td align="left" ><strong>Email Details: </strong>' . $exec['txt_body'] . ' </td></tr>';

        $html_message = file_get_contents($this->configObj->currentModulePath . 'html/templates/show_comment.tpl.php');
        $html_message = str_replace("@body", $body, $html_message);
        return $html_message;
    }

    function getEmails() {
        $dtformat = DEFAULT_DATEFORMAT;
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . "emails as e left join " . DB_PREFIX . "emailtype as et on e.fk_emailtype = et.int_glcode ");
        $this->configObj->glDbObj->addColumn('e.*, et.var_type as var_type,DATE_FORMAT(e.dt_createdate,"' . $dtformat . '") as date ,time(e.dt_createdate) as Time');
        $whereclause = "e.chr_delete = 'N'";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ($this->searchby == '0') ? " and et.var_type like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%' " : " and $this->searchby  like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%'";
        }

        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }

        if ($_REQUEST['modval'] != '0' && $_REQUEST['modval'] != '') {
            $whereclause .=" and fk_emailtype = '" . $_REQUEST['modval'] . "'";
        }

        $this->configObj->glDbObj->setWhere($whereclause);
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $this->configObj->glDbObj->setLimit($this->start . ', ' . $this->pagesize);
        if ($_REQUEST['type'] == 'autosearch') {
            $orderby = (isset($_REQUEST['orderby'])) ? 'order by ' . $this->orderby . ' ' . $this->ordertype : 'order by e.int_displayorder';

            $searchbyVal = (!empty($this->searchbyVal)) ? " and {$this->searchbyVal} like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%' " : "";

            $autoSearchQry = "select e.int_glcode ,et.var_type as AutoVal FROM " . DB_PREFIX . "emails as e left join " . DB_PREFIX . "emailtype as et on e.fk_emailtype = et.int_glcode where $whereclause  $searchbyVal group by et.var_type $orderby";

            $this->configObj->glLibraryObj->GetAutoSearch($autoSearchQry);
        }

        //   echo $this->configObj->glDbObj->buildQuery();
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        return $rs;
    }

    function load_emails() {




        $this->loadCount('CountRows_emails');
        $this->CountRows_emails();
        $this->configObj->glTplObj->set('numofrows', $this->numofrows);

        $result = $this->getEmails();
        $this->configObj->glTplObj->set('result', $result);

        $this->pagename = "index.php?module=settings&view=emails";
        $this->configObj->glTplObj->set('result', $result);
        $this->Generateurl();


        $view = 'Manage Emails';
        $tablename = DB_PREFIX . 'emails';
        $searcharray = array("et.var_type" => "Email Type");
        $parmas = $this->org_generateParam($view, $actionurl, $searcharray, $tablename);

        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas, 'no'));
        ////echo $configObj->glLibraryObj->generatePagingPannel($parmas);exit;
        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));
        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->org_generateParam($view, $actionurl, $searcharray, $tablename, 'bottom')));

        $tmpsetsortvar = 'setsortimg' . $this->orderby;
        $$finalsortvar = $tmpsetsortvar;
        $this->configObj->glTplObj->set($$finalsortvar, $this->sortvar);

        if ($this->configObj->isAjaxSet) {
            echo $this->configObj->glTplObj->process('emails.tpl.php');
            exit;
        } else {
            $this->configObj->adminContentPanel = $this->configObj->glTplObj->process('emails.tpl.php');
        }
    }

    function delete_emails($fk_modules) {

        $deleteids = $_REQUEST['dids'];
        $deletearray = explode(',', $deleteids);
        $totaldeletedrecords = count($deletearray);

        for ($i = 0; $i < $totaldeletedrecords; $i++) {

            $sql = "Update " . DB_PREFIX . "emails set chr_delete='Y',dt_modifydate = NOW() where int_glcode='$deletearray[$i]'";
            $this->configObj->glDbObj->query($sql);
            $this->configObj->glLibraryObj->insertinlogmanager($fk_modules, DB_PREFIX . 'emails', 'var_from', $deletearray[$i], 'D');
        }

        $this->load_emails();
        exit;
    }

    function sendthisformmail() {
        //   print_r($_POST); exit;
        $imgurl = SITE_PATH . "/" . GLOBAL_FRONT_IMAGES_PATH . "logo-royal-fidelity.gif";

        $this->configObj->setEmailConfig();

        $subject = "Email For More Features";
        $body = '<tr><td width="15"></td><td align="left" ><strong>Name: </strong>' . $_POST['varname'] . '</td></tr>
                         <tr><td width="15"></td><td align="left" ><strong>From: </strong>' . $_POST['varemail'] . ' </td></tr>
                             <tr><td width="15"></td><td align="left" ><strong>Kind of Features: </strong>' . $_POST['kindofneed'] . '</td></tr>';

        $body.='<tr><td width="15"></td><td align="left" ><strong>Personal Message: </strong>' . $_POST['varmessage'] . ' </td></tr>';


        //$html_message = file_get_contents($this->configObj->currentModulePath.'html/mailtemplates/contactus_admin.html');
        $html_message = file_get_contents($this->configObj->currentModulePath . 'html/mailtemplates/sendtofriend.html');
        $html_message = str_replace("@Feedback", "Email this", $html_message);
        $html_message = str_replace("@Admin", 'Admin', $html_message);
        $html_message = str_replace("@Sender", $_REQUEST['varname'], $html_message);
        $html_message = str_replace("@REQUEST_HEADING", 'Sender Details', $html_message);
        $html_message = str_replace("@DETAIL_DATA", $body, $html_message);
        $html_message = str_replace("@SITE_URL_FOR_MAIL_LINKS", SITE_PATH, $html_message);
        $html_message = str_replace("@SITE_NAME_IN_WORDS", SITE_NAME, $html_message);
        $html_message = str_replace("@MAIL_TEXT_AFTER_BEST_REGARDS", 'Royal Fidelity', $html_message);
        $html_message = str_replace("@LOGO_PATH", $imgurl, $html_message);
        $html_message = str_replace("@year", date('Y'), $html_message);
        $html_message = str_replace("@POSTNAME", $_REQUEST['varname'], $html_message);



        $sql = "select var_emailid1,var_emailid2 from " . DB_PREFIX . "users where chr_usertype='N'";
        $mailarray = $this->configObj->glDbObj->get_sql_row($sql);

        $mailarray = $_REQUEST['varemail'];

        if ($mailarray != '') {
            $addarr = explode(',', $mailarray);

            if (count($addarr) >= 1) {
                for ($i = 0; $i < count($addarr); $i++) {
                    if ($addarr[$i] != '')
                        $this->configObj->glMailObj->AddAddress($addarr[$i]);
                }
            }

            $this->configObj->glMailObj->AddReplyTo($_POST['varemail']);
            $this->configObj->glMailObj->Subject = $subject;
            $this->configObj->glMailObj->Body = $html_message;
            // echo $this->configObj->glMailObj->Body;exit;
            if (!$this->configObj->glLibraryObj->sendmail()) {
                $message = "Error in mail send";
            } else {
                //DB INSERT
                $message = mysql_real_escape_string($html_message);

                $s = "select int_glcode from " . DB_PREFIX . "modules where var_modulename='" . $_POST['kindofneed'] . "'";
                $r = $this->configObj->glDbObj->get_sql_row($s);
                $id = $r['int_glcode'];

                $insertSql = "insert into " . DB_PREFIX . "modules_features (fk_module, var_name, var_email, var_description,dt_createdate,dt_modifydate)
                   VALUES('" . $id . "','" . $_POST['varname'] . "','" . $_POST['varemail'] . "','" . $_POST['varmessage'] . "',now(),now())";
                $exec = $this->configObj->glDbObj->query($insertSql);
                $message = "The email has been successfully sent.";
            }
            return $message;
        }
        $message = 'Error in mail send';

        echo $message;
        exit;
        //return $message;
    }

    function selectall_seomodules() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules');
        $this->configObj->glDbObj->addColumn('int_glcode');
        $this->configObj->glDbObj->addColumn('var_modulename');
        $this->configObj->glDbObj->addColumn('var_seoprefix');
        $whereclause = "chr_delete = 'N' and chr_seoprefix='Y'";
        $this->configObj->glDbObj->setWhere($whereclause);
        //		echo $this->configObj->glDbObj->buildQuery();
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        while ($row = $this->configObj->glDbObj->fetch_assoc($rs)) {
            $seomodules_array[] = $row;
        }

        return $seomodules_array;
    }

    function update_seomodules($int_glcode) {
        //		print_r($this->varpostdata);exit;
        $this->configObj->glDbObj->resetfields();
        $this->configObj->glDbObj->setQueryType('update');
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules');

        $this->configObj->glDbObj->addColumn('var_seoprefix');
        $this->configObj->glDbObj->addValue($this->varpostdata['seoprefix_array'][$int_glcode]);

        $this->configObj->glDbObj->setWhere('int_glcode=' . $int_glcode);
        //		echo $this->configObj->glDbObj->buildQuery();exit;
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
    }

    function getModuleCombo() {
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules');
        $this->configObj->glDbObj->addColumn('var_modulename,int_glcode');
        //		$this->configObj->glDbObj->setWhere("chr_publish = 'Y' and chr_delete='N' and chr_featured='Y' and chr_powerpanel_module='Y'");
        $this->configObj->glDbObj->setWhere("chr_publish = 'Y' and chr_delete='N' and chr_powerpanel_module='Y' ");
        $this->configObj->glDbObj->setOrderBy($this->orderby . ' ' . $this->ordertype);
        $rs = $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());

        $combo = "<select name=\"fk_modules\" id=\"fk_modules\">
        <option value=\"0\" >--Please Select--</option>";

        while ($row = $this->configObj->glDbObj->fetch_array($rs)) {
            $combo .="<option value='" . $row['int_glcode'] . "'>" . $row['var_modulename'] . "</option>";
        }
        $combo .="</select>";
        return $combo;
    }

    function requestFeatureInsert($admin_id) {
        $imgurl = SITE_PATH . "/" . GLOBAL_FRONT_IMAGES_PATH . "admin_logo.png";

        //echo $imgurl;exit;
        $this->configObj->setEmailConfig();

        $subject = "Report Feature";
        $Feedback = "Report Feature";

        $mdlsql = "select var_modulename from " . DB_PREFIX . "modules where int_glcode = " . $this->varpostdata['fk_modules'] . "";
        $mdlarry = $this->configObj->glDbObj->get_sql_row($mdlsql);

        $usersql = "select * from " . DB_PREFIX . "users where intglcode = 1";
        $userarry = $this->configObj->glDbObj->get_sql_row($usersql);

        //  print_r($usrarry);
        // $this->configObj->glDbObj->addValue($this->varpostdata['var_message']);
        $msg = trim($this->varpostdata['var_description']);
        $name = trim($this->varpostdata['var_name']);
        $var_email = trim($this->varpostdata['var_email']);
        $body = '<tr>
                                <td width="10"></td>
                                <td align="left" ><strong>Name: </strong>' . $name . ' </td>
                            </tr>
                            <tr>
                                <td width="10"></td>
                                <td align="left" ><strong>E-mail: </strong>' . $var_email . ' </td>
                            </tr>
                            <tr>
                                <td width="10"></td>
                                <td align="left" ><strong>To change features for ' . $mdlarry['var_modulename'] . ' module: </strong>' . $msg . ' </td>
                            </tr>';



        $html_message = file_get_contents(PP_THEMEPATH . 'mailtemplates/report_feature.html');
        $html_message = str_replace("@Feedback", $Feedback, $html_message);
        $html_message = str_replace("@Admin", "Netclues Admin", $html_message);
        $html_message = str_replace("@DETAIL_DATA", $body, $html_message);
        $html_message = str_replace("@SITE_URL_FOR_MAIL_LINKS", SITE_PATH, $html_message);
        $html_message = str_replace("@SITE_NAME_IN_WORDS", SITE_NAME, $html_message);
        $html_message = str_replace("@MAIL_TEXT_AFTER_BEST_REGARDS", 'Royal Fidelity', $html_message);
        $html_message = str_replace("@LOGO_PATH", $imgurl, $html_message);
        $html_message = str_replace("@year", date('Y'), $html_message);
        //echo $html_message;die;
        $sep = "";
        if ($userarry['var_emailid1'] != "") {
            $to = $userarry['var_emailid1'];
            $sep = ",";
        }
        if ($userarry['var_emailid2'] != "") {
            $to .= $sep . $userarry['var_emailid2'];
        }

        $addarr = explode(',', $to);
        //print_r($addarr);die("here");
        if (count($addarr) > 1) {
            for ($i = 0; $i < count($addarr); $i++) {
                $this->configObj->glMailObj->AddAddress($addarr[$i]);
            }
        } else {
            $this->configObj->glMailObj->AddAddress($to);
        }

        //$this->configObj->glMailObj->AddReplyTo(MAIL_FROM);

        $this->configObj->glMailObj->Subject = $subject;

        $this->configObj->glMailObj->Body = $html_message;


        if (!$this->configObj->glLibraryObj->sendmail()) {
            $message = "Error in mail send";
            die;
        } else {
            $this->configObj->glDbObj->resetfields();
            $this->configObj->glDbObj->setTable(DB_PREFIX . 'modules_features');
            $this->configObj->glDbObj->setQueryType('insert');

            // Set the Columns

            $this->configObj->glDbObj->addColumn('fk_module');
            $this->configObj->glDbObj->addColumn('var_name');
            $this->configObj->glDbObj->addColumn('var_email');
            $this->configObj->glDbObj->addColumn('var_description');
            $this->configObj->glDbObj->addColumn('dt_createdate');

            $this->configObj->glDbObj->addValue($this->varpostdata['fk_modules']);
            $this->configObj->glDbObj->addValue($name);
            $this->configObj->glDbObj->addValue($var_email);
            $this->configObj->glDbObj->addValue($msg);
            $this->configObj->glDbObj->addValue('now()');

            $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());

            $message = "Your mail has sent Successfully. We will get you back soon..";
        }
        return $message;
    }

    function loadCount($function) {
        //echo "display load count";
        //exit;
        $this->initialize($view);
        $this->numofrows = (isset($_REQUEST['numofrows'])) ? $_REQUEST['numofrows'] : $this->{$function}();
        $this->noofpages = intval($this->numofrows / $this->pagesize);
        $this->noofpages = (($this->numofrows % $this->pagesize) > 0) ? ($this->noofpages + 1) : ($this->noofpages);
        $this->configObj->glTplObj->set('numofrows', $this->numofrows);
        $this->Generateurl();
    }

    function update_display_order($ids, $values, $oldvalues, $table = 'highlight') {
        $tablename = "" . DB_PREFIX . $table;

        for ($i = 0; $i < count($ids); $i++) {
            // Updation Of the Display Order
            if ($values[$i] != $oldvalues[$i]) {
                $this->configObj->glDbObj->resetfields();
                $this->configObj->glDbObj->setQueryType('select');
                $this->configObj->glDbObj->setTable($tablename);
                $this->configObj->glDbObj->addColumn('count(1) as total');
                $this->configObj->glDbObj->setWhere("int_displayorder=" . $values[$i] . " and chr_delete = 'N'");
                $rs = $this->configObj->glDbObj->get_sql_row($this->configObj->glDbObj->buildQuery());
                if ($rs['total'] > 0) {
                    if ($values[$i] > $oldvalues[$i]) {

                        $this->configObj->glDbObj->resetfields();
                        $this->configObj->glDbObj->setTable($tablename);
                        $this->configObj->glDbObj->setQueryType('update');
                        $this->configObj->glDbObj->addColumn('int_displayorder');
                        $this->configObj->glDbObj->UnsetQuotes();
                        $this->configObj->glDbObj->addValue('int_displayorder - 1');
                        $this->configObj->glDbObj->SetQuotes();
                        $this->configObj->glDbObj->setWhere('int_displayorder > ' . $oldvalues[$i] . ' and int_displayorder <= ' . $values[$i] . '');
                        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
                        // echo $this->configObj->glDbObj->buildQuery();
                    } else {
                        $this->configObj->glDbObj->resetfields();
                        $this->configObj->glDbObj->setTable($tablename);
                        $this->configObj->glDbObj->setQueryType('update');
                        $this->configObj->glDbObj->addColumn('int_displayorder');
                        $this->configObj->glDbObj->UnsetQuotes();
                        $this->configObj->glDbObj->addValue('int_displayorder + 1');
                        $this->configObj->glDbObj->SetQuotes();
                        $this->configObj->glDbObj->setWhere('int_displayorder >= ' . $values[$i] . ' and  int_displayorder < ' . $oldvalues[$i] . '');
                        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
                    }
                }
                $this->configObj->glDbObj->resetfields();
                $this->configObj->glDbObj->setTable($tablename);
                $this->configObj->glDbObj->setQueryType('update');
                $this->configObj->glDbObj->addColumn('int_displayorder');
                $this->configObj->glDbObj->addValue($values[$i]);
                $this->configObj->glDbObj->setWhere('int_glcode=' . $ids[$i] . '');
                $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
            }
        }
    }

    function get_var_imagepath($eid, $fieldname, $tablename) {
        $sql = "select " . $fieldname . " from " . $tablename . " where int_glcode=$eid AND chr_delete='N'";
        $rs = $this->configObj->glDbObj->get_sql_row($sql);
        $var_imagepath = $rs[$fieldname];
        return $var_imagepath;
    }

    function get_cropstatus($eid, $fieldname, $tablename) {
        $sql = "select " . $fieldname . " from " . $tablename . " where int_glcode=$eid AND chr_delete='N'";
        $rs = $this->configObj->glDbObj->get_sql_row($sql);
        $cropstatus = $rs[$fieldname];
        return $cropstatus;
    }

    /* function Bindmodule()
      {
      $selected_array=$_REQUEST['modval'];
      $module="select * from ".DB_PREFIX."modules where chr_delete='N' and chr_publish='Y' and chr_filterflag='Y'";
      $rs1=$this->configObj->glDbObj->query($module);
      $display = "<div class=\"new-search-show-all\">";
      $display .="<select name=\"module\" id=\"module\" class=\"more-textarea\" style=\"width:130px;\" onchange=\"SendGridBindRequest('$this->urlwithpara','gridbody','MVF')\">";
      $display .="<option value=\"0\">-- Filter By Module --</option>";
      while ($row = $this->configObj->glDbObj->fetch_array($rs1))
      {
      $p=($row['int_glcode']==$selected_array) ? 'selected' : '';
      $display.="<option value=".$row['int_glcode']." ".$p.">".$row['chr_pro_modulename']."</option>";
      }
      return $display.="</select></div>";

      } */

//    function getupdates() {
//        $updatearray = array();
//
//        //$sql1 = "SELECT count(1) as count from " . DB_PREFIX . "contactdetails where chr_delete='N' and chr_read='N'";
//        $rs1 = $this->configObj->glDbObj->get_sql_row($sql1);
//        $updatearray[1]['count'] = $rs1['count'];
//        $updatearray[1]['module'] = 'Contact Us Leads';
//        $updatearray[1]['link'] = 'index.php?module=contactusmsg';
//        return $updatearray;
//    }

    function getoperationcmb() {

        $display = "<div class=\"new-search-show-all\">";
        $display .="<select name=\"chr_action\" id=\"chr_action\" class=\"more-textarea\" style=\"width:140px\" onchange=\"SendGridBindRequest('$this->urlwithpara','gridbody','APP1')\">";
        $display .="<option value=\"0\">--All Operations--</option>";
        $display.="<option value='I' " . (($_REQUEST['chr_action'] == 'I') ? "selected" : "" ) . ">Insert</option>";
        $display.="<option value='U' " . (($_REQUEST['chr_action'] == 'U') ? "selected" : "" ) . ">Update</option>";
        $display.="<option value='D' " . (($_REQUEST['chr_action'] == 'D') ? "selected" : "" ) . ">Delete</option>";
        return $display.="</select></div>";
    }

    function Bindmodule() {
        $selected_array = $_REQUEST['modval'];
        // $custselected_array=$_REQUEST['modval'];
        $module = "select * from " . DB_PREFIX . "modules where chr_delete='N' and chr_publish='Y' and chr_filterflag='Y' order by chr_pro_modulename desc";
        $rs1 = $this->configObj->glDbObj->query($module);
        $custmodule = "select * from " . DB_PREFIX . "pages where chr_custom='Y' and chr_delete='N' and chr_publish='Y' ";
        $rs2 = $this->configObj->glDbObj->query($custmodule);
        $noofcus = "select count(1) as total from " . DB_PREFIX . "pages where chr_custom='Y' and chr_delete='N' and chr_publish='Y' ";
        $count = $this->configObj->glDbObj->get_sql_row($noofcus);

        $display = "<div class=\"new-search-show-all\">";
        $display .="<select name=\"module\" id=\"module\" class=\"more-textarea\" style=\"width:130px;\" onchange=\"SendGridBindRequest('$this->urlwithpara','gridbody','MVF')\">";
        $display .="<option value=\"0\">-- Sort By Module --</option>";
        $display .="<optgroup label=\"Modules\"></option>";
        while ($row = $this->configObj->glDbObj->fetch_array($rs1)) {
            $p = ($row['int_glcode'] . '-m' == $selected_array) ? 'selected' : '';
            $display.="<option value=" . $row['int_glcode'] . '-m' . " " . $p . ">" . $row['chr_pro_modulename'] . "</option>";
        }
        if ($this->configObj->glSessionObj->value('admin_id') == '1') {
            if ($count['total'] > 0) {
                $display .="<optgroup label=\"Custom Modules\"></option>";
            }
        }
        while ($custrow = $this->configObj->glDbObj->fetch_array($rs2)) {
            $p1 = ($custrow['int_glcode'] . '-c' == $selected_array) ? 'selected' : '';
            $display.="<option value=" . $custrow['int_glcode'] . '-c' . " " . $p1 . ">" . $custrow['var_pagename'] . "</option>";
        }
        return $display.="</select></div>";
    }

    function check_sameuser() {
        $sql = "select count(1) as total from " . DB_PREFIX . "users where var_emailid='" . $_REQUEST['userid'] . "' and chr_publish='Y'and chr_delete='N' and int_glcode!=" . $_REQUEST['eid'];
        $rs = $this->configObj->glDbObj->get_sql_row($sql);
        return $rs['total'];
    }

    function emailtype() {
        $selected_array = $_REQUEST['modval'];
        $sql = "select var_type,int_glcode from " . DB_PREFIX . "emailtype where chr_publish='Y' order by int_glcode";
        $data = $this->configObj->glDbObj->query($sql);

        $display = "<div class=\"new-search-show-all\">";
        $display .="<select name=\"module\" id=\"module\" class=\"more-textarea\" style=\"width:150px;\" onchange=\"SendGridBindRequest('$this->urlwithpara','gridbody','MVF')\">";
        $display .="<option value=\"0\">-- Sort By Email Type --</option>";
        while ($row = $this->configObj->glDbObj->fetch_array($data)) {
            $p = ($row['int_glcode'] == $selected_array) ? 'selected' : '';
            $display .="<option value='" . $row['int_glcode'] . "' " . $p . ">" . $row['var_type'] . "</option>";
        }
        return $display.="</select></div>";
    }

}
