<?php
defined('_VALID') or die(RESTRICTED_ACCESS);
include_once('../configuration.php');
include_once('class.inquiry.php');
$inquiryObj = new inquiry($configObj);
$action = $_REQUEST['action'];
$view = $_REQUEST['view'];
$configObj->glTplObj->change_path($configObj->currentModulePath . 'html/templates/');
$configObj->glTplObj->set('configObj', $configObj);
$configObj->glTplObj->set('inquiryObj', $inquiryObj);
$configObj->glTplObj->set('contactusTab', true);
$paramMain = $configObj->AllmoduleAccess[$configObj->ModuleName];
$configObj->glTplObj->set('paramMain', $paramMain);

switch ($view) {
    case 'newslatter' :
        switch ($action) {
			
            case 'delete':
                if ($configObj->isAjaxSet) {
                    $inquiryObj->is_newslatterused(46);
                }

                $inquiryObj->loadCount('CountRowsnews');
                break;

            case 'email':

                if ($_REQUEST['sub'] == 'reply') {
                    $id = $_REQUEST['userid'];
                    $inquiryObj->varpostdata = $_REQUEST;
                    $sendmailstatus = $inquiryObj->formemailnews($id);
                    $configObj->glLibraryObj->header_redirect('index.php?module=contactusmsg&view=newslatter&msg=send');
                } else {
                    echo $configObj->adminContentPanel = $configObj->glTplObj->process('reply_form.tpl.php');
                    exit;
                }
                break;

            case 'updatereaddata':

                $sql = "UPDATE " . DB_PREFIX . "newslatterleads SET chr_read='Y' where int_glcode=" . $_REQUEST['id'];
                $inquiryObj->configObj->glDbObj->query($sql);
                echo $_REQUEST['id'];
                exit;
                break;

            case 'export':

                $tablename = "newslatterleads";
                $configObj->glLibraryObj->xlsSQL = $inquiryObj->gettabledataData($tablename);
                $configObj->glLibraryObj->fileheader = "<center>Newsletter Leads\n</center>";
                $configObj->glLibraryObj->filename = "" . SITE_NAME . "_Newsletter_Leads"."[". date("Y-m-d")."].xls";
                $configObj->glLibraryObj->dataArray = $allrecordsset;
                $configObj->glLibraryObj->generateXLSfile();
                break;

            default:
                if ($configObj->AllmoduleAccess['newslatter']['View'] == 'Y') {
                    if ($_REQUEST['msg']) {
                        if ($_REQUEST['msg'] == 'send') {
                            $messagebox = $configObj->glLibraryObj->message("Congrats! The Email has been sent successfully.");
                            $configObj->glTplObj->set('messagebox', $messagebox);
                        }
                    }
                    $inquiryObj->load_newslatterleads();
                } else {
                    echo RESTRICTED_ACCESS;
                    exit;
                }
                break;
        }
        break;

    default:
        switch ($action) {
            case 'delete':
                if ($configObj->isAjaxSet) {
                    $inquiryObj->is_contactused(7);
                }
                break;

            case 'email':

                if ($_REQUEST['sub'] == 'reply') {
                    $id = $_REQUEST['userid'];
                    $inquiryObj->varpostdata = $_REQUEST;
                    $sendmailstatus = $inquiryObj->formemail($id);
                    $configObj->glLibraryObj->header_redirect('index.php?module=contactusmsg&msg=send');
                } else {
                    echo $configObj->adminContentPanel = $configObj->glTplObj->process('reply_form.tpl.php');
                    exit;
                }
                break;

            case 'export':

                $tablename = "contactdetails";
                $configObj->glLibraryObj->xlsSQL = $inquiryObj->gettabledataData($tablename);
                $configObj->glLibraryObj->fileheader = "<center>Contact Us Leads\n</center>";
                $configObj->glLibraryObj->filename = "" . SITE_NAME . "_Contact_Us_Leads"."[". date("Y-m-d")."].xls";
                $configObj->glLibraryObj->dataArray = $allrecordsset;
                $configObj->glLibraryObj->generateXLSfile();
                break;
             

            case 'updatereaddata':

                $sql = "UPDATE " . DB_PREFIX . "contactdetails SET chr_read='Y' where int_glcode=" . $_REQUEST['id'];
                $inquiryObj->configObj->glDbObj->query($sql);
                echo $_REQUEST['id'];
                exit;
                break;

            default:
                if ($_REQUEST['msg']) {
                    if ($_REQUEST['msg'] == 'send') {
                        $messagebox = $configObj->glLibraryObj->message("Congrats! The Email has been sent successfully.");
                        $configObj->glTplObj->set('messagebox', $messagebox);
                    }
                }
                $inquiryObj->load_contactinquiry();
                break;
        }
        break;
}
?>
