Пример #1
0
    function sendemailcertificate()
    {
        $datace = JRequest::get('post', JREQUEST_ALLOWRAW);
        $user = JFactory::getUser();
        include JPATH_SITE . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurubuy.php';
        $config = JFactory::getConfig();
        $from = $config->mailfrom;
        $fromname = $config->fromname;
        $guru_configs = guruModelguruBuy::getConfigs();
        $db = JFactory::getDBO();
        $imagename = "SELECT subjectt4 FROM #__guru_certificates WHERE id=1";
        $db->setQuery($imagename);
        $db->query();
        $imagename = $db->loadResult();
        if (isset($guru_configs["0"]["fromname"]) && trim($guru_configs["0"]["fromname"]) != "") {
            $fromname = trim($guru_configs["0"]["fromname"]);
        }
        if (isset($guru_configs["0"]["fromemail"]) && trim($guru_configs["0"]["fromemail"]) != "") {
            $from = trim($guru_configs["0"]["fromemail"]);
        }
        $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
        $db->setQuery($imagename);
        $db->query();
        $imagename = $db->loadAssocList();
        $site_url = JURI::root();
        $coursename = $datace['cn'];
        $authorname = $datace['an'];
        $certificateid = $datace['id'];
        $completiondate = $datace['cd'];
        $course_id = $datace['ci'];
        $sitename = $config->get('sitename');
        $user_id = $user->id;
        $firstnamelastname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($user_id);
        $db->setQuery($firstnamelastname);
        $db->query();
        $firstnamelastname = $db->loadAssocList();
        $coursemsg = "SELECT certificate_course_msg FROM #__guru_program WHERE id=" . intval($course_id);
        $db->setQuery($coursemsg);
        $db->query();
        $coursemsg = $db->loadResult();
        $avg_certc = "SELECT avg_certc FROM #__guru_program WHERE id=" . intval($course_id);
        $db->setQuery($avg_certc);
        $db->query();
        $avg_certc = $db->loadResult() . "%";
        $certificate_url = JUri::base() . "index.php?option=com_guru&view=guruOrders&task=printcertificate&opt=" . $certificateid . "&cn=" . $coursename . "&an=" . $authorname . "&cd=" . $completiondate . "&id=" . $certificateid . "&ct=" . $user_id;
        $certificate_url = str_replace(" ", "%20", $certificate_url);
        $imagename[0]["templates4"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[STUDENT_FIRST_NAME]", $firstnamelastname[0]["firstname"], $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[STUDENT_LAST_NAME]", $firstnamelastname[0]["lastname"], $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[CERT_URL]", $certificate_url, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[CERT_MESSAGE]", $datace["personalmessage"], $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[SITEURL]", $site_url, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[AUTHOR_NAME]", $authorname, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[COURSE_MSG]", $coursemsg, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[COURSE_AVG_SCORE]", $avg_certc, $imagename[0]["templates4"]);
        $imagename[0]["templates4"] = str_replace("[COURSE_FINAL_SCORE]", $avg_certc, $imagename[0]["templates4"]);
        $email_body = $imagename[0]["templates4"];
        $recipient = $datace["emails"];
        $recipient = explode(",", $recipient);
        $mode = true;
        $imagename = "SELECT subjectt4 FROM #__guru_certificates WHERE id=1";
        $db->setQuery($imagename);
        $db->query();
        $imagename = $db->loadResult();
        $imagename = str_replace("[SITENAME]", $sitename, $imagename);
        $imagename = str_replace("[STUDENT_FIRST_NAME]", $datace['studentfn'], $imagename);
        $imagename = str_replace("[STUDENT_LAST_NAME]", $datace['studentln'], $imagename);
        $imagename = str_replace("[SITEURL]", $site_url, $imagename);
        $imagename = str_replace("[CERTIFICATE_ID]", $certificateid, $imagename);
        $imagename = str_replace("[COMPLETION_DATE]", $completiondate, $imagename);
        $imagename = str_replace("[COURSE_NAME]", $coursename, $imagename);
        $imagename = str_replace("[AUTHOR_NAME]", $authorname, $imagename);
        $imagename = str_replace("[CERT_MESSAGE]", str_replace("'", "´", $datace["personalmessage"]), $imagename);
        $subject_procesed = $imagename;
        $body_procesed = $email_body;
        if (is_array($recipient) && count($recipient) > 0) {
            foreach ($recipient as $key => $recipient) {
                JFactory::getMailer()->sendMail($from, $fromname, $recipient, $subject_procesed, $body_procesed, $mode);
                $sql = "insert into #__guru_logs (`userid`, `emailname`, `emailid`, `to`, `subject`, `body`, `buy_date`, `send_date`, `buy_type`) values ('" . intval($user_id) . "', 'email-certificate', '0', '" . trim($recipient) . "', '" . addslashes(trim($subject_procesed)) . "', '" . addslashes(trim($body_procesed)) . "', '', '" . date("Y-m-d H:i:s") . "', '')";
                $db->setQuery($sql);
                $db->query();
            }
        }
        echo '
	<script language="javascript" type="text/javascript">
		window.close();
	</script>';
    }
Пример #2
0
 function emailCertificate($pid)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $id = $user->id;
     $config = JFactory::getConfig();
     include JPATH_SITE . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurubuy.php';
     @($guru_configs = guruModelguruBuy::getConfigs());
     $sql = "SELECT `name` from #__guru_program WHERE `id` =" . $pid;
     $db->setQuery($sql);
     $db->query();
     $resultcn = $db->loadResult();
     $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
     $db->setQuery($imagename);
     $db->query();
     $imagename = $db->loadAssocList();
     $date_completed = "SELECT datecertificate FROM #__guru_mycertificates WHERE user_id=" . intval($id) . " and course_id=" . $pid;
     $db->setQuery($date_completed);
     $db->query();
     $date_completed = $db->loadResult();
     $format = "SELECT datetype FROM #__guru_config WHERE id=1";
     $db->setQuery($format);
     $db->query();
     $format = $db->loadResult();
     $date_completed = date($format, strtotime($date_completed));
     $completiondate = $date_completed;
     $sitename = $config->get('config.sitename');
     $coursename = $resultcn;
     $firstname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($id);
     $db->setQuery($firstname);
     $db->query();
     $firstname = $db->loadAssocList();
     $email = "SELECT email FROM #__users WHERE id=" . intval($id);
     $db->setQuery($email);
     $db->query();
     $email = $db->loadResult();
     $imagename[0]["templates3"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[STUDENT_FIRST_NAME]", $firstname[0]["firstname"], $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates3"]);
     if (isset($guru_configs["0"]["fromname"]) && trim($guru_configs["0"]["fromname"]) != "") {
         $fromname = trim($guru_configs["0"]["fromname"]);
     }
     if (isset($guru_configs["0"]["fromemail"]) && trim($guru_configs["0"]["fromemail"]) != "") {
         $from = trim($guru_configs["0"]["fromemail"]);
     }
     $email_body = $imagename[0]["templates3"];
     $recipient = $email;
     $mode = true;
     $imagename[0]["subjectt3"] = str_replace("[SITENAME]", $sitename, $imagename[0]["subjectt3"]);
     $imagename[0]["subjectt3"] = str_replace("[STUDENT_FIRST_NAME]", $firstname[0]["firstname"], $imagename[0]["subjectt3"]);
     $imagename[0]["subjectt3"] = str_replace("[STUDENT_LAST_NAME]", $firstname[0]["lastname"], $imagename[0]["subjectt3"]);
     $subject_procesed = $imagename[0]["subjectt3"];
     $body_procesed = $email_body;
     $email_sent = "SELECT emailcert FROM #__guru_mycertificates WHERE user_id=" . intval($id) . " and course_id=" . $pid;
     $db->setQuery($email_sent);
     $db->query();
     $email_sent = $db->loadResult();
     if ($email_sent == 0) {
         JFactory::getMailer()->sendMail($from, $fromname, $recipient, $subject_procesed, $body_procesed, $mode);
         $email_sentok = "UPDATE #__guru_mycertificates set emailcert=1 where user_id=" . intval($id) . " and course_id=" . $pid;
         $db->setQuery($email_sentok);
         $db->query();
     }
 }
Пример #3
0
# Technical Support:  Forum - http://www.ijoomla.com.com/forum/index/
-------------------------------------------------------------------------*/
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();
$document->addScript(JURI::base() . "components/com_guru/js/buy.js");
$document->addStyleSheet("components/com_guru/css/guru_style.css");
JHTML::_('behavior.modal');
require_once JPATH_BASE . "/components/com_guru/helpers/Mobile_Detect.php";
$total = "";
$order_id = isset($_SESSION["order_id"]) ? intval($_SESSION["order_id"]) : "";
$promocode = "";
if (isset($_SESSION["promo_code"])) {
    $promocode = $_SESSION["promo_code"];
}
$guruModelguruBuy = new guruModelguruBuy();
$configs = $guruModelguruBuy->getConfigs();
$currency = $configs["0"]["currency"];
$currencypos = $configs["0"]["currencypos"];
$character = "GURU_CURRENCY_" . $currency;
$action = JRequest::getVar("action", "");
$all_product = array();
if ($action == "") {
    if (isset($_SESSION["courses_from_cart"])) {
        $all_product = $_SESSION["courses_from_cart"];
    }
} else {
    $all_product = $_SESSION["renew_courses_from_cart"];
}
$user = JFactory::getUser();
$user_id = $user->id;
if ($user_id != "0" && $action == "") {
Пример #4
0
 function emailCertificate($pid)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $id = $user->id;
     $config = JFactory::getConfig();
     include JPATH_SITE . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurubuy.php';
     @($guru_configs = guruModelguruBuy::getConfigs());
     $sql = "SELECT `name` from #__guru_program WHERE `id` =" . $pid;
     $db->setQuery($sql);
     $db->query();
     $resultcn = $db->loadResult();
     $imagename = "SELECT * FROM #__guru_certificates WHERE id=1";
     $db->setQuery($imagename);
     $db->query();
     $imagename = $db->loadAssocList();
     $date_completed = "SELECT datecertificate FROM #__guru_mycertificates WHERE user_id=" . intval($id) . " and course_id=" . $pid;
     $db->setQuery($date_completed);
     $db->query();
     $date_completed = $db->loadResult();
     $format = "SELECT datetype FROM #__guru_config WHERE id=1";
     $db->setQuery($format);
     $db->query();
     $format = $db->loadResult();
     $date_completed = date($format, strtotime($date_completed));
     $completiondate = $date_completed;
     $sitename = $config->get('config.sitename');
     $coursename = $resultcn;
     $firstname = "SELECT firstname, lastname FROM #__guru_customer WHERE id=" . intval($id);
     $db->setQuery($firstname);
     $db->query();
     $firstname = $db->loadAssocList();
     $email = "SELECT email FROM #__users WHERE id=" . intval($id);
     $db->setQuery($email);
     $db->query();
     $email = $db->loadResult();
     $sql = "SELECT * FROM #__guru_mycertificates WHERE user_id=" . intval($id) . " and course_id=" . $pid;
     $db->setQuery($sql);
     $db->query();
     $certificate_details = $db->loadAssocList();
     $certificate_id = @$certificate_details["0"]["id"];
     $course_id = @$certificate_details["0"]["course_id"];
     $user_id = @$certificate_details["0"]["user_id"];
     $certificate_href = JURI::root() . "index.php?option=com_guru&view=guruTasks&task=viewcertificate&certificate=" . intval($certificate_id) . "&pdf=1&dw=2&ci=2&course_id=" . intval($course_id);
     $certificate_url = '<a href="' . $certificate_href . '" target="_blank">' . $certificate_href . '</a>';
     $imagename[0]["templates3"] = str_replace("[SITENAME]", $sitename, $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[STUDENT_FIRST_NAME]", $firstname[0]["firstname"], $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[COMPLETION_DATE]", $completiondate, $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[COURSE_NAME]", $coursename, $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[CERTIFICATE_URL]", $certificate_url, $imagename[0]["templates3"]);
     $imagename[0]["templates3"] = str_replace("[SITEURL]", JURI::root(), $imagename[0]["templates3"]);
     if (isset($guru_configs["0"]["fromname"]) && trim($guru_configs["0"]["fromname"]) != "") {
         $fromname = trim($guru_configs["0"]["fromname"]);
     }
     if (isset($guru_configs["0"]["fromemail"]) && trim($guru_configs["0"]["fromemail"]) != "") {
         $from = trim($guru_configs["0"]["fromemail"]);
     }
     $email_body = $imagename[0]["templates3"];
     $recipient = $email;
     $mode = true;
     $imagename[0]["subjectt3"] = str_replace("[SITENAME]", $sitename, $imagename[0]["subjectt3"]);
     $imagename[0]["subjectt3"] = str_replace("[STUDENT_FIRST_NAME]", $firstname[0]["firstname"], $imagename[0]["subjectt3"]);
     $imagename[0]["subjectt3"] = str_replace("[STUDENT_LAST_NAME]", $firstname[0]["lastname"], $imagename[0]["subjectt3"]);
     $subject_procesed = $imagename[0]["subjectt3"];
     $body_procesed = $email_body;
     $email_sent = "SELECT emailcert FROM #__guru_mycertificates WHERE user_id=" . intval($id) . " and course_id=" . $pid;
     $db->setQuery($email_sent);
     $db->query();
     $email_sent = $db->loadResult();
     if ($email_sent == 0) {
         JFactory::getMailer()->sendMail($from, $fromname, $recipient, $subject_procesed, $body_procesed, $mode);
         $sql = "insert into #__guru_logs (`userid`, `emailname`, `emailid`, `to`, `subject`, `body`, `buy_date`, `send_date`, `buy_type`) values ('" . intval($id) . "', 'get-certificate', '0', '" . trim($recipient) . "', '" . addslashes(trim($subject_procesed)) . "', '" . addslashes(trim($body_procesed)) . "', '', '" . date("Y-m-d H:i:s") . "', '')";
         $db->setQuery($sql);
         $db->query();
         $email_sentok = "UPDATE #__guru_mycertificates set emailcert=1 where user_id=" . intval($id) . " and course_id=" . $pid;
         $db->setQuery($email_sentok);
         $db->query();
     }
 }