public function pjActionReminderEmail() { $this->setAjax(true); if ($this->isXHR() && $this->isLoged()) { if (isset($_POST['send_email']) && isset($_POST['to']) && !empty($_POST['to']) && !empty($_POST['from']) && !empty($_POST['subject']) && !empty($_POST['message']) && !empty($_POST['id'])) { $Email = new pjEmail(); $Email->setContentType('text/html'); if ($this->option_arr['o_send_email'] == 'smtp') { $Email->setTransport('smtp')->setSmtpHost($this->option_arr['o_smtp_host'])->setSmtpPort($this->option_arr['o_smtp_port'])->setSmtpUser($this->option_arr['o_smtp_user'])->setSmtpPass($this->option_arr['o_smtp_pass']); } $r = $Email->setTo($_POST['to'])->setFrom($_POST['from'])->setSubject($_POST['subject'])->send(pjUtil::textToHtml($_POST['message'])); if (isset($r) && $r) { pjAppController::jsonResponse(array('status' => 'OK', 'code' => 200, 'text' => __('lblEmailSent', true, false))); } pjAppController::jsonResponse(array('status' => 'ERR', 'code' => 100, 'text' => __('lblFailedToSend', true, false))); } if (isset($_GET['id']) && (int) $_GET['id'] > 0) { $pjOrderModel = pjOrderModel::factory(); $arr = $pjOrderModel->join('pjClient', "t2.id=t1.client_id", 'left outer')->select('t1.*, t2.c_title, t2.c_email, t2.c_name, t2.c_phone, t2.c_company, t2.c_address_1, t2.c_address_2, t2.c_country, t2.c_state, t2.c_city, t2.c_zip, t2.c_notes')->find($_GET['id'])->getData(); if (!empty($arr)) { pjAppController::addOrderDetails($arr, $this->getLocaleId()); $tokens = pjAppController::getTokens($this->option_arr, $arr, PJ_SALT, $this->getLocaleId()); $pjMultiLangModel = pjMultiLangModel::factory(); $lang_message = $pjMultiLangModel->reset()->select('t1.*')->where('t1.model', 'pjOption')->where('t1.locale', $this->getLocaleId())->where('t1.field', 'o_email_confirmation_message')->limit(0, 1)->findAll()->getData(); $lang_subject = $pjMultiLangModel->reset()->select('t1.*')->where('t1.model', 'pjOption')->where('t1.locale', $this->getLocaleId())->where('t1.field', 'o_email_confirmation_subject')->limit(0, 1)->findAll()->getData(); if (count($lang_message) === 1 && count($lang_subject) === 1) { if ($arr['type'] == 'delivery') { $message = str_replace(array('[Delivery]', '[/Delivery]'), array('', ''), $lang_message[0]['content']); } else { $message = preg_replace('/\\[Delivery\\].*\\[\\/Delivery\\]/s', '', $lang_message[0]['content']); } $subject_client = str_replace($tokens['search'], $tokens['replace'], $lang_subject[0]['content']); $message_client = str_replace($tokens['search'], $tokens['replace'], $message); $from = !empty($this->option_arr['o_sender_email']) ? $this->option_arr['o_sender_email'] : $this->getAdminEmail(); $this->set('arr', array('id' => $_GET['id'], 'client_email' => $arr['c_email'], 'from' => $from, 'message' => $message_client, 'subject' => $subject_client)); } } else { exit; } } else { exit; } } }
public function pjActionCancel() { $this->setLayout('pjActionCancel'); $pjOrderModel = pjOrderModel::factory(); if (isset($_POST['order_cancel'])) { $order_arr = $pjOrderModel->reset()->join('pjClient', "t2.id=t1.client_id", 'left outer')->select('t1.*, t2.c_title, t2.c_email, t2.c_name, t2.c_phone, t2.c_company, t2.c_address_1, t2.c_address_2, t2.c_country, t2.c_state, t2.c_city, t2.c_zip, t2.c_notes')->find($_POST['id'])->getData(); if (count($order_arr) > 0) { $sql = "UPDATE `" . $pjOrderModel->getTable() . "` SET status = 'cancelled' WHERE SHA1(CONCAT(`id`, `created`, '" . PJ_SALT . "')) = '" . $_POST['hash'] . "'"; $pjOrderModel->reset()->execute($sql); pjAppController::addOrderDetails($order_arr, $this->getLocaleId()); pjFront::pjActionConfirmSend($this->option_arr, $order_arr, PJ_SALT, 'cancel'); pjUtil::redirect($_SERVER['PHP_SELF'] . '?controller=pjFront&action=pjActionCancel&err=200'); } } else { if (isset($_GET['hash']) && isset($_GET['id'])) { $arr = $pjOrderModel->reset()->join('pjClient', "t2.id=t1.client_id", 'left outer')->join('pjMultiLang', "t3.model='pjCountry' AND t3.foreign_id=t1.d_country_id AND t3.field='name' AND t3.locale='" . $this->getLocaleId() . "'", 'left outer')->join('pjMultiLang', "t4.model='pjCountry' AND t4.foreign_id=t1.location_id AND t4.field='name' AND t4.locale='" . $this->getLocaleId() . "'", 'left outer')->join('pjClient', "t2.id=t1.client_id", 'left outer')->select('t1.*, t3.content as d_country, t4.content as location, t2.c_title, t2.c_email, t2.c_name, t2.c_phone, t2.c_company, t2.c_address_1, t2.c_address_2, t2.c_country, t2.c_state, t2.c_city, t2.c_zip, t2.c_notes')->find($_GET['id'])->getData(); if (count($arr) == 0) { $this->set('status', 2); } else { if ($arr['status'] == 'cancelled') { $this->set('status', 4); } else { $hash = sha1($arr['id'] . $arr['created'] . PJ_SALT); if ($_GET['hash'] != $hash) { $this->set('status', 3); } else { pjAppController::addOrderDetails($arr, $this->getLocaleId()); $this->set('arr', $arr); } } } } elseif (!isset($_GET['err'])) { $this->set('status', 1); } } }