Merge branch 'ticket-parrainageMobile' into develop

This commit is contained in:
Marion Muszynski 2016-05-10 16:29:02 +02:00
commit 696a5fa546
4 changed files with 163 additions and 92 deletions

View File

@ -0,0 +1,102 @@
<?php
require_once('../../config/config.inc.php');
require_once('../privatesales/Sale.php');
if (!defined('_PS_BASE_URL_'))
define('_PS_BASE_URL_', Tools::getShopDomain(true));
$id_lang = Tools::getValue('id_lang');
if (!$id_lang
|| !in_array($id_lang, array(2,3))
) {
$id_lang = 2;
}
$catalog = new Catalog();
$catalog->displayContent($id_lang);
// $catalog->debug();
class Catalog
{
private $_xml;
private $_debug;
public $id_lang;
public $currentTime;
public function __construct(){
$this->_xml ="";
}
public function setContent($id_lang)
{
global $cookie;
$dom = new DomDocument();
if ($id_lang == 2) {
$site_version = 'fr';
} else if ($id_lang == 3) {
$site_version = 'es';
}
if (Tools::getValue('future') && Tools::getValue('future') == 1)
$sales = Sale::getSales(TRUE, NULL, NULL, TRUE, FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` DESC', NULL, $filter_type, $site_version);
else
$sales = Sale::getSales(TRUE, NULL, NULL, 'current', FALSE, Configuration::get('PRIVATESALES_SHOW_PUBLIC'), '`date_start` DESC', NULL, $filter_type, $site_version);
foreach ($sales as $sale) {
$sql = 'SELECT value FROM '._DB_PREFIX_.'privatesale_extrafield_sale WHERE id_field = 2 AND id_lang = '.(int) $id_lang.' AND id_sale = ' . $sale->id;
if ($value = Db::getInstance()->getValue($sql)){
$sale->reduction = $value;
}else{
$sale->reduction = "Non défini";
}
}
$this->setXml($sales, false, $id_lang);
}
public function displayContent($id_lang)
{
$this->setContent($id_lang);
header('Content-Type: text/xml');
echo $this->_xml;
}
public function setXml($items, $rss=false, $id_lang){
$this->_xml = '<?xml version="1.0" encoding="UTF-8" ?>';
// Catalog
$this->_xml .= '<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><catalogue>';
//Shop details
$this->_xml .= '<infos_boutique>';
$this->_xml .= '<logo>http://www.bebeboutik.com/img/logo.png</logo>';
$this->_xml .= '<nom>bebeboutik.com</nom>';
if (Tools::getValue('partenaire')
&& Tools::getValue('partenaire') == "family_deal") {
$this->_xml .= '<url><![CDATA[http://www.bebeboutik.com/invite/MjAxMy0xMC0y=02bj5yapRXdvJWZiVmYAxWYlRWL5xWatFmZ&lp=mosaique-enfant]]></url>';
} else {
$this->_xml .= '<url>www.bebeboutik.com</url>';
}
$this->_xml .= '</infos_boutique>';
foreach ($items as $item) {
$this->_xml.='<vente>';
// $this->_xml .= '<id_vente>'.$item->id.'</id_vente>';
$this->_xml .= '<nom_vente><![CDATA['.$item->title[(int) $id_lang].']]></nom_vente>';
$this->_xml .= '<description><![CDATA['.$item->description[(int) $id_lang].']]></description>';
$this->_xml .= '<date_debut>'.$item->date_start.'</date_debut>';
$this->_xml .= '<date_fin>'.$item->date_end.'</date_fin>';
$this->_xml .= '<reduction>'.$item->reduction.'</reduction>';
$this->_xml .= '<image_vente>http://www.bebeboutik.com/modules/privatesales/img/'.$item->id.'/liston_'.(int) $id_lang.'.jpg</image_vente>';
$this->_xml.='</vente>';
}
$this->_xml .= '</catalogue></rss>';
}
}

View File

@ -83,6 +83,7 @@ if($canSendInvitations) {
$mails_exists = array();
foreach ($friendsEmail AS $key => $friendEmail) {
$friendEmail = strval($friendEmail);
$friendEmail = trim($friendEmail);
if($askName) {
$friendLastName = strval($friendsLastName[$key]);
$friendFirstName = strval($friendsFirstName[$key]);

View File

@ -57,16 +57,22 @@ foreach ($langs as $iso => $id_lang) {
foreach($sales as $sale) {
$period[(int) $sale['id_sale']] = array(0, 0);
$ids_product = array();
foreach (Db::getInstance()->ExecuteS('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
') as $key => $value) {
$ids_product[] = $value['id_product'];
}
$total = Db::getInstance()->getRow('
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON d.`id_order` = o.`id_order`
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
AND o.`id_lang` = '.(int) $id_lang.'
AND o.`date_add` >= "'.pSQL(date('Y-m-d 00:00:00', strtotime($day_from))).'"
@ -81,11 +87,7 @@ foreach ($langs as $iso => $id_lang) {
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON d.`id_order` = o.`id_order`
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
AND o.`id_lang` = '.(int) $id_lang.'
');
@ -143,11 +145,7 @@ foreach ($langs as $iso => $id_lang) {
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.valid = 1
AND o.`id_lang` = '.(int) $id_lang.'
');
@ -209,16 +207,23 @@ foreach($sales as $sale) {
$detail_stocks[(int) $sale['id_sale']] = array();
$detail_sales[(int) $sale['id_sale']] = array();
$ids_product = array();
foreach (Db::getInstance()->ExecuteS('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
') as $key => $value) {
$ids_product[] = $value['id_product'];
}
$sold_products = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `product_id`, `product_attribute_id`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON d.id_order = o.id_order
WHERE `product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE a.`id_product` IN ('.implode(',', $ids_product).')
AND o.valid = 1
') as $row) {
$sold_products[] = (int) $row['product_id'].'-'.(int) $row['product_attribute_id'];
@ -229,11 +234,7 @@ foreach($sales as $sale) {
FROM `'._DB_PREFIX_.'product_attribute` a
LEFT JOIN `'._DB_PREFIX_.'product` p
ON p.`id_product` = a.`id_product`
WHERE a.`id_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE a.`id_product` IN ('.implode(',', $ids_product).')
GROUP BY a.`id_product_attribute`
');
@ -259,11 +260,7 @@ foreach($sales as $sale) {
$query = Db::getInstance()->ExecuteS('
SELECT p.`quantity`, p.`id_product`
FROM `'._DB_PREFIX_.'product` p
WHERE p.`id_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE p.`id_product` IN ('.implode(',', $ids_product).')
'.((count($id_attributes) > 0)? ' AND p.`id_product` NOT IN ('.implode(', ', $id_attributes).')': '').'
GROUP BY p.`id_product`
');
@ -291,11 +288,7 @@ foreach($sales as $sale) {
SELECT `product_id`, `product_attribute_id`, SUM(`product_quantity`) AS `quantity`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON d.id_order = o.id_order
WHERE `product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE `product_id` IN ('.implode(',', $ids_product).')
AND o.valid = 1
GROUP BY `product_id`, `product_attribute_id`
') as $row) {
@ -359,11 +352,7 @@ foreach($sales as $sale) {
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.valid = 1
');
@ -375,11 +364,7 @@ foreach($sales as $sale) {
ON d.`product_id` = p.`id_product`
LEFT JOIN `'._DB_PREFIX_.'product_attribute` a
ON d.`product_attribute_id` = a.`id_product_attribute`
WHERE p.`id_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE p.`id_product` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
');

View File

@ -46,16 +46,22 @@ foreach ($langs as $iso => $id_lang) {
foreach($sales as $sale) {
$period[(int) $sale['id_sale']] = array(0, 0);
$ids_product = array();
foreach (Db::getInstance()->ExecuteS('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
') as $key => $value) {
$ids_product[] = $value['id_product'];
}
$total = Db::getInstance()->getRow('
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON d.`id_order` = o.`id_order`
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
AND o.`id_lang` = '.(int) $id_lang.'
AND o.`date_add` >= "'.pSQL(date('Y-m-d 00:00:00', strtotime($day_from))).'"
@ -70,11 +76,7 @@ foreach ($langs as $iso => $id_lang) {
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON d.`id_order` = o.`id_order`
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
AND o.`id_lang` = '.(int) $id_lang.'
');
@ -132,11 +134,7 @@ foreach ($langs as $iso => $id_lang) {
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.valid = 1
AND o.`id_lang` = '.(int) $id_lang.'
');
@ -199,16 +197,21 @@ foreach($sales as $sale) {
$detail_stocks[(int) $sale['id_sale']] = array();
$detail_sales[(int) $sale['id_sale']] = array();
$ids_product = array();
foreach (Db::getInstance()->ExecuteS('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
') as $key => $value) {
$ids_product[] = $value['id_product'];
}
$sold_products = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `product_id`, `product_attribute_id`
FROM `'._DB_PREFIX_.'order_detail`d
INNER JOIN `'._DB_PREFIX_.'orders` o ON d.id_order = o.id_order
WHERE `product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE `product_id` IN ('.implode(',', $ids_product).')
AND o.valid = 1
') as $row) {
$sold_products[] = (int) $row['product_id'].'-'.(int) $row['product_attribute_id'];
@ -219,11 +222,7 @@ foreach($sales as $sale) {
FROM `'._DB_PREFIX_.'product_attribute` a
LEFT JOIN `'._DB_PREFIX_.'product` p
ON p.`id_product` = a.`id_product`
WHERE a.`id_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE a.`id_product` IN ('.implode(',', $ids_product).')
AND p.`active` = 1
GROUP BY a.`id_product_attribute`
');
@ -250,11 +249,7 @@ foreach($sales as $sale) {
$query = Db::getInstance()->ExecuteS('
SELECT p.`quantity`, p.`id_product`
FROM `'._DB_PREFIX_.'product` p
WHERE p.`id_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE p.`id_product` IN ('.implode(',', $ids_product).')
'.((count($id_attributes) > 0)? ' AND p.`id_product` NOT IN ('.implode(', ', $id_attributes).')': '').'
AND p.`active` = 1
GROUP BY p.`id_product`
@ -283,11 +278,7 @@ foreach($sales as $sale) {
SELECT `product_id`, `product_attribute_id`, SUM(`product_quantity`) AS `quantity`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
WHERE `product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE `product_id` IN ('.implode(',', $ids_product).')
AND o.valid = 1
GROUP BY `product_id`, `product_attribute_id`
') as $row) {
@ -351,11 +342,7 @@ foreach($sales as $sale) {
SELECT SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100) * (1 + d.`tax_rate` / 100)) * d.`product_quantity`, 6)) AS `total_sales_wt`, SUM(d.`product_quantity`) AS `total_products`, SUM(ROUND(((d.`product_price` * (1 - d.`reduction_percent` / 100) - d.`reduction_amount`) * (1 - d.`group_reduction` / 100)), 6)) AS `total_unit_sales`
FROM `'._DB_PREFIX_.'order_detail` d
INNER JOIN `'._DB_PREFIX_.'orders` o ON o.id_order = d.id_order
WHERE d.`product_id` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE d.`product_id` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
');
@ -367,11 +354,7 @@ foreach($sales as $sale) {
ON d.`product_id` = p.`id_product`
LEFT JOIN `'._DB_PREFIX_.'product_attribute` a
ON d.`product_attribute_id` = a.`id_product_attribute`
WHERE p.`id_product` IN (
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` = '.(int) $sale['id_sale'].'
)
WHERE p.`id_product` IN ('.implode(',', $ids_product).')
AND o.`valid` = 1
');