Merge branch 'ticket-extract' into develop

This commit is contained in:
Marion Muszynski 2016-04-13 12:23:22 +02:00
commit 7496b8fb5d

View File

@ -2,6 +2,7 @@
if(!defined('_PS_VERSION_')) {
exit;
}
include_once(_PS_ROOT_DIR_.'/modules/privatesales/Sale.php');
class AdminBulkUpdate extends AdminTab {
public $_html = '';
@ -610,7 +611,9 @@ class AdminBulkUpdate extends AdminTab {
foreach(glob(dirname(__FILE__).'/*.csv') as $filename) {
unlink($filename);
}
$fname = Tools::passwdGen(10).'.csv';
$privatesale = Sale::getSaleFromCategory((int) $id_category);
//$fname = Tools::passwdGen(10).'.csv';
$fname = date( "Ymd", strtotime($privatesale->date_start)).'-'.$privatesale->title[(int)$id_lang].'.csv';
$f = fopen(dirname(__FILE__).'/'.$fname, 'w');
// uft8 sans bom pour accent
@ -627,20 +630,23 @@ class AdminBulkUpdate extends AdminTab {
'product_name',
'combination',
'ean13',
'location',
'brand',
// 'location',
// 'brand',
'quantity_sold',
'public_price_wt',
'price_wt',
'wholesale_price',
'BDC HT',
'id_TVA',
'active',
// 'active',
'description_short',
'description',
'images',
'nb_images',
'categories',
'categories_title',
'sous-categories',
'sous-sous-categories',
// 'categories_title',
), ';', '"');
foreach($products as $product) {
$p = new Product((int) $product, $id_lang);
@ -663,6 +669,7 @@ class AdminBulkUpdate extends AdminTab {
') as $cat) {
$categories[] = (int) $cat['id_category'];
}
sort($categories);
$categories_title = array();
foreach ($categories as $category) {
@ -672,7 +679,19 @@ class AdminBulkUpdate extends AdminTab {
WHERE `id_category` = '.(int) $category.'
AND id_lang = '. $id_lang . '
');
$categories_title[] = $title;
$categories_title[(int) $category] = $title;
}
$categorie_0 = '';
$categorie_1 = '';
$categorie_2 = '';
foreach ($categories as $key => $cat) {
if ($key == 0) {
$categorie_0 = $categories_title[$cat];
} elseif ($key == 1) {
$categorie_1 = $categories_title[$cat];
} elseif ($key == 2) {
$categorie_2 = $categories_title[$cat];
}
}
$combinations = array();
@ -722,58 +741,7 @@ class AdminBulkUpdate extends AdminTab {
// $c_images[] = 'http://static.bebeboutik.com/'.(int) $p->id.'-'.$img['id_image'].'.jpg';
}
$names = array_unique($v['name']);
sort($names, SORT_STRING);
fputcsv($f, array(
$v['supplier_reference'],
$p->id,
$k,
$p->position,
$p->weight,
$v['qty'],
$p->name[$id_lang],
implode(' - ', $names),
$v['ean13'],
$v['location'],
$v['brand'],
(int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_history` h
ON h.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND h.`id_order_state` = 2
'),
$p->getPrice(TRUE, (int) $k, 2, NULL, FALSE, FALSE),
$p->getPrice(TRUE, (int) $k, 2),
Tools::ps_round($p->wholesale_price, 2),
$p->id_tax_rules_group,
$p->active,
$p->description_short[$id_lang],
$p->description[$id_lang],
count($c_images) > 0? implode(', ', $c_images): implode(', ', $images),
count($c_images) > 0? count($c_images): count($images),
implode(', ', $categories),
implode(', ', $categories_title),
), ';', '"');
}
} else {
fputcsv($f, array(
$p->supplier_reference,
$p->id,
0,
$p->position,
$p->weight,
$p->quantity,
$p->name[$id_lang],
'',
$p->ean13,
$p->location,
$p->manufacturer_name,
(int) Db::getInstance()->getValue('
$quantity_sold = (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
@ -781,19 +749,83 @@ class AdminBulkUpdate extends AdminTab {
LEFT JOIN `'._DB_PREFIX_.'order_history` h
ON h.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND h.`id_order_state` = 2
'),
$p->getPrice(TRUE, NULL, 2, NULL, FALSE, FALSE),
$p->getPrice(TRUE, NULL, 2),
Tools::ps_round($p->wholesale_price, 2),
');
$names = array_unique($v['name']);
sort($names, SORT_STRING);
fputcsv($f, array(
$v['supplier_reference'],
$p->id,
$k,
$p->position,
str_replace('.', ',', $p->weight),
$v['qty'],
$p->name[$id_lang],
implode(' - ', $names),
$v['ean13'],
// $v['location'],
// $v['brand'],
$quantity_sold,
str_replace('.', ',', $p->getPrice(TRUE, (int) $k, 2, NULL, FALSE, FALSE)),
str_replace('.', ',', $p->getPrice(TRUE, (int) $k, 2)),
str_replace('.', ',', Tools::ps_round($p->wholesale_price, 2)),
str_replace('.', ',', Tools::ps_round(($quantity_sold * $p->wholesale_price),2)),
$p->id_tax_rules_group,
// $p->active,
$p->description_short[$id_lang],
$p->description[$id_lang],
count($c_images) > 0? implode(', ', $c_images): implode(', ', $images),
count($c_images) > 0? count($c_images): count($images),
$categorie_0,
$categorie_1,
$categorie_2,
//implode(', ', $categories),
//implode(', ', $categories_title),
), ';', '"');
}
} else {
$quantity_sold = (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_history` h
ON h.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND h.`id_order_state` = 2
');
fputcsv($f, array(
$p->supplier_reference,
$p->id,
0,
$p->position,
str_replace('.', ',', $p->weight),
$p->quantity,
$p->name[$id_lang],
'',
$p->ean13,
// $p->location,
// $p->manufacturer_name,
$quantity_sold,
str_replace('.', ',', $p->getPrice(TRUE, NULL, 2, NULL, FALSE, FALSE)),
str_replace('.', ',', $p->getPrice(TRUE, NULL, 2)),
str_replace('.', ',', Tools::ps_round($p->wholesale_price, 2)),
str_replace('.', ',', Tools::ps_round(($quantity_sold * $p->wholesale_price),2)),
$p->id_tax_rules_group,
$p->active,
// $p->active,
$p->description_short[$id_lang],
$p->description[$id_lang],
implode(', ', $images),
count($images),
implode(', ', $categories),
implode(', ', $categories_title),
$categorie_0,
$categorie_1,
$categorie_2,
// implode(', ', $categories),
// implode(', ', $categories_title),
), ';', '"');
}
}
@ -831,7 +863,9 @@ class AdminBulkUpdate extends AdminTab {
foreach(glob(dirname(__FILE__).'/*.csv') as $filename) {
unlink($filename);
}
$fname = Tools::passwdGen(10).'.csv';
//$fname = Tools::passwdGen(10).'.csv';
$privatesale = Sale::getSaleFromCategory((int) $id_category);
$fname = date( "Ymd", strtotime($privatesale->date_start)).'-'.$privatesale->title[(int)$id_lang].'.csv';
$f = fopen(dirname(__FILE__).'/'.$fname, 'w');
// uft8 sans bom pour accent
@ -848,18 +882,21 @@ class AdminBulkUpdate extends AdminTab {
'product_name',
'combination',
'ean13',
'location',
'brand',
// 'location',
// 'brand',
'quantity_sold',
'public_price_wt',
'price_wt',
'wholesale_price',
'active',
'BDC HT',
// 'active',
'description_short',
'description',
'images',
'categories',
'categories_title',
'sous-categories',
'sous-sous-categories',
// 'categories_title',
), ';', '"');
foreach($products as $product) {
$p = new Product((int) $product, $id_lang);
@ -882,6 +919,7 @@ class AdminBulkUpdate extends AdminTab {
') as $cat) {
$categories[] = (int) $cat['id_category'];
}
sort($categories);
$categories_title = array();
foreach ($categories as $category) {
@ -893,6 +931,18 @@ class AdminBulkUpdate extends AdminTab {
');
$categories_title[] = $title;
}
$categorie_0 = '';
$categorie_1 = '';
$categorie_2 = '';
foreach ($categories as $key => $cat) {
if ($key == 0) {
$categorie_0 = $categories_title[$cat];
} elseif ($key == 1) {
$categorie_1 = $categories_title[$cat];
} elseif ($key == 2) {
$categorie_2 = $categories_title[$cat];
}
}
$combinations = array();
foreach($p->getAttributeCombinaisons($id_lang) as $combi) {
@ -943,72 +993,86 @@ class AdminBulkUpdate extends AdminTab {
$names = array_unique($v['name']);
sort($names, SORT_STRING);
fputcsv($f, array(
$v['supplier_reference'],
$p->id,
$k,
$p->position,
$p->weight,
$v['qty'],
$p->name[$id_lang],
implode(' - ', $names),
$v['ean13'],
$v['location'],
$v['brand'],
(int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_history` h
ON h.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND h.`id_order_state` = 2
'),
$p->getPrice(TRUE, (int) $k, 2, NULL, FALSE, FALSE),
$p->getPrice(TRUE, (int) $k, 2),
Tools::ps_round($p->wholesale_price, 2),
$p->active,
$p->description_short[$id_lang],
$p->description[$id_lang],
count($c_images) > 0? implode(', ', $c_images): implode(', ', $images),
implode(', ', $categories),
implode(', ', $categories_title),
), ';', '"');
}
} else {
fputcsv($f, array(
$p->supplier_reference,
$p->id,
0,
$p->position,
$p->weight,
$p->quantity,
$p->name[$id_lang],
'',
$p->ean13,
$p->location,
$p->manufacturer_name,
(int) Db::getInstance()->getValue('
$quantity_sold = (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_history` h
ON h.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
WHERE d.`product_id` = '.(int) $p->id.'
AND d.`product_attribute_id` = '.(int) $k.'
AND h.`id_order_state` = 2
'),
$p->getPrice(TRUE, NULL, 2, NULL, FALSE, FALSE),
$p->getPrice(TRUE, NULL, 2),
Tools::ps_round($p->wholesale_price, 2),
$p->active,
');
fputcsv($f, array(
$v['supplier_reference'],
$p->id,
$k,
$p->position,
str_replace('.', ',', $p->weight),
$v['qty'],
$p->name[$id_lang],
implode(' - ', $names),
$v['ean13'],
// $v['location'],
// $v['brand'],
$quantity_sold,
str_replace('.', ',', $p->getPrice(TRUE, (int) $k, 2, NULL, FALSE, FALSE)),
str_replace('.', ',', $p->getPrice(TRUE, (int) $k, 2)),
str_replace('.', ',', Tools::ps_round($p->wholesale_price, 2)),
str_replace('.', ',', Tools::ps_round(($quantity_sold * $p->wholesale_price),2)),
// $p->active,
$p->description_short[$id_lang],
$p->description[$id_lang],
count($c_images) > 0? implode(', ', $c_images): implode(', ', $images),
$categorie_0,
$categorie_1,
$categorie_2,
// implode(', ', $categories),
// implode(', ', $categories_title),
), ';', '"');
}
} else {
$quantity_sold = (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_detail` d
LEFT JOIN `'._DB_PREFIX_.'orders` o
ON o.`id_order` = d.`id_order`
LEFT JOIN `'._DB_PREFIX_.'order_history` h
ON h.`id_order` = d.`id_order`
WHERE d.`product_id` = '.(int) $p->id.'
AND h.`id_order_state` = 2
');
fputcsv($f, array(
$p->supplier_reference,
$p->id,
0,
$p->position,
str_replace('.', ',', $p->weight),
$p->quantity,
$p->name[$id_lang],
'',
$p->ean13,
// $p->location,
// $p->manufacturer_name,
$quantity_sold,
str_replace('.', ',', $p->getPrice(TRUE, NULL, 2, NULL, FALSE, FALSE)),
str_replace('.', ',', $p->getPrice(TRUE, NULL, 2)),
str_replace('.', ',', Tools::ps_round($p->wholesale_price, 2)),
str_replace('.', ',', Tools::ps_round(($quantity_sold * $p->wholesale_price),2)),
// $p->active,
$p->description_short[$id_lang],
$p->description[$id_lang],
implode(', ', $images),
implode(', ', $categories),
implode(', ', $categories_title),
$categorie_0,
$categorie_1,
$categorie_2,
// implode(', ', $categories),
// implode(', ', $categories_title),
), ';', '"');
}
}