<?php

defined('_VALID') or die(RESTRICTED_ACCESS);
include_once('class.ourteam.php');
$preObj = new ourteam($configObj);
$configObj->glTplObj->change_path($configObj->currentModulePath . 'html/templates/');
$configObj->glTplObj->set('preObj', $preObj);
$configObj->glTplObj->set('configObj', $configObj);
$action = $_REQUEST['action'];
$view = $_REQUEST['view'];
$paramMain = $configObj->AllmoduleAccess[$configObj->ModuleName];
$configObj->glTplObj->set('paramMain', $paramMain);
switch ($action) {
    case 'add':
        $preObj->varpostdata = $_REQUEST;
        $preObj->loadCount('CountRows');
        $preObj->intitialize();
        if ($paramMain['Add'] != 'Y') {
            $configObj->glLibraryObj->header_redirect('index.php?module=ourteam');
        }
        $configObj->glTplObj->set('ourteamAddTab', true);
        if ($_REQUEST['h_save'] == 'T') {
            if ($preObj->insert_ourteam()) {
                if ($_POST['btnsaveandc_x'] != '') {
                    $eid = $preObj->lastinsertid;
                    $configObj->glLibraryObj->header_redirect('index.php?module=ourteam&action=edit&msg=add&eid=' . $eid);
                } else if ($_POST['btnsaveande_x'] != '') {
                    $configObj->glLibraryObj->header_redirect('index.php?module=ourteam&msg=add&types=' . $preObj->types);
                } else if ($_POST['btnsaveandnew_x'] != '') {
                    $configObj->glLibraryObj->header_redirect('index.php?module=ourteam&action=add&msg=add&types=' . $preObj->types);
                } else if ($_POST['btnsaveandcopy_x'] != '') {
                    $configObj->glLibraryObj->header_redirect('index.php?module=ourteam&action=edit&msg=add&mode=copy&eid=' . $preObj->lastinsertid . '&types=' . $preObj->types);
                }
            }
        } else {

            $configObj->glTplObj->set('imghelpdiv', $configObj->glLibraryObj->helpdivforimg('933', '366'));
            $configObj->glTplObj->set('frmaction', $preObj->urlwithpara . '&action=' . $_REQUEST['action']);
            $configObj->glTplObj->set('BottomSubmitButtons', $configObj->glLibraryObj->GetSubmitButtons($preObj->urlwithpara, 'bottom'));
            if ($_REQUEST['msg'] == 'add') {
                $messagebox = $configObj->glLibraryObj->message("Congrats! The data has been successfully saved.");
                $configObj->glTplObj->set('messagebox', $messagebox);
            } else if ($_REQUEST['msg'] == 'edit') {
                $messagebox = $preObj->configObj->glLibraryObj->message("Congrats! The data has been successfully edited and saved.");
                $configObj->glTplObj->set('messagebox', $messagebox);
            }
            $configObj->adminContentPanel = $configObj->glTplObj->process('ourteam_add.tpl.php');
        }
        break;
    case 'edit':
        $preObj->intitialize();
        $preObj->loadCount('CountRows');
        $configObj->glTplObj->set('ourteamAddTab', true);
        $configObj->glTplObj->set('frmaction', $preObj->urlwithpara . '&action=' . $_REQUEST['action'] . '&eid=' . $_REQUEST['eid']);
        if ($_REQUEST['h_save'] == 'T') {
            $preObj->varpostdata = $_REQUEST;
            if ($preObj->update_ourteam()) {
                if ($_POST['btnsaveandc_x'] != '') {
                    $configObj->glLibraryObj->header_redirect($preObj->urlwithpara . '&action=' . $_REQUEST['action'] . '&eid=' . $_REQUEST['eid'] . '&msg=edit');
                } else if ($_POST['btnsaveande_x'] != '') {
                    $configObj->glLibraryObj->header_redirect($preObj->urlwithpara . '&msg=edit');
                } else if ($_POST['btnsaveandnew_x'] != '') {
                    $configObj->glLibraryObj->header_redirect('index.php?module=ourteam&action=add&msg=edit');
                } else if ($_POST['btnsaveandcopy_x'] != '') {
                    $configObj->glLibraryObj->header_redirect('index.php?module=ourteam&action=edit&msg=edit&eid=' . $_REQUEST['eid']);
                }
            }
        } else {
            if ($_REQUEST['mode'] == 'copy') {
                $action = 'add';
                $preObj->configObj->glTplObj->set('action', $action);
            } else {
                $action = $_REQUEST['action'];
            }
            $row = $preObj->select_ourteam($_REQUEST['eid']);
            $configObj->glTplObj->set('row', $row);
            $configObj->glTplObj->set('row1', $row1);

            $configObj->glTplObj->set('imghelpdiv', $configObj->glLibraryObj->helpdivforimg('698', '276'));
            $configObj->glTplObj->set('frmbanner', $preObj->urlwithpara . '&action=' . $action . '&eid=' . $_REQUEST['eid']);
            $configObj->glTplObj->set('BottomSubmitButtons', $configObj->glLibraryObj->GetSubmitButtons($preObj->urlwithpara, 'bottom'));
            if ($_REQUEST['msg'] == 'add') {
                $messagebox = $configObj->glLibraryObj->message("Congrats! The record is successfully saved.");
                $configObj->glTplObj->set('messagebox', $messagebox);
            } else if ($_REQUEST['msg'] == 'edit') {
                $messagebox = $preObj->configObj->glLibraryObj->message("Congrats! The record is successfully edited and saved.");
                $configObj->glTplObj->set('messagebox', $messagebox);
            }
            $configObj->adminContentPanel = $configObj->glTplObj->process('ourteam_add.tpl.php');
        }
        break;
    case 'delete' :
        if ($configObj->isAjaxSet) {
            $preObj->delete_user();
        }
        break;

    case 'updatepublish':
        $id = $_REQUEST['id'];
        $configObj->glLibraryObj->updatefieldinmultiple();
        echo 1;
        exit;


    default:
        $configObj->glTplObj->set('ourteamTab', true);
        $preObj->load_ourteam();
        break;
}
?>
