Compare commits

...

2 Commits

Author SHA1 Message Date
Marion Muszynski
eff75be205 update labelgenerate 2016-03-02 10:03:17 +01:00
Marion Muszynski
ff53fe1768 update gitignore 2016-02-26 10:58:14 +01:00
7 changed files with 129 additions and 229 deletions

3
.gitignore vendored
View File

@ -110,4 +110,5 @@ modules/privatesales_logistique/files/*
modules/emarsys_rss/flux.xml
modules/emarsys_rss/*.xml
modules/bulkupdate/*.csv
modules/logistics/carriers/laposte/summaries/*.pdf
modules/logistics/carriers/laposte/summaries/*.pdf
modules/labelgenerate/img/*

View File

@ -1,199 +0,0 @@
<?php
/*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 8937 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
/* Debug only */
@ini_set('display_errors', 'off');
define('_PS_DEBUG_SQL_', false);
$start_time = microtime(true);
/* Compatibility warning */
define('_PS_DISPLAY_COMPATIBILITY_WARNING_', false);
/* SSL configuration */
define('_PS_SSL_PORT_', 443);
/* Improve PHP configuration to prevent issues */
ini_set('upload_max_filesize', '100M');
ini_set('default_charset', 'utf-8');
ini_set('magic_quotes_runtime', 0);
// correct Apache charset (except if it's too late
if (!headers_sent())
header('Content-Type: text/html; charset=utf-8');
/* No settings file? goto installer...*/
if (!file_exists(dirname(__FILE__).'/settings.inc.php'))
{
$dir = ((is_dir($_SERVER['REQUEST_URI']) OR substr($_SERVER['REQUEST_URI'], -1) == '/') ? $_SERVER['REQUEST_URI'] : dirname($_SERVER['REQUEST_URI']).'/');
if (!file_exists(dirname(__FILE__).'/../install'))
die('Error: \'install\' directory is missing');
header('Location: install/');
exit;
}
require_once(dirname(__FILE__).'/settings.inc.php');
define('_PS_OPEN_SHOP_', 0);
/* Include all defines */
require_once(dirname(__FILE__).'/defines.inc.php');
if (!defined('_PS_MAGIC_QUOTES_GPC_'))
define('_PS_MAGIC_QUOTES_GPC_', get_magic_quotes_gpc());
if (!defined('_PS_MODULE_DIR_'))
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_.'/modules/');
if (!defined('_PS_MYSQL_REAL_ESCAPE_STRING_'))
define('_PS_MYSQL_REAL_ESCAPE_STRING_', function_exists('mysql_real_escape_string'));
/* Autoload */
require_once(dirname(__FILE__).'/autoload.php');
/* Redefine REQUEST_URI if empty (on some webservers...) */
if (!isset($_SERVER['REQUEST_URI']) OR empty($_SERVER['REQUEST_URI']))
{
if (substr($_SERVER['SCRIPT_NAME'], -9) == 'index.php' && empty($_SERVER['QUERY_STRING']))
$_SERVER['REQUEST_URI'] = dirname($_SERVER['SCRIPT_NAME']).'/';
else
{
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
if (isset($_SERVER['QUERY_STRING']) AND !empty($_SERVER['QUERY_STRING']))
$_SERVER['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
}
}
/* Trying to redefine HTTP_HOST if empty (on some webservers...) */
if (!isset($_SERVER['HTTP_HOST']) OR empty($_SERVER['HTTP_HOST']))
$_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
/* aliases */
function p($var) {
return (Tools::p($var));
}
function d($var) {
Tools::d($var);
}
function ppp($var) {
return (Tools::p($var));
}
function ddd($var) {
Tools::d($var);
}
global $_MODULES;
$_MODULES = array();
/* Load all configuration keys */
Configuration::loadConfiguration();
/* Load all language definitions */
Language::loadLanguages();
/* Define order state */
// DEPRECATED : these defines are going to be deleted on 1.6 version of Prestashop
// USE : Configuration::get() method in order to getting the id of order state
define('_PS_OS_CHEQUE_', Configuration::get('PS_OS_CHEQUE'));
define('_PS_OS_PAYMENT_', Configuration::get('PS_OS_PAYMENT'));
define('_PS_OS_PREPARATION_', Configuration::get('PS_OS_PREPARATION'));
define('_PS_OS_SHIPPING_', Configuration::get('PS_OS_SHIPPING'));
define('_PS_OS_DELIVERED_', Configuration::get('PS_OS_DELIVERED'));
define('_PS_OS_CANCELED_', Configuration::get('PS_OS_CANCELED'));
define('_PS_OS_REFUND_', Configuration::get('PS_OS_REFUND'));
define('_PS_OS_ERROR_', Configuration::get('PS_OS_ERROR'));
define('_PS_OS_OUTOFSTOCK_', Configuration::get('PS_OS_OUTOFSTOCK'));
define('_PS_OS_BANKWIRE_', Configuration::get('PS_OS_BANKWIRE'));
define('_PS_OS_PAYPAL_', Configuration::get('PS_OS_PAYPAL'));
define('_PS_OS_WS_PAYMENT_', Configuration::get('PS_OS_WS_PAYMENT'));
/* It is not safe to rely on the system's timezone settings, and this would generate a PHP Strict Standards notice. */
if (function_exists('date_default_timezone_set'))
@date_default_timezone_set(Configuration::get('PS_TIMEZONE'));
/* Smarty */
require_once(dirname(__FILE__).'/smarty.config.inc.php');
/* Possible value are true, false, 'URL'
(for 'URL' append SMARTY_DEBUG as a parameter to the url)
default is false for production environment */
define('SMARTY_DEBUG_CONSOLE', false);
// INTERNATIONALISATION
global $site_versions, $site_version;
$site_versions = array('com', 'es','local'/*'it'*/);
//$domain_chunks = explode('.bebeboutik.', strtolower($_SERVER['HTTP_HOST']));
$domain_chunks = explode('bebeboutik.', strtolower($_SERVER['HTTP_HOST']));
if(count($domain_chunks) !== 2) {
/*$extensions = explode('.', $domain_chunks[0]);
if(in_array($extensions[1], $site_versions)) {
header('Location: http://www.bebeboutik.'.$extensions[1]);
exit;
} else {*/
header('Location: http://www.bebeboutik.com');
exit;
/*}*/
}
$cookie_version = (
isset($_COOKIE['site_version']) && in_array(strtolower($_COOKIE['site_version']), $site_versions)
? strtolower($_COOKIE['site_version'])
: FALSE
);
if(!in_array($domain_chunks[0], array('www', 'm',''/*'dev'*/))
|| ($domain_chunks[1] !== 'com' && !in_array($domain_chunks[1], $site_versions))
|| ($domain_chunks[1] === 'com' && $domain_chunks[0] !== 'bo' && $cookie_version !== FALSE)) {
/*
* Security check in case of a misconfigured web server
* If the selected domain is not allowed, redirect to default site
*/
header('Location: http://'
.(in_array($domain_chunks[0], array('www', 'm', 'bo'))? $domain_chunks[0]: 'www')
.'.bebeboutik.'
.($cookie_version
? $cookie_version
: (in_array($domain_chunks[1], $site_versions)
? $domain_chunks[1]
: 'com'
)
)
.$_SERVER['REQUEST_URI']
);
exit;
}
$_COOKIE['site_version'] = $domain_chunks[1];
$_GET['isolang'] = $domain_chunks[1];
$site_version = $domain_chunks[1];
if ($site_version == 'com' || $site_version == 'local') {
$site_version_front = 'fr';
} else {
$site_version_front = $site_version;
}
if(isset($site_version)) {
global $smarty;
$smarty->assign('site_version', $site_version);
}

View File

@ -30,13 +30,13 @@ class AdminLabelGenerate extends AdminTab {
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`
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']
@ -47,9 +47,9 @@ class AdminLabelGenerate extends AdminTab {
}
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);
$barcode->_assocProductTest($combination['id_product'], $combination['id_product_attribute'], $quantity);
Db::getInstance()->execute('
UPDATE
UPDATE
`'._DB_PREFIX_.'product_attribute`
SET `ean13` = '. $ean_generate . '
WHERE `id_product` = ' . (int)$product->id .'
@ -61,7 +61,7 @@ class AdminLabelGenerate extends AdminTab {
} else {
if (empty($product->ean13)) {
$result_quantities = Db::getInstance()->executeS('
SELECT od.`product_quantity`,od.`product_quantity_reinjected`
SELECT od.`product_quantity`,od.`product_quantity_reinjected`
FROM '._DB_PREFIX_.'order_detail od
WHERE od.`product_id` = ' . (int)$product->id
);
@ -71,9 +71,9 @@ class AdminLabelGenerate extends AdminTab {
}
if ($quantity>0) {
$ean_generate = $barcode->generateBarcode($product->id, NULL, $product->reference);
$barcode->_assocProduct($product->id, NULL, $quantity);
$barcode->_assocProductTest($product->id, NULL, $quantity);
Db::getInstance()->execute('
UPDATE
UPDATE
`'._DB_PREFIX_.'product`
SET `ean13` = '. $ean_generate . '
WHERE `id_product` = ' . (int)$product->id
@ -82,21 +82,19 @@ class AdminLabelGenerate extends AdminTab {
}
}
}
if (!empty($ean_generate)) {
$barcode->_printPDF();
$barcode->_printPDFTest();
$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 {
$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>';
/*$this->_html .= '<p class="conf">Tous les produits de la vente ont déjà des EANS</p>';
$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">
@ -118,7 +116,7 @@ class AdminLabelGenerate extends AdminTab {
$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(
$(".chosen-select").chosen(
{
allow_single_deselect:true,
placeholder_text_single : "Choisir une vente",
@ -127,11 +125,11 @@ class AdminLabelGenerate extends AdminTab {
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();
if($(this).val() != 999999) {
$(\'#category_selector\').hide();
document.location.href=\'index.php?tab=AdminLabelGenerate&token='.Tools::getAdminTokenLite('AdminLabelGenerate').'&id_sale=\' + $(this).val();
}
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -38,7 +38,7 @@ class GenerateBarcode {
Barcode::gd($im, $black, $width / 2, $height / 2 - 10 , 0, "code128", $str, 3, 50);
/* imagettftext($im, 11, 0, $width / 2 - (strlen('*'.$ean.'*')* 4), $height - 10 , $black, dirname(__FILE__).'/arial.ttf', substr(str_replace(' ', '_', '*'.$ean.'*'),0, 35) );*/
imagettftext($im, 11, 0, $width / 2 - (strlen('*'.$reference.'*')* 4), $height - 10 , $black, dirname(__FILE__).'/arial.ttf', '*'.$reference.'*' );
if ($id_product_attribute) {
imagegif($im, $this->directory.'/ean-'.$id_product.'-'.$id_product_attribute.'.gif');
} else {
@ -64,8 +64,6 @@ class GenerateBarcode {
public function _assocProduct($id_product, $id_product_attribute = NULL, $quantity) {
global $cookie;
/*$p = new Product((int)$id_product, FALSE, $cookie->id_lang);*/
$p = Db::getInstance()->getRow('
SELECT pl.name
FROM `'._DB_PREFIX_.'product` p
@ -92,6 +90,37 @@ class GenerateBarcode {
}
}
public function _assocProductTest($id_product, $id_product_attribute = NULL, $quantity) {
global $cookie;
$p = Db::getInstance()->getRow('
SELECT pl.name
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON pl.`id_product` = p.`id_product`
WHERE p.`id_product` = '.(int)$id_product.'
AND pl.`id_lang`='.(int)$cookie->id_lang);
if ($id_product_attribute) {
$details = Product::getDetailsCombination($id_product_attribute, $cookie->id_lang);
$name_combination = '';
foreach ($details as $key_attr => $detail) {
$name_combination .= $detail['attribute_name'].'-';
}
for ($i=1; $i <= $quantity; $i++) {
$this->products[] = array(
'key' => ($id_product.'-'.$id_product_attribute),
'label' => ($name_combination . ' ' . $p['name'])
);
}
} else {
for ($i=1; $i <= $quantity; $i++) {
$this->products[] = array(
'key' => $id_product.'-0',
'label' => $p['name']
);
}
}
$this->products[] = array();
}
public function printPDF() {
global $cookie;
@ -112,7 +141,7 @@ class GenerateBarcode {
$pdf->SetAutoPageBreak(FALSE);
$pdf->AddPage();
$pdf->SetFont('Arial','',14);
foreach ($this->products as $key => $quantity) {
$quantity_already_print = 0;
$explode = explode('-', $key);
@ -131,10 +160,10 @@ class GenerateBarcode {
$label = $product->name;
}
// printed line
// printed line
$nb_line = ceil(($quantity/self::_NB_PER_LINE_));
for ($i=1; $i <= $nb_line; $i++) {
if($nb_per_page == self::_TOTAL_PER_PAGE_) {
$pdf->addPage();
$nb_per_page = 0;
@ -200,10 +229,10 @@ class GenerateBarcode {
foreach ($this->products as $k => $p) {
$quantity_already_print = 0;
if ($this->products[$k]['quantity']>0){
// printed line
// printed line
$nb_line = ceil(($this->products[$k]['quantity']/self::_NB_PER_LINE_));
for ($i=1; $i <= $nb_line; $i++) {
if($nb_per_page == self::_TOTAL_PER_PAGE_) {
$pdf->addPage();
$nb_per_page = 0;
@ -255,15 +284,86 @@ class GenerateBarcode {
return TRUE;
}
public function _printPDFTest() {
global $cookie;
// données test
/*for ($i=0; $i < 30; $i++) {
$this->products[$i] = array(
'key' => "125415-322",
'label' => "03 mois (62 cm)- Lot de 2 bodies Ri"
);
}
$this->products[count($this->products)] = array();
for ($i=31; $i < 80; $i++) {
$this->products[$i] = array(
'key' => "125416-332",
'label' => "03 mois (62 cm)- Ensemble grenouill"
);
}
$this->products[count($this->products)] = array();*/
if (empty($this->products)) {
die('Tous les produits ont déjà un EAN');
}
ob_start();
$pdf = new FPDF();
$nb_per_page = 0;
$pdf->SetMargins(8,15,8);
$pdf->SetAutoPageBreak(FALSE);
$pdf->AddPage();
$pdf->SetFont('Arial','',14);
$nb_line = ceil((count($this->products)/self::_NB_PER_LINE_));
for ($i=1; $i <= $nb_line; $i++) {
if (empty($this->products[0])) {
unset($this->products[0]);
}
if (!empty($this->products)) {
$product_per_line = array_slice($this->products, 0, self::_NB_PER_LINE_);
$this->products = array_splice($this->products, self::_NB_PER_LINE_);
if($nb_per_page == self::_TOTAL_PER_PAGE_) {
$pdf->addPage();
$nb_per_page = 0;
}
foreach ($product_per_line as $key => $product) {
if (empty($product)) {
$pdf->Cell(48, 4, '', 0,0, 'C');
} else {
$this->_printLabel($pdf, $product['label'], 1);
}
}
$pdf->Ln(4);
foreach ($product_per_line as $key => $product) {
if (empty($product)) {
$pdf->Cell(48, 10, '', 0,0, 'C');
} else {
$ean_image = $this->directory.'/ean-'.$product['key'].'.gif';
$this->_printEAN($pdf, $ean_image, 1);
}
}
$pdf->Ln(13);
$nb_per_page += 1;
}
}
$pdf->Output($this->directory.'/barcode.pdf', 'F');
ob_clean();
return TRUE;
}
private function _printLabel($pdf, $label, $limit = 1) {
$pdf->SetFont('Arial', '', 5);
for ($i=0; $i < $limit; $i++) {
$pdf->Cell(48, 4, substr(utf8_decode($label), 0, 35), 0,0, 'C');
}
}
private function _printEAN($pdf, $ean_image, $limit = 1) {
for ($i=0; $i < $limit; $i++) {
for ($i=0; $i < $limit; $i++) {
$pdf->Cell(48, 10, $pdf->Image($ean_image, $pdf->GetX(), $pdf->GetY(),48, 10), 0,0, 'C');
}
}