fix conflicts

This commit is contained in:
Marion Muszynski 2017-02-03 16:57:12 +01:00
commit 54b9bfd989
4 changed files with 310 additions and 120 deletions

View File

@ -165,7 +165,7 @@ class HelperFormBootstrap{
}
}
public static function generateInput($input) {
public function generateInput($input) {
$this->addInput($input);
$result = $this->_html;

View File

@ -180,6 +180,18 @@ form label{
.ln_solid-small{
margin: 25px 0 10px;
}
.lateral-solid-l{
border-left:1px solid #E6E9ED;
}
.lateral-solid-r{
border-right:1px solid #E6E9ED;
}
.lateral-solid-b{
border-bottom:1px solid #E6E9ED;
}
.lateral-solid-t{
border-top:1px solid #E6E9ED;
}
/* FORM */
form p:first-child{
@ -206,6 +218,7 @@ div.tagsinput span.tag a {
color: #fff;
}
/* Alert */
#content .alert {
width: 100%;
margin: 0;
@ -247,7 +260,16 @@ div.tagsinput span.tag a {
background-color: #1ABB9C;
border: 1px solid #169F85;
}
#content .alert-warning{
color: #fff;
background-color: #FFA74E;
border: 1px solid #FFA74E;
}
#content .alert-error{
color: #fff;
background-color: #E36363;
border: 1px solid #C22222;
}
/* form */
.form-control {

View File

@ -5,6 +5,7 @@ if(!defined('_PS_VERSION_')) {
require_once dirname(__FILE__).'/../privatesales/Sale.php';
require_once dirname(__FILE__).'/models/generatebarcode.php';
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
class AdminLabelGenerate extends AdminTab {
@ -30,7 +31,7 @@ class AdminLabelGenerate extends AdminTab {
$barcode->printRackPDF($rackCodes);
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>';
$this->displaySucess('Rack générés : <a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/rack/rack.pdf">Télécharger le PDF rack</a>');
}
} elseif ($current_sale && Tools::getValue('generateRef')) {
$sale = new Sale((int)$current_sale);
@ -82,10 +83,13 @@ class AdminLabelGenerate extends AdminTab {
}
}
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>';
$this->displayWarning('Les références ont déjà été générées<br>Dernières ref générées : <a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/reference.pdf">Télécharger le PDF</a>');
} 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>';
if($barcode->printPDF(true)) {
$this->displaySucess('Génération terminée : <a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/reference.pdf">Télécharger le PDF</a>');
} else {
$this->_html .= $this->displayError('Pas de produit à générer !');
}
}
}
} elseif ($current_sale && Tools::getValue('deleteEAN')) {
@ -138,9 +142,116 @@ class AdminLabelGenerate extends AdminTab {
}
}
}
$this->_html .= '<p class="conf">Suppression terminée </p>';
$this->_html .= $this->displaySuccess('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);
$count = 0;
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) {
$quantity = 0;
$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']
);
foreach ($result_quantities as $od) {
$quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']);
}
if($quantity>0){
$count++;
if (empty($combination['ean13'])) {
$ean_generate = $barcode->generateBarcode($combination['id_product'], $combination['id_product_attribute'],$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 {
$ean_generate = $barcode->generateBarcode($combination['id_product'], $combination['id_product_attribute'],$product->reference, $combination['ean13']);
}
$barcode->assocProduct($combination['id_product'], $combination['id_product_attribute'], $quantity, $product->reference);
}
}
} else {
$quantity = 0;
$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'
);
foreach ($result_quantities as $od) {
$quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']);
}
if($quantity>0){
$count++;
if (empty($product->ean13)) {
$ean_generate = $barcode->generateBarcode($product->id, NULL, $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
');
} else {
$ean_generate = $barcode->generateBarcode($product->id, NULL, $product->reference, $product->ean13);
}
$barcode->assocProduct($product->id, NULL, $quantity, $product->reference);
}
}
}
if (!empty($ean_generate)) {
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode_all.pdf')) {
unlink(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode_all.pdf');
}
if($barcode->printPDF(false,'barcode_all')) {
$this->_html .= $this->displaySuccess('Génération terminée :<br><a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode_all.pdf">Télécharger le PDF</a>');
} else {
$this->_html .= $this->displayError('Pas de produit à générer !');
}
} else {
$message = 'Aucun ean trouvé ou généré !';
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode_all.pdf')) {
$message .= '<br>Dernières étiquettes générées : <a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode_all.pdf">Télécharger le PDF</a>';
}
$this->_html .= $this->displayWarning($message);
}
}
} elseif ($current_sale && Tools::getValue('generateALLEAN_initial')) {
$sale = new Sale((int)$current_sale);
if(!Validate::isLoadedObject($sale)) {
@ -161,10 +272,18 @@ class AdminLabelGenerate extends AdminTab {
$combinations = $product->getAttributeCombinaisons($cookie->id_lang);
if ($combinations) {
foreach ($combinations as $key => $combination) {
$quantity = (int)$combination['quantity'];
$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']
);
foreach ($result_quantities as $od) {
$quantity += ((int)$od['product_quantity'] - (int)$od['product_quantity_reinjected']);
}
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`
@ -179,13 +298,23 @@ class AdminLabelGenerate extends AdminTab {
WHERE `product_id` = '. (int)$product->id .'
AND `product_attribute_id` = '. (int)$combination['id_product_attribute']
);
} else {
$ean_generate = $barcode->generateBarcode($combination['id_product'], $combination['id_product_attribute'],$product->reference, $combination['ean13']);
}
$barcode->assocProduct($combination['id_product'], $combination['id_product_attribute'], $quantity, $product->reference);
}
} else {
$quantity = $product->quantity;
$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'
);
foreach ($result_quantities as $od) {
$quantity += ($od['product_quantity'] - $od['product_quantity_reinjected']);
}
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`
@ -199,18 +328,28 @@ class AdminLabelGenerate extends AdminTab {
WHERE `product_id` = '. (int)$product->id .'
AND `product_attribute_id` = 0
');
} else {
$ean_generate = $barcode->generateBarcode($product->id, NULL, $product->reference, $product->ean13);
}
$barcode->assocProduct($product->id, NULL, $quantity, $product->reference);
}
}
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>';
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode_all_initial.pdf')) {
unlink(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode_all_initial.pdf');
}
if($barcode->printPDF(false,'barcode_all_initial')) {
$this->_html .= $this->displaySuccess('Génération terminée :<br><a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode_all_initial.pdf">Télécharger le PDF</a>');
} else {
$this->_html .= $this->displayError('Pas de produit à générer !');
}
} else {
$message = 'Tous les produits de la vente ont déjà des EANS';
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode_all_initial.pdf')) {
$message .= '<br>Dernières étiquettes générées : <a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode_all_initial.pdf">Télécharger le PDF</a>';
}
$this->_html .= $this->displayWarning($message);
}
}
} elseif ($current_sale && Tools::getValue('generateEAN')) {
@ -298,115 +437,140 @@ class AdminLabelGenerate extends AdminTab {
}
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>';
unlink(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf');
}
if($barcode->printPDF()) {
$this->_html .= $this->displaySuccess('Génération terminée :<br><a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf">Télécharger le PDF</a>');
} else {
$this->_html .= $this->displayError('Pas de produit à générer !');
}
} else {
$message = 'Tous les produits de la vente ont déjà des EANS';
if (glob(_PS_MODULE_DIR_.'labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf')) {
$message .= '<br>Dernières étiquettes générées : <a class="btn btn-primary btn-xs" target="_blank" href="/modules/labelgenerate/img/'.$barcode->id_sale.'/barcode.pdf">Télécharger le PDF</a>';
}
$this->_html .= $this->displayWarning($message);
}
}
}
$this->_html .= '<fieldset>
<legend>'.$this->l('Sale selection').'</legend>
<div class="" style="text-align:center;">
<label for="id_sale" style="display: inline; float: none; width: auto;">'.$this->l('Select a sale:').'</label><br/><br class="clear"/>
<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', 500) 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>
<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>
<br class="clear"/>
<div style="text-align:center">
<button class="button" id="generateALLEAN" style="display:inline-block">Générer les EANs pour tous les produits d\'une vente</button>
</div>
<br class="clear"/>
<div style="text-align:center">
<button class="button" id="deleteEAN" style="display:inline-block">Supprimer les EANs</button>
</div>
$helperForm = new HelperFormBootstrap();
$helperForm->_select2 = true;
$id_sale_options = array();
foreach(Sale::getSales(NULL, NULL, NULL, NULL, FALSE, FALSE, '`date_start` DESC', 500) as $sale) {
$id_sale_options[(int)$sale->id] = array(
'label' => $sale->id.' - '.$sale->title[(int) $cookie->id_lang],
'value' => (int) $sale->id
);
if($sale->id == $current_sale) {
$id_sale_options[(int)$sale->id]['selected'] = true;
}
}
$this->_html .= $helperForm->renderStyle();
$this->_html .= '<div class="panel">
<div class="panel-title">
<h2><span class="anticon anticon-barcode"></span> '.$this->l('Génération EAN').'</h2>
<div class="clearfix"></div>
</div>
</fieldset>
<br /><br />';
/*$this->_html .='<fieldset>
<legend>'.$this->l('Rack barcode').'</legend>
<div class="margin-form">
<button class="button" id="generateRack">'.$this->l('Generate rack').'</button>
<div class="panel-content">
<div class="col-md-5 col-md-offset-3">';
$input = array(
'type' => 'select2',
'label' => $this->l('Select a sale:'),
'label-class' => 'text-left',
'select-class' => 'text-left',
'name' => 'id_sale',
'id' => 'id_sale',
'options' => $id_sale_options,
);
$this->_html .= $helperForm->generateInput($input).'
</div>
<div class="col-md-3 col-md-offset-1 lateral-solid-l">
<p class="hidden"><button class="btn btn-primary" id="generateRef" data-toggle="tooltip" data-placement="left" title="Produits vendus">Générer Refs</button></p>
<p><button class="btn btn-primary" id="generateEAN" data-toggle="tooltip" data-placement="left" title="EAN manquants des quantités vendus">Générer EANs (manquants)</button></p>
<p><button class="btn btn-primary" id="generateALLEAN" data-toggle="tooltip" data-placement="left" title="Tous les EAN et génère les manquants des quantités vendus">Générer EANs (qté vendus)</button></p>
<p><button class="btn btn-primary" id="generateALLEAN_initial" data-toggle="tooltip" data-placement="left" title="Tous les EAN et génère les manquants des quantités initiales">Générer EANs (qté initiales)</button></p>
<p><button class="btn btn-default" id="deleteEAN" data-toggle="tooltip" data-placement="left" title="Supprimer tous les EAN de la vente">Supprimer les EANs</button></p>
<p class="hidden"><button class="hidden btn btn-default" id="generateRack">Générer Rack</button></p>
</div>
</fieldset>
<br /><br />';*/
<div class="clear"></div>
</div>
</div>';
$this->_html.= '<link type="text/css" rel="stylesheet" href="'._MODULE_DIR_.'bulkupdate/chosen.min.css" />';
$this->_html.= '<style>.chosen-drop{text-align:left;}</style>';
$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() {});
$("#generateEAN").click(function(){
if ($(".chosen-select").val() != 999999) {
$(\'#category_selector\').hide();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateEAN=1&id_sale=\' + $(".chosen-select").val();
}
});
$("#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();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateALLEAN=1&id_sale=\' + $(".chosen-select").val();
}
});
$("#deleteEAN").click(function(){
ok = confirm("Êtes vous sur de vouloir supprimer les eans de cette vente ?")
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();
}
}
});
$("#generateRack").click(function(){
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&rack=1\';
});
$helperForm->_js .='<script type="text/javascript">
$(function() {
$(\'[data-toggle="tooltip"]\').tooltip();
$("#generateEAN").click(function(){
if ($("#id_sale").val() != 999999) {
$(\'#category_selector\').hide();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateEAN=1&id_sale=\' + $("#id_sale").val();
}
});
</script>';
$("#generateRef").click(function(){
if ($("#id_sale").val() != 999999) {
$(\'#category_selector\').hide();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateRef=1&id_sale=\' + $("#id_sale").val();
}
});
$("#generateALLEAN").click(function(){
if ($("#id_sale").val() != 999999) {
$(\'#category_selector\').hide();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateALLEAN=1&id_sale=\' + $("#id_sale").val();
}
});
$("#generateALLEAN_initial").click(function(){
if ($("#id_sale").val() != 999999) {
$(\'#category_selector\').hide();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&generateALLEAN_initial=1&id_sale=\' + $("#id_sale").val();
}
});
$("#deleteEAN").click(function(){
ok = confirm("Êtes vous sur de vouloir supprimer les eans de cette vente ?")
if (ok == true){
if ($("#id_sale").val() != 999999) {
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&deleteEAN=1&id_sale=\' + $("#id_sale").val();
}
}
});
$("#generateRack").click(function(){
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&rack=1\';
});
});
</script>';
$this->_html .= $helperForm->renderScript();
echo $this->_html;
}
public function displaySuccess($message){
return '<div class="col-sm-6 col-sm-offset-3 alert-custom alert-ok" style="margin-bottom: 10px;">
<i class="glyphicon glyphicon-ok"></i> <span class="text-alert">'.$message.'</span>
</div>';
}
public function displayWarning($message){
return '<div class="col-sm-6 col-sm-offset-3 alert-custom alert-warning" style="margin-bottom: 10px;">
<i class="anticon anticon-notification"></i> <span class="text-alert">'.$message.'</span>
</div>';
}
public function displayError($message){
return '<div class="col-sm-6 col-sm-offset-3 alert-custom alert-error" style="margin-bottom: 10px;">
<i class="glyphicon glyphicon-remove"></i> <span class="text-alert">'.$message.'</span>
</div>';
}
}

View File

@ -80,8 +80,10 @@ class GenerateBarcode {
$this->directory = self::$barcode_directory.$name;
}
public function generateBarcode($id_product, $id_product_attribute = NULL, $reference = NULL) {
$ean = $this->_getEanNumber();
public function generateBarcode($id_product, $id_product_attribute = NULL, $reference = NULL, $ean = NULL) {
if($ean == null) {
$ean = $this->_getEanNumber();
}
$str = $ean;
$width = 320;
@ -144,7 +146,7 @@ class GenerateBarcode {
//$this->products[] = array();
}
public function printPDF($generate_ref = false) {
public function printPDF($generate_ref = false,$file='') {
global $cookie;
// données test
@ -190,13 +192,14 @@ class GenerateBarcode {
// }
if (empty($this->products)) {
die('Pas de produits à générer !');
}
if($generate_ref){
$this->products = $this->_multiSortProduct($this->products);
} else {
$this->products = $this->_sortProducts($this->products, 'ref');
return false;
}
// if($generate_ref){
// $this->products = $this->_multiSortProduct($this->products);
// } else {
// $this->products = $this->_sortProducts($this->products, 'ref');
// }
$this->products = $this->_multiSortProduct($this->products);
ob_start();
$pdf = new FPDF('P', 'mm', 'A4');
@ -263,7 +266,8 @@ class GenerateBarcode {
if($generate_ref){
$pdf->Output($this->directory.'/reference.pdf', 'F');
} else {
$pdf->Output($this->directory.'/barcode.pdf', 'F');
$file = $file!=''?$file:'barcode';
$pdf->Output($this->directory.'/'.$file.'.pdf', 'F');
}
ob_clean();
return TRUE;