From 75c06c785369816c5455619db6eeda063bff5c55 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 29 May 2017 12:33:38 +0200 Subject: [PATCH] Cleanup --- classes/pdf/HTMLTemplateOffredefidelite.php | 48 +++++-------------- controllers/front/OffrefideliteController.php | 18 +------ themes/default/pdf/Offrefidelite.tpl | 4 +- 3 files changed, 16 insertions(+), 54 deletions(-) diff --git a/classes/pdf/HTMLTemplateOffredefidelite.php b/classes/pdf/HTMLTemplateOffredefidelite.php index 6401478..7f14ce5 100755 --- a/classes/pdf/HTMLTemplateOffredefidelite.php +++ b/classes/pdf/HTMLTemplateOffredefidelite.php @@ -67,49 +67,27 @@ class HTMLTemplateOffredefideliteCore extends HTMLTemplate // print_r($this->offredefidelite->selecteds); // die(); } - - /** - * Returns the template's HTML content - * @return string HTML content - */ - public function getItemsProducts2() - { - // if(Tools::getValue('id_product')) - // $id_product=Tools::getValue('id_product'); - // $id_shop = $this->context->shop->id; - $id_lang = Context::getContext()->language->id; - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default - FROM '._DB_PREFIX_.'product p - LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product) - LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and p.id_category_default = cl.id_category) - LEFT JOIN '._DB_PREFIX_.'category c ON (cl.id_category = c.id_category) - WHERE c.id_category!=12 - and c.id_category!=13 - and c.id_category!=14 - and c.id_category!=15 - and c.id_category!=16 - and c.id_category!=17 - ORDER BY c.position asc,pl.name asc'); - } + public function getItemsProducts() { - $id_lang = Context::getContext()->language->id; - $sql=' + $id_shop = $this->context->shop->id; + $id_lang = $this->context->language->id; + $id_category = Configuration::get('PS_CATEGORY_FIDELITY'); + $sql = ' SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default FROM '._DB_PREFIX_.'category_product cp LEFT JOIN '._DB_PREFIX_.'category c ON (cp.id_category = c.id_category) LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and c.id_category = cl.id_category) LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product) LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product) - WHERE cp.id_category=3 - or cp.id_category=4 + WHERE c.id_category = '.(int)$id_category.' + AND p.active = 1 ORDER BY cl.name desc,cp.position asc,pl.name asc'; - $products= Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - // echo $sql; - // print_r($products); - return $products; - } + + $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); + return $products; + } + public function getContent() { // $country = new Country((int)$this->order->id_address_invoice); @@ -128,7 +106,7 @@ class HTMLTemplateOffredefideliteCore extends HTMLTemplate 'days' => $days )); - $this->smarty->assign('generationProduits',self::getItemsProducts()); + $this->smarty->assign('productFidelity', self::getItemsProducts()); // print_r($this->offredefidelite); // die(); $this->smarty->assign( diff --git a/controllers/front/OffrefideliteController.php b/controllers/front/OffrefideliteController.php index cdc94d9..9caf2ec 100755 --- a/controllers/front/OffrefideliteController.php +++ b/controllers/front/OffrefideliteController.php @@ -94,23 +94,7 @@ class OffrefideliteControllerCore extends FrontController ($active ? ' AND hss.`active` = 1' : ' '). ' AND hss.`en_avant` = 1 ORDER BY hss.position'); - } - public function getItemsProducts2() - { - // if(Tools::getValue('id_product')) - // $id_product=Tools::getValue('id_product'); - $id_shop = $this->context->shop->id; - $id_lang = $this->context->language->id; - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default - FROM '._DB_PREFIX_.'product p - LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product) - LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and p.id_category_default = cl.id_category) - LEFT JOIN '._DB_PREFIX_.'category c ON (cl.id_category = c.id_category) - WHERE c.id_category = 31 - AND active = 1 - ORDER BY c.position asc,pl.name asc'); - } + } public function getItemsProducts() { diff --git a/themes/default/pdf/Offrefidelite.tpl b/themes/default/pdf/Offrefidelite.tpl index 5a89465..3b67c28 100755 --- a/themes/default/pdf/Offrefidelite.tpl +++ b/themes/default/pdf/Offrefidelite.tpl @@ -70,11 +70,11 @@



{l s='- Cochez votre indice de satisfaction sur les produits que vous avez testés :'}
{l s='1 = Très satisfaite, 2 = Satisfaite, 3 = Assez satisfaite, 4 = Pas du tout satisfaite'}

- {if $generationProduits|@count>0} + {if $productFidelity|@count>0} {assign var=idCategory value=0} - {foreach from=$generationProduits item=produit} + {foreach from=$productFidelity item=produit} {if $idCategory!=$produit.id_category} {assign var=idCategory value=$produit.id_category}