Solutecjb.com 0 Posted December 16, 2015 Posted December 16, 2015 Hola Amigo espero que estes bien necesito una ayuda y queria saber si me puedes dar una mano.Tengo la Web lista y la modificación del Formulario de contacto funciona bien. Pero en el Correo que recibo me sale asi MENSAJE DE UN CLIENTE EMPRESA:prueba@prueba.comNOMBRE Y APELLIDO:prueba@prueba.comDIRECCIÓN DE E-MAIL: prueba@prueba.comTELÉFONO:prueba@prueba.comMensaje: prueba1No se que debo modificar o en que falle ya que el resultado de todos los datos apunta al mismo de E-mail, me puedes ayudar? Share this post Link to post Share on other sites
Rolige 449 Posted December 16, 2015 Posted December 16, 2015 Seguramente editaste la plantilla y repetiste la misma variable que esta dentro de los corchetes. Share this post Link to post Share on other sites
Solutecjb.com 0 Posted December 16, 2015 Posted December 16, 2015 Esto es lo que tengo en el Contact-form <p id="desc_contact0" class="desc_contact{if isset($smarty.request.id_contact)} unvisible{/if}"> </p>{foreach from=$contacts item=contact}<p id="desc_contact{$contact.id_contact|intval}" class="desc_contact contact-title{if !isset($smarty.request.id_contact) || $smarty.request.id_contact|intval != $contact.id_contact|intval} unvisible{/if}"><i class="icon-comment-alt"></i>{$contact.description|escape:'html':'UTF-8'}</p>{/foreach}{/if} <p class="form-group"><label for="empresa">{l s='Empresa'}</label>{if isset($customerThread.empresa)}<input class="form-control grey" type="text" id="empresa" name="from" value="{$customerThread.empresa|escape:'html':'UTF-8'}" readonly="readonly" />{else}<input class="form-control grey validate" type="text" id="empresa" name="empresa" data-validate="isEmpresa" value="{$empresa|escape:'html':'UTF-8'}" />{/if} </p> <p class="form-group"><label for="nombre">{l s='Nombre y Apellido'}</label>{if isset($customerThread.nombre)}<input class="form-control grey" type="text" id="nombre" name="from" value="{$customerThread.nombre|escape:'html':'UTF-8'}" readonly="readonly" />{else}<input class="form-control grey validate" type="text" id="nombre" name="from" data-validate="isnombre" value="{$nombre|escape:'html':'UTF-8'}" />{/if} </p> <p class="form-group"><label for="email">{l s='Email address'}</label>{if isset($customerThread.email)} <input class="form-control grey" type="text" id="email" name="from" value="{$customerThread.email|escape:'html':'UTF-8'}" readonly="readonly" /> {else}<input class="form-control grey validate" type="text" id="email" name="from" data-validate="isEmail" value="{$email|escape:'html':'UTF-8'}" />{/if} <p class="form-group"> <label for="telefono">{l s='Teléfono'}</label> {if isset($customerThread.telefono)} <input class="form-control grey" type="text" id="telefono" name="from" value="{$customerThread.telefono|escape:'html':'UTF-8'}" readonly="readonly" /> {else} <input class="form-control grey" type="text" id="telefono" value="{if isset($smarty.post.telefono)}{$smarty.post.telefono}{/if}" /> {/if}</p> </p><p>{if $fileupload == 1} </p><p class="form-group"> <label for="fileUpload">{l s='Attach File'}</label><input type="hidden" name="MAX_FILE_SIZE" value="{if isset($max_upload_size) && $max_upload_size}{$max_upload_size|intval}{else}2500000{/if}" /><input type="file" name="fileUpload" id="fileUpload" class="form-control" /></p> <p>{/if} </p> <p> </p></div> <div class="col-xs-12 col-md-9"><div class="form-group"><label for="message">{l s='Message'}</label><textarea class="form-control" id="message" name="message">{if isset($message)}{$message|escape:'html':'UTF-8'|stripslashes}{/if}</textarea></div></div></div><div class="submit"><button type="submit" name="submitMessage" id="submitMessage" class="button btn btn-default button-medium"><span>{l s='Send'}<i class="icon-chevron-right right"></i></span></button></div></fieldset></form>{/if} Y ESTO ES LO QUE TENGO EN EL ContactController class ContactControllerCore extends FrontController { public $php_self = 'contact'; public $ssl = true; /** * Start forms process * @see FrontController::postProcess() */ public function postProcess() { if (Tools::isSubmit('submitMessage')) { $extension = array('.txt', '.rtf', '.doc', '.docx', '.pdf', '.zip', '.png', '.jpeg', '.gif', '.jpg'); $file_attachment = Tools::fileAttachment('fileUpload'); $message = Tools::getValue('message'); // Html entities is not usefull, iscleanHtml check there is no bad html tags. if (!($from = trim(Tools::getValue('from'))) || !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. '); } elseif (!empty($file_attachment['name']) && $file_attachment['error'] != 0) { $this->errors[] = Tools::displayError('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->errors[] = Tools::displayError('Bad file extension'); } 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['empresa'] == $empresa) { $tmp += 1; } if ($row['nombre'] == $nombre) { $tmp += 2; } if ($row['email'] == $from) { $tmp += 3; } if ($row['telefono'] == $telefono) { $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->empresa = ''; $contact->nombre = ''; $contact->email = ''; $contact->telefono = ''; $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)), '{empresa}' => $empresa, '{nombre}' => $nombre, '{email}' => $from, '{telefono}' => $telefono, '{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); } } } } public function setMedia() { parent::setMedia(); $this->addCSS(_THEME_CSS_DIR_.'contact-form.css'); $this->addJS(_THEME_JS_DIR_.'contact-form.js'); $this->addJS(_PS_JS_DIR_.'validate.js'); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->assignOrderList(); $email = Tools::safeOutput(Tools::getValue('from', ((isset($this->context->cookie) && isset($this->context->cookie->email) && Validate::isEmail($this->context->cookie->email)) ? $this->context->cookie->email : ''))); $this->context->smarty->assign(array( 'errors' => $this->errors, 'empresa' => $fromempresa, 'nombre' => $fromnombre, 'email' => $email, 'telefono' => $fromtelefono, 'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD'), 'max_upload_size' => (int)Tools::getMaxUploadSize() )); if (($id_customer_thread = (int)Tools::getValue('id_customer_thread')) && $token = Tools::getValue('token')) { $customer_thread = Db::getInstance()->getRow(' SELECT cm.* 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($token).'\' '); $order = new Order((int)$customer_thread['id_order']); if (Validate::isLoadedObject($order)) { $customer_thread['reference'] = $order->getUniqReference(); } $this->context->smarty->assign('customerThread', $customer_thread); } $this->context->smarty->assign(array( 'contacts' => Contact::getContacts($this->context->language->id), 'message' => html_entity_decode(Tools::getValue('message')) )); $this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl'); } /** * Assign template vars related to order list and product list ordered by the customer */ protected function assignOrderList() { if ($this->context->customer->isLogged()) { $this->context->smarty->assign('isLogged', 1); $products = array(); $result = Db::getInstance()->executeS(' SELECT id_order FROM '._DB_PREFIX_.'orders WHERE id_customer = '.(int)$this->context->customer->id.Shop::addSqlRestriction(Shop::SHARE_ORDER).' ORDER BY date_add'); $orders = array(); foreach ($result as $row) { $order = new Order($row['id_order']); $date = explode(' ', $order->date_add); $tmp = $order->getProducts(); foreach ($tmp as $key => $val) { $products[$row['id_order']][$val['product_id']] = array('value' => $val['product_id'], 'label' => $val['product_name']); } $orders[] = array('value' => $order->id, 'label' => $order->getUniqReference().' - '.Tools::displayDate($date[0], null) , 'selected' => (int)$this->getOrder() == $order->id); } $this->context->smarty->assign('orderList', $orders); $this->context->smarty->assign('orderedProductList', $products); } } protected function getOrder() { $id_order = false; if (!is_numeric($reference = Tools::getValue('id_order'))) { $reference = ltrim($reference, '#'); $orders = Order::getByReference($reference); if ($orders) { foreach ($orders as $order) { $id_order = (int)$order->id; break; } } } elseif (Order::getCartIdStatic((int)Tools::getValue('id_order'))) { $id_order = (int)Tools::getValue('id_order'); } return (int)$id_order; } } cual seria la parte que repeti. ..? Share this post Link to post Share on other sites
Recommended Posts