createRackFolder(); $rackCodes = array(); for ($i=0;$i<21;$i++) { for ($j=1;$j<6;$j++) { $name = $i.$j; $barcode->generateRack($name); $rackCodes[] = $name; } } $barcode->printRackPDF($rackCodes); if (glob(_PS_MODULE_DIR_.'labelgenerate/img/rack/rack.pdf')) { $this->_html .= '

Rack générés : Télécharger le PDF rack

'; } } elseif ($current_sale && Tools::getValue('deleteEAN')) { $sale = new Sale((int)$current_sale); if(!Validate::isLoadedObject($sale)) { throw new Exception('This sale doesnt exist'); } else { $products = $sale->getProducts(); foreach ($products as $key => $id_product) { $product = new Product($id_product, FALSE, (int) $cookie->id_lang); $attributes = array(); $combinations = $product->getAttributeCombinaisons($cookie->id_lang); if ($combinations) { foreach ($combinations as $key => $combination) { if (!empty($combination['ean13'])) { Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'product_attribute` SET `ean13` = "" WHERE `id_product` = ' . (int)$product->id .' AND `id_product_attribute` = ' . (int)$combination['id_product_attribute'] ); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'order_detail` SET `product_ean13` = "" WHERE `product_id` = '. (int)$product->id .' AND `product_attribute_id` = '. (int)$combination['id_product_attribute'] ); } } } else { if (!empty($product->ean13)) { Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'product` SET `ean13` = "" WHERE `id_product` = ' . (int)$product->id ); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'order_detail` SET `product_ean13` = "" WHERE `product_id` = '. (int)$product->id .' AND `product_attribute_id` = 0 '); } } } $this->_html .= '

Suppression terminée

'; } } elseif ($current_sale && Tools::getValue('generateALLEAN')) { $sale = new Sale((int)$current_sale); if(!Validate::isLoadedObject($sale)) { throw new Exception('This sale doesnt exist'); } else { $products = $sale->getProducts(); $ean_generate = ''; $products_generate = array(); $barcode = new GenerateBarcode(); $barcode->id_sale = $sale->id; $barcode->createFolder($barcode->id_sale); foreach ($products as $key => $id_product) { $product = new Product($id_product, FALSE, (int) $cookie->id_lang); $attributes = array(); $combinations = $product->getAttributeCombinaisons($cookie->id_lang); if ($combinations) { foreach ($combinations as $key => $combination) { if (empty($combination['ean13'])) { $quantity = $combination['quantity']; $ean_generate = $barcode->generateBarcode($combination['id_product'], $combination['id_product_attribute'],$product->reference); $barcode->assocProduct($combination['id_product'], $combination['id_product_attribute'], $quantity, $product->reference); Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'product_attribute` SET `ean13` = '. $ean_generate . ' WHERE `id_product` = ' . (int)$product->id .' AND `id_product_attribute` = ' . (int)$combination['id_product_attribute'] ); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'order_detail` SET `product_ean13` = "'. pSQL($ean_generate) .'" WHERE `product_id` = '. (int)$product->id .' AND `product_attribute_id` = '. (int)$combination['id_product_attribute'] ); } } } else { if (empty($product->ean13)) { $quantity = $product->quantity; $ean_generate = $barcode->generateBarcode($product->id, NULL, $product->reference); $barcode->assocProduct($product->id, NULL, $quantity, $product->reference); Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'product` SET `ean13` = '. $ean_generate . ' WHERE `id_product` = ' . (int)$product->id ); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'order_detail` SET `product_ean13` = "'. pSQL($ean_generate) .'" WHERE `product_id` = '. (int)$product->id .' AND `product_attribute_id` = 0 '); } } } if (!empty($ean_generate)) { $barcode->printPDF(); $this->_html .= '

Génération terminée : Télécharger le PDF

'; } else { $this->_html .= '

Tous les produits de la vente ont déjà des EANS

'; if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf')) { $this->_html .= '

Dernières étiquettes générées : Télécharger le PDF

'; } } } } elseif ($current_sale && Tools::getValue('generateEAN')) { $sale = new Sale((int)$current_sale); if(!Validate::isLoadedObject($sale)) { throw new Exception('This sale doesnt exist'); } else { $products = $sale->getProducts(); $ean_generate = ''; $products_generate = array(); $barcode = new GenerateBarcode(); $barcode->id_sale = $sale->id; $barcode->createFolder($barcode->id_sale); foreach ($products as $key => $id_product) { $product = new Product($id_product, FALSE, (int) $cookie->id_lang); $attributes = array(); $combinations = $product->getAttributeCombinaisons($cookie->id_lang); if ($combinations) { foreach ($combinations as $key => $combination) { if (empty($combination['ean13'])) { $result_quantities = Db::getInstance()->executeS(' SELECT od.`product_quantity`,od.`product_quantity_reinjected` FROM '._DB_PREFIX_.'order_detail od WHERE od.`product_id` = ' . (int)$combination['id_product'] .' AND od.`product_attribute_id`= ' . (int)$combination['id_product_attribute'] ); $quantity = 0; foreach ($result_quantities as $od) { $quantity += ($od['product_quantity'] - $od['product_quantity_reinjected']); } if ($quantity>0) { $ean_generate = $barcode->generateBarcode($combination['id_product'], $combination['id_product_attribute'],$product->reference); $barcode->assocProduct($combination['id_product'], $combination['id_product_attribute'], $quantity, $product->reference); Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'product_attribute` SET `ean13` = '. $ean_generate . ' WHERE `id_product` = ' . (int)$product->id .' AND `id_product_attribute` = ' . (int)$combination['id_product_attribute'] ); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'order_detail` SET `product_ean13` = "'. pSQL($ean_generate) .'" WHERE `product_id` = '. (int)$product->id .' AND `product_attribute_id` = '. (int)$combination['id_product_attribute'] ); } } } } else { if (empty($product->ean13)) { $result_quantities = Db::getInstance()->executeS(' SELECT od.`product_quantity`,od.`product_quantity_reinjected` FROM '._DB_PREFIX_.'order_detail od WHERE od.`product_id` = ' . (int)$product->id . ' AND `product_attribute_id` = 0' ); $quantity = 0; foreach ($result_quantities as $od) { $quantity += ($od['product_quantity'] - $od['product_quantity_reinjected']); } if ($quantity>0) { $ean_generate = $barcode->generateBarcode($product->id, NULL, $product->reference); $barcode->assocProduct($product->id, NULL, $quantity, $product->reference); Db::getInstance()->execute(' UPDATE `'._DB_PREFIX_.'product` SET `ean13` = '. $ean_generate . ' WHERE `id_product` = ' . (int)$product->id ); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'order_detail` SET `product_ean13` = "'. pSQL($ean_generate) .'" WHERE `product_id` = '. (int)$product->id .' AND `product_attribute_id` = 0 '); } } } } if (!empty($ean_generate)) { $barcode->printPDF(); $this->_html .= '

Génération terminée : Télécharger le PDF

'; } else { $this->_html .= '

Tous les produits de la vente ont déjà des EANS

'; if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf')) { $this->_html .= '

Dernières étiquettes générées : Télécharger le PDF

'; } } } } $this->_html .= '
'.$this->l('Sale selection').'








'; /*$this->_html .='
'.$this->l('Rack barcode').'


';*/ $this->_html.= ''; $this->_html.= ''; $this->_html.= ''; $this->_html.= ''; echo $this->_html; } }