<?php

class ourteam {

    var $pagename = 'index.php?module=ourteam'; // Attribute of Page Name
    var $numofrows; // Attribute of Num Of Rows In Result
    var $numofpages; // Attribute of Num Of Pagues In Result
    var $orderby = 'int_displayorder'; // Attribute of Deafult Order By
    var $ordertype = 'asc'; // 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 $hurlwithpara = ''; // Attribute of URL With parameters for history
    var $urlwithpara = ''; // 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 $filterby = '0';
    var $urlwithoutfilter = '';
    var $display_limit_array = array('5', '10', '20', '30');
    var $thumb_width = '124';
    var $thumb_height = '126';
    var $thumb_width1;
    var $thumb_height1;
    var $UsertypeArray = array("M" => "Member", "O" => "Owner", "E" => "Employee");
    var $modstaus = array("N" => "New", "R" => "Renewed", "U" => "Upgraded");
    var $status = array("A" => "Active", "P" => "Pending", "C" => "Close");
    var $monthArray = array("1" => "January", "2" => "February", "3" => "March", "4" => "April", "5" => "May", "6" => "June", "7" => "July", "8" => "August", "9" => "September", "10" => "October", "11" => "November", "12" => "December");
    var $fk_pageId;
    var $fk_project;

    function ourteam($configObj) {
       // $this->sortvar = '<img alt="sorting" src="' . GLOBAL_ADMIN_IMAGES_PATH . 'arrow-up.png" style="vertical-align:middle;">';
        $this->configObj = $configObj;
        $this->moduleid = $this->configObj->glLibraryObj->get_fk_tml_modules($_REQUEST['module']);
    }

    function intitialize() {
        if (!empty($_REQUEST['history'])) {
            $this->configObj->glLibraryObj->hintitialize($this);
            return;
        }

        $this->searchby = (isset($_REQUEST['searchby'])) ? $_REQUEST['searchby'] : $this->searchby;
        $_REQUEST['searchtxt'] = ($_REQUEST['type'] == 'autosearch') ? $_REQUEST['term'] : $_REQUEST['searchtxt'];
        $this->searchbyVal = (isset($_REQUEST['searchbyVal'])) ? $_REQUEST['searchbyVal'] : $this->searchbyVal;
        $this->optval = (isset($_REQUEST['optval'])) ? $_REQUEST['optval'] : $this->optval;
        $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;
        $this->types = (isset($_REQUEST['types'])) ? $_REQUEST['types'] : 'M';
        $this->uid = (isset($_REQUEST['uid'])) ? $_REQUEST['uid'] : $this->uid;
        $this->categorytype = (isset($_REQUEST['optval'])) ? $_REQUEST['optval'] : $this->categorytype;

        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;\">";
            }
        } else {
           // $this->sortvar = "<img alt=\"sorting\" src=\"" . GLOBAL_ADMIN_IMAGES_PATH . "arrow-up.png\" style=\"vertical-align:middle;\">";
        }

        $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;
    }

    function loadCount($function) {
        $this->intitialize();
        $this->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 CountRows() {
        if (trim($this->searchtxt) != '') {
        $whereclause.=" and var_name like '%" . $this->configObj->glDbObj->addSlashes($this->searchtxt) . "%'";
        }
        if ($this->filterby != '0' && $this->filterby != '') {
            $filterarray = explode('-', $this->filterby);
            $whereclause .=" and $filterarray[0] = '$filterarray[1]'";
        }
        $sqlCountarticle = "select count(1) as total FROM " . DB_PREFIX . "ourteam  where chr_delete='N'  $whereclause ";
        $rs = $this->configObj->glDbObj->get_sql_row($sqlCountarticle);
        return $rs['total'];
    }

    function select_ourteam($id) {


        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $tablename = DB_PREFIX . "ourteam";
        $this->configObj->glDbObj->setTable($tablename);
        $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 selectall() {
        $dtformat = DEFAULT_DATEFORMAT;
        $dtformat = "%d/%m/%Y";
        $this->configObj->glDbObj->resetfields(); // Reset the object
        $this->configObj->glDbObj->setQueryType('select');    // Set the Table
        $tablename = DB_PREFIX . "ourteam p";
        $this->configObj->glDbObj->setTable($tablename);
        $this->configObj->glDbObj->addColumn("*");
        $whereclause = "p.chr_delete = 'N' ";

        if (trim($this->searchtxt) != '') {
            $whereclause .= ( $this->searchby == '0') ? " and p.var_name 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 p.$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') {
            $orderby = (isset($_REQUEST['orderby'])) ? 'order by p.' . $this->orderby . ' ' . $this->ordertype : 'order by p.dt_modifydate';

            $searchbyVal = (!empty($this->searchbyVal)) ? " $whereclause " : $whereclause;


            $autoSearchQry = "select p.int_glcode ," . $this->searchbyVal . " as AutoVal FROM " . $tablename . " where $searchbyVal group by " . $this->searchbyVal . " $orderby";

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

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

    function insert_ourteam() {
        $this->configObj->glLibraryObj->updatedisplay_order('ourteam', $this->varpostdata['int_displayorder']);
        $this->int_glcode = ""; // clear key for autoincrement
        $this->configObj->glDbObj->resetfields();
        $tablename = DB_PREFIX . 'ourteam';
        $this->configObj->glDbObj->setTable($tablename);
        $this->configObj->glDbObj->setQueryType('insert');
        $this->thumb_width1 = 133;
        $this->thumb_height1 = 200;
        $this->thumb_src_image_width = 50;
        $this->thumb_src_image_height = 50;
        $file_extension = $this->configObj->glLibraryObj->file_extension($_FILES['var_image']['name']);
        if ($_FILES["var_image"]["name"] != "") {
            $maindir = '../upimages/ourteam/images/';
            $thumbdir = '../upimages/ourteam/images/';
            $var_main_file = $this->configObj->glLibraryObj->generate_image('var_image', $maindir); // Main Upload and Resize
            $this->imagename = $var_main_file;
            if (isset($var_main_file)) {
                if (empty($this->varpostdata['var_name'])) {
                    $temp = explode(".", $_FILES["var_image"]["name"]);
                    $this->varpostdata['var_name'] = $temp[0];
                }
                $file_photo = basename($var_main_file);
                $file = $maindir . $var_main_file;
                $tmp = $_FILES['var_image']['tmp_name'];
                $uploadedfile = $maindir . $file_photo;
                $var_thumb1 = $this->configObj->glLibraryObj->create_image($this->thumb_width1, $this->thumb_height1, 'thumb_', $this->thumb_width1, $this->thumb_height1, $uploadedfile, '', $thumbdir);
                //$this->imagename = $var_thumb1;
            }
        } else {
            $this->imagename = $_REQUEST['hidvar_image'];
        }

        $this->configObj->glDbObj->addColumn('var_name');
        $this->configObj->glDbObj->addColumn('var_alias');
        $this->configObj->glDbObj->addColumn('var_nationality');
        $this->configObj->glDbObj->addColumn('var_description');
        $this->configObj->glDbObj->addColumn('var_specialize');
        $this->configObj->glDbObj->addColumn('var_expertise');
        $this->configObj->glDbObj->addColumn('var_experience');
        $this->configObj->glDbObj->addColumn('var_phone');
        $this->configObj->glDbObj->addColumn('var_email');
        $this->configObj->glDbObj->addColumn('var_image');
        $this->configObj->glDbObj->addColumn('var_study');
        $this->configObj->glDbObj->addColumn('var_history');
        $this->configObj->glDbObj->addColumn('var_cayman_since');
        $this->configObj->glDbObj->addColumn('var_eclipze_since');
        $this->configObj->glDbObj->addColumn('var_objective');
        $this->configObj->glDbObj->addColumn('chr_delete');
        $this->configObj->glDbObj->addColumn('chr_read');
        $this->configObj->glDbObj->addColumn('chr_publish');
        $this->configObj->glDbObj->addColumn('dt_createdate');
        $this->configObj->glDbObj->addColumn('dt_modifydate');
        $this->configObj->glDbObj->addColumn('int_displayorder');
        $this->configObj->glDbObj->addColumn('var_metatitle');
        $this->configObj->glDbObj->addColumn('var_metakeyword');
        $this->configObj->glDbObj->addColumn('var_metadescription');

        // set the values

        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_name'])));
        $this->configObj->glDbObj->addValue($this->configObj->glLibraryObj->convertspacetodesh($this->varpostdata['var_alias']));
        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_nationality'])));
        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_description'])));
        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_specialize'])));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_expertise']));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_experience']));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_phone']));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_email']));
        $this->configObj->glDbObj->addValue($this->imagename);
        if($this->varpostdata['var_desc1'] == 'Y'){
             $this->configObj->glDbObj->addValue($this->varpostdata['var_study']);
            } else {
                $this->configObj->glDbObj->addValue('');  
            }
        if($this->varpostdata['var_desc'] == 'Y'){
             $this->configObj->glDbObj->addValue($this->varpostdata['var_history']);
            } else {
                $this->configObj->glDbObj->addValue('');  
            }            
        $this->configObj->glDbObj->addValue($this->varpostdata['var_cayman_since']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_eclipze_since']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_objective']);
        $this->configObj->glDbObj->addValue('N');
        $this->configObj->glDbObj->addValue('N');
        $this->configObj->glDbObj->addValue('Y');
        $this->configObj->glDbObj->addValue('NOW()');
        $this->configObj->glDbObj->addValue('NOW()');
        $this->configObj->glDbObj->addValue($this->varpostdata['int_displayorder']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_metatitle']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_metakeyword']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_metadescription']);



        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->varpostdata['eid']);
//        echo $this->configObj->glDbObj->buildQuery();exit;
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());


        $this->lastinsertid = mysql_insert_id();
        $this->configObj->glLibraryObj->set_display_order_sequence($tablename);
        //insert into logmanager
        $this->configObj->glLibraryObj->insertinlogmanager(79, $tablename, 'var_name', $this->lastinsertid, 'I');

        return true;
    }

    function update_ourteam() {


        if ($this->varpostdata['int_displayorder'] != $this->varpostdata['old_displayorder']) {
            $this->update_display_order($this->varpostdata['eid'], $this->varpostdata['int_displayorder'], $this->varpostdata['old_displayorder']);
        }
        $this->configObj->glDbObj->resetfields();
        $tablename = DB_PREFIX . 'ourteam';
        $this->configObj->glDbObj->setTable($tablename);
        $this->configObj->glDbObj->setQueryType('update');
        $this->thumb_width1 = 133;
        $this->thumb_height1 = 200;
        $file_extension = $this->configObj->glLibraryObj->file_extension($_FILES['var_image']['name']);
        if ($_FILES["var_image"]["name"] != "") {
            $maindir = '../upimages/ourteam/images/';
            $thumbdir = '../upimages/ourteam/images/';
            $var_main_file = $this->configObj->glLibraryObj->generate_image('var_image', $maindir); // Main Upload and Resize
            $this->imagename = $var_main_file;
            if (isset($var_main_file)) {
                if (empty($this->varpostdata['var_name'])) {
                    $temp = explode(".", $_FILES["var_image"]["name"]);
                    $this->varpostdata['var_name'] = $temp[0];
                }
                $file_photo = basename($var_main_file);
                $file = $maindir . $var_main_file;
                $tmp = $_FILES['var_image']['tmp_name'];
                $uploadedfile = $maindir . $file_photo;
                $var_thumb1 = $this->configObj->glLibraryObj->create_image($this->thumb_width1, $this->thumb_height1, 'thumb_', $this->thumb_width1, $this->thumb_height1, $uploadedfile, '', $thumbdir);
            }
        } else {
            $this->imagename = $_REQUEST['hidvar_image'];
        }

        $this->configObj->glDbObj->addColumn('var_name');
        $this->configObj->glDbObj->addColumn('var_alias');
        $this->configObj->glDbObj->addColumn('var_nationality');
         $this->configObj->glDbObj->addColumn('var_description');
        $this->configObj->glDbObj->addColumn('var_specialize');
        $this->configObj->glDbObj->addColumn('var_expertise');
        $this->configObj->glDbObj->addColumn('var_experience');
        $this->configObj->glDbObj->addColumn('var_phone');
        $this->configObj->glDbObj->addColumn('var_email');
        $this->configObj->glDbObj->addColumn('var_image');
        $this->configObj->glDbObj->addColumn('var_study');
        $this->configObj->glDbObj->addColumn('var_history');
        $this->configObj->glDbObj->addColumn('var_cayman_since');
        $this->configObj->glDbObj->addColumn('var_eclipze_since');
        $this->configObj->glDbObj->addColumn('var_objective');
        $this->configObj->glDbObj->addColumn('chr_delete');
        $this->configObj->glDbObj->addColumn('chr_read');
        $this->configObj->glDbObj->addColumn('chr_publish');
        $this->configObj->glDbObj->addColumn('dt_createdate');
        $this->configObj->glDbObj->addColumn('dt_modifydate');
        $this->configObj->glDbObj->addColumn('int_displayorder');
        $this->configObj->glDbObj->addColumn('var_metatitle');
        $this->configObj->glDbObj->addColumn('var_metakeyword');
        $this->configObj->glDbObj->addColumn('var_metadescription');

        // set the values

        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_name'])));
        $this->configObj->glDbObj->addValue($this->configObj->glLibraryObj->convertspacetodesh($this->varpostdata['var_alias']));
        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_nationality'])));
        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_description'])));
        $this->configObj->glDbObj->addValue(htmlspecialchars(trim($this->varpostdata['var_specialize'])));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_expertise']));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_experience']));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_phone']));
        $this->configObj->glDbObj->addValue(htmlspecialchars($this->varpostdata['var_email']));
        $this->configObj->glDbObj->addValue($this->imagename);
        if($this->varpostdata['var_desc1'] == 'Y'){
             $this->configObj->glDbObj->addValue($this->varpostdata['var_study']);
            } else {
                $this->configObj->glDbObj->addValue('');  
            }
        if($this->varpostdata['var_desc'] == 'Y'){
             $this->configObj->glDbObj->addValue($this->varpostdata['var_history']);
            } else {
                $this->configObj->glDbObj->addValue('');  
            } 
//        $this->configObj->glDbObj->addValue($this->varpostdata['var_study']);
//        $this->configObj->glDbObj->addValue($this->varpostdata['var_history']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_cayman_since']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_eclipze_since']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_objective']);
        $this->configObj->glDbObj->addValue('N');
        $this->configObj->glDbObj->addValue('N');
        $this->configObj->glDbObj->addValue($this->varpostdata['chr_publish']);
        $this->configObj->glDbObj->addValue('NOW()');
        $this->configObj->glDbObj->addValue('NOW()');
        $this->configObj->glDbObj->addValue($this->varpostdata['int_displayorder']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_metatitle']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_metakeyword']);
        $this->configObj->glDbObj->addValue($this->varpostdata['var_metadescription']);
      
        $this->configObj->glDbObj->setWhere('int_glcode=' . $this->varpostdata['eid']);
        
        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
        $this->lastinsertid = $this->varpostdata['eid'];
        $this->configObj->glLibraryObj->set_display_order_sequence($tablename);
        $this->configObj->glLibraryObj->insertinlogmanager(79, $tablename, 'var_name', $this->lastinsertid, 'U');
        return true;
    }

    function update_display_order($ids, $values, $oldvalues) {
        $tablename = "ourteam";

        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(DB_PREFIX . "ourteam");

                $this->configObj->glDbObj->addColumn('count(1) as total');

                $this->configObj->glDbObj->setWhere("int_displayorder=" . $values[$i] . " and chr_delete = 'N' $updatewhereclause");

                $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(DB_PREFIX . "ourteam");

                        $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] . '' . $updatewhereclause);

                        $this->configObj->glDbObj->query($this->configObj->glDbObj->buildQuery());
                    } else {
                        $this->configObj->glDbObj->resetfields();

                        $this->configObj->glDbObj->setTable(DB_PREFIX . "ourteam");

                        $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] . '' . $updatewhereclause);

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

                $this->configObj->glDbObj->setTable(DB_PREFIX . "ourteam");

                $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] . '' . $updatewhereclause);

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

    function delete_user() {
        $tablename = DB_PREFIX . "ourteam";

        $deleteids = $_REQUEST['dids'];

        $deletearray = explode(',', $deleteids);

        $totaldeletedrecords = count($deletearray);

        $is_assigned = 0;

        for ($i = 0; $i < $totaldeletedrecords; $i++) {
            $sql = "Update " . $tablename . " set chr_delete='Y', dt_modifydate=NOW(),var_ipaddress='" . $_SERVER['REMOTE_ADDR'] . "',var_adminuser='" . ADMIN_NAME . "' where int_glcode=" . $deletearray[$i];

            $this->configObj->glDbObj->query($sql);
            $this->configObj->glLibraryObj->insertinlogmanager(79, $tablename, 'var_name', $deletearray[$i], 'D');
        }

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

        $this->load_ourteam();
    }

    function load_ourteam() {
        if ($_REQUEST['task'] == 'orderupdate') {
            $updateids = $_REQUEST['uids'];

            $updatevalues = $_REQUEST['uvals'];

            $updateoldvalues = $_REQUEST['uoldvals'];

            $upidsarray = explode(',', $updateids);  //Intglcode array

            $upvalsarray = explode(',', $updatevalues);  // New Display Order Array

            $upoldvalsarray = explode(',', $updateoldvalues); //Old Display Order Array
            $this->update_display_order($upidsarray, $upvalsarray, $upoldvalsarray, 'ourteam');
            $tablename = "" . DB_PREFIX . 'ourteam';
            $this->configObj->glLibraryObj->set_display_order_sequence($tablename);
        }

        $this->intitialize();
        $this->pagename = 'index.php?module=ourteam';
        $this->loadCount('CountRows');
        $this->configObj->glTplObj->set('speakerbioTab', true);
        $this->configObj->glTplObj->set('setsortimg' . $this->orderby, $this->sortvar);
        $result = $this->selectall();
        $this->configObj->glTplObj->set('result', $result);
        $table = DB_PREFIX . 'users';
        $view = 'Manage Our Team';
        $actionurl = 'index.php?module=ourteam&action=add';

        $searchArray = array("var_name" => "Name");
        $parmas = $this->generateParam($view, $actionurl, $searchArray, $table);


        $this->configObj->glTplObj->set('headerpanel', $this->configObj->glLibraryObj->generateHeaderPanel($parmas));

        $this->configObj->glTplObj->set('pagingTop', $this->configObj->glLibraryObj->generatePagingPannel($parmas));

        $this->configObj->glTplObj->set('pagingBottom', $this->configObj->glLibraryObj->generatePagingPannel($this->generateParam($view, $actionurl, $searchArray, $table, 'bottom')));

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

        if ($_REQUEST['msg']) {
            if ($_REQUEST['msg'] == 'add') {
                $messagebox = $this->configObj->glLibraryObj->message("Congrats! The data has been successfully saved.");

                $this->configObj->glTplObj->set('messagebox', $messagebox);
            } else if ($_REQUEST['msg'] == 'edit') {
                $messagebox = $this->configObj->glLibraryObj->message("The record has been successfully edited!");
                $this->configObj->glTplObj->set('messagebox', $messagebox);
            }
        }

        $notemessagebox = $this->configObj->glLibraryObj->notemessage("Note: ", "Adding Team Members are incremental, once you add a new Team Member it will display as first record and previous Team Members will move down in the order.");

        $this->configObj->glTplObj->set('notemessagebox', $notemessagebox);

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

    function Generateurl() {

        $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 . '&hfilterby=' . $this->filterby . '&history=T&types=' . $this->types . '&fk_pageId=' . $this->fk_pageId . '&package_id=' . $this->package_id . '&optval=' . $this->optval;
        $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 . '&types=' . $this->types . '&fk_pageId=' . $this->fk_pageId . '&package_id=' . $this->package_id . '&optval=' . $this->optval;
        $this->urlwithpoutsearch = $this->pagename . '&' . 'pagesize=' . $this->pagesize . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&filterby=' . $this->filterby . '&types=' . $this->types . '&fk_pageId=' . $this->fk_pageId . '&package_id=' . $this->package_id . '&optval=' . $this->optval;
        $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 . '&types=' . $this->types . '&fk_pageId=' . $this->fk_pageId . '&package_id=' . $this->package_id . '&optval=' . $this->optval;
        $this->urlwithoutpaging = $this->pagename . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&searchby=' . $this->searchby . '&searchtxt=' . $this->searchtxtjs . '&filterby=' . $this->filterby . '&types=' . $this->types . '&fk_pageId=' . $this->fk_pageId . '&package_id=' . $this->package_id . '&optval=' . $this->optval;
        $this->urlwithoutfilter = $this->pagename . '&' . 'pagesize=' . $this->pagesize . '&orderby=' . $this->orderby . '&ordertype=' . $this->ordertype . '&searchby=' . $this->searchby . '&searchtxt=' . $this->searchtxtjs . '&types=' . $this->types . '&fk_pageId=' . $this->fk_pageId . '&package_id=' . $this->package_id . '&optval=' . $this->optval;
        $this->configObj->AutoSearchUrl = $this->urlwithpara . "&type=autosearch&searchbyVal=" . $this->searchbyVal . $homepara . $this->optval;
    }

    function generateParam($view = '', $actionurl = '', $searchArray = array(""), $table = '', $position = 'top', $otheraction = '', $renew = '', $upgrade = '') {
        $this->intitialize();
        $filterPos = ($position == 'top') ? 'FT' : 'FB';
        if ($this->configObj->glSessionObj->value('admin_id') == '1' && $_REQUEST['view'] == '') {
            $filterstar = array(
                'filterurl' => $this->urlwithoutfilter,
                'filterposition' => $filterPos,
                'filterby' => $this->filterby
            );
        } else {
            $filterstar = array();
        }
        return array('pageurl' => $this->pagename,
            'heading' => $view,
            'listImage' => 'listing-icon.png',
            'tablename' => $table,
            '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
                '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,
            ),
            'cmbteam' => $cmbteam
        );
    }
}

?>