本文整理汇总了PHP中CustomerMessage类的典型用法代码示例。如果您正苦于以下问题:PHP CustomerMessage类的具体用法?PHP CustomerMessage怎么用?PHP CustomerMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CustomerMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
//.........这里部分代码省略.........
if ($row['id_contact'] == $id_contact) {
$tmp++;
}
if (Tools::getValue('id_product') != 0 && $row['id_product'] == Tools::getValue('id_product')) {
$tmp += 2;
}
if ($tmp >= 5 && $tmp >= $score) {
$score = $tmp;
$id_customer_thread = $row['id_customer_thread'];
}
}
}
$old_message = Db::getInstance()->getValue('
SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
LEFT JOIN ' . _DB_PREFIX_ . 'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
WHERE cc.id_customer_thread = ' . (int) $id_customer_thread . ' AND cc.id_shop = ' . (int) $this->context->shop->id . '
ORDER BY cm.date_add DESC');
if ($old_message == $message) {
$this->context->smarty->assign('alreadySent', 1);
$contact->email = '';
$contact->customer_service = 0;
}
if ($contact->customer_service) {
if ((int) $id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int) $this->context->language->id;
$ct->id_contact = (int) $id_contact;
$ct->id_order = (int) $id_order;
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int) $customer->id;
}
$ct->id_shop = (int) $this->context->shop->id;
$ct->id_order = (int) $id_order;
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int) $id_contact;
$ct->id_lang = (int) $this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = $message;
if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_ . basename($file_attachment['rename']))) {
$cm->file_name = $file_attachment['rename'];
@chmod(_PS_UPLOAD_DIR_ . basename($file_attachment['rename']), 0664);
}
$cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add()) {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
}
if (!count($this->errors)) {
$var_list = array('{order_name}' => '-', '{attached_file}' => '-', '{message}' => Tools::nl2br(stripslashes($message)), '{email}' => $from, '{product_name}' => '');
if (isset($file_attachment['name'])) {
$var_list['{attached_file}'] = $file_attachment['name'];
}
$id_product = (int) Tools::getValue('id_product');
if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) {
$order = new Order((int) $ct->id_order);
$var_list['{order_name}'] = $order->getUniqReference();
$var_list['{id_order}'] = (int) $order->id;
}
if ($id_product) {
$product = new Product((int) $id_product);
if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) {
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
}
if (empty($contact->email)) {
Mail::Send($this->context->language->id, 'contact_form', isset($ct) && Validate::isLoadedObject($ct) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent'), $var_list, $from, null, null, null, $file_attachment);
} else {
if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form') . ' [no_sync]', $var_list, $contact->email, $contact->name, null, null, $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $from) || !Mail::Send($this->context->language->id, 'contact_form', isset($ct) && Validate::isLoadedObject($ct) ? sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token) : Mail::l('Your message has been correctly sent'), $var_list, $from, null, null, null, $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $contact->email)) {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
}
}
if (count($this->errors) > 1) {
array_unique($this->errors);
} elseif (!count($this->errors)) {
$this->context->smarty->assign('confirmation', 1);
}
}
}
}
示例2: postProcess
//.........这里部分代码省略.........
$tmp += 2;
}
if ($tmp >= 5 && $tmp >= $score) {
$score = $tmp;
$id_customer_thread = $row['id_customer_thread'];
}
}
}
$old_message = Db::getInstance()->getValue('
SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
LEFT JOIN ' . _DB_PREFIX_ . 'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
WHERE cc.id_customer_thread = ' . (int) $id_customer_thread . ' AND cc.id_shop = ' . (int) $this->context->shop->id . '
ORDER BY cm.date_add DESC');
if ($old_message == $message) {
$this->context->smarty->assign('alreadySent', 1);
$contact->email = '';
$contact->customer_service = 0;
}
if (!empty($contact->email)) {
$id_order = (int) Tools::getValue('id_order', 0);
$order = new Order($id_order);
$mail_var_list = array('{email}' => $from, '{message}' => Tools::nl2br(stripslashes($message)), '{id_order}' => $id_order, '{order_name}' => $order->getUniqReference(), '{attached_file}' => isset($_FILES['fileUpload'], $_FILES['fileUpload']['name']) ? $_FILES['fileUpload']['name'] : '');
if (Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form'), $mail_var_list, $contact->email, $contact->name, $from, $customer->id ? $customer->firstname . ' ' . $customer->lastname : '', $fileAttachment) && Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), $mail_var_list, $from)) {
$this->context->smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
}
if ($contact->customer_service) {
if ((int) $id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int) $this->context->language->id;
$ct->id_contact = (int) $id_contact;
if ($id_order = (int) Tools::getValue('id_order')) {
$ct->id_order = $id_order;
}
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int) $customer->id;
}
$ct->id_shop = (int) $this->context->shop->id;
if ($id_order = (int) Tools::getValue('id_order')) {
$ct->id_order = $id_order;
}
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int) $id_contact;
$ct->id_lang = (int) $this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = Tools::htmlentitiesUTF8($message);
if (isset($filename) && rename($_FILES['fileUpload']['tmp_name'], _PS_MODULE_DIR_ . '../upload/' . $filename)) {
$cm->file_name = $filename;
}
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if ($cm->add()) {
if (empty($contact->email)) {
$var_list = array('{order_name}' => '-', '{attached_file}' => '-', '{message}' => stripslashes($message));
if ($ct->id_order) {
$order = new Order($ct->id_order);
$var_list['{order_name}'] = $order->reference;
}
if (isset($filename)) {
$var_list['{attached_file}'] = $_FILES['fileUpload']['name'];
}
Mail::Send($this->context->language->id, 'contact_form', Mail::l('Your message has been correctly sent'), $var_list, $from);
}
$this->context->smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
}
if (count($this->errors) > 1) {
array_unique($this->errors);
}
}
}
}
}
}
}
}
}
示例3: pSQL
WHERE `md5_header` = \'' . pSQL($md5) . '\'');
if ($exist) {
if (Configuration::get('PS_SAV_IMAP_DELETE_MSG')) {
if (!imap_delete($mbox, $overview->msgno)) {
$str_error_delete = ', "Fail to delete message"';
}
}
} else {
//check if subject has id_order
preg_match('/\\#ct([0-9]*)/', $subject, $matches1);
preg_match('/\\#tc([0-9-a-z-A-Z]*)/', $subject, $matches2);
if (isset($matches1[1]) && isset($matches2[1])) {
//check if order exist in database
$ct = new CustomerThread((int) $matches1[1]);
if (Validate::isLoadedObject($ct) && $ct->token == $matches2[1]) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = imap_fetchbody($mbox, $overview->msgno, 1);
$cm->add();
}
}
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'customer_message_sync_imap` (`md5_header`) VALUES (\'' . pSQL($md5) . '\')');
}
}
imap_expunge($mbox);
imap_close($mbox);
die('{"hasError" : false, "errors" : ["' . $str_errors . $str_error_delete . '"]}');
}
if (Tools::isSubmit('searchCategory')) {
$q = Tools::getValue('q');
$limit = Tools::getValue('limit');
示例4: preProcess
//.........这里部分代码省略.........
WHERE email = \'' . pSQL($from) . '\' AND (' . ($customer->id ? 'id_customer = ' . (int) $customer->id . ' OR ' : '') . '
id_order = ' . (int) Tools::getValue('id_order') . ')');
$score = 0;
foreach ($fields as $key => $row) {
$tmp = 0;
if ((int) $row['id_customer'] and $row['id_customer'] != $customer->id and $row['email'] != $from) {
continue;
}
if ($row['id_order'] != 0 and Tools::getValue('id_order') != $row['id_order']) {
continue;
}
if ($row['email'] == $from) {
$tmp += 4;
}
if ($row['id_contact'] == $id_contact) {
$tmp++;
}
if (Tools::getValue('id_product') != 0 and $row['id_product'] == Tools::getValue('id_product')) {
$tmp += 2;
}
if ($tmp >= 5 and $tmp >= $score) {
$score = $tmp;
$id_customer_thread = $row['id_customer_thread'];
}
}
}
$old_message = Db::getInstance()->getValue('
SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . '
ORDER BY date_add DESC');
if ($old_message == htmlentities($message, ENT_COMPAT, 'UTF-8')) {
self::$smarty->assign('alreadySent', 1);
$contact->email = '';
$contact->customer_service = 0;
}
if (!empty($contact->email)) {
if (Mail::Send((int) self::$cookie->id_lang, 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (int) self::$cookie->id_customer ? $customer->firstname . ' ' . $customer->lastname : '', $fileAttachment) and Mail::Send((int) self::$cookie->id_lang, 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from)) {
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
}
if ($contact->customer_service) {
if ((int) $id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int) self::$cookie->id_lang;
$ct->id_contact = (int) $id_contact;
if ($id_order = (int) Tools::getValue('id_order')) {
$ct->id_order = $id_order;
}
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int) $customer->id;
}
if ($id_order = (int) Tools::getValue('id_order')) {
$ct->id_order = $id_order;
}
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int) $id_contact;
$ct->id_lang = (int) self::$cookie->id_lang;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = htmlentities($message, ENT_COMPAT, 'UTF-8');
if (isset($filename) and rename($_FILES['fileUpload']['tmp_name'], _PS_MODULE_DIR_ . '../upload/' . $filename)) {
$cm->file_name = $filename;
}
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if ($cm->add()) {
if (empty($contact->email)) {
Mail::Send((int) self::$cookie->id_lang, 'contact_form', Mail::l('Your message has been correctly sent'), array('{message}' => stripslashes($message)), $from);
}
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while sending message.');
}
}
if (count($this->errors) > 1) {
array_unique($this->errors);
}
}
}
}
示例5: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('submitMessage')) {
$idOrder = (int) Tools::getValue('id_order');
$msgText = Tools::getValue('msgText');
if (!$idOrder || !Validate::isUnsignedId($idOrder)) {
$this->errors[] = $this->trans('The order is no longer valid.', array(), 'Shop.Notifications.Error');
} elseif (empty($msgText)) {
$this->errors[] = $this->trans('The message cannot be blank.', array(), 'Shop.Notifications.Error');
} elseif (!Validate::isMessage($msgText)) {
$this->errors[] = $this->trans('This message is invalid (HTML is not allowed).', array(), 'Shop.Notifications.Error');
}
if (!count($this->errors)) {
$order = new Order($idOrder);
if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
//check if a thread already exist
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id);
$id_product = (int) Tools::getValue('id_product');
$cm = new CustomerMessage();
if (!$id_customer_thread) {
$ct = new CustomerThread();
$ct->id_contact = 0;
$ct->id_customer = (int) $order->id_customer;
$ct->id_shop = (int) $this->context->shop->id;
if ($id_product && $order->orderContainProduct($id_product)) {
$ct->id_product = $id_product;
}
$ct->id_order = (int) $order->id;
$ct->id_lang = (int) $this->context->language->id;
$ct->email = $this->context->customer->email;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
} else {
$ct = new CustomerThread((int) $id_customer_thread);
$ct->status = 'open';
$ct->update();
}
$cm->id_customer_thread = $ct->id;
$cm->message = $msgText;
$cm->ip_address = (int) ip2long($_SERVER['REMOTE_ADDR']);
$cm->add();
if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) {
$to = strval(Configuration::get('PS_SHOP_EMAIL'));
} else {
$to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE'));
$to = strval($to->email);
}
$toName = strval(Configuration::get('PS_SHOP_NAME'));
$customer = $this->context->customer;
$product = new Product($id_product);
$product_name = '';
if (Validate::isLoadedObject($product) && isset($product->name[(int) $this->context->language->id])) {
$product_name = $product->name[(int) $this->context->language->id];
}
if (Validate::isLoadedObject($customer)) {
Mail::Send($this->context->language->id, 'order_customer_comment', Mail::l('Message from a customer'), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference(), '{message}' => Tools::nl2br($msgText), '{product_name}' => $product_name), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
Tools::redirect('index.php?controller=order-detail&id_order=' . $idOrder . '&messagesent');
} else {
$this->redirect_after = '404';
$this->redirect();
}
}
}
}
示例6: ajaxProcessSyncImap
//.........这里部分代码省略.........
}
if ($conf['PS_SAV_IMAP_OPT_VALIDATE-CERT']) {
$conf_str .= '/validate-cert';
}
if ($conf['PS_SAV_IMAP_OPT_NOVALIDATE-CERT']) {
$conf_str .= '/novalidate-cert';
}
if ($conf['PS_SAV_IMAP_OPT_TLS']) {
$conf_str .= '/tls';
}
if ($conf['PS_SAV_IMAP_OPT_NOTLS']) {
$conf_str .= '/notls';
}
if (!function_exists('imap_open')) {
die('{"hasError" : true, "errors" : ["imap is not installed on this server"]}');
}
$mbox = @imap_open('{' . $url . ':' . $port . $conf_str . '}', $user, $password);
//checks if there is no error when connecting imap server
$errors = imap_errors();
$str_errors = '';
$str_error_delete = '';
if (sizeof($errors) && is_array($errors)) {
$str_errors = '';
foreach ($errors as $error) {
$str_errors .= '"' . $error . '",';
}
$str_errors = rtrim($str_errors, ',') . '';
}
//checks if imap connexion is active
if (!$mbox) {
die('{"hasError" : true, "errors" : ["Cannot connect to the mailbox:.<br />' . addslashes($str_errors) . '"]}');
}
//Returns information about the current mailbox. Returns FALSE on failure.
$check = imap_check($mbox);
if (!$check) {
die('{"hasError" : true, "errors" : ["Fail to get information about the current mailbox"]}');
}
if ($check->Nmsgs == 0) {
die('{"hasError" : true, "errors" : ["NO message to sync"]}');
}
$result = imap_fetch_overview($mbox, "1:{$check->Nmsgs}", 0);
foreach ($result as $overview) {
//check if message exist in database
if (isset($overview->subject)) {
$subject = $overview->subject;
} else {
$subject = '';
}
//Creating an md5 to check if message has been allready processed
$md5 = md5($overview->date . $overview->from . $subject . $overview->msgno);
$exist = Db::getInstance()->getValue('SELECT `md5_header`
FROM `' . _DB_PREFIX_ . 'customer_message_sync_imap`
WHERE `md5_header` = \'' . pSQL($md5) . '\'');
if ($exist) {
if (Configuration::get('PS_SAV_IMAP_DELETE_MSG')) {
if (!imap_delete($mbox, $overview->msgno)) {
$str_error_delete = ', "Fail to delete message"';
}
}
} else {
//check if subject has id_order
preg_match('/\\#ct([0-9]*)/', $subject, $matches1);
preg_match('/\\#tc([0-9-a-z-A-Z]*)/', $subject, $matches2);
$new_ct = Configuration::get('PS_SAV_IMAP_CREATE_THREADS') && !isset($matches1[1]) && !isset($matches2[1]) && !preg_match('/[no_sync]/', $subject);
if (isset($matches1[1]) && isset($matches2[1]) || $new_ct) {
if ($new_ct) {
if (!preg_match('/<(' . Tools::cleanNonUnicodeSupport('[a-z\\p{L}0-9!#$%&\'*+\\/=?^`{}|~_-]+[.a-z\\p{L}0-9!#$%&\'*+\\/=?^`{}|~_-]*@[a-z\\p{L}0-9]+[._a-z\\p{L}0-9-]*\\.[a-z0-9]+') . ')>/', $overview->from, $result) || !Validate::isEmail($from = $result[1])) {
continue;
}
$contacts = Contact::getCategoriesContacts();
if (!$contacts) {
continue;
}
$id_contact = $contacts[0]['id_contact'];
$ct = new CustomerThread();
$ct->email = $from;
$ct->id_contact = $id_contact;
$ct->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
} else {
$ct = new CustomerThread((int) $matches1[1]);
}
//check if order exist in database
if (Validate::isLoadedObject($ct) && (isset($matches2[1]) && $ct->token == $matches2[1] || $new_ct)) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = imap_fetchbody($mbox, $overview->msgno, 1);
$cm->add();
}
}
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'customer_message_sync_imap` (`md5_header`) VALUES (\'' . pSQL($md5) . '\')');
}
}
imap_expunge($mbox);
imap_close($mbox);
die('{"hasError" : false, "errors" : ["' . $str_errors . $str_error_delete . '"]}');
}
}
示例7: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) {
$this->errors[] = Tools::displayError('Order ID required');
} else {
$order = new Order($id_order);
if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
$id_order_state = (int) $order->getCurrentState();
$carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
$addressInvoice = new Address((int) $order->id_address_invoice);
$addressDelivery = new Address((int) $order->id_address_delivery);
$inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
$invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
$deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
if ($order->total_discounts > 0) {
$this->context->smarty->assign('total_old', (double) $order->total_paid - $order->total_discounts);
}
$products = $order->getProducts();
/* DEPRECATED: customizedDatas @since 1.5 */
$customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($products, $customizedDatas);
OrderReturn::addReturnedQuantity($products, $order->id);
$order_status = new OrderState((int) $id_order_state, (int) $order->id_lang);
$customer = new Customer($order->id_customer);
//by webkul to show order details properly on order history page
if (Module::isInstalled('hotelreservationsystem')) {
require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
$obj_cart_bk_data = new HotelCartBookingData();
$obj_htl_bk_dtl = new HotelBookingDetail();
$obj_rm_type = new HotelRoomType();
if (!empty($products)) {
foreach ($products as $type_key => $type_value) {
$product = new Product($type_value['product_id'], false, $this->context->language->id);
$cover_image_arr = $product->getCover($type_value['product_id']);
if (!empty($cover_image_arr)) {
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default');
} else {
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
}
$unit_price = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
if (isset($customer->id)) {
$cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, (new Cart($order->id_cart))->id_guest, $type_value['product_id'], $customer->id);
} else {
$cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, $customer->id_guest, $type_value['product_id']);
}
$rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']);
$cart_htl_data[$type_key]['id_product'] = $type_value['product_id'];
$cart_htl_data[$type_key]['cover_img'] = $cover_img;
$cart_htl_data[$type_key]['name'] = $product->name;
$cart_htl_data[$type_key]['unit_price'] = $unit_price;
$cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
$cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
foreach ($cart_bk_data as $data_k => $data_v) {
$date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']);
if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
$num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
$vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days;
$amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
$amount *= $vart_quant;
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
} else {
$num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
$amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
$amount *= $num_days;
$cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
}
}
}
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
}
}
//end
$this->context->smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection()), 'logable' => (bool) $order_status->logable, 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas, 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING')));
if ($carrier->url && $order->shipping_number) {
$this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
}
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order));
unset($carrier, $addressInvoice, $addressDelivery);
} else {
$this->errors[] = Tools::displayError('This order cannot be found.');
}
unset($order);
}
$this->setTemplate(_PS_THEME_DIR_ . 'order-detail.tpl');
}
示例8: saveContact
public function saveContact()
{
$message = Tools::getValue('message');
// Html entities is not usefull, iscleanHtml check there is no bad html tags.
if (!($from = trim(Tools::getValue('email'))) || !Validate::isEmail($from)) {
$this->errors[] = Tools::displayError('Invalid email address.');
} elseif (!$message) {
$this->errors[] = Tools::displayError('The message cannot be blank.');
} elseif (!Validate::isCleanHtml($message)) {
$this->errors[] = Tools::displayError('Invalid message');
} elseif (!($id_contact = (int) Tools::getValue('id_contact')) || !Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))) {
$this->errors[] = Tools::displayError('Please select a subject from the list provided. ');
} else {
$customer = $this->context->customer;
if (!$customer->id) {
$customer->getByEmail($from);
}
$id_order = (int) $this->getOrder();
if (!(($id_customer_thread = (int) Tools::getValue('id_customer_thread')) && (int) Db::getInstance()->getValue('
SELECT cm.id_customer_thread FROM ' . _DB_PREFIX_ . 'customer_thread cm
WHERE cm.id_customer_thread = ' . (int) $id_customer_thread . ' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND token = \'' . pSQL(Tools::getValue('token')) . '\'') || ($id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order)))) {
$fields = Db::getInstance()->executeS('
SELECT cm.id_customer_thread, cm.id_contact, cm.id_customer, cm.id_order, cm.id_product, cm.email
FROM ' . _DB_PREFIX_ . 'customer_thread cm
WHERE email = \'' . pSQL($from) . '\' AND cm.id_shop = ' . (int) $this->context->shop->id . ' AND (' . ($customer->id ? 'id_customer = ' . (int) $customer->id . ' OR ' : '') . '
id_order = ' . (int) $id_order . ')');
$score = 0;
foreach ($fields as $key => $row) {
$tmp = 0;
if ((int) $row['id_customer'] && $row['id_customer'] != $customer->id && $row['email'] != $from) {
continue;
}
if ($row['id_order'] != 0 && $id_order != $row['id_order']) {
continue;
}
if ($row['email'] == $from) {
$tmp += 4;
}
if ($row['id_contact'] == $id_contact) {
$tmp++;
}
if (Tools::getValue('id_product') != 0 && $row['id_product'] == Tools::getValue('id_product')) {
$tmp += 2;
}
if ($tmp >= 5 && $tmp >= $score) {
$score = $tmp;
$id_customer_thread = $row['id_customer_thread'];
}
}
}
$old_message = Db::getInstance()->getValue('
SELECT cm.message FROM ' . _DB_PREFIX_ . 'customer_message cm
LEFT JOIN ' . _DB_PREFIX_ . 'customer_thread cc on (cm.id_customer_thread = cc.id_customer_thread)
WHERE cc.id_customer_thread = ' . (int) $id_customer_thread . ' AND cc.id_shop = ' . (int) $this->context->shop->id . '
ORDER BY cm.date_add DESC');
if ($old_message == $message) {
$this->context->smarty->assign('alreadySent', 1);
$contact->email = '';
$contact->customer_service = 0;
}
if ($contact->customer_service) {
if ((int) $id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int) $this->context->language->id;
$ct->id_contact = (int) $id_contact;
$ct->id_order = (int) $id_order;
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int) $customer->id;
}
$ct->id_shop = (int) $this->context->shop->id;
$ct->id_order = (int) $id_order;
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int) $id_contact;
$ct->id_lang = (int) $this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = $message;
$cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add()) {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
//.........这里部分代码省略.........
示例9: initContent
public function initContent()
{
${"GLOBALS"}["wcbwhorf"] = "id_order";
parent::initContent();
if (!(${${"GLOBALS"}["tdrhijkvhp"]} = (int) Tools::getValue("id_order")) || !Validate::isUnsignedId(${${"GLOBALS"}["wcbwhorf"]})) {
$this->errors[] = Tools::displayError("Order ID required");
} else {
${"GLOBALS"}["vtkcznmlk"] = "id_customer_seller";
${"GLOBALS"}["bwkdjg"] = "id_order";
${${"GLOBALS"}["thtbvco"]} = new Order(${${"GLOBALS"}["bwkdjg"]});
${"GLOBALS"}["tkggscllp"] = "order";
${${"GLOBALS"}["gfrblyem"]} = AgileSellerManager::getObjectOwnerID("order", $order->id);
${${"GLOBALS"}["taultlaseq"]} = AgileSellerManager::getLinkedSellerID($this->context->customer->id);
if (Validate::isLoadedObject(${${"GLOBALS"}["thtbvco"]}) && ${${"GLOBALS"}["gfrblyem"]} == ${${"GLOBALS"}["vtkcznmlk"]} && ${${"GLOBALS"}["taultlaseq"]} > 0) {
$fwsweyfqnpv = "dlv_adr_fields";
$gcjosivnd = "carrier";
${"GLOBALS"}["pffjtshcnb"] = "deliveryAddressFormatedValues";
$uztnjfwuwsv = "customizedDatas";
$uvmwhue = "addressDelivery";
${"GLOBALS"}["atrcjjwf"] = "carrier";
${"GLOBALS"}["flawpcbih"] = "products";
${${"GLOBALS"}["tthrzd"]} = (int) $order->getCurrentState();
${$gcjosivnd} = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
${"GLOBALS"}["rovfqvkjb"] = "addressDelivery";
${${"GLOBALS"}["hoviucftx"]} = new Address((int) $order->id_address_invoice);
$mjqwhmgoyrm = "customizedDatas";
${"GLOBALS"}["qguglflbdd"] = "dlv_adr_fields";
$sitqckqhoebi = "inv_adr_fields";
$vejelhbyrbl = "addressDelivery";
${"GLOBALS"}["zpyvneijb"] = "addressInvoice";
$tsvbkseunn = "dlv_adr_fields";
${"GLOBALS"}["cdlqrupc"] = "inv_adr_fields";
${${"GLOBALS"}["rovfqvkjb"]} = new Address((int) $order->id_address_delivery);
${$sitqckqhoebi} = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
$shfzuivbjgg = "inv_adr_fields";
${${"GLOBALS"}["qguglflbdd"]} = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
${${"GLOBALS"}["elucej"]} = AddressFormat::getFormattedAddressFieldsValues(${${"GLOBALS"}["hoviucftx"]}, ${$shfzuivbjgg});
${${"GLOBALS"}["pffjtshcnb"]} = AddressFormat::getFormattedAddressFieldsValues(${${"GLOBALS"}["gkxhkddsjf"]}, ${$fwsweyfqnpv});
$tbfgtqy = "order";
if ($order->total_discounts > 0) {
$this->context->smarty->assign("total_old", (double) ($order->total_paid - $order->total_discounts));
}
${"GLOBALS"}["ikavgzhqpt"] = "deliveryAddressFormatedValues";
${${"GLOBALS"}["flawpcbih"]} = $order->getProducts();
${${"GLOBALS"}["gdodxcerle"]} = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice(${${"GLOBALS"}["umrxyqn"]}, ${$mjqwhmgoyrm});
$buaccdx = "carrier";
${${"GLOBALS"}["cdmray"]} = new Customer($order->id_customer);
${"GLOBALS"}["betrwosx"] = "products";
${${"GLOBALS"}["bfrxhizen"]} = $order->getCurrentOrderState();
${${"GLOBALS"}["sslziuxrs"]} = OrderState::getOrderStates((int) $this->context->language->id);
${"GLOBALS"}["bwcmquq"] = "addressInvoice";
$this->context->smarty->assign(array("order_states" => ${${"GLOBALS"}["sslziuxrs"]}));
$this->context->smarty->assign(array("shop_name" => strval(Configuration::get("PS_SHOP_NAME")), "order" => ${${"GLOBALS"}["thtbvco"]}, "return_allowed" => (int) $order->isReturnable(), "currency" => new Currency($order->id_currency), "order_cur_state" => (int) ${${"GLOBALS"}["tthrzd"]}, "invoiceAllowed" => (int) Configuration::get("PS_INVOICE"), "invoice" => OrderState::invoiceAvailable(${${"GLOBALS"}["tthrzd"]}) && $order->invoice_number, "order_history" => $order->getHistory($this->context->language->id, false, true), "products" => ${${"GLOBALS"}["betrwosx"]}, "discounts" => $order->getCartRules(), "carrier" => ${${"GLOBALS"}["atrcjjwf"]}, "address_invoice" => ${${"GLOBALS"}["bwcmquq"]}, "invoiceState" => Validate::isLoadedObject(${${"GLOBALS"}["zpyvneijb"]}) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, "address_delivery" => ${$uvmwhue}, "inv_adr_fields" => ${${"GLOBALS"}["cdlqrupc"]}, "dlv_adr_fields" => ${$tsvbkseunn}, "invoiceAddressFormatedValues" => ${${"GLOBALS"}["elucej"]}, "deliveryAddressFormatedValues" => ${${"GLOBALS"}["ikavgzhqpt"]}, "deliveryState" => Validate::isLoadedObject(${${"GLOBALS"}["gkxhkddsjf"]}) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, "is_guest" => false, "messages" => CustomerMessage::getMessagesByOrderId((int) $order->id, false), "CUSTOMIZE_FILE" => Product::CUSTOMIZE_FILE, "CUSTOMIZE_TEXTFIELD" => Product::CUSTOMIZE_TEXTFIELD, "isRecyclable" => Configuration::get("PS_RECYCLABLE_PACK"), "use_tax" => Configuration::get("PS_TAX"), "group_use_tax" => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, "customizedDatas" => ${$uztnjfwuwsv}));
if ($carrier->url && $order->shipping_number) {
$this->context->smarty->assign("followup", str_replace("@", $order->shipping_number, $carrier->url));
}
$this->context->smarty->assign("HOOK_ORDERDETAILDISPLAYED", Hook::exec("displayOrderDetail", array("order" => ${${"GLOBALS"}["thtbvco"]})));
Hook::exec("actionOrderDetail", array("carrier" => ${${"GLOBALS"}["tvqrewgc"]}, "order" => ${$tbfgtqy}));
unset(${$buaccdx}, ${${"GLOBALS"}["hoviucftx"]}, ${$vejelhbyrbl});
} else {
$this->errors[] = Tools::displayError("Cannot find this order");
}
unset(${${"GLOBALS"}["tkggscllp"]});
}
self::$smarty->assign(array("seller_tab_id" => 4));
$this->setTemplate("sellerorderdetail.tpl");
}
示例10: postProcess
public function postProcess()
{
global $currentIndex, $cookie;
if ($id_customer_thread = (int) Tools::getValue('id_customer_thread')) {
if ($id_contact = (int) Tools::getValue('id_contact')) {
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'customer_thread SET id_contact = ' . (int) $id_contact . ' WHERE id_customer_thread = ' . (int) $id_customer_thread);
}
if ($id_status = (int) Tools::getValue('setstatus')) {
$statusArray = array(1 => 'open', 2 => 'closed', 3 => 'pending1', 4 => 'pending2');
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'customer_thread SET status = "' . $statusArray[$id_status] . '" WHERE id_customer_thread = ' . (int) $id_customer_thread . ' LIMIT 1');
}
if (isset($_POST['id_employee_forward'])) {
// Todo: need to avoid doubles
$messages = Db::getInstance()->ExecuteS('
SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname
FROM ' . _DB_PREFIX_ . 'customer_thread ct
LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm ON (ct.id_customer_thread = cm.id_customer_thread)
LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) $cookie->id_lang . ')
LEFT OUTER JOIN ' . _DB_PREFIX_ . 'employee e ON e.id_employee = cm.id_employee
LEFT OUTER JOIN ' . _DB_PREFIX_ . 'customer c ON (c.email = ct.email)
WHERE ct.id_customer_thread = ' . (int) Tools::getValue('id_customer_thread') . '
ORDER BY cm.date_add DESC');
$output = '';
foreach ($messages as $message) {
$output .= $this->displayMsg($message, true, (int) Tools::getValue('id_employee_forward'));
}
$cm = new CustomerMessage();
$cm->id_employee = (int) $cookie->id_employee;
$cm->id_customer_thread = (int) Tools::getValue('id_customer_thread');
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$currentEmployee = new Employee($cookie->id_employee);
if ($id_employee = (int) Tools::getValue('id_employee_forward') and $employee = new Employee($id_employee) and Validate::isLoadedObject($employee)) {
$params = array('{messages}' => $output, '{employee}' => $currentEmployee->firstname . ' ' . $currentEmployee->lastname, '{comment}' => stripslashes($_POST['message_forward']));
Mail::Send((int) $cookie->id_lang, 'forward_msg', Mail::l('Fwd: Customer message'), $params, $employee->email, $employee->firstname . ' ' . $employee->lastname, $currentEmployee->email, $currentEmployee->firstname . ' ' . $currentEmployee->lastname);
$cm->message = $this->l('Message forwarded to') . ' ' . $employee->firstname . ' ' . $employee->lastname . "\n" . $this->l('Comment:') . ' ' . $_POST['message_forward'];
$cm->add();
} elseif ($email = Tools::getValue('email') and Validate::isEmail($email)) {
$params = array('{messages}' => $output, '{employee}' => $currentEmployee->firstname . ' ' . $currentEmployee->lastname, '{comment}' => stripslashes($_POST['message_forward']));
Mail::Send((int) $cookie->id_lang, 'forward_msg', Mail::l('Fwd: Customer message'), $params, $email, NULL, $currentEmployee->email, $currentEmployee->firstname . ' ' . $currentEmployee->lastname);
$cm->message = $this->l('Message forwarded to') . ' ' . $email . "\n" . $this->l('Comment:') . ' ' . $_POST['message_forward'];
$cm->add();
} else {
echo '<div class="alert error">' . Tools::displayError('Email invalid.') . '</div>';
}
}
if (Tools::isSubmit('submitReply')) {
$ct = new CustomerThread($id_customer_thread);
$cm = new CustomerMessage();
$cm->id_employee = (int) $cookie->id_employee;
$cm->id_customer_thread = $ct->id;
$cm->message = Tools::htmlentitiesutf8(nl2br2(Tools::getValue('reply_message')));
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
if (isset($_FILES) and !empty($_FILES['joinFile']['name']) and $_FILES['joinFile']['error'] != 0) {
$this->_errors[] = Tools::displayError('An error occurred with the file upload.');
} else {
if ($cm->add()) {
$fileAttachment = NULL;
if (!empty($_FILES['joinFile']['name'])) {
$fileAttachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']);
$fileAttachment['name'] = $_FILES['joinFile']['name'];
$fileAttachment['mime'] = $_FILES['joinFile']['type'];
}
$params = array('{reply}' => nl2br2(Tools::getValue('reply_message')), '{link}' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'contact-form.php?id_customer_thread=' . (int) $ct->id . '&token=' . $ct->token);
Mail::Send($ct->id_lang, 'reply_msg', Mail::l('An answer to your message is available'), $params, Tools::getValue('msg_email'), NULL, NULL, NULL, $fileAttachment);
$ct->status = 'closed';
$ct->update();
Tools::redirectAdmin($currentIndex . '&id_customer_thread=' . (int) $id_customer_thread . '&viewcustomer_thread&token=' . Tools::getValue('token'));
} else {
$this->_errors[] = Tools::displayError('An error occurred, your message was not sent. Please contact your system administrator.');
}
}
}
}
return parent::postProcess();
}
示例11: sendMessage
public function sendMessage()
{
$extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg');
$file_attachment = Tools::fileAttachment('fileUpload');
$message = Tools::getValue('message');
if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from)) {
$this->context->controller->errors[] = $this->l('Invalid email address.');
} elseif (!$message) {
$this->context->controller->errors[] = $this->l('The message cannot be blank.');
} elseif (!Validate::isCleanHtml($message)) {
$this->context->controller->errors[] = $this->l('Invalid message');
} elseif (!($id_contact = (int) Tools::getValue('id_contact')) || !Validate::isLoadedObject($contact = new Contact($id_contact, $this->context->language->id))) {
$this->context->controller->errors[] = $this->l('Please select a subject from the list provided. ');
} elseif (!empty($file_attachment['name']) && $file_attachment['error'] != 0) {
$this->context->controller->errors[] = $this->l('An error occurred during the file-upload process.');
} elseif (!empty($file_attachment['name']) && !in_array(Tools::strtolower(substr($file_attachment['name'], -4)), $extension) && !in_array(Tools::strtolower(substr($file_attachment['name'], -5)), $extension)) {
$this->context->controller->errors[] = $this->l('Bad file extension');
} else {
$customer = $this->context->customer;
if (!$customer->id) {
$customer->getByEmail($from);
}
$id_order = (int) Tools::getValue('id_order');
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($from, $id_order);
if ($contact->customer_service) {
if ((int) $id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int) $this->context->language->id;
$ct->id_contact = (int) $id_contact;
$ct->id_order = (int) $id_order;
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int) $customer->id;
}
$ct->id_shop = (int) $this->context->shop->id;
$ct->id_order = (int) $id_order;
if ($id_product = (int) Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int) $id_contact;
$ct->id_lang = (int) $this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
if ($ct->id) {
$lastMessage = CustomerMessage::getLastMessageForCustomerThread($ct->id);
$testFileUpload = isset($file_attachment['rename']) && !empty($file_attachment['rename']);
// if last message is the same as new message (and no file upload), do not consider this contact
if ($lastMessage != $message || $testFileUpload) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = $message;
if ($testFileUpload && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_ . basename($file_attachment['rename']))) {
$cm->file_name = $file_attachment['rename'];
@chmod(_PS_UPLOAD_DIR_ . basename($file_attachment['rename']), 0664);
}
$cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add()) {
$this->context->controller->errors[] = $this->l('An error occurred while sending the message.');
}
} else {
$mailAlreadySend = true;
}
} else {
$this->context->controller->errors[] = $this->l('An error occurred while sending the message.');
}
}
if (!count($this->context->controller->errors) && empty($mailAlreadySend)) {
$var_list = ['{order_name}' => '-', '{attached_file}' => '-', '{message}' => Tools::nl2br(stripslashes($message)), '{email}' => $from, '{product_name}' => ''];
if (isset($file_attachment['name'])) {
$var_list['{attached_file}'] = $file_attachment['name'];
}
$id_product = (int) Tools::getValue('id_product');
if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) {
$order = new Order((int) $ct->id_order);
$var_list['{order_name}'] = $order->getUniqReference();
$var_list['{id_order}'] = (int) $order->id;
}
if ($id_product) {
$product = new Product((int) $id_product);
if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) {
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
}
if (empty($contact->email)) {
Mail::Send($this->context->language->id, 'contact_form', isset($ct) && Validate::isLoadedObject($ct) ? $this->trans('Your message has been correctly sent #ct%thread_id% #tc%thread_token%', array('%thread_id%' => $ct->id, '%thread_token%' => $ct->token), 'Emails.Subject') : $this->trans('Your message has been correctly sent', array(), 'Emails.Subject'), $var_list, $from, null, null, null, $file_attachment);
} else {
if (!Mail::Send($this->context->language->id, 'contact', $this->trans('Message from contact form', array(), 'Emails.Subject') . ' [no_sync]', $var_list, $contact->email, $contact->name, null, null, $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $from) || !Mail::Send($this->context->language->id, 'contact_form', isset($ct) && Validate::isLoadedObject($ct) ? $this->trans('Your message has been correctly sent #ct%thread_id% #tc%thread_token%', array('%thread_id%' => $ct->id, '%thread_token%' => $ct->token), 'Emails.Subject') : $this->trans('Your message has been correctly sent', array(), 'Emails.Subject'), $var_list, $from, null, null, null, $file_attachment, null, _PS_MAIL_DIR_, false, null, null, $contact->email)) {
$this->context->controller->errors[] = $this->l('An error occurred while sending the message.');
}
}
//.........这里部分代码省略.........
示例12: syncImap
//.........这里部分代码省略.........
}
// fix email format: from "Mr Sanders <sanders@blueforest.com>" to "sanders@blueforest.com"
$from = $overview->from;
if (isset($from_parsed[1])) {
$from = $from_parsed[1];
}
// we want to assign unrecognized mails to the right contact category
$contacts = Contact::getContacts($this->context->language->id);
if (!$contacts) {
continue;
}
foreach ($contacts as $contact) {
if (isset($overview->to) && strpos($overview->to, $contact['email']) !== false) {
$id_contact = $contact['id_contact'];
}
}
if (!isset($id_contact)) {
// if not use the default contact category
$id_contact = $contacts[0]['id_contact'];
}
$customer = new Customer();
$client = $customer->getByEmail($from);
//check if we already have a customer with this email
$ct = new CustomerThread();
if (isset($client->id)) {
//if mail is owned by a customer assign to him
$ct->id_customer = $client->id;
}
$ct->email = $from;
$ct->id_contact = $id_contact;
$ct->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$ct->id_shop = $this->context->shop->id;
//new customer threads for unrecognized mails are not shown without shop id
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
} else {
$ct = new CustomerThread((int) $matches1[1]);
}
//check if order exist in database
if (Validate::isLoadedObject($ct) && (isset($matches2[1]) && $ct->token == $matches2[1] || $new_ct)) {
$structure = imap_bodystruct($mbox, $overview->msgno, '1');
if ($structure->type == 0) {
$message = imap_fetchbody($mbox, $overview->msgno, '1');
} elseif ($structure->type == 1) {
$structure = imap_bodystruct($mbox, $overview->msgno, '1.1');
$message = imap_fetchbody($mbox, $overview->msgno, '1.1');
} else {
continue;
}
switch ($structure->encoding) {
case 3:
$message = imap_base64($message);
break;
case 4:
$message = imap_qprint($message);
break;
}
$message = iconv($this->getEncoding($structure), 'utf-8', $message);
$message = nl2br($message);
if (!$message || strlen($message) == 0) {
$message_errors[] = $this->trans('The message body is empty, cannot import it.', array(), 'Admin.OrdersCustomers.Notification');
$fetch_succeed = false;
continue;
}
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
if (empty($message) || !Validate::isCleanHtml($message)) {
$str_errors .= Tools::displayError(sprintf('Invalid Message Content for subject: %1s', $subject));
} else {
try {
$cm->message = $message;
$cm->add();
} catch (PrestaShopException $pse) {
$message_errors[] = $this->trans('The message content is not valid, cannot import it.', array(), 'Admin.OrdersCustomers.Notification');
$fetch_succeed = false;
continue;
}
}
}
}
if ($fetch_succeed) {
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'customer_message_sync_imap` (`md5_header`) VALUES (\'' . pSQL($md5) . '\')');
}
}
}
imap_expunge($mbox);
imap_close($mbox);
if (sizeof($message_errors) > 0) {
if (($more_error = $str_errors . $str_error_delete) && strlen($more_error) > 0) {
$message_errors = array_merge(array($more_error), $message_errors);
}
return array('hasError' => true, 'errors' => $message_errors);
}
if ($str_errors . $str_error_delete) {
return array('hasError' => true, 'errors' => array($str_errors . $str_error_delete));
} else {
return array('hasError' => false, 'errors' => '');
}
}
示例13: validateOrder
//.........这里部分代码省略.........
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list[] = array('voucher_name' => $cart_rule['obj']->name, 'voucher_reduction' => ($values['tax_incl'] != 0.0 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false));
}
$cart_rules_list_txt = '';
$cart_rules_list_html = '';
if (count($cart_rules_list) > 0) {
$cart_rules_list_txt = $this->getEmailTemplateContent('order_conf_cart_rules.txt', Mail::TYPE_TEXT, $cart_rules_list);
$cart_rules_list_html = $this->getEmailTemplateContent('order_conf_cart_rules.tpl', Mail::TYPE_HTML, $cart_rules_list);
}
// Specify order id for message
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
// Add this message in the customer thread
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Hook validateOrder is about to be called', 1, null, 'Cart', (int) $id_cart, true);
}
// Hook validate order
Hook::exec('actionValidateOrder', array('cart' => $this->context->cart, 'order' => $order, 'customer' => $this->context->customer, 'currency' => $this->context->currency, 'orderStatus' => $order_status));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status is about to be added', 1, null, 'Cart', (int) $id_cart, true);
}
// Set the order status
$new_history = new OrderHistory();
$new_history->id_order = (int) $order->id;
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
// Switch to back order if needed
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(Configuration::get($order->valid ? 'PS_OS_OUTOFSTOCK_PAID' : 'PS_OS_OUTOFSTOCK_UNPAID'), $order, true);
$history->addWithemail();
示例14: validateOrder
//.........这里部分代码省略.........
$values['tax_excl'] -= $values['tax_excl'] - $order->total_products;
}
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && !in_array($cart_rule['obj']->id, $cart_rule_used)) {
$cart_rule_used[] = $cart_rule['obj']->id;
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
$cart_rule_to_update = new CartRule($cart_rule['obj']->id);
$cart_rule_to_update->quantity = max(0, $cart_rule_to_update->quantity - 1);
$cart_rule_to_update->update();
}
$cart_rules_list .= '
<tr>
<td colspan="4" style="padding:0.6em 0.4em;text-align:right">' . Tools::displayError('Voucher name:') . ' ' . $cart_rule['obj']->name . '</td>
<td style="padding:0.6em 0.4em;text-align:right">' . ($values['tax_incl'] != 0.0 ? '-' : '') . Tools::displayPrice($values['tax_incl'], $this->context->currency, false) . '</td>
</tr>';
}
// Specify order id for message
$old_message = Message::getMessageByCartId((int) $this->context->cart->id);
if ($old_message) {
$update_message = new Message((int) $old_message['id_message']);
$update_message->id_order = (int) $order->id;
$update_message->update();
// Add this message in the customer thread
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
$customer_thread->id_customer = (int) $order->id_customer;
$customer_thread->id_shop = (int) $this->context->shop->id;
$customer_thread->id_order = (int) $order->id;
$customer_thread->id_lang = (int) $this->context->language->id;
$customer_thread->email = $this->context->customer->email;
$customer_thread->status = 'open';
$customer_thread->token = Tools::passwdGen(12);
$customer_thread->add();
$customer_message = new CustomerMessage();
$customer_message->id_customer_thread = $customer_thread->id;
$customer_message->id_employee = 0;
$customer_message->message = $update_message->message;
$customer_message->private = 0;
if (!$customer_message->add()) {
$this->errors[] = Tools::displayError('An error occurred while saving message');
}
}
// Hook validate order
Hook::exec('actionValidateOrder', array('cart' => $this->context->cart, 'order' => $order, 'customer' => $this->context->customer, 'currency' => $this->context->currency, 'orderStatus' => $order_status));
foreach ($this->context->cart->getProducts() as $product) {
if ($order_status->logable) {
ProductSale::addProductSale((int) $product['id_product'], (int) $product['cart_quantity']);
}
}
if (Configuration::get('PS_STOCK_MANAGEMENT') && $order_detail->getStockState()) {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$history->changeIdOrderState(Configuration::get('PS_OS_OUTOFSTOCK'), $order, true);
$history->addWithemail();
}
// Set order state in order history ONLY even if the "out of stock" status has not been yet reached
// So you migth have two order states
$new_history = new OrderHistory();
$new_history->id_order = (int) $order->id;
$new_history->changeIdOrderState((int) $id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
unset($order_detail);
// Order is reloaded because the status just changed
$order = new Order($order->id);
// Send an e-mail to customer (one order = one email)
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
示例15: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) {
$this->errors[] = Tools::displayError('Order ID required');
} else {
$order = new Order($id_order);
if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
$id_order_state = (int) $order->getCurrentState();
$carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
$addressInvoice = new Address((int) $order->id_address_invoice);
$addressDelivery = new Address((int) $order->id_address_delivery);
$inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
$dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
$invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
$deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
if ($order->total_discounts > 0) {
$this->context->smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts));
}
$products = $order->getProducts();
/* DEPRECATED: customizedDatas @since 1.5 */
$customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
Product::addCustomizationPrice($products, $customizedDatas);
OrderReturn::addReturnedQuantity($products, $order->id);
$customer = new Customer($order->id_customer);
$this->context->smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection()), 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas));
if ($carrier->url && $order->shipping_number) {
$this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
}
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order));
unset($carrier, $addressInvoice, $addressDelivery);
} else {
$this->errors[] = Tools::displayError('This order cannot be found.');
}
unset($order);
}
$this->setTemplate(_PS_THEME_DIR_ . 'order-detail.tpl');
}