108 lines
4.8 KiB
PHP
Executable File
108 lines
4.8 KiB
PHP
Executable File
<?php
|
|
include dirname(__FILE__).'/../../config/config.inc.php';
|
|
|
|
|
|
if((Tools::getValue('token') === Tools::getAdminToken('AdminEANManager'.(int) Tab::getIdFromClassName('AdminEANManager').(int) Tools::getValue('id_employee')))) {
|
|
$product = NULL;
|
|
$attributes = array();
|
|
if($row = Db::getInstance()->getRow('
|
|
SELECT `id_product`
|
|
FROM `'._DB_PREFIX_.'product`
|
|
WHERE `ean13` = "'.pSQL(Tools::getValue('ean')).'
|
|
')) {
|
|
$product = new Product((int) $row['id_product'], FALSE, 2);
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT pa.`id_product_attribute`, pa.`id_product`, pa.`quantity`, ag.`public_name` as `group`, al.`name`, pa.`ean13`, pa.`reference`
|
|
FROM `'._DB_PREFIX_.'product_attribute` pa, `'._DB_PREFIX_.'product_attribute_combination` ac, `'._DB_PREFIX_.'attribute` a, `'._DB_PREFIX_.'attribute_lang` al, `'._DB_PREFIX_.'attribute_group_lang` ag
|
|
WHERE pa.`id_product` = '.(int) $product->id.'
|
|
AND ac.`id_product_attribute` = pa.`id_product_attribute`
|
|
AND al.`id_attribute` = ac.`id_attribute`
|
|
AND al.`id_lang` = 2
|
|
AND a.`id_attribute` = al.`id_attribute`
|
|
AND ag.`id_attribute_group` = a.`id_attribute_group`
|
|
AND ag.`id_lang` = 2
|
|
ORDER BY pa.`id_product` ASC, ag.`public_name` ASC, al.`name` ASC
|
|
') as $attr) {
|
|
if(!isset($attributes[$attr['id_product_attribute']])) {
|
|
$attributes[$attr['id_product_attribute']] = array();
|
|
}
|
|
|
|
$attributes[$attr['id_product_attribute']]['name'] .= '<br />'.$attr['group'].' : '.$attr['name'];
|
|
|
|
$attributes[$attr['id_product_attribute']]['id_product_attribute'] = $attr['id_product_attribute'];
|
|
$attributes[$attr['id_product_attribute']]['ean13'] = $attr['ean13'];
|
|
$attributes[$attr['id_product_attribute']]['reference'] = $attr['reference'];
|
|
}
|
|
|
|
$cover = Product::getCover($product->id);
|
|
} else {
|
|
if($row = Db::getInstance()->getRow('
|
|
SELECT `id_product`, `id_product_attribute`
|
|
FROM `'._DB_PREFIX_.'product_attribute`
|
|
WHERE `ean13` = "'.pSQL(Tools::getValue('ean')).'"
|
|
')) {
|
|
$product = new Product((int) $row['id_product'], FALSE, 2);
|
|
$attr = Db::getInstance()->getRow('
|
|
SELECT pa.`id_product_attribute`, pa.`id_product`, pa.`quantity`, ag.`public_name` as `group`, al.`name`, pa.`ean13`, pa.`reference`
|
|
FROM `'._DB_PREFIX_.'product_attribute` pa, `'._DB_PREFIX_.'product_attribute_combination` ac, `'._DB_PREFIX_.'attribute` a, `'._DB_PREFIX_.'attribute_lang` al, `'._DB_PREFIX_.'attribute_group_lang` ag
|
|
WHERE pa.`id_product` = '.(int) $product->id.'
|
|
AND ac.`id_product_attribute` = pa.`id_product_attribute`
|
|
AND pa.`id_product_attribute` = '.(int) $row['id_product_attribute'].'
|
|
AND al.`id_attribute` = ac.`id_attribute`
|
|
AND al.`id_lang` = 2
|
|
AND a.`id_attribute` = al.`id_attribute`
|
|
AND ag.`id_attribute_group` = a.`id_attribute_group`
|
|
AND ag.`id_lang` = 2
|
|
ORDER BY pa.`id_product` ASC, ag.`public_name` ASC, al.`name` ASC
|
|
');
|
|
$attributes[$attr['id_product_attribute']] = array();
|
|
|
|
$attributes[$attr['id_product_attribute']]['name'] .= '<br />'.$attr['group'].' : '.$attr['name'];
|
|
|
|
$attributes[$attr['id_product_attribute']]['id_product_attribute'] = $attr['id_product_attribute'];
|
|
$attributes[$attr['id_product_attribute']]['ean13'] = $attr['ean13'];
|
|
$attributes[$attr['id_product_attribute']]['reference'] = $attr['reference'];
|
|
|
|
$cover = Product::getCover($product->id);
|
|
}
|
|
}
|
|
|
|
if($product) {
|
|
$link = new Link();
|
|
|
|
echo '<table class="std table">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 100px;"></th>
|
|
<th>EAN</th>
|
|
<th>Référence</th>
|
|
<th>Nom</th>
|
|
<th>Nouvel EAN</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
|
|
if(count($attributes) > 0) {
|
|
foreach($attributes as $attr) {
|
|
echo '<tr>
|
|
<td><img src="http://'.$link->getImageLink($product->link_rewrite, $product->id.'-'.$cover['id_image'], 'small').'" alt="" style="width: 80px; height: 80px;" /></td>
|
|
<td class="ean">'.(!empty($attr['ean13'])? $attr['ean13']: '<span style="opacity: .4">'.$product->ean13).'</span>'.'</td>
|
|
<td>'.((string) $attr['reference'] == ''? $product->reference: $attr['reference']).'</td>
|
|
<td>'.$product->name.$attr['name'].'</td>
|
|
<td><input id="ean_'.(int) $product->id.'_'.$attr['id_product_attribute'].'" type="text" value="" autocomplete="off" onkeyup="saveEAN(event, '.(int) $product->id.', '.(int) $attr['id_product_attribute'].', $(this).val());" /></td>
|
|
</tr>';
|
|
}
|
|
} else {
|
|
echo '<tr>
|
|
<td><img src="http://'.$link->getImageLink($product->link_rewrite, $product->id.'-'.$cover['id_image']).'" alt="" style="width: 100px; height: 100px;" /></td>
|
|
<td class="ean">'.$product->ean13.'</td>
|
|
<td>'.$product->reference.'</td>
|
|
<td>'.$product->name.'</td>
|
|
<td><input id="ean_'.(int) $product->id.'_0" type="text" value="" autocomplete="off" onkeyup="saveEAN(event, '.(int) $product->id.', 0, $(this).val());" /></td>
|
|
</tr>';
|
|
}
|
|
|
|
echo '</table>';
|
|
}
|
|
}
|