Apply correct tabulation

This commit is contained in:
Francis Appels 2015-05-03 11:51:54 +02:00
parent cb75d0778a
commit 2b32dc4ba8
7 changed files with 638 additions and 639 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -10,7 +10,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -18,9 +18,9 @@
*/
/**
* \file htdocs/barcode/printsheet.php
* \ingroup member
* \brief Page to print sheets with barcodes using the document templates into core/modules/printsheets
* \file htdocs/barcode/printsheet.php
* \ingroup member
* \brief Page to print sheets with barcodes using the document templates into core/modules/printsheets
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
@ -96,13 +96,13 @@ if ($action == 'builddoc')
if (empty($forbarcode)) // barcode value
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeValue")),'errors');
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeValue")),'errors');
$error++;
}
if (empty($fk_barcode_type)) // barcode type = barcode encoding
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeType")),'errors');
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("BarcodeType")),'errors');
$error++;
}
if (! $error)
@ -123,55 +123,54 @@ if ($action == 'builddoc')
$code=$forbarcode;
$generator=$stdobject->barcode_type_coder; // coder (loaded by fetch_barcode). Engine.
$encoding=strtoupper($stdobject->barcode_type_code); // code (loaded by fetch_barcode). Example 'ean', 'isbn', ...
$diroutput=$conf->barcode->dir_temp;
dol_mkdir($diroutput);
// Generate barcode
$dirbarcode=array_merge(array("/core/modules/barcode/doc/"),$conf->modules_parts['barcode']);
$dirbarcode=array_merge(array("/core/modules/barcode/doc/"),$conf->modules_parts['barcode']);
foreach($dirbarcode as $reldir)
{
$dir=dol_buildpath($reldir,0);
$newdir=dol_osencode($dir);
foreach($dirbarcode as $reldir)
{
$dir=dol_buildpath($reldir,0);
$newdir=dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (! is_dir($newdir)) continue;
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (! is_dir($newdir)) continue;
$result=@include_once $newdir.$generator.'.modules.php';
if ($result) break;
}
// Load barcode class for generating barcode image
$classname = "mod".ucfirst($generator);
$module = new $classname($db);
if ($generator != 'tcpdfbarcode') {
$template = 'standardlabel';
$is2d = false;
if ($module->encodingIsSupported($encoding))
{
$barcodeimage=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
dol_delete_file($barcodeimage);
// File is created with full name $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
$result=$module->writeBarCode($code,$encoding,'Y',4);
if ($result <= 0 || ! dol_is_file($barcodeimage))
{
$error++;
setEventMessage('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), 'errors');
}
}
else
{
$error++;
setEventMessage("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, 'errors');
}
} else {
$template = 'tcpdflabel';
$encoding = $module->getTcpdfEncodingType($encoding); //convert to TCPDF compatible encoding types
$is2d = $module->is2d;
}
$result=@include_once $newdir.$generator.'.modules.php';
if ($result) break;
}
// Load barcode class for generating barcode image
$classname = "mod".ucfirst($generator);
$module = new $classname($db);
if ($generator != 'tcpdfbarcode') {
$template = 'standardlabel';
$is2d = false;
if ($module->encodingIsSupported($encoding))
{
$barcodeimage=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
dol_delete_file($barcodeimage);
// File is created with full name $barcodeimage = $conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
$result=$module->writeBarCode($code,$encoding,'Y',4);
if ($result <= 0 || ! dol_is_file($barcodeimage))
{
$error++;
setEventMessage('Failed to generate image file of barcode for code='.$code.' encoding='.$encoding.' file='.basename($barcodeimage), 'errors');
}
}
else
{
$error++;
setEventMessage("Error, encoding ".$encoding." is not supported by encoder ".$generator.'. You must choose another barcode type or install a barcode generation engine that support '.$encoding, 'errors');
}
} else {
$template = 'tcpdflabel';
$encoding = $module->getTcpdfEncodingType($encoding); //convert to TCPDF compatible encoding types
$is2d = $module->is2d;
}
}
if (! $error)
@ -198,7 +197,7 @@ if ($action == 'builddoc')
if ($mode == 'label')
{
$txtforsticker="%PHOTO%"; // Photo will be barcode image, %BARCODE% posible when using TCPDF generator
$txtforsticker="%PHOTO%"; // Photo will be barcode image, %BARCODE% posible when using TCPDF generator
$textleft=make_substitutions((empty($conf->global->BARCODE_LABEL_LEFT_TEXT)?$txtforsticker:$conf->global->BARCODE_LABEL_LEFT_TEXT), $substitutionarray);
$textheader=make_substitutions((empty($conf->global->BARCODE_LABEL_HEADER_TEXT)?'':$conf->global->BARCODE_LABEL_HEADER_TEXT), $substitutionarray);
$textfooter=make_substitutions((empty($conf->global->BARCODE_LABEL_FOOTER_TEXT)?'':$conf->global->BARCODE_LABEL_FOOTER_TEXT), $substitutionarray);
@ -213,9 +212,9 @@ if ($action == 'builddoc')
'textheader'=>$textheader,
'textfooter'=>$textfooter,
'textright'=>$textright,
'code'=>$code,
'encoding'=>$encoding,
'is2d'=>$is2d,
'code'=>$code,
'encoding'=>$encoding,
'is2d'=>$is2d,
'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
);
}
@ -243,11 +242,11 @@ if ($action == 'builddoc')
dol_print_error('',$result);
}
if (! $mesg)
{
$db->close();
exit;
}
if (! $mesg)
{
$db->close();
exit;
}
}
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -10,7 +10,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -18,13 +18,13 @@
*/
/**
* \file htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
* \ingroup barcode
* \brief File of class to manage barcode numbering with tcpdf library
* \file htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
* \ingroup barcode
* \brief File of class to manage barcode numbering with tcpdf library
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc
require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // This is to include def like $genbarcode_loc and $font_loc
/**
* Class to generate barcode images using tcpdf barcode generator
@ -35,39 +35,39 @@ class modTcpdfbarcode extends ModeleBarCode
var $error='';
var $is2d = false;
/**
* Return description of numbering model
*
* @return string Text with description
*/
function info()
{
global $langs;
return 'TCPDF-barcode';
}
/**
* Return if a module can be used or not
/**
* Return description of numbering model
*
* @return boolean true if module can be used
* @return string Text with description
*/
function info()
{
global $langs;
return 'TCPDF-barcode';
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
function isEnabled()
{
return true;
}
}
/**
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
global $langs;
global $langs;
return true;
return true;
}
/**
@ -78,28 +78,28 @@ class modTcpdfbarcode extends ModeleBarCode
*/
function encodingIsSupported($encoding)
{
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) {
return 0;
} else {
return 1;
}
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) {
return 0;
} else {
return 1;
}
}
/**
/**
* Return an image file on the fly (no need to write on disk)
*
* @param String $code Value to encode
* @param String $encoding Mode of encoding
* @param String $readable Code can be read
* @param String $code Value to encode
* @param String $encoding Mode of encoding
* @param String $readable Code can be read
* @return int <0 if KO, >0 if OK
*/
function buildBarCode($code,$encoding,$readable='Y')
{
global $_GET;
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) return -1;
*/
function buildBarCode($code,$encoding,$readable='Y')
{
global $_GET;
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) return -1;
$color = array(0,0,0);
@ -109,45 +109,45 @@ class modTcpdfbarcode extends ModeleBarCode
$_GET["readable"]=$readable;
if ($code) {
// Load the tcpdf barcode class
if ($this->is2d) {
$height = 3;
$width = 3;
require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
$barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
} else {
$height = 50;
$width = 1;
require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
$barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
}
dol_syslog("buildBarCode::TCPDF.getBarcodePNG");
$barcodeobj->getBarcodePNG($width, $height, $color);
return 1;
// Load the tcpdf barcode class
if ($this->is2d) {
$height = 3;
$width = 3;
require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
$barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
} else {
$height = 50;
$width = 1;
require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
$barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
}
dol_syslog("buildBarCode::TCPDF.getBarcodePNG");
$barcodeobj->getBarcodePNG($width, $height, $color);
return 1;
} else {
return -2;
return -2;
}
}
}
/**
* Save an image file on disk (with no output)
*
* @param String $code Value to encode
* @param String $encoding Mode of encoding
* @param String $readable Code can be read
* Save an image file on disk (with no output)
*
* @param String $code Value to encode
* @param String $encoding Mode of encoding
* @param String $readable Code can be read
* @return int <0 if KO, >0 if OK
*/
function writeBarCode($code,$encoding,$readable='Y')
{
global $conf,$_GET;
*/
function writeBarCode($code,$encoding,$readable='Y')
{
global $conf,$_GET;
dol_mkdir($conf->barcode->dir_temp);
$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) return -1;
if (empty($tcpdfEncoding)) return -1;
$color = array(0,0,0);
@ -156,97 +156,97 @@ class modTcpdfbarcode extends ModeleBarCode
$_GET["height"]=$height;
$_GET["readable"]=$readable;
if ($code) {
// Load the tcpdf barcode class
if ($this->is2d) {
$height = 1;
$width = 1;
require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
$barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
} else {
$height = 50;
$width = 1;
require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
$barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
}
dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
if (function_exists('imagecreate')) {
$imageData = imagecreatefromstring($imageData);
}
if (imagepng($imageData, $file)) {
return 1;
} else {
return -3;
}
} else {
return -4;
}
if ($code) {
// Load the tcpdf barcode class
if ($this->is2d) {
$height = 1;
$width = 1;
require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
$barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
} else {
$height = 50;
$width = 1;
require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
$barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
}
dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
if (function_exists('imagecreate')) {
$imageData = imagecreatefromstring($imageData);
}
if (imagepng($imageData, $file)) {
return 1;
} else {
return -3;
}
} else {
return -4;
}
} else {
return -2;
return -2;
}
}
/**
* get available output_modes for tcpdf class wth its translated description
*
* @param string $dolEncodingType dolibarr barcode encoding type
* @return string tcpdf encoding type
*/
public function getTcpdfEncodingType($dolEncodingType)
{
$tcpdf1dEncodingTypes = array(
'C39' => 'C39',
'C39+' => 'C39+',
'C39E' => 'C39E',
'C39E+' => 'C39E+',
'S25' => 'S25',
'S25+' => 'S25+',
'I25' => 'I25',
'I25+' => 'I25+',
'C128' => 'C128',
'C128A' => 'C128A',
'C128B' => 'C128B',
'C128C' => 'C128C',
'EAN2' => 'EAN2',
'EAN5' => 'EAN5',
'EAN8' => 'EAN8',
'EAN13' => 'EAN13',
'ISBN' => 'EAN13',
'UPC' => 'UPCA',
'UPCE' => 'UPCE',
'MSI' => 'MSI',
'MSI+' => 'MSI+',
'POSTNET' => 'POSTNET',
'PLANET' => 'PLANET',
'RMS4CC' => 'RMS4CC',
'KIX' => 'KIX',
'IMB' => 'IMB',
'CODABAR' => 'CODABAR',
'CODE11' => 'CODE11',
'PHARMA' => 'PHARMA',
'PHARMA2T' => 'PHARMA2T'
);
$tcpdf2dEncodingTypes = array(
'DATAMATRIX' => 'DATAMATRIX',
'PDF417' => 'PDF417',
'QRCODE' => 'QRCODE,L',
'QRCODE,L' => 'QRCODE,L',
'QRCODE,M' => 'QRCODE,M',
'QRCODE,Q' => 'QRCODE,Q',
'QRCODE,H' => 'QRCODE,H'
);
if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
$this->is2d = false;
return $tcpdf1dEncodingTypes[$dolEncodingType];
} else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
$this->is2d = true;
return $tcpdf2dEncodingTypes[$dolEncodingType];
} else {
return '';
}
}
}
/**
* get available output_modes for tcpdf class wth its translated description
*
* @param string $dolEncodingType dolibarr barcode encoding type
* @return string tcpdf encoding type
*/
public function getTcpdfEncodingType($dolEncodingType)
{
$tcpdf1dEncodingTypes = array(
'C39' => 'C39',
'C39+' => 'C39+',
'C39E' => 'C39E',
'C39E+' => 'C39E+',
'S25' => 'S25',
'S25+' => 'S25+',
'I25' => 'I25',
'I25+' => 'I25+',
'C128' => 'C128',
'C128A' => 'C128A',
'C128B' => 'C128B',
'C128C' => 'C128C',
'EAN2' => 'EAN2',
'EAN5' => 'EAN5',
'EAN8' => 'EAN8',
'EAN13' => 'EAN13',
'ISBN' => 'EAN13',
'UPC' => 'UPCA',
'UPCE' => 'UPCE',
'MSI' => 'MSI',
'MSI+' => 'MSI+',
'POSTNET' => 'POSTNET',
'PLANET' => 'PLANET',
'RMS4CC' => 'RMS4CC',
'KIX' => 'KIX',
'IMB' => 'IMB',
'CODABAR' => 'CODABAR',
'CODE11' => 'CODE11',
'PHARMA' => 'PHARMA',
'PHARMA2T' => 'PHARMA2T'
);
$tcpdf2dEncodingTypes = array(
'DATAMATRIX' => 'DATAMATRIX',
'PDF417' => 'PDF417',
'QRCODE' => 'QRCODE,L',
'QRCODE,L' => 'QRCODE,L',
'QRCODE,M' => 'QRCODE,M',
'QRCODE,Q' => 'QRCODE,Q',
'QRCODE,H' => 'QRCODE,H'
);
if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
$this->is2d = false;
return $tcpdf1dEncodingTypes[$dolEncodingType];
} else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
$this->is2d = true;
return $tcpdf2dEncodingTypes[$dolEncodingType];
} else {
return '';
}
}
}

View File

@ -2,8 +2,8 @@
/* Copyright (C) 2003 Steve Dillon
* Copyright (C) 2003 Laurent Passebecq
* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
*
* This program is free software; you can redistribute it and/or modify
@ -13,7 +13,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -21,9 +21,9 @@
*/
/**
* \file htdocs/core/modules/member/doc/pdf_standard.class.php
* \ingroup member
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
* \file htdocs/core/modules/member/doc/pdf_standard.class.php
* \ingroup member
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonstickergenerator.class.php';
@ -37,37 +37,37 @@ class pdf_standard extends CommonStickerGenerator
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
*
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
*/
function addSticker(&$pdf,$outputlangs,$param) {
// use this method in future refactoring
}
/**
// use this method in future refactoring
}
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
* - %LOGO% is replace with company logo
* - %PHOTO% is replace with photo provided as parameter
*
* @param PDF $pdf PDF
* @param string $textleft Text left
* @param string $header Header
* @param string $footer Footer
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @param int $idmember Id member
* @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @return void
* @param PDF $pdf PDF
* @param string $textleft Text left
* @param string $header Header
* @param string $footer Footer
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @param int $idmember Id member
* @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @return void
*/
function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$idmember=0,$photo='')
{
global $mysoc,$conf,$langs;
global $forceimgscalewidth,$forceimgscaleheight;
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
// We are in a new page, then we must add a page
if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
@ -235,9 +235,9 @@ class pdf_standard extends CommonStickerGenerator
*
* @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ...'id'=>,'photo'=>)
* @param Translate $outputlangs Lang object for output language
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param string $mode Tell if doc module is called for 'member', ...
* @return int 1=OK, 0=KO
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param string $mode Tell if doc module is called for 'member', ...
* @return int 1=OK, 0=KO
*/
function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$mode='member')
{
@ -261,8 +261,8 @@ class pdf_standard extends CommonStickerGenerator
if (empty($mode) || $mode == 'member')
{
$title=$outputlangs->transnoentities('MembersCards');
$keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
$title=$outputlangs->transnoentities('MembersCards');
$keywords=$outputlangs->transnoentities('MembersCards')." ".$outputlangs->transnoentities("Foundation")." ".$outputlangs->convToOutputCharset($mysoc->name);
$outputdir=$conf->adherent->dir_temp;
}
else
@ -284,14 +284,14 @@ class pdf_standard extends CommonStickerGenerator
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->SetTitle($title);
$pdf->SetSubject($title);
@ -344,7 +344,7 @@ class pdf_standard extends CommonStickerGenerator
$type=dol_mimetype($filename);
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -11,7 +11,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -20,9 +20,9 @@
*/
/**
* \file htdocs/core/modules/member/modules_cards.php
* \ingroup member
* \brief File of parent class of document generator for members cards.
* \file htdocs/core/modules/member/modules_cards.php
* \ingroup member
* \brief File of parent class of document generator for members cards.
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
@ -38,11 +38,11 @@ class ModelePDFCards
/**
* Return list of active generation modules
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
function liste_modeles($db,$maxfilenamelength=0)
{
@ -62,13 +62,13 @@ class ModelePDFCards
/**
* Cree un fichier de cartes de visites en fonction du modele de ADHERENT_CARDS_ADDON_PDF
*
* @param DoliDB $db Database handler
* @param array $arrayofmembers Array of members
* @param DoliDB $db Database handler
* @param array $arrayofmembers Array of members
* @param string $modele Force modele to use ('' to not force)
* @param Translate $outputlangs Object langs to use for translation
* @param string $outputdir Output directory
* @param string $template pdf generenate document class to use default 'standard'
* @return int <0 if KO, >0 if OK
* @param string $outputdir Output directory
* @param string $template pdf generenate document class to use default 'standard'
* @return int <0 if KO, >0 if OK
*/
function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir='', $template='standard')
{
@ -118,7 +118,7 @@ function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $o
foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$template.".class.php";
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/member/doc/".$file,0);
if (file_exists($file))

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -10,7 +10,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -18,11 +18,11 @@
*/
/**
* \defgroup barcode Module barcode
* \brief Module pour gerer les codes barres
* \file htdocs/core/modules/modBarcode.class.php
* \ingroup barcode,produit
* \brief Fichier de description et activation du module Barcode
* \defgroup barcode Module barcode
* \brief Module pour gerer les codes barres
* \file htdocs/core/modules/modBarcode.class.php
* \ingroup barcode,produit
* \brief Fichier de description et activation du module Barcode
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
@ -34,9 +34,9 @@ class modBarcode extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
* @param DoliDB $db Database handler
*/
function __construct($db)
{
@ -56,7 +56,7 @@ class modBarcode extends DolibarrModules
$this->dirs = array("/barcode/temp");
// Dependances
$this->depends = array(); // May be used for product or service or third party module
$this->depends = array(); // May be used for product or service or third party module
$this->requiredby = array();
// Config pages
@ -64,12 +64,12 @@ class modBarcode extends DolibarrModules
// Constants
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
$this->const = array();
//$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
//$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
//$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
//$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
//$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
//$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
//$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
//$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
// Boxes
$this->boxes = array();
@ -90,43 +90,43 @@ class modBarcode extends DolibarrModules
$this->rights[2][3] = 0; // La permission est-elle une permission par defaut
$this->rights[2][4] = 'creer_advance';
// Main menu entries
$r=0;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'mainmenu'=>'tools',
'leftmenu'=>'barcodeprint',
'type'=>'left', // This is a Left menu entry
'titre'=>'BarCodePrintsheet',
'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>200,
'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// Main menu entries
$r=0;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'mainmenu'=>'tools',
'leftmenu'=>'barcodeprint',
'type'=>'left', // This is a Left menu entry
'titre'=>'BarCodePrintsheet',
'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>200,
'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left', // This is a Left menu entry
'titre'=>'MassBarcodeInit',
'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=modulesadmintools',
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>300,
'enabled'=>'$conf->barcode->enabled && $leftmenu=="modulesadmintools"', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'enabled'=>'$conf->barcode->enabled && $leftmenu=="modulesadmintools"', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
$r++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
@ -140,26 +140,26 @@ class modBarcode extends DolibarrModules
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1)
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1)
);
return $this->_init($sql, $options);
}
/**
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_remove($sql, $options);
}
}
}

View File

@ -2,8 +2,8 @@
/* Copyright (C) 2003 Steve Dillon
* Copyright (C) 2003 Laurent Passebecq
* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
*
* This program is free software; you can redistribute it and/or modify
@ -13,7 +13,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -21,9 +21,9 @@
*/
/**
* \file htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
* \ingroup core
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
* \file htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
* \ingroup core
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonstickergenerator.class.php';
@ -33,41 +33,41 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonstickergenerator.class.php';
*/
class pdf_standardlabel extends CommonStickerGenerator
{
/**
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
*
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
*/
function addSticker(&$pdf,$outputlangs,$param) {
// use this method in future refactoring
}
// use this method in future refactoring
}
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
* - %LOGO% is replace with company logo
* - %PHOTO% is replace with photo provided as parameter
*
* @param PDF $pdf PDF reference
* @param string $textleft Text left
* @param string $header Header
* @param string $footer Footer
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @return void
* @param PDF $pdf PDF reference
* @param string $textleft Text left
* @param string $header Header
* @param string $footer Footer
* @param Translate $outputlangs Output langs
* @param string $textright Text right
* @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
* @return void
*/
function Add_PDF_label(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
{
global $mysoc,$conf,$langs;
global $forceimgscalewidth,$forceimgscaleheight;
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth); // Scale of image for width (1=Full width of sticker)
$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth); // Scale of image for height (1=Full height of sticker)
// We are in a new page, then we must add a page
// We are in a new page, then we must add a page
if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
$pdf->AddPage();
}
@ -224,121 +224,121 @@ class pdf_standardlabel extends CommonStickerGenerator
/**
* Function to build PDF on disk, then output on HTTP strem.
*
* @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
* @param Translate $outputlangs Lang object for output language
* @param string $srctemplatepath Full path of source filename for generator using a template file
/**
* Function to build PDF on disk, then output on HTTP strem.
*
* @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
* @param Translate $outputlangs Lang object for output language
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param string $outputdir Output directory for pdf file
* @return int 1=OK, 0=KO
*/
function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='')
{
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
* @return int 1=OK, 0=KO
*/
function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='')
{
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
$this->code=$srctemplatepath;
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
$this->code=$srctemplatepath;
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
if (! is_object($outputlangs)) $outputlangs=$langs;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("admin");
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("admin");
$title=$outputlangs->transnoentities('Labels');
$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
$title=$outputlangs->transnoentities('Labels');
$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
$filename='tmp_address_sheet.pdf';
$file = $dir."/".$filename;
$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
$filename='tmp_address_sheet.pdf';
$file = $dir."/".$filename;
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($keywords);
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($keywords);
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$this->_Metric_Doc = $this->Tformat['metric'];
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
$posX=1;
$posY=1;
if ($posX > 0) $posX--; else $posX=0;
if ($posY > 0) $posY--; else $posY=0;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($pdf, $this->Tformat);
$this->_Metric_Doc = $this->Tformat['metric'];
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
$posX=1;
$posY=1;
if ($posX > 0) $posX--; else $posX=0;
if ($posY > 0) $posY--; else $posY=0;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($pdf, $this->Tformat);
$pdf->Open();
$pdf->AddPage();
$pdf->Open();
$pdf->AddPage();
// Add each record
foreach($arrayofrecords as $val)
{
// imprime le texte specifique sur la carte
$this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']);
}
// Add each record
foreach($arrayofrecords as $val)
{
// imprime le texte specifique sur la carte
$this->Add_PDF_label($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']);
}
//$pdf->SetXY(10, 295);
//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
//$pdf->SetXY(10, 295);
//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
// Output to file
$pdf->Output($file,'F');
// Output to file
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
// Output to http stream
clearstatcache();
// Output to http stream
clearstatcache();
$attachment=true;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
$type=dol_mimetype($filename);
$attachment=true;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
$type=dol_mimetype($filename);
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($file);
readfile($file);
return 1;
}
return 1;
}
}

View File

@ -2,8 +2,8 @@
/* Copyright (C) 2003 Steve Dillon
* Copyright (C) 2003 Laurent Passebecq
* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
*
* This program is free software; you can redistribute it and/or modify
@ -13,7 +13,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
@ -21,9 +21,9 @@
*/
/**
* \file htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
* \ingroup core
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
* \file htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
* \ingroup core
* \brief Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonstickergenerator.class.php';
@ -33,83 +33,83 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonstickergenerator.class.php';
*/
class pdf_tcpdflabel extends CommonStickerGenerator
{
// define 1d barcode style
private $_style1d = array(
'position' => '',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => false,
'hpadding' => 'auto',
'vpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false,
'text' => true,
'font' => 'helvetica',
'fontsize' => 8,
'stretchtext' => 4
);
// set style for 2d barcode
private $_style2d = array(
'border' => false,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false,
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
private $_align2d = 'N';
private $_xres = 0.4;
/**
* write barcode to pdf
*
* @param PDF $pdf PDF reference
* @param string $code code to print
* @param string $encoding type of barcode
* @param boolean $is2d true if 2d barcode
* @param int $x x position in user units
* @param int $y y position in user units
* @param int $w width in user units
* @param int $h height in user units
*/
private function writeBarcode(&$pdf, $code, $encoding, $is2d, $x, $y, $w, $h)
{
if ($is2d) {
$pdf->write2DBarcode($code, $encoding, $x, $y, $w, $h, $this->_style2d, $this->_align2d);
} else {
$pdf->write1DBarcode($code, $encoding, $x, $y, $w, $h, $this->_xres, $this->_style1d);
}
}
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
*
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
*/
function addSticker(&$pdf,$outputlangs,$param)
{
global $mysoc,$conf;
$textleft = $param['textleft'];
$header = $param['textheader'];
$footer = $param['textfooter'];
$textright = $param['textright'];
$code = $param['code'];
$encoding = $param['encoding'];
$is2d = $param['is2d'];
// define 1d barcode style
private $_style1d = array(
'position' => '',
'align' => 'C',
'stretch' => false,
'fitwidth' => true,
'cellfitalign' => '',
'border' => false,
'hpadding' => 'auto',
'vpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false,
'text' => true,
'font' => 'helvetica',
'fontsize' => 8,
'stretchtext' => 4
);
// set style for 2d barcode
private $_style2d = array(
'border' => false,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false,
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
private $_align2d = 'N';
private $_xres = 0.4;
/**
* write barcode to pdf
*
* @param PDF $pdf PDF reference
* @param string $code code to print
* @param string $encoding type of barcode
* @param boolean $is2d true if 2d barcode
* @param int $x x position in user units
* @param int $y y position in user units
* @param int $w width in user units
* @param int $h height in user units
*/
private function writeBarcode(&$pdf, $code, $encoding, $is2d, $x, $y, $w, $h)
{
if ($is2d) {
$pdf->write2DBarcode($code, $encoding, $x, $y, $w, $h, $this->_style2d, $this->_align2d);
} else {
$pdf->write1DBarcode($code, $encoding, $x, $y, $w, $h, $this->_xres, $this->_style1d);
}
}
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
*
* @param PDF $pdf PDF reference
* @param Translate $outputlangs Output langs
* @param array $param Associative array containing label content and optional parameters
* @return void
*/
function addSticker(&$pdf,$outputlangs,$param)
{
global $mysoc,$conf;
$textleft = $param['textleft'];
$header = $param['textheader'];
$footer = $param['textfooter'];
$textright = $param['textright'];
$code = $param['code'];
$encoding = $param['encoding'];
$is2d = $param['is2d'];
// We are in a new page, then we must add a page
// We are in a new page, then we must add a page
if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
$pdf->AddPage();
}
@ -164,7 +164,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
else if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
}
else
{
@ -174,12 +174,12 @@ class pdf_tcpdflabel extends CommonStickerGenerator
}
else if ($textleft!='' && $textright!='') // left and right part
{
if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') ) // left part logo/barcode right part text
if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') ) // left part logo/barcode right part text
{
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0);
else if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
}
$pdf->SetXY($_PosX+($widthtouse/2), $_PosY+$ytop);
$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
@ -189,32 +189,32 @@ class pdf_tcpdflabel extends CommonStickerGenerator
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0);
else if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
}
$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($widthtouse/2, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
}
else if ($textleft == '%LOGO%') // left part logo right part text/barcode
else if ($textleft == '%LOGO%') // left part logo right part text/barcode
{
if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
} else {
$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
if ($logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, 0, $logoHeight);
if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
} else {
$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
}
}
else if ($textright == '%LOGO%') // right part logo left part text/barcode
{
if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
} else {
$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
}
if ($logo) $pdf->Image($logo, $_PosX+$xleft+$widthtouse-$logoWidth+1, $_PosY+$ytop, 0, $logoHeight);
if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
} else {
$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
$pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
}
}
else // text on halft left and text on half right
{
@ -230,7 +230,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, 0, $logoHeight);
else if ($code && !empty($encoding))
{
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$this->_Width-$widthtouse-$xleft, $_PosY+$ytop, $widthtouse, $heighttouse);
}
else
{
@ -265,121 +265,121 @@ class pdf_tcpdflabel extends CommonStickerGenerator
/**
* Function to build PDF on disk, then output on HTTP strem.
*
* @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
* @param Translate $outputlangs Lang object for output language
* @param string $srctemplatepath Full path of source filename for generator using a template file
/**
* Function to build PDF on disk, then output on HTTP strem.
*
* @param array $arrayofrecords Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
* @param Translate $outputlangs Lang object for output language
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param string $outputdir Output directory for pdf file
* @return int 1=OK, 0=KO
*/
function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='')
{
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
* @return int 1=OK, 0=KO
*/
function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='')
{
global $user,$conf,$langs,$mysoc,$_Avery_Labels;
$this->code=$srctemplatepath;
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
$this->code=$srctemplatepath;
$this->Tformat = $_Avery_Labels[$this->code];
if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
$this->type = 'pdf';
$this->format = $this->Tformat['paper-size'];
if (! is_object($outputlangs)) $outputlangs=$langs;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("admin");
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("admin");
$title=$outputlangs->transnoentities('Labels');
$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
$title=$outputlangs->transnoentities('Labels');
$keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
$filename='tmp_address_sheet.pdf';
$file = $dir."/".$filename;
$dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
$filename='tmp_address_sheet.pdf';
$file = $dir."/".$filename;
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
$pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($keywords);
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
$pdf->SetTitle($title);
$pdf->SetSubject($title);
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($keywords);
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$pdf->SetMargins(0,0);
$pdf->SetAutoPageBreak(false);
$this->_Metric_Doc = $this->Tformat['metric'];
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
$posX=1;
$posY=1;
if ($posX > 0) $posX--; else $posX=0;
if ($posY > 0) $posY--; else $posY=0;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($pdf, $this->Tformat);
$this->_Metric_Doc = $this->Tformat['metric'];
// Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
$posX=1;
$posY=1;
if ($posX > 0) $posX--; else $posX=0;
if ($posY > 0) $posY--; else $posY=0;
$this->_COUNTX = $posX;
$this->_COUNTY = $posY;
$this->_Set_Format($pdf, $this->Tformat);
$pdf->Open();
$pdf->AddPage();
$pdf->Open();
$pdf->AddPage();
// Add each record
foreach($arrayofrecords as $val)
{
// imprime le texte specifique sur la carte
$this->addSticker($pdf, $outputlangs, $val);
}
// Add each record
foreach($arrayofrecords as $val)
{
// imprime le texte specifique sur la carte
$this->addSticker($pdf, $outputlangs, $val);
}
//$pdf->SetXY(10, 295);
//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
//$pdf->SetXY(10, 295);
//$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
// Output to file
$pdf->Output($file,'F');
// Output to file
$pdf->Output($file,'F');
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
// Output to http stream
clearstatcache();
// Output to http stream
clearstatcache();
$attachment=true;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
$type=dol_mimetype($filename);
$attachment=true;
if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
$type=dol_mimetype($filename);
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
readfile($file);
readfile($file);
return 1;
}
return 1;
}
}