adding labelgenerate
142
modules/labelgenerate/AdminLabelGenerate.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
if(!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__).'/../privatesales/Sale.php';
|
||||
require_once dirname(__FILE__).'/models/generatebarcode.php';
|
||||
|
||||
class AdminLabelGenerate extends AdminTab {
|
||||
public $_html = '';
|
||||
|
||||
public function display() {
|
||||
global $cookie;
|
||||
|
||||
$current_sale = Tools::getValue('id_sale');
|
||||
if ($current_sale) {
|
||||
$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);
|
||||
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']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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
|
||||
);
|
||||
$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);
|
||||
Db::getInstance()->execute('
|
||||
UPDATE
|
||||
`'._DB_PREFIX_.'product`
|
||||
SET `ean13` = '. $ean_generate . '
|
||||
WHERE `id_product` = ' . (int)$product->id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($ean_generate)) {
|
||||
$barcode->printPDF();
|
||||
$this->_html .= '<p class="conf">Génération terminée : <a target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf">Télécharger le PDF</a></p>';
|
||||
} else {
|
||||
$this->_html .= '<p class="conf">Tous les produits de la vente ont déjà des EANS</p>';
|
||||
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf')) {
|
||||
$this->_html .= '<p class="conf">Dernières étiquettes générées : <a target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf">Télécharger le PDF</a></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_html .= '<fieldset>
|
||||
<legend>'.$this->l('Sale selection').'</legend>
|
||||
<div class="margin-form">
|
||||
<label for="id_sale" style="display: inline; float: none; width: auto;">'.$this->l('Select a sale:').'</label>
|
||||
<select class="chosen-select" id="id_sale" name="id_sale">
|
||||
<option value=""></option>
|
||||
';
|
||||
foreach(Sale::getSales(NULL, NULL, NULL, NULL, FALSE, FALSE, '`date_start` DESC', NULL) as $sale) {
|
||||
$this->_html .= '<option value="'.(int) $sale->id.'"'.($sale->id == $current_sale? ' selected="selected"': '').'>'.$sale->id.' - '.$sale->title[(int) $cookie->id_lang].'</option>';
|
||||
}
|
||||
$this->_html .= '
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
<br /><br />';
|
||||
|
||||
|
||||
$this->_html.= '<link type="text/css" rel="stylesheet" href="'._MODULE_DIR_.'bulkupdate/chosen.min.css" />';
|
||||
$this->_html.= '<script type="text/javascript" src="'._MODULE_DIR_.'bulkupdate/chosen.jquery.min.js"></script>';
|
||||
$this->_html.= '<script type="text/javascript">
|
||||
$(function() {
|
||||
$(".chosen-select").chosen(
|
||||
{
|
||||
allow_single_deselect:true,
|
||||
placeholder_text_single : "Choisir une vente",
|
||||
no_results_text : "Aucun résultat",
|
||||
enable_split_word_search : true,
|
||||
search_contains : true,
|
||||
}
|
||||
);
|
||||
|
||||
$(".chosen-select").chosen().change( function() {
|
||||
if($(this).val() != 999999) {
|
||||
$(\'#category_selector\').hide();
|
||||
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&id_sale=\' + $(this).val();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>';
|
||||
|
||||
|
||||
echo $this->_html;
|
||||
}
|
||||
}
|
BIN
modules/labelgenerate/img/2370/barcode.pdf
Normal file
BIN
modules/labelgenerate/img/2370/ean-123362-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2370/ean-123363-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2370/ean-123364-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2370/ean-123365-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2370/ean-123366-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124766-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124767-0.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
modules/labelgenerate/img/2389/ean-124768-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124769-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124770-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124771-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124772-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124773-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124774-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124775-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124776-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124777-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124778-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124779-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124780-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124781-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124782-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124783-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124784-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124785-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124786-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124787-0.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
modules/labelgenerate/img/2389/ean-124788-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124789-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124790-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124791-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124792-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124793-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124794-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124795-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124796-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124797-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124798-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124799-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124800-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124801-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124802-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124803-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124804-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124805-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124806-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124807-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124808-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124809-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124810-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124811-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124812-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124813-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124814-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124815-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124816-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124817-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124818-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124819-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124820-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124821-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124822-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124823-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124824-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124825-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124826-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124827-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124828-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124829-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124830-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124831-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124832-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124833-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124834-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124835-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124836-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124837-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124838-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124839-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124840-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124841-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124842-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124843-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124844-0.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
modules/labelgenerate/img/2389/ean-124845-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124846-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124847-0.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
modules/labelgenerate/img/2389/ean-124848-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124849-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124850-0.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
modules/labelgenerate/img/2389/ean-124851-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124852-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124853-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124854-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124855-0.gif
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/labelgenerate/img/2389/ean-124856-0.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
modules/labelgenerate/img/2389/ean-124857-0.gif
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
modules/labelgenerate/img/2389/ean-124858-0.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |