<?php

include_once $CFG->dirroot . "/lib/classes/" . "application/Contect_us.Class.php5";
$contect_us = new Contect_us();
if ($mode == "Update") {
    $iContactId = $_POST['iContactId'];
    $contect_us->select($iContactId);
}
$GeneralObj->getRequestVars();
$contect_us->setAllVar();
if ($mode == "Add") {
    $dAddedDate = date('Y-m-d H:i:s');
    $contect_us->setdAddedDate($dAddedDate);
    $contect_us->insert();
    $msg = urlencode(MSG_ADD);
    header("Location:index.php?file=Contact_us&AX=Yes&var_msg={$msg}");
    exit;
} else {
    if ($mode == "Update") {
        $contect_us->update($iContactId);
        $msg = urlencode(MSG_UPDATE);
        header("Location:index.php?file=Contact_us&AX=Yes&var_msg={$msg}");
        exit;
    }
}
 public function contect_us_admin($iContactId)
 {
     global $site_url, $COMPANY_NAME, $EMAIL_ADMIN, $GeneralObj, $SEO_FRIENDLY_UR, $EMAIL_SUPPORT;
     include_once $CFG->dirroot . "/lib/classes/" . 'application/Contect_us.Class.php5';
     $code = 'CONTACT_US';
     $sql_select = "SELECT * FROM system_email WHERE vEmailCode='" . $code . "' AND eStatus='Active'";
     $db_select = $this->obj->select($sql_select);
     $vEmailTitle = $db_select[0]["vEmailTitle"];
     $vFromName = $db_select[0]["vFromName"];
     $vFromEmail = $db_select[0]["vFromEmail"];
     $eEmailFormat = $db_select[0]["eEmailFormat"];
     $vEmailSubject = $db_select[0]["vEmailSubject"];
     $tEmailMessage = stripslashes($db_select[0]["tEmailMessage"]);
     $vEmailFooter = $db_select[0]["vEmailFooter"];
     $toEmail = $EMAIL_ADMIN;
     if (count($db_select) > 0) {
         $contect_obj = new Contect_us();
         $contect_obj->select($iContactId);
         $array = array('#NAME#' => $contect_obj->getvName(), '#EMAIL#' => $contect_obj->getvEmail(), '#DESCRIPTION#' => $contect_obj->gettDescription());
         $tContent = str_replace(array_keys($array), array_values($array), $tEmailMessage);
         $status = $this->mail_mailMe($toEmail, $vEmailSubject, $tContent, $vFromEmail, $format, $cc, $bcc);
     }
 }