Jump to content

fair-agenceweb

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by fair-agenceweb

  1. j'ai le même soucis en 1.6.0.5, modifier le formulaire de contact est une horreur sur prestashop

     

    voici le code de mon formulaire dans contact-form.tpl

    	<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std" enctype="multipart/form-data">
    		<fieldset>
    			<div class="contL">
    				<label for="lastname">Votre nom <span class="requis">(obligatoire)</span></label>
    					<input type="text" id="lastname" name="lastname" value="{$customerThread.lastname|escape:'htmlall':'UTF-8'}" />
    			</div>
          
    			<div class="contR">
    				<label for="firstname">Votre prénom <span class="requis">(obligatoire)</span></label>
    					<input type="text" id="firstname" name="firstname" value="{$customerThread.firstname|escape:'htmlall':'UTF-8'}" />
    			</div>
          
    			<div class="contL">
    				<label for="email">{l s='Email address'} <span class="requis">(obligatoire)</span></label>
    				{if isset($customerThread.email)}
    					<input type="text" id="email" name="from" value="{$customerThread.email|escape:'htmlall':'UTF-8'}" readonly />
    				{else}
    					<input type="text" id="email" name="from" value="{$email|escape:'htmlall':'UTF-8'}" />
    				{/if}
    			</div>
          
    			<div class="contR">
    				<label for="phone">{l s='Votre numéro de téléphone'}</label>
    					<input type="phone" id="phone" name="phone" value="{$customerThread.phone|escape:'htmlall':'UTF-8'}" />
    			</div>
          
          <div class="contL">
    				<label for="nature">{l s='Vous êtes'}</label>
    				<div class="select">
              <select id="nature" name="nature" value="{$customerThread.nature|escape:'htmlall':'UTF-8'}">
                <option value="pro">{l s='Un professionnel'}</option>
                <option value="part">{l s='Un particulier'}</option>
               </select>
             </div>
          </div>
    
          <div class="contR">
    				<label for="id_contact">{l s='Vous souhaitez'}</label>
    				<div class="select">
              <select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">
                <option value="comptepro">Créer votre compte professionnel</option>
                <option value="contact">Nous contacter</option>
                <option value="sav">Signaler un problème avec un article ou une commande</option>
                <option value="autre">Autre</option>
              </select>
            </div>
          </div>
          
    			<div class="contL">
    				<label for="company">{l s='Votre société'}</label>
    					<input type="text" id="company" name="company" value="{$customerThread.company|escape:'htmlall':'UTF-8'}" />
    			</div>
          
    			<div class="contR">
    				<label for="company">{l s='Siren de votre société'}</label>
    					<input type="text" id="siren" name="siren" value="{$customerThread.siren|escape:'htmlall':'UTF-8'}" />
    			</div>
          
          
    		{if !$PS_CATALOG_MODE}
    			{if (!isset($customerThread.id_order) || $customerThread.id_order > 0)}
    			
    				
    				{if !isset($customerThread.id_order) && isset($isLogged) && $isLogged == 1}
    					<div class="contL"><label for="id_order">{l s='Order reference'}</label><div class="select"><select name="id_order" >
    						<option value="0">{l s='-- Choose --'}</option>
    						{foreach from=$orderList item=order}
    							<option value="{$order.value|intval}" {if $order.selected|intval}selected="selected"{/if}>{$order.label|escape:'htmlall':'UTF-8'}</option>
    						{/foreach}
    					</select></div>
            </div>
    				{elseif !isset($customerThread.id_order) && !isset($isLogged)}
    					<div class="contF"><label for="id_order">{l s='Order reference'}</label><input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order|intval > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order) && !empty($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" /></div>
    				{elseif $customerThread.id_order|intval > 0}
    					<div class="contL"><label for="id_order">{l s='Order reference'}</label><input type="text" name="id_order" id="id_order" value="{$customerThread.id_order|intval}" readonly /></div>
    				{/if}
    			
    			{/if}
    			{if isset($isLogged) && $isLogged}
    			<div class="contR">
    			<label for="id_product">{l s='Product'}</label>
    				{if !isset($customerThread.id_product)}<div class="select">
    				{foreach from=$orderedProductList key=id_order item=products name=products}
    					<select name="id_product" id="{$id_order}_order_products" class="product_select" style="{if !$smarty.foreach.products.first} display:none; {/if}" {if !$smarty.foreach.products.first}disabled="disabled" {/if}>
    						<option value="0">{l s='-- Choose --'}</option>
    						{foreach from=$products item=product}
    							<option value="{$product.value|intval}">{$product.label|escape:'htmlall':'UTF-8'}</option>
    						{/foreach}
    					</select>
             
    				{/foreach}</div></div>
    				{elseif $customerThread.id_product > 0}
    					<div class="contR"><input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly /></div>
    				{/if}
    			{/if}
    		{/if}
    		{if $fileupload == 1}
    			<div class="contF">
    			<label for="fileUpload">{l s='Attach File'}</label>
    				<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
    				<input type="file" name="fileUpload" id="fileUpload" />
    			</div>
    		{/if}
    		<div class="contF">
    			<label for="message">{l s='Message'}</label>
    			 <textarea id="message" name="message" rows="15" cols="10">{if isset($message)}{$message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>
    		</div>
        
    
    		<div class="contF">
    			<input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" />
    		</div>
    	</fieldset>
    </form>
    
    

    mon code dans ContactController.php que j'ai placé dans override/controllers/front

    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');
    			$fileAttachment = Tools::fileAttachment('fileUpload');
    			$message = Tools::getValue('message'); // Html entities is not usefull, iscleanHtml check there is no bad html tags.
    			$firstname = Tools::getValue('firstname');
    			$lastname = Tools::getValue('lastname');
    			$phone = Tools::getValue('phone');
    			$nature = Tools::getValue('nature');
    			$id_contact = Tools::getValue('id_contact');
    			$company = Tools::getValue('company');
    			$siren = Tools::getValue('siren');
    			
    			if (!($from = trim(Tools::getValue('from'))) || !Validate::isEmail($from))
    				$this->errors[] = Tools::displayError('Invalid email address.');
    			else if (!$lastname)
    				$this->errors[] = Tools::displayError('Veuillez renseigner votre nom');
    			else if (!$firstname)
    				$this->errors[] = Tools::displayError('Veuillez renseigner votre prénom');
    			else if (!Validate::isCleanHtml($message))
    				$this->errors[] = Tools::displayError('Invalid message');
    			else if (!empty($fileAttachment['name']) && $fileAttachment['error'] != 0)
    				$this->errors[] = Tools::displayError('An error occurred during the file-upload process.');
    			else if (!empty($fileAttachment['name']) && !in_array( Tools::strtolower(substr($fileAttachment['name'], -4)), $extension) && !in_array( Tools::strtolower(substr($fileAttachment['name'], -5)), $extension))
    				$this->errors[] = Tools::displayError('Bad file extension');
    			else
    			{
    				$customer = $this->context->customer;
    				if (!$customer->id)
    					$customer->getByEmail($from);
    
    				$contact = new Contact($id_contact, $this->context->language->id);
    
    				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, (int)Tools::getValue('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)(Tools::getValue('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 && 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 && $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);
    						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 = $message;
    						if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename'])))
    							$cm->file_name = $fileAttachment['rename'];
    						$cm->ip_address = 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($fileAttachment['name']))
    						$var_list['{attached_file}'] = $fileAttachment['name'];
    
    					$id_order = (int)Tools::getValue('id_order');
    					
    					$id_product = (int)Tools::getValue('id_product');
    					
    					if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order)
    						$id_order = $ct->id_order;
    
    					if ($id_order)
    					{
    						$order = new Order((int)$id_order);
    						$var_list['{order_name}'] = $order->getUniqReference();
    						$var_list['{id_order}'] = $id_order;
    					}
    					
    					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, $fileAttachment);
    					else
    					{					
    						if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
    							$var_list, $contact->email, $contact->name, $from, ($customer->id ? $customer->firstname.' '.$customer->lastname : ''),
    									$fileAttachment) ||
    								!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, $contact->email, $contact->name, $fileAttachment))
    									$this->errors[] = Tools::displayError('An error occurred while sending the message.');
    					}
    				}
    				
    				if (count($this->errors) > 1)
    					array_unique($this->errors);
    				else
    					$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,
    			'email' => $email,
    			'fileupload' => Configuration::get('PS_CUSTOMER_SERVICE_FILE_UPLOAD')
    		));
    
    
    		if (($id_customer_thread = (int)Tools::getValue('id_customer_thread')) && $token = Tools::getValue('token'))
    		{
    			$customerThread = 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).'\'
    			');
    			$this->context->smarty->assign('customerThread', $customerThread);
    		}
    		
    		$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.' 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)Tools::getValue('id_order') == $order->id);
    			}
    
    			$this->context->smarty->assign('orderList', $orders);
    			$this->context->smarty->assign('orderedProductList', $products);
    		}
    	}
    }
    

    et enfin mon code dans contact_form.html :

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    		<title>Message de {shop_name}</title>
    	</head>
    	
    <body bgcolor="#EEEEEE"  style="text-align:center;color:#414141">
    
    <p style="padding:15px 0; margin:0 auto; text-align:center;"><img src="http://localhost:8888/themes/zensation/css/images/salamandre-design-logo.png" width="425px" height="95px" /></p>	
      
      	<table width="500px" align="center" cellpadding="5px" cellspacing="0" border="0">
    <tr>
    	<td style="text-align:center">Voici votre message à l'attention du service client de <strong>Salamandre Design</strong></td>
    </tr>
    <tr>
    	<td style="background:#fff;">Vous êtes <strong>{nature}</strong></td>
    </tr>
    <tr>
    	<td>Vous representez la société <strong>{company}</strong></td>
    </tr>
    <tr>
      <td>Dont le siren est {siren}</td>
    </tr>
    <tr>
    	<td style="background:#fff;">Vous souhaitez</td>
    </tr>
    <tr>
      <td style="background:#fff;"><strong>{id_contact}</strong></td>
    </tr>
    <tr>
    	<td>Vous nous contactez concernant la commande <strong>{order_name}</strong></td>
    </tr>
    <tr>
      <td style="background:#fff;">et notamment le produit <strong>{product_name}</strong></td>
    </tr>
    <tr>
    	<td style="background:#fff;text-align:center">Votre message</td>
    </tr>
    <tr>
    	<td style="text-align:center">{message}</td>
    </tr>
    <tr>
    	<td style="background:#fff;">Vous avez joint à votre demande</td>
    </tr>
    <tr>
      <td style="background:#fff;">{attached_file}</td>
    </tr>
    </table>
    	</body>
    </html>
    

    la plupart de mes données n'apparaissent pas dans mon mail, je ne reçois même pas le mail en tant qu'administrateur.

     

    Les problèmes sur les formulaires de contact sont plus que récurrents, à quand une vraie amélioration de ce côté la ? quand seront-ils enfin intégrés au système, ce qui est plutôt basique pour un cms même de type e-shop ?

  2. Bonjour,

    Je sais que ce topic est marqué résolu cependant j'avais tout de même une question.

     

    La méthode de Chourak fonctionne aussi en 1.6.0.5, cela dit elle engendre un chargement très long dans le backoffice sur la page produit, quelqu'un a-t'il une idée d'ou ce ralentissement peut provenir ? j'ai essayé en enlevant le datepicker mais ça ne semble pas venir de la.

  3. Bonjour,

    J'ai deux soucis majeurs sur prestashop 1.6 :

     

    Tout d'abord, et je viens de le découvrir, je n'ai plus accès à mon administration. Le chemin est bien le bon, mais lorsque je le rentre je tombe sur une 404 du site. J'ai essayé le chemin direct du login.php mais même résultat. Lorsque je vérifie directement sur mon ftp je vois pourtant bien que mon dossier d'administration est toujours la avec le même nom qu'auparavant. Une suggestion pour ce problème ?

     

    Ensuite mon second problème vient des filtres à facette. En effet je ne peux activer ces derniers sous peine de provoquer une page blanche sur mon site. J'utilise le thème Zensation que j'ai modifié, mais ces modifications sont principalement de l'ordre du css. quelqu'un a-t'il déjà eu ce problème ou a-t'il une idée ?

     

    cordialement,

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More