<?php

class headerpanel {

    function headerpanel($configObj) {
        $this->configObj = $configObj;
    }

    function formemail() {
        $imgurl = SITE_PATH . "/" . powerpanel . "/" . GLOBAL_ADMIN_IMAGES_PATH . "logo.jpg";
        $this->configObj->setEmailConfig();

        $subject = "Sending Help mail";
        $Feedback = "Sending Help mail";

        $bulletImage = '<img src="' . BULLET_IMAGE . '" alt="bullet" width="8" height="8" vspace="7" />';

        $body = '<tr><td width="20" height="24" align="left" valign="middle"><img border="0" style="display:block;" src="@IMG_URLimages/bullet.png" alt="" width="21" height="12" vspace="7" />' . '</td> <td height="24" align="left" valign="middle" style="font-family:Calibri; color:#96C11F; font-size:15px;">Name: ' . $_REQUEST['var_helpname'] . ' </td></tr>            
                 <tr><td width="20" height="24" align="left" valign="middle"><img border="0" style="display:block;" src="@IMG_URLimages/bullet.png" alt="" width="21" height="12" vspace="7" />' . '</td> <td height="24" align="left" valign="middle" style="font-family:Calibri; color:#96C11F; font-size:15px;">Email: ' . '<a href="mailto:' . $_REQUEST['var_helpemail'] . '" style="text-decoration:none; color:#96C11F;">' . $_REQUEST['var_helpemail'] . '</a>' . ' </td></tr>
                 <tr><td width="20" height="24" align="left" valign="middle"><img border="0" style="display:block;" src="@IMG_URLimages/bullet.png" alt="" width="21" height="12" vspace="7" />' . '</td> <td height="24" align="left" valign="middle" style="font-family:Calibri; color:#96C11F; font-size:15px;">Subject: ' . $_REQUEST['var_helpsubject'] . ' </td></tr>
                 <tr><td width="20" height="24" align="left" valign="top">   <img border="0" style="display:block;" src="@IMG_URLimages/bullet.png" alt="" width="21" height="12" vspace="7" />' . '</td> <td height="24" align="left" valign="middle" style="font-family:Calibri; color:#96C11F; font-size:15px;">Description: ' . $_REQUEST['var_helpdescription'] . ' </td></tr>';

        $this->configObj->glLibraryObj->settings();
        $html_message = file_get_contents(GLOBAL_ADMIN_HTML_PATH . '/mailtemplates/help_admin.html');
        $html_message = str_replace("@Feedback", $Feedback, $html_message);
        $html_message = str_replace("@DETAIL_DATA", $body, $html_message);
        $html_message = str_replace("@SITE_URL_FOR_MAIL_LINKS", SITE_PATH, $html_message);
        $html_message = str_replace("@IMG_URL", SITE_PATH . 'front-html/', $html_message);
        $html_message = str_replace("@SITE_NAME_IN_WORDS", SITE_NAME, $html_message);
        $html_message = str_replace("@IMG_URL", SITE_PATH . $this->configObj->themePath, $html_message);
        $html_message = str_replace("@MAIL_TEXT_AFTER_BEST_REGARDS", SITE_NAME, $html_message);
        $html_message = str_replace("@LOGO_PATH", $imgurl, $html_message);
        $html_message = str_replace("@BODYBGIMAGE", BODY_BG_IMAGE, $html_message);
        $html_message = str_replace("@TOPSHADOW", TOP_SHADOW, $html_message);
        $html_message = str_replace("@BOTTOMBGIMAGE", BOTTOM_BG_IMAGE, $html_message);
        $html_message = str_replace("@MAIL_BOTTOM_LINK", MAILBOTTOM_LINK, $html_message);
        $html_message = str_replace("@MAIL_BOTTOM_TEXT", MAILBOTTOM_TEXT, $html_message);
        $html_message = str_replace("@YEAR", date('Y'), $html_message);
        $html_message = str_replace("@EMAIL_SIGNATURE", EMAIL_SIGNATURE, $html_message);

        $sql = "Select var_careeremail from " . DB_PREFIX . "general_settings ";
        $exec = $this->configObj->glDbObj->query($sql);
        $rows = $this->configObj->glDbObj->fetch_array($exec);
        $addarr = $rows['var_careeremail'];
        $this->configObj->glMailObj->AddAddress($addarr);
        $this->configObj->glMailObj->Subject = $subject;
        $this->configObj->glMailObj->Body = $html_message;
        if (!$this->configObj->glLibraryObj->sendmail()) {
            $message = "Error in mail send";
        } else {
            $message = mysql_real_escape_string($html_message);
            $message = "Your Mail sent Successfully. We will get you back soon..";
        }
        return $message;
    }

    function getupdates() {

        $sql11 = "SELECT count(1) as count from " . DB_PREFIX . "contactdetails where  chr_read='N' and chr_delete='N' ";
        $rs11 = $this->configObj->glDbObj->get_sql_row($sql11);
        $updatearray[11]['count'] = $rs11['count'];
        return $updatearray;
    }

    function getModuleId($modulename) {
        if ($modulename == "contactusmsg") {
            $modulename = "contactus";
        }
        $sql = "select int_glcode from " . DB_PREFIX . "modules WHERE var_modulename='" . $modulename . "'";
        $result = $this->configObj->glDbObj->get_sql_row($sql);
        if ($_REQUEST['action'] != '') {
            $returndata = "action-" . $result['int_glcode'];
        } else if ($_REQUEST['view'] != '') {
            $returndata = "view-" . $result['int_glcode'];
        } else {
            $returndata = $result['int_glcode'];
        }
        return $returndata;
    }
}
?>