Merge branch 'ticket-10884' into develop

This commit is contained in:
Marion Muszynski 2016-09-14 17:00:16 +02:00
commit 120303fa1b
2 changed files with 125 additions and 93 deletions

View File

@ -9,7 +9,7 @@ class AdminBulkUpdate extends AdminTab {
public function postProcess() {
global $cookie;
set_time_limit(300);
if (Tools::isSubmit('submitUploadProductCustoms')) {
@ -32,7 +32,7 @@ class AdminBulkUpdate extends AdminTab {
DELETE FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` IN ('.implode(', ', array_keys($products)).')
');
}
foreach($products as $line) {
@ -466,7 +466,7 @@ class AdminBulkUpdate extends AdminTab {
$products[] = (int) $line[0];
}
} elseif(Tools::getValue('price_process') == 3
} elseif(Tools::getValue('price_process') == 3
|| Tools::getValue('price_process') == 4){
while($line = fgetcsv($f, 0, ';')) {
if(empty($line[0])) {
@ -508,7 +508,7 @@ class AdminBulkUpdate extends AdminTab {
}
if(Tools::getValue('price_process') == 1) {
foreach($prices as $price) {
foreach($prices as $price) {
if((int) $price[0] != 0) {
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'specific_price` VALUES (
@ -538,7 +538,7 @@ class AdminBulkUpdate extends AdminTab {
$price_ht = floatval($price[1]);
Db::getInstance()->ExecuteS('
UPDATE `'._DB_PREFIX_.'product`
SET wholesale_price = '. (float)$price_ht .'
SET wholesale_price = '. (float)$price_ht .'
WHERE id_product ='. (int)$price[0]);
}else{
$output .= '<p class="error">ID produit à 0, ligne non traitée : '.serialize($price).'</p>';
@ -552,7 +552,7 @@ class AdminBulkUpdate extends AdminTab {
$price_ht = floatval($price[1] / 1.20);
Db::getInstance()->ExecuteS('
UPDATE `'._DB_PREFIX_.'product`
SET price = '. (float)$price_ht .'
SET price = '. (float)$price_ht .'
WHERE id_product ='. (int)$price[0]);
}else{
$output .= '<p class="error">ID produit à 0, ligne non traitée : '.serialize($price).'</p>';
@ -578,7 +578,7 @@ class AdminBulkUpdate extends AdminTab {
foreach($products as $line) {
$result = Db::getInstance()->ExecuteS('
UPDATE `'._DB_PREFIX_.'product_lang`
SET `description` = "'. pSQL($line[1],true) .'"
SET `description` = "'. pSQL($line[1],true) .'"
WHERE `id_product` ='. (int) $line[0].'
AND `id_lang` = '.(int) $id_lang.'
');
@ -644,7 +644,7 @@ class AdminBulkUpdate extends AdminTab {
switch ($deb) {
case '1':
// DEB INTRODUCTION
// DEB INTRODUCTION
$ids = Db::getInstance()->ExecuteS('
SELECT c.id_category
FROM `'._DB_PREFIX_.'privatesale` p
@ -693,9 +693,9 @@ class AdminBulkUpdate extends AdminTab {
}
}
$f = fopen(dirname(__FILE__).'/'.$fname, 'w');
// uft8 sans bom pour accent
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
fwrite($f, $BOM); // NEW LINE
fputcsv($f, array(
@ -725,7 +725,7 @@ class AdminBulkUpdate extends AdminTab {
$customs = Db::getInstance()->getRow('
SELECT `nc8`, `id_country`
FROM `'._DB_PREFIX_.'product_customs`
FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` = '.(int) $p->id
);
if (strtolower($customs['id_country']) == 'france') {
@ -781,9 +781,9 @@ class AdminBulkUpdate extends AdminTab {
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND (
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
ORDER BY `date_add` DESC LIMIT 1
) NOT IN (1,6,8,9,10,11,14,15,18)
');
@ -822,9 +822,9 @@ class AdminBulkUpdate extends AdminTab {
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND (
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
ORDER BY `date_add` DESC LIMIT 1
) NOT IN (1,6,8,9,10,11,14,15,18)
');
@ -883,7 +883,7 @@ class AdminBulkUpdate extends AdminTab {
break;
case '2':
// DEB EXPEDITION
// DEB EXPEDITION
// Seulement les expeditions vers Espagne et Belgique
$orders = Db::getInstance()->ExecuteS('
@ -892,11 +892,11 @@ class AdminBulkUpdate extends AdminTab {
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = od.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` psc ON (psc.`id_product` = od.`product_id`)
LEFT JOIN `'._DB_PREFIX_.'address` a ON (a.`id_address` = o.`id_address_delivery`)
WHERE
WHERE
o.date_add >= "'.$date_start.' 00:00:00"
AND o.date_add <= "'.$date_end.' 23:59:59"
AND a.`id_country` IN (3,6)
AND
AND
(o.valid = 1
OR (
o.valid = 0
@ -909,9 +909,9 @@ class AdminBulkUpdate extends AdminTab {
AND (SELECT h.id_order_state FROM `'._DB_PREFIX_.'order_history` h WHERE h.id_order = o.id_order ORDER BY h.date_add DESC LIMIT 1) != 14
-- o.`date_add` BETWEEN "'. $date_start .' 00:00:00" AND "'. $date_end .' 00:00:00
-- AND (
-- SELECT `id_order_state`
-- FROM `'._DB_PREFIX_.'order_history`
-- WHERE `id_order`=od.`id_order`
-- SELECT `id_order_state`
-- FROM `'._DB_PREFIX_.'order_history`
-- WHERE `id_order`=od.`id_order`
-- ORDER BY `date_add` DESC LIMIT 1
-- ) NOT IN (1,6,8,9,10,11,14,15,18)
ORDER BY od.`product_id` ASC
@ -963,9 +963,9 @@ class AdminBulkUpdate extends AdminTab {
}
}
$f = fopen(dirname(__FILE__).'/'.$fname, 'w');
// uft8 sans bom pour accent
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
fwrite($f, $BOM); // NEW LINE
fputcsv($f, array(
@ -997,7 +997,7 @@ class AdminBulkUpdate extends AdminTab {
$customs = Db::getInstance()->getRow('
SELECT `nc8`, `id_country`
FROM `'._DB_PREFIX_.'product_customs`
FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` = '.(int) $p->id
);
@ -1078,7 +1078,7 @@ class AdminBulkUpdate extends AdminTab {
/* if ($quantity_sold == 0) {
continue;
}
$products_detail[] = array(
'position' => $p->position,
'sale_country' => $row_properties[$p->id]['country'],
@ -1129,8 +1129,8 @@ class AdminBulkUpdate extends AdminTab {
}
foreach ($products_detail as $key => $row) {
$id_sale[$key] = (int)$row['id_sale'];
$sale_date[$key] = (int)$row['sale_date'];
$id_sale[$key] = (int)$row['id_sale'];
$sale_date[$key] = (int)$row['sale_date'];
}
array_multisort($sale_date, SORT_ASC, $id_sale, SORT_DESC, $products_detail);
$pos = 0;
@ -1168,7 +1168,7 @@ class AdminBulkUpdate extends AdminTab {
} elseif(Tools::isSubmit('submitExport')) {
set_time_limit(300);
$id_lang = Tools::getValue('id_lang', $cookie->id_lang);
if ($id_category = (int) Tools::getValue('category')) {
$c = new Category($id_category, $cookie->id_lang);
$children = $c->recurseLiteCategTree(5, 0, $id_lang);
@ -1194,9 +1194,9 @@ class AdminBulkUpdate extends AdminTab {
}
$f = fopen(dirname(__FILE__).'/'.$fname, 'w');
// uft8 sans bom pour accent
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
fwrite($f, $BOM); // NEW LINE
fputcsv($f, array(
@ -1242,7 +1242,7 @@ class AdminBulkUpdate extends AdminTab {
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_category` = '.(int) $id_category.'
AND id_product = '. (int) $p->id . '
');
');
$p->position = $position;
$categories = array();
@ -1303,13 +1303,13 @@ class AdminBulkUpdate extends AdminTab {
WHERE l.`id_lang` = '.(int) $id_lang.'
AND i.`id_product` = '.(int) $p->id.'
') as $img) {
$link_image = str_split($img['id_image']);
$link_image = str_split($img['id_image']);
$images[] = 'http://static.bebeboutik.com/img/p/'.implode('/', $link_image) .'/'. $img['id_image'].'.jpg';
}
$customs = Db::getInstance()->getRow('
SELECT `nc8`, `id_country`
FROM `'._DB_PREFIX_.'product_customs`
FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` = '.(int) $p->id
);
@ -1350,9 +1350,9 @@ class AdminBulkUpdate extends AdminTab {
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND (
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
ORDER BY `date_add` DESC LIMIT 1
) NOT IN (1,6,8,9,10,11,14,15,18)
');*/
@ -1412,9 +1412,9 @@ class AdminBulkUpdate extends AdminTab {
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND (
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
ORDER BY `date_add` DESC LIMIT 1
) NOT IN (1,6,8,9,10,11,14,15,18)
');*/
@ -1494,9 +1494,9 @@ class AdminBulkUpdate extends AdminTab {
}
$f = fopen(dirname(__FILE__).'/'.$fname, 'w');
// uft8 sans bom pour accent
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
$BOM = "\xEF\xBB\xBF"; // UTF-8 BOM
fwrite($f, $BOM); // NEW LINE
fputcsv($f, array(
@ -1540,7 +1540,7 @@ class AdminBulkUpdate extends AdminTab {
FROM `'._DB_PREFIX_.'category_product`
WHERE `id_category` = '.(int) $p->id_category_default.'
AND id_product = '. (int) $p->id . '
');
');
$p->position = $position;
$categories = array();
@ -1645,16 +1645,16 @@ class AdminBulkUpdate extends AdminTab {
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND (
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
ORDER BY `date_add` DESC LIMIT 1
) NOT IN (1,6,8,9,10,11,14,15,18)
');*/
$customs = Db::getInstance()->getRow('
SELECT `nc8`, `id_country`
FROM `'._DB_PREFIX_.'product_customs`
FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` = '.(int) $p->id
);
@ -1709,16 +1709,16 @@ class AdminBulkUpdate extends AdminTab {
LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND (
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
SELECT `id_order_state`
FROM `'._DB_PREFIX_.'order_history`
WHERE `id_order`=d.`id_order`
ORDER BY `date_add` DESC LIMIT 1
) NOT IN (1,6,8,9,10,11,14,15,18)
');*/
$customs = Db::getInstance()->getRow('
SELECT `nc8`, `id_country`
FROM `'._DB_PREFIX_.'product_customs`
FROM `'._DB_PREFIX_.'product_customs`
WHERE `id_product` = '.(int) $p->id
);
@ -1822,13 +1822,13 @@ class AdminBulkUpdate extends AdminTab {
}
echo $output;
}
public function display(){
global $cookie;
$output = '<h2>Mise à jour groupée</h2>';
$output = '<h2>Mise à jour groupée</h2>';
$output .= '
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
<fieldset><legend><img src="/modules/bulkupdate/logo.gif" alt="" title="" />'.$this->l('Update categories').'</legend>
@ -1862,8 +1862,8 @@ class AdminBulkUpdate extends AdminTab {
<label>'.$this->l('File:').'</label>
<div class="margin-form">
<input type="file" name="csvfile" />
<p>'.$this->l('Format: id_product;montant').'</p>
<p>'.$this->l('Montant : Pourcentage de remise, Prix HT, Prix TTC en fonction du choix').'</p>
<p>'.$this->l('Format: id_product;montant').'</p>
<p>'.$this->l('Montant : Pourcentage de remise, Prix HT, Prix TTC en fonction du choix').'</p>
</div>
<p> </p>
<center><input type="submit" name="submitUploadPrices" value="'.$this->l('Upload').'" class="button" /></center>
@ -2112,8 +2112,8 @@ class AdminBulkUpdate extends AdminTab {
AND c.`id_parent` = 1
ORDER BY id_category DESC
') as $row) {
$extrafields = Category::getSalesInfos(array((int) $row['id_category']));
$output .= '<option value="'.$row['id_category'].'">'.$row['id_category'].' - '.$row['name'].' - '.$extrafields[(int) $row['id_category']]['sales'][1].'</option>';
$extrafields = Category::getSalesInfosWithDate(array((int) $row['id_category']));
$output .= '<option value="'.$row['id_category'].'">'.$row['id_category'].' - '.date("d/m/Y",strtotime($extrafields[(int) $row['id_category']]['date_start'])).' - '.$row['name'].' - '.$extrafields[(int) $row['id_category']]['sales'][1].'</option>';
}
$output .= '</select>
</div>
@ -2132,7 +2132,7 @@ class AdminBulkUpdate extends AdminTab {
foreach(Language::getLanguages(FALSE) as $lang) {
$output .= '<option value="'.$lang['id_lang'].'"'.($cookie->id_lang == $lang['id_lang']? ' selected="selected"': '').'>'.$lang['name'].'</option>';
}
$output.= '</select>
</div>
<p> </p>
@ -2188,7 +2188,7 @@ class AdminBulkUpdate extends AdminTab {
echo '<script type="text/javascript" src="'._MODULE_DIR_.'bulkupdate/chosen.jquery.min.js"></script>';
echo '<script type="text/javascript">
$(function() {
$(".chosen-select").chosen(
$(".chosen-select").chosen(
{
allow_single_deselect:true,
placeholder_text_single : "Choisir une vente",
@ -2245,7 +2245,7 @@ class AdminBulkUpdate extends AdminTab {
return $res;
}
private function _recurse_array($array) {
$result = array();
foreach($array as $i) {

View File

@ -89,9 +89,9 @@
/* Modify SQL result */
return Product::getProductsProperties($id_lang, $result);
}
public function getProductsStats($id_lang, $p, $n, $orderBy = NULL, $orderWay = NULL, $getTotal = false, $active = true, $random = false, $randomNumberProducts = 1, $checkAccess = true)
{
global $cookie;
@ -142,9 +142,9 @@
$categories = array();
foreach (Db::getInstance()->ExecuteS('
SELECT
SELECT
`id_category`
FROM `'._DB_PREFIX_.'category`
FROM `'._DB_PREFIX_.'category`
WHERE `id_parent` = ' . $this->id
) as $row ) {
$categories[] = $row['id_category'];
@ -153,25 +153,25 @@
$sql = '
SELECT
p.*,
pa.`id_product_attribute`,
pl.`description`,
pl.`description_short`,
pl.`available_now`,
pl.`available_later`,
pl.`link_rewrite`,
pl.`meta_description`,
pl.`meta_keywords`,
pl.`meta_title`,
pl.`name`,
i.`id_image`,
il.`legend`,
m.`name` AS manufacturer_name,
tl.`name` AS tax_name,
t.`rate`,
cl.`name` AS category_default,
DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
SELECT
p.*,
pa.`id_product_attribute`,
pl.`description`,
pl.`description_short`,
pl.`available_now`,
pl.`available_later`,
pl.`link_rewrite`,
pl.`meta_description`,
pl.`meta_keywords`,
pl.`meta_title`,
pl.`name`,
i.`id_image`,
il.`legend`,
m.`name` AS manufacturer_name,
tl.`name` AS tax_name,
t.`rate`,
cl.`name` AS category_default,
DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new,
(p.`price` * IF(t.`rate`,((100 + (t.`rate`))/100),1)) AS orderprice
FROM `'._DB_PREFIX_.'category_product` cp
@ -189,7 +189,7 @@
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
WHERE cp.`id_category` IN ('.implode($categories, ',').')'.($active ? ' AND p.`active` = 1' : '').'
'.($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '');
// if ($random === true)
// {
@ -205,9 +205,9 @@
$sql .= " GROUP BY p.`id_product`, pa.`id_product_attribute`
ORDER BY CAST( SPLIT_STRING(
'-', p.`reference` , 2
) AS unsigned )";
) AS unsigned )";
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
// if ($orderBy == 'orderprice')
@ -226,11 +226,11 @@
public static function getIdParent($id_category){
$sql = 'SELECT c.id_parent
FROM '._DB_PREFIX_.'category c
WHERE id_category ='.$id_category;
WHERE id_category ='.$id_category;
return $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
/**
* Return current category products
*
@ -316,7 +316,7 @@
if ( $attributes ){
$sql .= ' AND pac.`id_attribute` IN ('.$attributes.')
AND pa.`quantity` > 0';
AND pa.`quantity` > 0';
}
if ($random === true)
@ -353,7 +353,7 @@
FROM `'._DB_PREFIX_.'category`
');
}
public static function getCategoriesSameVP($id_category, $id_lang) {
return $categories = Db::getInstance()->ExecuteS('
SELECT pc.`id_category`, cl.`name`, c.`id_parent`
@ -382,7 +382,7 @@
$results = array();
$id_sales = array();
foreach (Db::getInstance()->executeS('SELECT `id_sale`, `id_category`
foreach (Db::getInstance()->executeS('SELECT `id_sale`, `id_category`
FROM `'._DB_PREFIX_.'privatesale_category`
WHERE id_category IN ('.implode(', ', $ids).')
') as $key => $value) {
@ -399,7 +399,39 @@
foreach ($results as $key => $result) {
$results[$key]['sales'] = $extrafields[$result['id_sale']];
}
return $results;
}
public static function getSalesInfosWithDate($ids)
{
if (!class_exists('PrivateSales_ExtraFields')) {
require_once dirname(__FILE__).'/../../modules/privatesales_extrafields/privatesales_extrafields.php';
}
$results = array();
$id_sales = array();
foreach (Db::getInstance()->executeS('SELECT pc.`id_sale`, pc.`id_category` , p.`date_start`
FROM `'._DB_PREFIX_.'privatesale_category` pc
LEFT JOIN `'._DB_PREFIX_.'privatesale` p ON p.`id_sale` = pc.`id_sale`
WHERE pc.`id_category` IN ('.implode(', ', $ids).')
') as $key => $value) {
if(!isset($results[$value['id_category']])) {
$results[$value['id_category']] = array();
}
$results[$value['id_category']]['id_sale'] = $value['id_sale'];
$results[$value['id_category']]['date_start'] = $value['date_start'];
$id_sales[] = $value['id_sale'];
}
array_unique($id_sales);
$extrafields = PrivateSales_ExtraFields::getFieldsForSale($id_sales);
foreach ($results as $key => $result) {
$results[$key]['sales'] = $extrafields[$result['id_sale']];
}
return $results;
}