<?php

defined('_VALID') or die(RESTRICTED_ACCESS);
include_once('class.contactuspage.php');
$contactuspageObj = new contactuspage($configObj);
$action = $_REQUEST['action'];
$configObj->glTplObj->change_path($configObj->currentModulePath . 'html/templates/');
$configObj->glTplObj->set('configObj', $configObj);
$configObj->glTplObj->set('contactuspageObj', $contactuspageObj);
$configObj->glTplObj->set('contactpageTab', true);

switch ($action) {

    case 'edit':
        $configObj->glTplObj->set('contactpageAddTab', true);
        $contactuspageObj->Generateurl();
        $contactuspageObj->countFunction = $contactuspageObj->CountRows();
        $contactuspageObj->loadCount();
        $configObj->glTplObj->set('frmaction', $contactuspageObj->urlwithpara . '&action=' . $_REQUEST['action'] . '&eid=' . $_REQUEST['eid']);
        if ($_REQUEST['h_save'] == 'T') {
            $contactuspageObj->varpostdata = $_REQUEST;
            if ($contactuspageObj->update_contactuspage()) {
                if ($_POST['btnsaveandc_x'] != '') {
                    $configObj->glLibraryObj->header_redirect($contactuspageObj->urlwithpara . '&action=' . $_REQUEST['action'] . '&eid=' . $_REQUEST['eid'] . '&msg=edit');
                } else if ($_POST['btnsaveande_x'] != '') {
                    $configObj->glLibraryObj->header_redirect('index.php?module=contactuspage&msg=edit');
                }
            }
        } else {
            if ($_REQUEST['msg']) {
                if ($_REQUEST['msg'] == 'add') {
                    $messagebox = $contactuspageObj->configObj->glLibraryObj->message("Congrats! The record is successfully saved.");
                    $contactuspageObj->configObj->glTplObj->set('messagebox', $messagebox);
                } else if ($_REQUEST['msg'] == 'edit') {
                    $messagebox = $contactuspageObj->configObj->glLibraryObj->message("Congrats! The record is successfully edited and saved.");
                    $contactuspageObj->configObj->glTplObj->set('messagebox', $messagebox);
                }
            }
            $configObj->glTplObj->set('fk_modules', 27);

            $row = $contactuspageObj->select_contactuspage($_REQUEST['eid']);
            $configObj->glTplObj->set('row', $row);

            $configObj->adminContentPanel = $configObj->glTplObj->process('contactuspage_form.tpl.php');
        }
        break;
    default:
        $contactuspageObj->load_contactuspage();
        break;
}
?>
