Merge branch 'ticket-12132-EvoGeneratLabel'
This commit is contained in:
commit
cd4e9f14a7
@ -32,6 +32,62 @@ class AdminLabelGenerate extends AdminTab {
|
||||
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/rack/rack.pdf')) {
|
||||
$this->_html .= '<p class="conf">Rack générés : <a target="_blank" href="/modules/labelgenerate/img/rack/rack.pdf">Télécharger le PDF rack</a></p>';
|
||||
}
|
||||
} elseif ($current_sale && Tools::getValue('generateRef')) {
|
||||
$sale = new Sale((int)$current_sale);
|
||||
|
||||
if(!Validate::isLoadedObject($sale)) {
|
||||
throw new Exception('This sale doesnt exist');
|
||||
} else {
|
||||
$products = $sale->getProducts();
|
||||
$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) {
|
||||
$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) {
|
||||
$barcode->assocProduct($combination['id_product'], $combination['id_product_attribute'], $quantity, $product->reference);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$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) {
|
||||
$barcode->assocProduct($product->id, NULL, $quantity, $product->reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/reference.pdf')) {
|
||||
$this->_html .= '<p class="conf">Dernières ref générées : <a target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/reference.pdf">Télécharger le PDF</a></p>';
|
||||
} else {
|
||||
$barcode->printPDF(true);
|
||||
$this->_html .= '<p class="conf">Génération terminée : <a target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/reference.pdf">Télécharger le PDF</a></p>';
|
||||
}
|
||||
}
|
||||
} elseif ($current_sale && Tools::getValue('deleteEAN')) {
|
||||
$sale = new Sale((int)$current_sale);
|
||||
|
||||
@ -267,6 +323,10 @@ class AdminLabelGenerate extends AdminTab {
|
||||
</select>
|
||||
<br class="clear"/>
|
||||
<br class="clear"/>
|
||||
<div style="text-align:center">
|
||||
<button class="button" id="generateRef" style="display:inline-block">Générer les Ref pour tous les produits vendus</button>
|
||||
</div>
|
||||
<br class="clear"/>
|
||||
<div style="text-align:center">
|
||||
<button class="button" id="generateEAN" style="display:inline-block">Générer les EANs pour produits vendus</button>
|
||||
</div>
|
||||
@ -307,7 +367,7 @@ class AdminLabelGenerate extends AdminTab {
|
||||
);
|
||||
|
||||
$(".chosen-select").chosen().change( function() {});
|
||||
|
||||
|
||||
$("#generateEAN").click(function(){
|
||||
if ($(".chosen-select").val() != 999999) {
|
||||
$(\'#category_selector\').hide();
|
||||
@ -315,6 +375,13 @@ class AdminLabelGenerate extends AdminTab {
|
||||
}
|
||||
});
|
||||
|
||||
$("#generateRef").click(function(){
|
||||
if ($(".chosen-select").val() != 999999) {
|
||||
$(\'#category_selector\').hide();
|
||||
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateRef=1&id_sale=\' + $(".chosen-select").val();
|
||||
}
|
||||
});
|
||||
|
||||
$("#generateALLEAN").click(function(){
|
||||
if ($(".chosen-select").val() != 999999) {
|
||||
$(\'#category_selector\').hide();
|
||||
@ -324,7 +391,7 @@ class AdminLabelGenerate extends AdminTab {
|
||||
|
||||
$("#deleteEAN").click(function(){
|
||||
ok = confirm("Êtes vous sur de vouloir supprimer les eans de cette vente ?")
|
||||
if (ok == true){
|
||||
if (ok == true){
|
||||
if ($(".chosen-select").val() != 999999) {
|
||||
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&deleteEAN=1&id_sale=\' + $(".chosen-select").val();
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ class GenerateBarcode {
|
||||
//$this->products[] = array();
|
||||
}
|
||||
|
||||
public function printPDF() {
|
||||
public function printPDF($generate_ref = false) {
|
||||
global $cookie;
|
||||
|
||||
// données test
|
||||
@ -200,6 +200,9 @@ class GenerateBarcode {
|
||||
foreach ($product_per_line as $key => $product) {
|
||||
if (empty($product)) {
|
||||
$pdf->Cell(48, 10, '', 0,0, 'C');
|
||||
} elseif($generate_ref) {
|
||||
$pdf->SetFont('Arial', '', 7);
|
||||
$pdf->Cell(48, 10, $product['ref'], 0,0, 'C');
|
||||
} else {
|
||||
$ean_image = $this->directory.'/ean-'.$product['key'].'.gif';
|
||||
$this->_printEAN($pdf, $ean_image, 1);
|
||||
@ -210,7 +213,11 @@ class GenerateBarcode {
|
||||
$nb_per_page += 1;
|
||||
}
|
||||
}
|
||||
$pdf->Output($this->directory.'/barcode.pdf', 'F');
|
||||
if($generate_ref){
|
||||
$pdf->Output($this->directory.'/reference.pdf', 'F');
|
||||
} else {
|
||||
$pdf->Output($this->directory.'/barcode.pdf', 'F');
|
||||
}
|
||||
ob_clean();
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user