<?php

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

switch ($action) {
    case 'delete':
        if ($configObj->isAjaxSet) {
            $newsletterObj->is_newslatterused(95);
        }
        $newsletterObj->loadCount('CountRowsnews');
        break;

    case 'updatereaddata':

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

        case 'export':

        $tablename = "newsletterleads";
        $configObj->glLibraryObj->xlsSQL = $newsletterObj->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 ($_REQUEST['msg']) {
            if ($_REQUEST['msg'] == 'send') {
                $messagebox = $configObj->glLibraryObj->message("Congrats! The Email has been sent successfully.");
                $configObj->glTplObj->set('messagebox', $messagebox);
            }
        }
        $newsletterObj->load_newslatterleads();
        break;
}
?>
