Jump to content

Récupérer une donnée pour un pdf


Recommended Posts

Bonjour à tous,
je cherche à récupérer une date d'un module de devis pour l'afficher dans le pdf généré par ce devis.

Voici ce que j'ai dans le code tpl qui est la structure de mon devis:

 

...<div id="layer1" style="width:307px; height:73px; position:absolute; left:550px; top:44px; z-index:1; visibility:visible; font-family: Arial, Helvetica, sans-serif; color:#333;">
    <p>Le: {$smarty.now|date_format:"%d %m %Y"}</p>
    <p>Client: {$customerName}</p>...

 

Bien sûr la date change à chaque fois que l'on crée le pdf.
Hors je voudrais récupérer la date de création du devis qui se trouve dans le tpl qui permet d'afficher la liste des devis sauvegardés:

 

...<tbody>
        {foreach from=$quote_collection item=quote}
            <tr class="first_item ">
                <td class="history_link bold footable-first-column">
                    <a class="color-myaccount" href="{$link->getModuleLink('cartquotationwizard', 'quoteview', ['action' => 'view'], true)|escape:'html':'UTF-8'}&id_quote={$quote->id|escape:'htmlall':'UTF-8'}">
                        {$quote->name|escape:'htmlall':'UTF-8'}
                    </a>
                </td>
                <td data-value="11401007092016" class="history_date bold">
                    {$quote->date_add|escape:'htmlall':'UTF-8'}
                </td>
                <td class="history_detail footable-last-column">
                    <a class="link-button" href="{$link->getModuleLink('cartquotationwizard', 'quoteview', ['action' => 'view'], true)|escape:'html':'UTF-8'}&id_quote={$quote->id|escape:'htmlall':'UTF-8'}" title="">
                        <i class="fa fa-eye" aria-hidden="true"></i> {l s='View' mod='cartquotationwizard'}
                    </a>......

 

cette date est gardée dans la base de donnée mais je ne sais pas comment la faire afficher dans mon pdf.

Merci à tous pour votre aide.

Link to comment
Share on other sites

On n parle pas d'un problème informatique là. Enfin tant que les ordinateur ne seront pas omniscient et ne pourrons pas aller dans le passé. Si ton devis ne mémorise nulle part la date de création et se contente de l'imprimer, il n'y a pas de solution

 

J'ai mal lu. La date étant dans la base de donnée, il te faut aller chercher celle-ci. Comme fait tu le lien entre la commande et le devis?

Edited by doekia (see edit history)
Link to comment
Share on other sites

en fait j'utilise un module existant qui crée un devis à partir du panier.
Dans le panier, il y a un champ pour donner un nom au devis, et un bouton creer le devis.
Dans "mon compte", il y a un nouveau bouton: "liste des devis sauvegardés"
Dans cette liste, il y a tous les devis en liste avec le nom du devis, la date de création, un bouton pour creer le pdf et un bouton pour effacer le devis.
J'ai regardé la bdd et j'ai vi que mes devis étaient sauvegardés dans une table et la clé commune doit être l'id du panier.
Dans cette table, il y a un champ "date_add" et c'est ce champ que je voudrais récupérer
 

voici la structure de la table:

s_fulltext.png

  id_cqw_quote name id_cart id_shop_group id_shop id_carrier delivery_option id_lang id_address_delivery id_address_invoice id_currency id_customer id_guest secure_key recyclable gift gift_message mobile_theme allow_seperated_package date_add date_upd Edited by Michel Faure (see edit history)
Link to comment
Share on other sites

Alors un truc un peu crado mais qui doit marcher:

{capture name="sql"}select q.date_add from `{smarty.const._DB_PREFIX_}cqw_quote` q where id_cart = {$order->id_cart}{/capture}
{assign var="date_quote" value=Db::getInstance()->getValue($smarty.capture.sql)}

<p>Le {$date_quote|date_format:"%d %m %Y}</p>

J'ai imaginé que ta table s'appelle cqw_quote puisque tu as oublié de me dire.

Link to comment
Share on other sites

Re
{capture name="sql"}select q.date_add from `{smarty.const._DB_PREFIX_}cqw_quote` q where id_cart = {$order->id_cart}{/capture}
{assign var="date_quote" value=Db::getInstance()->getValue($smarty.capture.sql)}

cette partie de code n'est pas valable dans mon tpl.
La table est bien ps_cqw_quote mais ça ne fonctionne pas, j'ai une page blanche.
Peut être faut il insérer ce code ailleurs que dans le tpl?

 

Encore merci pour ton aide précieuse.
 

Link to comment
Share on other sites

Bonjour et merci.
Voici ce que j'ai mis dans mon tpl:

 

<div id="layer1" style="width:307px; height:73px; position:absolute; left:550px; top:44px; z-index:1; visibility:visible; font-family: Arial, Helvetica, sans-serif; color:#333;">
    {capture name="sql"}select q.date_add from `{smarty.const._DB_PREFIX_}cqw_quote` q where id_cart = {$order->id_cart}{/capture}
    {assign var="date_quote" value=Db::getInstance()->getValue($smarty.capture.sql)}

    <p>Le {$date_quote|date_format:"%d %m %Y}</p>*}
    <p>Client: {$customerName}</p>
</div>

Ça ne fonctionne pas :(

j'obtiens une page blanche

Link to comment
Share on other sites

pour info voici mon tpl complet:

c'est a la ligne 8 que je voudrais mettre la date de création du devis

<p><img src="http://www.esportsnatura.com/img/esports-natura-logo-14526774231.jpg" border="0" alt="LOGO" width="123" height="74" style="margin-top: -30px;">
<br>
<br>
</p>
<p> </p>

<div id="layer1" style="width:307px; height:73px; position:absolute; left:550px; top:44px; z-index:1; visibility:visible; font-family: Arial, Helvetica, sans-serif; color:#333;">
    <p>Le: {$smarty.now|date_format:"%d %m %Y"}</p>
    <p>Client: {$customerName}</p>
 
</div>
<div id="layer3" style="width:100%; height:54px; position:absolute; left:2px; top:200px; z-index:1;">
    <h3 align="center">DEVIS nº {$smarty.now|date_format:"%S%d%m%Y"}</h3>
        <p align="center"> </p>
</div>
<h3 align="center"> </h3>
<table width="500" style="margin-top:60px; ;" height="250">
    <tr>
        <th colspan="2" width="350"></th>
        <th style='font-size:14px; font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; color:#333; text-align: right;' width="50">
			{l s='Prix TTC' mod='cartquotationwizard'}
        </th>
        <th  style='font-size:14px; font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; color:#333; text-align: right;' width="50">
			{l s='Total TTC' mod='cartquotationwizard'}
        </th>
    </tr>
{foreach from=$products item=product}
	<tr>
    <td width="10%" style="border-bottom:1px solid #ccc" height="auto">
			<img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'medium_default')|escape:'html':'UTF-8'}" width="32" />
    </td>
    <td style='font-size:14px; font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; color:#333; border-bottom:1px solid #ccc' width="318" height="auto">
			<strong>{$product.quantity|escape:'htmlall':'UTF-8'}</strong> x {$product.name|escape:'htmlall':'UTF-8'} ({l s='ref:' mod='cartquotationwizard'} {$product.reference|escape:'htmlall':'UTF-8'})
    </td>
    <td style='font-size:14px; font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; color:#333; border-bottom:1px solid #ccc; text-align: right;' width="50" height="auto">
			{displayPrice price=$product.price}
    </td>
    <td style='font-size:15px; font-family: "DejaVu Sans", Arial, Helvetica, sans-serif; color:#333; border-bottom:1px solid #ccc; text-align: right;' width="50" height="auto">
			{*{displayPrice price=$product.total}*}
			{*{displayPrice price=$product.total_wt}*}
			{if empty($product.price_with_reduction_without_tax)}
				{displayPrice price=$product.total_wt}
			{else}
				{displayPrice price=$product.price_with_reduction_without_tax}
			{/if}
    </td>
</tr>
{/foreach}
</table>

<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td width="50%" style="padding: 5px; border-width:0; border-color:none; border-style:solid;" align="left" valign="top">            
		<p style="font-size:12px; font-family: Arial, Helvetica, sans-serif; color:#333;">Devis à nous retourner tamponné suivi de la mention</p>
		<p style="margin-top: -15px; font-size:12px; font-family: Arial, Helvetica, sans-serif; color:#333;"> "BON POUR ACCORD"</p>
        <p style="font-size: 12px; font-family: Arial, Helvetica, sans-serif; color:#333;">DATE                                            SIGNATURE</p>
            <p> </p>
        </td>
        <td width="40%" bordercolor="white" style="border-left: 1px solid #ccc; padding-right: 5px;" align="right" valign="top">
            <p align="right"><span style='font-size:15px; line-height: 26px; font-family: Arial, Helvetica, sans-serif; color:#333; display: block; '>
            {if (isset($total_discounts_exctax) && $total_discounts_exctax gt 0)} {l s='Discounts (Exc.Tax):' mod='cartquotationwizard'} {displayPrice price=$total_discounts_exctax}{/if}
            {if (isset($shipping_exctax))} {l s='Transport HT:' mod='cartquotationwizard'} {displayPrice price=$shipping_exctax}{/if}<br>
            {l s='Total Pièces HT:' mod='cartquotationwizard'} {displayPrice price=$total_inctax-($total_inctax - $total_exctax)-$shipping_exctax}<br>
            {l s='Total Devis HT:' mod='cartquotationwizard'} {displayPrice price=$total_inctax-($total_inctax - $total_exctax)}<br>
            {l s='Total Tax:' mod='cartquotationwizard'} {displayPrice price=$total_inctax - $total_exctax}<br>
    <strong>{l s='Total Quote TTC:' mod='cartquotationwizard'} {displayPrice price=$total_inctax}</strong></span></p>
        </td>
    </tr>
</table>
<br>
<p align="center" style="font-size:15px; line-height: 26px; font-family: Arial, Helvetica, sans-serif; color:#333;">
 Esportsnatura devis nº: {$smarty.now|date_format:"%S%d%m%Y"} valable 1 mois à partir de sa date d'émission</p>

Edited by Michel Faure (see edit history)
Link to comment
Share on other sites

Bon voilà:
Si c'est ça que je dois mettre:

{capture name="sql"}select q.date_add from `$ {$smarty.const._DB_PREFIX_}cqw_quote` q where id_cart = {$order->id_cart}{/capture}
{assign var="date_quote" value=Db::getInstance()->getValue($smarty.capture.sql)}

<p>Le {$date_quote|date_format:"%d %m %Y}</p>

ça ne fonctionne toujours pas, j'obtiens toujours une page blanche.

d'ailleurs, le code ne sort pas formaté comme les autres codes de la page, j'utilise Sublime Text pour éditer le tpl et les codes ont des couleurs différentes selon le code. et là il sort en blanc comme du texte.

 

c'est un peu galère non?

post-148277-0-97978200-1492072002_thumb.jpg

Edited by Michel Faure (see edit history)
Link to comment
Share on other sites

je ne comprends pas ta réflexion "et cette phrase concerne un humain" ??
Mais ça ne fonctionne pas non plus.
Désolé si je ne comprends pas tout car je suis un novice qui ne demande qu'à apprendre.

 

:blink:

{capture name="sql"}select q.date_add from `{$smarty.const._DB_PREFIX_}cqw_quote` q where id_cart = {$order->id_cart}{/capture}

J'ai dis j'ai oublié un $ et cette phrase concerne un humain

Link to comment
Share on other sites

Donc le code complet corrigé doit être:

{capture name="sql"}select q.date_add from `{$smarty.const._DB_PREFIX_}cqw_quote` q where id_cart = {$order->id_cart}{/capture}
{assign var="date_quote" value=Db::getInstance()->getValue($smarty.capture.sql)}

{if !empty($date_quote)}<p>Le {$date_quote|date_format:"%d %m %Y"}</p>{/if}
Edited by doekia (see edit history)
Link to comment
Share on other sites

Merci pour tout.
Ça ne fonctionne pas
Peut être est ce dû au fait que ce tpl ne sert qu'à générer un pdf et qu'il faudrait modifier un fichier autre part?
Je continue de chercher.
Pour info:
Avec le {if...]{/if} ça n'affiche rien dans mon pdf et sans les if, ça affiche "Le" mai pas la date.
Le souci c'est qu'il ne capture pas la date de la BDD.
Encore merci mais je ne veux pas t’ennuyer car je sais que c'est difficile d'avoir à faire a des personnes qui n'y connaissent rien.

Link to comment
Share on other sites

Je suis désolé mais je dois partir maintenant et le ne reviendrais que dans 10 jours.
Si tu le permet, je me permettrais de te recontacter le 24 à mon retour.
Pour le moment, je n'activerais pas le module..
Pour répondre à ta réflexion, il y a forcément une date dans la table puisqu'elle est générée quand le devis est généré.

Link to comment
Share on other sites

  • 3 weeks later...

Bonjour,
Mon problème est résolu.
Je ne sais pas comment mais j'ai demandé au développeur et il a ajouté deux variables que je n'ais eu qu'a insérer dans mon code.
Maintenant je cherche a inserer le nom de la société et j'aimerais savoir comment on récupère la variable {$company}  pour pouvoir l'afficher dans mon module.
Si quelqu'un peut m'aider.
Merci d'avance

Link to comment
Share on other sites

Voici ce que me propose Alex--77:
 

//init du cookie si ce n'est pas déjà fait dans le php qui génère ta vue tpl
$this->context->cookie;

// je ne suis pas sur que cela marche, je n'ai pas vérifié
$cookie->customer_company;

//Sinon voici le code pour récupérer l'id du client
$id_customer = $cookie->id_customer;
// init d'un objet client
$customer = new Customer($id_customer);

// je ne suis pas sur que cela marche
$company = $customer->company; // ou peut-être $customer->company_name

//Et tu retourne ta nouvelle variable a smarty pour l'utiliser
$this->context->smarty->assign(
array(
'MaVariableTPL' => $company
)
);
// remplacer MaVariableTPL par le nom que tu veux

et voici (semble-t-il) le php correspondant aux déclarations des variables utilisées dans le module:

use Dompdf\Dompdf;

class CQWFrontCartController extends CQWControllerCore
{

	public function setMedia()
	{
		$this->sibling->context->controller->addCSS($this->sibling->_path.'views/css/front/cartquotationwizard.css');

		if (Tools::getValue('controller') == 'order' || Tools::getValue('controller') == 'orderopc' || Tools::getValue('controller') == 'quoteview')
		{
			$this->sibling->context->controller->addCSS($this->sibling->_path.'views/js/front/CQWFrontCartController.js');
			$this->sibling->context->controller->addJS($this->sibling->_path.'views/js/front/CQWFrontCartController.js');
		}


		if (Tools::getValue('controller') == 'product')
			$this->sibling->context->controller->addJS($this->sibling->_path.'views/js/front/CQWFrontProductController.js');
	}

	public function renderActionButtons()
	{
		Media::addJsDefL('email_popup_text', $this->sibling->l('Enter email address separated by commas', null, true, false));
		$this->sibling->smarty->assign(array(
			'cqw_hide_checkout_btn' => (int)Configuration::get('cqw_hide_checkout_btn'),
			'cqw_download_btn_cart_visible' => (int)Configuration::get('cqw_download_btn_cart_visible'),
			'cqw_email_btn_cart_visible' => (int)Configuration::get('cqw_email_btn_cart_visible')
		));
		return $this->sibling->display($this->sibling->module_file, 'views/templates/front/hook/shopping_cart_footer.tpl');
	}

	private function getQuoteProductsHtml($id_cqw_quote)
	{
		$cqw_quote_model = new CQWQuoteModel($id_cqw_quote);
		$cqw_quote_product_model = new CQWQuoteProductModel();
		$product_collection = $cqw_quote_product_model->getCollection($id_cqw_quote);

		foreach ($product_collection as &$product)
		{
			if (is_object($product))
				$product = get_object_vars($product);

			$tmp_product = new Product($product['id_product']);
			$tmp_product = get_object_vars($tmp_product);
			CQWHelper::addQuoteInfoToProduct($product, $tmp_product, $product['id_product_attribute'], $cqw_quote_model->id_address_delivery);
		}

		unset($product);

		$quote_totals = CQWHelper::getQuoteOrderTotals($product_collection);

		if (Tools::getValue('source') == 'quote')
		{
			$this->sibling->smarty->assign(array(
				'total_exctax' => $quote_totals['total_et'],
				'total_inctax' => $quote_totals['total_wt']
			));
		}
		else
		{
			$this->sibling->smarty->assign(array(
				'total_exctax' => $this->context->cart->getordertotal(false),
				'total_inctax' => $this->context->cart->getordertotal(true),
				'shipping_exctax' => $this->context->cart->getTotalShippingCost(null, false),
				'shipping_inctax' => $this->context->cart->getTotalShippingCost(null, true),
				'total_discounts_exctax' => $this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS),
				'total_discounts_inctax' => $this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS),
                'quote_reference' => CQWHelper::formatReference($cqw_quote_model->id, $cqw_quote_model->name),
                'quote_date' => Tools::displayDate($cqw_quote_model->date_add)
			));
		}

		/* objects to array, because products from cart are arrays and from quote are objects */
		foreach ($product_collection as &$product)
		{
			if (is_object($product))
				$product = get_object_vars($product);
				
			$product['price'] = $product['unit_price'];
			$product['price_et'] = $product['unit_price_et'];				
		}

		$this->sibling->smarty->assign(array(
			'products' => $product_collection
		));
		return $this->sibling->display($this->sibling->module_file, 'views/templates/front/pdf_cart.tpl');
	}

	private function getCartProductsHtml($source)
	{
		if (empty($this->context->cart)) return '';
		$id_cart = $this->context->cart->id;
		$cqw_quote_model = new CQWQuoteModel($id_cart);
		$cqw_quote_product = new CQWQuoteProductModel();

		if (Tools::getValue('source') == 'quote')
			$products = $cqw_quote_product->getAll($id_cart);

		else
			$products = $this->context->cart->getProducts(true);

		if (empty($products)) return '';

		foreach ($products as &$product)
		{
			if (is_object($product))
				$product = get_object_vars($product);

			if (empty($product['total_wt']))
			{
				$tmp_product = new Product($product['id_product']);
				$tmp_product = get_object_vars($tmp_product);
				CQWHelper::addQuoteInfoToProduct($product, $tmp_product, $product['id_product_attribute'], $cqw_quote_model->id_address_delivery);
			}
			//if (Tools::getValue('source') == 'quote')
			//$product_obj = new Product($product['id_product']);
		}
		unset($product);

		$quote_totals = CQWHelper::getQuoteOrderTotals($products);

		if (Tools::getValue('source') == 'quote')
		{
			$this->sibling->smarty->assign(array(
				'total_exctax' => $quote_totals['total_et'],
				'total_inctax' => $quote_totals['total_wt']
			));
		}
		else
		{
			$this->sibling->smarty->assign(array(
				'total_exctax' => $this->context->cart->getordertotal(false),
				'total_inctax' => $this->context->cart->getordertotal(true),
				'shipping_exctax' => $this->context->cart->getTotalShippingCost(null, false),
				'shipping_inctax' => $this->context->cart->getTotalShippingCost(null, true),
				'total_discounts_exctax' => $this->context->cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS),
				'total_discounts_inctax' => $this->context->cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS),
                'quote_reference' => CQWHelper::formatReference($cqw_quote_model->id, $cqw_quote_model->name),
                'quote_date' => Tools::displayDate($cqw_quote_model->date_add) 				
			));
		}

		/* objects to array, because products from cart are arrays and from quote are objects */
		foreach ($products as &$product)
		{
			if (is_object($product))
				$product = get_object_vars($product);
		}

		$this->sibling->smarty->assign(array(
			'products' => $products
		));
		return $this->sibling->display($this->sibling->module_file, 'views/templates/front/pdf_cart.tpl');
	}

	/**
	 * product and download PDF Quote based on cart contents
	 * @param Dompdf $dompdf
	 */
	public function createPDF(Dompdf $dompdf)
	{
		/* @var $page_collection CQWPageModel[] */
		$page_collection = array();
		$page_model = new CQWPageModel();
		$page_collection = $page_model->getAll();

		$pdf_html = '';

		foreach ($page_collection as $page)
		{
			$page_lang_model = new CQWPageLangModel();
			$page_lang = $page_lang_model->getByPage($page->id_cqw_page, Context::getContext()->language->id);

			$pdf_html .= '<div class="page" style="width: 100%; height: 100%;">';
			$pdf_html .= $page_lang[Context::getContext()->language->id]->html_content;

			$pdf_html = str_replace('[*PRODUCTS*]', $this->getCartProductsHtml(Tools::getValue('source')), $pdf_html);

			$pdf_html .= '</div>';
		}
		
		$pdf_html = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><style> body { font-family: DejaVu Sans, sans-serif; }</style></head></body>'.$pdf_html.'</body></html>';

		$dompdf->setPaper('A4', 'portrait');
		$dompdf->loadHtml($pdf_html);
		$dompdf->render();
		$dompdf->stream();
	}


	/**
	 * product and trigger download of a PDF quote from a saved quote source
	 * @param $id_cqw_quote
	 */
	public function createPDFFromQuote($dompdf, $id_cqw_quote)
	{
		$page_collection = array();
		$page_model = new CQWPageModel();
		$page_collection = $page_model->getAll();

		$pdf_html = '';

		foreach ($page_collection as $page)
		{
			$page_lang_model = new CQWPageLangModel();
			$page_lang = $page_lang_model->getByPage($page->id_cqw_page, Context::getContext()->language->id);

			$pdf_html .= '<div class="page" style="width: 100%; height: 100%;">';
			$pdf_html .= $page_lang[Context::getContext()->language->id]->html_content;

			$pdf_html = str_replace('[*PRODUCTS*]', $this->getQuoteProductsHtml($id_cqw_quote), $pdf_html);

			$pdf_html .= '</div>';
		}

		$dompdf->setPaper('A4', 'portrait');
		$dompdf->loadHtml($pdf_html);
		$dompdf->render();
		$dompdf->stream();
	}

	public function downloadPDF()
	{
		require_once _PS_MODULE_DIR_.'/cartquotationwizard/lib/dompdf/autoload.inc.php';
		$dompdf = new Dompdf();

		if ((int)Tools::getValue('id_cqw_quote') > 0)
			$this->createPDFFromQuote($dompdf, Tools::getValue('id_cqw_quote'));
		else
			$this->createPDF($dompdf);
	}

	public function saveQuote($id_cqw_quote = 0, $redirect = true, $redirect_login = true)
	{
		$quote_name = Tools::getValue('quote_name');

		if ((int)Context::getContext()->customer->id == 0 && $redirect_login)
			Tools::redirect(Context::getContext()->link->getPageLink('authentication', true));

		/*$cqw_quote_model = new CQWQuoteModel();
		$cqw_quote_model->loadByName(Tools::getValue('quote_name'));

		if (Tools::getIsset('quote_name'))
		{
			if (empty($cqw_quote_model->id))
				$id_cqw_quote = 0;
			else
				$id_cqw_quote = $cqw_quote_model->id;
		}*/

		if ($id_cqw_quote == 0)
			$id_cqw_quote = CQWHelper::createNewQuote($quote_name);

		$cart = Context::getContext()->cart;

		$cart_products = $cart->getProducts();

		if ($id_cqw_quote > 0)
			CQWQuoteProductModel::deleteByQuote($id_cqw_quote);

		foreach ($cart_products as $cart_product)
		{
			$cqw_quoteproduct_model = new CQWQuoteProductModel();
			$cqw_quoteproduct_model->id_cqw_quote = $id_cqw_quote;
			$cqw_quoteproduct_model->id_cart = $cart->id;
			$cqw_quoteproduct_model->id_product = (int)$cart_product['id_product'];
			$cqw_quoteproduct_model->id_product_attribute = (int)$cart_product['id_product_attribute'];
			$cqw_quoteproduct_model->id_address_delivery = (int)$cart_product['id_address_delivery'];
			$cqw_quoteproduct_model->id_shop = (int)$cart_product['id_shop'];
			$cqw_quoteproduct_model->quantity = (int)$cart_product['quantity'];
			$cqw_quoteproduct_model->save();
		}

		if ($redirect)
			Tools::redirect($this->context->link->getModuleLink('cartquotationwizard', 'quoteview', array()));
		else
			return $cqw_quoteproduct_model->id_cqw_quote;
	}


	/**
	 * Display Add to quote button if quote block enabled
	 * @param $params
	 */
	public function hookDisplayProductButtons($params)
	{
		//return $this->context->link->getModuleLink('cqw', 'quoteview', array());
		if (!Configuration::get('cqw_quote_block_enabled')) return '';

		$this->sibling->smarty->assign(array(
			'module_url' => $this->module_url,
			'quote_block_link' => $this->context->link->getModuleLink('cartquotationwizard', 'quoteview', array())
		));
		return $this->sibling->display($this->sibling->module_file, 'views/templates/front/hook/display_product_buttons.tpl');
	}

	public function hookDisplayTop($params)
	{
		if (!Configuration::get('cqw_quote_block_enabled')) return '';

		$this->sibling->smarty->assign(array(
			'quote_block_link' => $this->context->link->getModuleLink('cartquotationwizard', 'quoteview', array()),
			//'module_url' => $this->module_url
		));
		return $this->sibling->display($this->sibling->module_file, 'views/templates/front/hook/display_top.tpl');
	}

	/**
	 * Send Quote by email (either saved quote or cart as quote)
	 */
	public function processEmailQuote()
	{
		$module_file_path = $this->sibling->module_file;

		//convert cart to quote and email that
		if ((int)Tools::getValue('id_cqw_quote') == 0)
		{
			$cqw_quote_model = new CQWQuoteModel();
			$cqw_quote_model->loadByCartID(Context::getContext()->cookie->id_cart);
			$id_cqw_quote = $this->saveQuote($cqw_quote_model->id, false, false);
		}
		else
			$id_cqw_quote = (int)Tools::getValue('id_cqw_quote');

		if (Context::getContext()->cookie->id_customer == 0 && Context::getContext()->cookie->id_cart > 0)
			$quote_link = CQWHelper::getQuoteConvertLink($id_cqw_quote, Context::getContext()->cookie->id_cart);
		else
			$quote_link = CQWHelper::getQuoteLink($id_cqw_quote);

		if ($id_cqw_quote > 0)
		{
			$mail_template_vars = array(
				'{products}' => $this->getQuoteProductsHtml($id_cqw_quote),
				'{quote_link}' => $quote_link
			);
			Mail::Send(Context::getContext()->language->id, 'email_quote', Mail::l('Quote', Context::getContext()->language->id), $mail_template_vars, pSQL(Tools::getValue('email_addresses')), null, null, null, null, null, dirname($module_file_path).'/mails/', false, Context::getContext()->shop->id);
		}
	}

	public function route()
	{
		switch (Tools::getValue('action'))
		{
			case 'download_pdf' :
				die ($this->downloadPDF());

			case 'savequote' :
				die ($this->saveQuote());

			case 'processemailquote' :
				die($this->processEmailQuote());

			default:
				return $this->renderActionButtons();
		}
	}

}

J'ai demandé au développeur de m'ajouter la date de création du devis et la référence et il m'a ajouté les lignes 83 et 84.

Merci pour votre aide

Edited by Michel Faure (see edit history)
Link to comment
Share on other sites

  • 5 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...