Merge branch 'ticket-12200-FuturSalesInMenu'
This commit is contained in:
commit
ffaffefc08
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
class Privatesales_Family_Menu extends Module {
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$this->name = 'privatesales_family_menu';
|
||||
$this->tab = 'pricing_promotion';
|
||||
@ -27,7 +27,7 @@ class Privatesales_Family_Menu extends Module {
|
||||
|
||||
$filename = _PS_ROOT_DIR_.'/modules/privatesales_family_menu/menu_'.$id_lang.'.txt';
|
||||
$expire = time() -3600;
|
||||
|
||||
|
||||
if(file_exists($filename) && filemtime($filename) > $expire) {
|
||||
$data = file_get_contents($filename);
|
||||
$menus = json_decode($data, TRUE);
|
||||
@ -70,55 +70,74 @@ class Privatesales_Family_Menu extends Module {
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale_lang` pl ON pl.`id_sale` = p.`id_sale`
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale_category` pc ON pc.`id_sale` = p.`id_sale`
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_family_association` pcf ON pcf.`id_category` = pc.`id_category`
|
||||
WHERE p.`public` = 0
|
||||
WHERE p.`public` = 0
|
||||
AND pv.`version` = "'.pSql($site_version_front).'"
|
||||
AND p.`enabled` = 1
|
||||
AND p.`date_start` < NOW()
|
||||
AND p.`date_start` < NOW()
|
||||
AND p.`date_end` > NOW()
|
||||
AND pcf.`id_category_family` = '.(int)$child['id_category_family'].'
|
||||
GROUP BY p.`id_sale`
|
||||
ORDER BY p.`date_end` ASC
|
||||
');
|
||||
$childrens[$key_child]['sales'] = array();
|
||||
$childrens[$key_child]['sales'] = $this->buildSales($sales, $id_lang);
|
||||
|
||||
foreach ($sales as $key_sale => $sale) {
|
||||
$info_cat = Db::getInstance()->getRow('
|
||||
SELECT `name`, `link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'category_lang`
|
||||
WHERE `id_category` = '.(int)$sale['category_sale'].
|
||||
' AND id_lang ='.(int)$id_lang
|
||||
);
|
||||
|
||||
if (!file_exists(_PS_ROOT_DIR_.'/img/menu/'.$sale['id_category'].'.jpg')) {
|
||||
$img_tmp = '';
|
||||
if (file_exists(_PS_ROOT_DIR_.'/img/c/'. $sale['id_category']. '.jpg')) {
|
||||
$img_tmp = _PS_ROOT_DIR_.'/img/c/'. $sale['id_category']. '.jpg';
|
||||
} else {
|
||||
$id_parent = Category::getIdParent($sale['id_category']);
|
||||
if(file_exists(_PS_ROOT_DIR_.'/img/c/'. $id_parent. '.jpg')) {
|
||||
$img_tmp = _PS_ROOT_DIR_.'/img/c/'. $id_parent. '.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
// create new format image
|
||||
$image_menu = imagecreatetruecolor(260, 211);
|
||||
$image_cat = imagecreatefromjpeg($img_tmp);
|
||||
imagecopyresampled($image_menu, $image_cat, 0, 0, 0, 0, 260, 211, 260, 211);
|
||||
imagejpeg($image_menu, _PS_ROOT_DIR_.'/img/menu/'.$sale['id_category'].'.jpg',100);
|
||||
}
|
||||
|
||||
$sales[$key_sale]['img'] = '/img/menu/'.$sale['id_category'].'.jpg';
|
||||
$sales[$key_sale]['link_rewrite'] = $info_cat['link_rewrite'];
|
||||
$sales[$key_sale]['name'] = $info_cat['name'];
|
||||
}
|
||||
|
||||
$childrens[$key_child]['sales'] = $sales;
|
||||
$future_sales = Db::getInstance()->Executes('
|
||||
SELECT p.`id_sale`, p.`id_category` as category_sale, pc.`id_category`
|
||||
FROM `'._DB_PREFIX_.'privatesale` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale_site_version` pv ON pv.`id_sale` = p.`id_sale`
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale_lang` pl ON pl.`id_sale` = p.`id_sale`
|
||||
LEFT JOIN `'._DB_PREFIX_.'privatesale_category` pc ON pc.`id_sale` = p.`id_sale`
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_family_association` pcf ON pcf.`id_category` = pc.`id_category`
|
||||
WHERE p.`public` = 0
|
||||
AND pv.`version` = "'.pSql($site_version_front).'"
|
||||
AND p.`enabled` = 1
|
||||
AND p.`date_start` > NOW()
|
||||
AND p.`date_end` > NOW()
|
||||
AND pcf.`id_category_family` = '.(int)$child['id_category_family'].'
|
||||
GROUP BY p.`id_sale`
|
||||
ORDER BY p.`date_end` ASC
|
||||
');
|
||||
$childrens[$key_child]['future_sales'] = array();
|
||||
$childrens[$key_child]['future_sales'] = $this->buildSales($future_sales, $id_lang);
|
||||
}
|
||||
|
||||
|
||||
$families_menu[$key]['children'] = $childrens;
|
||||
}
|
||||
|
||||
return $families_menu;
|
||||
}
|
||||
|
||||
public function buildSales($sales, $id_lang) {
|
||||
foreach ($sales as $key_sale => $sale) {
|
||||
$info_cat = Db::getInstance()->getRow('
|
||||
SELECT `name`, `link_rewrite`
|
||||
FROM `'._DB_PREFIX_.'category_lang`
|
||||
WHERE `id_category` = '.(int)$sale['category_sale'].
|
||||
' AND id_lang ='.(int)$id_lang
|
||||
);
|
||||
|
||||
if (!file_exists(_PS_ROOT_DIR_.'/img/menu/'.$sale['id_category'].'.jpg')) {
|
||||
$img_tmp = '';
|
||||
if (file_exists(_PS_ROOT_DIR_.'/img/c/'. $sale['id_category']. '.jpg')) {
|
||||
$img_tmp = _PS_ROOT_DIR_.'/img/c/'. $sale['id_category']. '.jpg';
|
||||
} else {
|
||||
$id_parent = Category::getIdParent($sale['id_category']);
|
||||
if(file_exists(_PS_ROOT_DIR_.'/img/c/'. $id_parent. '.jpg')) {
|
||||
$img_tmp = _PS_ROOT_DIR_.'/img/c/'. $id_parent. '.jpg';
|
||||
}
|
||||
}
|
||||
|
||||
// create new format image
|
||||
$image_menu = imagecreatetruecolor(260, 211);
|
||||
$image_cat = imagecreatefromjpeg($img_tmp);
|
||||
imagecopyresampled($image_menu, $image_cat, 0, 0, 0, 0, 260, 211, 260, 211);
|
||||
imagejpeg($image_menu, _PS_ROOT_DIR_.'/img/menu/'.$sale['id_category'].'.jpg',100);
|
||||
}
|
||||
|
||||
$sales[$key_sale]['img'] = '/img/menu/'.$sale['id_category'].'.jpg';
|
||||
$sales[$key_sale]['link_rewrite'] = $info_cat['link_rewrite'];
|
||||
$sales[$key_sale]['name'] = $info_cat['name'];
|
||||
}
|
||||
return $sales;
|
||||
}
|
||||
}
|
||||
|
@ -1983,7 +1983,35 @@ li.active .container_submenu .content_submenu {
|
||||
border-color: #786ec7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.submenu .sales_submenu p.separator-future-sales {
|
||||
text-align: center;
|
||||
border-bottom: 4px double #EAEAEA;
|
||||
margin: 0 auto;
|
||||
width: 30%;
|
||||
color: #AAA;
|
||||
}
|
||||
}
|
||||
/*.submenu .sales_submenu hr.separator-future-sales {
|
||||
clear: both;
|
||||
width: 70%;
|
||||
margin:0 auto;
|
||||
border-top: 4px double #8c8b8b;
|
||||
border-bottom:transparent;
|
||||
border-right:transparent;
|
||||
border-left:transparent;
|
||||
text-align: center;
|
||||
}
|
||||
.submenu .sales_submenu hr.separator-future-sales:after {
|
||||
content: 'Ventes à venir';
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: -13px;
|
||||
padding: 0 10px;
|
||||
background: #fff;
|
||||
color: #CCC;
|
||||
font-size: 14px;
|
||||
font-family: tahoma, arial, sans-serif;
|
||||
}*/
|
||||
|
||||
#shopping_cart_container {
|
||||
float: right !important;
|
||||
|
@ -13,8 +13,9 @@
|
||||
{foreach from=$menu.children item=child}
|
||||
<li>
|
||||
<a href="#" class="sublink"><span>{$child.name}</span></a>
|
||||
{if $child.sales}
|
||||
{if $child.sales || $child.future_sales}
|
||||
<div class="sales_submenu">
|
||||
{if $child.sales}
|
||||
<ul>
|
||||
{foreach from=$child.sales item=sale}
|
||||
<li>
|
||||
@ -24,6 +25,20 @@
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
{if $child.future_sales}
|
||||
<p class="clearfix"></p>
|
||||
<p class="separator-future-sales">{l s='Future Sales' mod='privatesales_family_menu'}</p>
|
||||
<ul>
|
||||
{foreach from=$child.future_sales item=sale}
|
||||
<li>
|
||||
<a class="link_sale">
|
||||
<img class="thumb_menu" height="50px" src="https://static3.bebeboutik.com{$sale.img}" alt="">
|
||||
{$sale.name}</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
{else}
|
||||
<div class="sales_submenu">
|
||||
@ -44,7 +59,7 @@
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if $page_name != 'authentication'}
|
||||
@ -67,7 +82,7 @@
|
||||
|
||||
img1 = new Image();
|
||||
img1.src = "/themes/site/img/img_menu.jpg";
|
||||
|
||||
|
||||
|
||||
$(document).ready(function(e) {
|
||||
$('#sales_menu ul li a').live('click', function(event){
|
||||
|
Loading…
Reference in New Issue
Block a user