dolibarr/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php

297 lines
8.7 KiB
PHP
Raw Permalink Normal View History

<?php
/* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2015-05-03 09:51:54 +00:00
* 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
2019-09-23 19:55:30 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
2015-05-03 09:51:54 +00:00
* \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
/**
* Class to generate barcode images using tcpdf barcode generator
*/
class modTcpdfbarcode extends ModeleBarCode
{
2018-09-20 10:30:38 +00:00
/**
* Dolibarr version of the loaded document
Qual: Fix PhanPluginUnknownObjectMethodCall ("part 1") (#30563) * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add typing hint to fix phan notice. * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add typing hint in phan config to fix phan notice. * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint to fix phan notice. * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for linkedObjectBlock * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for linkedObjectBlock * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for linkedObjects * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Fix: MemberNumRefNumbers getExample does not take any arguments Found thanks to adding the typing for phan! * Qual: Correct forced type for $module * Qual: Ignore phan false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Ignore false positive * Qual: phan/Ignore false positive, replace depr.prop with method * Qual: Fix typing for count by adding is_array check * Qual: replace depr.prop `nom` with method * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Fix depr.prop with getter and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: Improve typing for mymodule template * Make info method arguments match calls * Make PrintingDriver abstract class because we added abstract methods * Add phpdoc typing for phan * Update getExample function signature for compatibility * Update getExample function signature for compatibility * Update getExample function signature for compatibility * Update header wit correct information * Update getExample method signature * Update getExample method signature * Correct reference to class in comment * Force php phan typing for numbering modules * Correct $_GLOBALS to $GLOBALS * Add phpdoc to indicat type of properties * Correct default to null * Improve getNextValue typehint * Improve getNextValue typehint * Qual: Improve ModeleNumRefTakepos typing * Qual: Improve ModeleNumRefRecruitmentJobPosition typing * Fix default for $langs * Do not use non-existing ModeleNumRefTakepos::nom * Allow getNextValue argument to be null * Correct $_GLOBAL into $GLOBALS * Improve typing for ldap functions * Allow null for outputlangs argument * Improve typing for printOriginLine * Improve typing for linkedObject access * Fix PhanTypeMismatchArgumentNullableInternal and optimize * Fix PhanPossiblyUndeclaredVariable by setting default value * Ignore PhanPluginDuplicateExpressionAssignmentOperation - needs PHP7.4 * getToolTip does not accept null, changed to '' * Improve getNextValue typing * Change PrintingDriver back to normal class (instantiated) And add errors for functions that should be overloaded * Adjust pringOriginLine typing to match parent * Fix phpdoc for getNextValue * Fix phan typing * Add/Improve phpdoc typing hints * Qual: Adjustments to match typing * Update typing for unit, use GETPOSTINT * ModeleNumRefTask needs Project * Fix several notices appearing after update from develop * Index for choices is int, use GETPOSTINT * Qual: Ignore empty foreach * Force BOMLine on object line * phan typing to indicate that linked objects are BOM * Type the correct variable name (phan) * Add typing for $langs * Type to CommonNumRefGenerator (no class for availabilities) * Resolve several phan notices after update from dev branch * Extra typing fixes * Move common attributes to parent class (phan) * Add typing to Calendar class * Improve typing hints * Add typing to pdf_eagle_proforma * Qual: Add typing for token in generic_oauthcallback.php * Add typing for objMod * Correct getNextValue function signature (phpstan) * Fix typing (phpstan) * Update version declarations (fix phpstan) * Fix phpstan typing issues * Adjust typing (phpstan) * Qual: Update baseline & conf to detect 25% of PhanPluginUnknownObjectMethodCall
2024-08-17 17:32:52 +00:00
* @var string Version, possible values are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z''development'|'experimental'|'dolibarr'
*/
Qual: Fix PhanPluginUnknownObjectMethodCall ("part 1") (#30563) * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add typing hint to fix phan notice. * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add typing hint in phan config to fix phan notice. * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint to fix phan notice. * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for linkedObjectBlock * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for linkedObjectBlock * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for linkedObjects * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) # Qual: Fix PhanPluginUnknownObjectMethodCall (add typing hints) Add/improve typing hint for PhanPluginUnknownObjectMethodCall * Fix: MemberNumRefNumbers getExample does not take any arguments Found thanks to adding the typing for phan! * Qual: Correct forced type for $module * Qual: Ignore phan false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Ignore false positive * Qual: phan/Ignore false positive, replace depr.prop with method * Qual: Fix typing for count by adding is_array check * Qual: replace depr.prop `nom` with method * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Fix depr.prop with getter and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: phan/Correct module type and ignore false positive * Qual: Improve typing for mymodule template * Make info method arguments match calls * Make PrintingDriver abstract class because we added abstract methods * Add phpdoc typing for phan * Update getExample function signature for compatibility * Update getExample function signature for compatibility * Update getExample function signature for compatibility * Update header wit correct information * Update getExample method signature * Update getExample method signature * Correct reference to class in comment * Force php phan typing for numbering modules * Correct $_GLOBALS to $GLOBALS * Add phpdoc to indicat type of properties * Correct default to null * Improve getNextValue typehint * Improve getNextValue typehint * Qual: Improve ModeleNumRefTakepos typing * Qual: Improve ModeleNumRefRecruitmentJobPosition typing * Fix default for $langs * Do not use non-existing ModeleNumRefTakepos::nom * Allow getNextValue argument to be null * Correct $_GLOBAL into $GLOBALS * Improve typing for ldap functions * Allow null for outputlangs argument * Improve typing for printOriginLine * Improve typing for linkedObject access * Fix PhanTypeMismatchArgumentNullableInternal and optimize * Fix PhanPossiblyUndeclaredVariable by setting default value * Ignore PhanPluginDuplicateExpressionAssignmentOperation - needs PHP7.4 * getToolTip does not accept null, changed to '' * Improve getNextValue typing * Change PrintingDriver back to normal class (instantiated) And add errors for functions that should be overloaded * Adjust pringOriginLine typing to match parent * Fix phpdoc for getNextValue * Fix phan typing * Add/Improve phpdoc typing hints * Qual: Adjustments to match typing * Update typing for unit, use GETPOSTINT * ModeleNumRefTask needs Project * Fix several notices appearing after update from develop * Index for choices is int, use GETPOSTINT * Qual: Ignore empty foreach * Force BOMLine on object line * phan typing to indicate that linked objects are BOM * Type the correct variable name (phan) * Add typing for $langs * Type to CommonNumRefGenerator (no class for availabilities) * Resolve several phan notices after update from dev branch * Extra typing fixes * Move common attributes to parent class (phan) * Add typing to Calendar class * Improve typing hints * Add typing to pdf_eagle_proforma * Qual: Add typing for token in generic_oauthcallback.php * Add typing for objMod * Correct getNextValue function signature (phpstan) * Fix typing (phpstan) * Update version declarations (fix phpstan) * Fix phpstan typing issues * Adjust typing (phpstan) * Qual: Update baseline & conf to detect 25% of PhanPluginUnknownObjectMethodCall
2024-08-17 17:32:52 +00:00
public $version = 'dolibarr';
2018-09-20 10:30:38 +00:00
2018-08-17 16:35:51 +00:00
/**
* @var string Error code (or message)
*/
public $error = '';
2018-09-20 10:30:38 +00:00
/**
* @var bool Is this barcode 2d or 1d
*/
2018-09-20 10:30:38 +00:00
public $is2d = false;
2018-07-26 17:05:34 +00:00
2015-05-03 09:51:54 +00:00
/**
* Return description of numbering model
*
2023-08-09 16:00:31 +00:00
* @param Translate $langs Lang object to use for output
* @return string Descriptive text
2015-05-03 09:51:54 +00:00
*/
2023-08-09 16:00:31 +00:00
public function info($langs)
2015-05-03 09:51:54 +00:00
{
return 'TCPDF-barcode';
}
2015-05-03 09:51:54 +00:00
/**
* Return if a module can be used or not
*
2015-05-03 09:51:54 +00:00
* @return boolean true if module can be used
*/
2019-02-25 21:27:04 +00:00
public function isEnabled()
{
return true;
2018-07-26 17:05:34 +00:00
}
/**
2020-04-03 16:01:54 +00:00
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
2023-08-09 15:35:35 +00:00
* @param Object $object Object we need next value for
* @return boolean false if KO (there is a conflict), true if OK
*/
2023-08-09 15:35:35 +00:00
public function canBeActivated($object)
{
2015-05-03 09:51:54 +00:00
return true;
}
2018-07-26 17:05:34 +00:00
/**
* Return true if encoding is supported
*
* @param string $encoding Encoding norm
* @return int >0 if supported, 0 if not
*/
2019-02-25 21:27:04 +00:00
public function encodingIsSupported($encoding)
{
2015-05-03 09:51:54 +00:00
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
if (empty($tcpdfEncoding)) {
return 0;
} else {
return 1;
2018-07-26 17:05:34 +00:00
}
}
2015-05-03 09:51:54 +00:00
/**
2024-05-22 13:49:33 +00:00
* Return an image file on the fly (no need to write on disk) with the HTTP content-type (generated by TCPDF) of image.
*
2024-05-22 13:49:33 +00:00
* @param string $code Value to encode
* @param string $encoding Mode of encoding
* @param string $readable Code can be read (What is this ? is this used ?)
* @param integer $scale Scale (not used with this engine)
* @param integer $nooutputiferror No output if error (not used with this engine)
* @param string $filebarcode Filename to store barcode image file (instead of output it). Not supported by this driver.
* @return int Return integer <0 if KO, >0 if OK
2015-05-03 09:51:54 +00:00
*/
2024-05-22 13:49:33 +00:00
public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0, $filebarcode = '')
2015-05-03 09:51:54 +00:00
{
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
2021-02-23 21:03:23 +00:00
if (empty($tcpdfEncoding)) {
return -1;
}
2018-07-26 17:05:34 +00:00
$color = array(0, 0, 0);
$_GET["code"] = $code;
$_GET["type"] = $encoding;
$_GET["readable"] = $readable;
2018-07-26 17:05:34 +00:00
if ($code) {
2015-05-03 09:51:54 +00:00
// 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);
2018-07-26 17:05:34 +00:00
}
2015-05-03 09:51:54 +00:00
dol_syslog("buildBarCode::TCPDF.getBarcodePNG");
$barcodeobj->getBarcodePNG($width, $height, $color);
2018-07-26 17:05:34 +00:00
2015-05-03 09:51:54 +00:00
return 1;
} else {
2015-05-03 09:51:54 +00:00
return -2;
2018-07-26 17:05:34 +00:00
}
2015-05-03 09:51:54 +00:00
}
/**
2015-05-03 09:51:54 +00:00
* Save an image file on disk (with no output)
*
* @param string $code Value to encode
2024-04-29 14:32:28 +00:00
* @param string $encoding Mode of encoding ('QRCODE', 'EAN13', ...)
* @param string $readable Code can be read
* @param integer $scale Scale (not used with this engine)
* @param integer $nooutputiferror No output if error (not used with this engine)
2023-12-01 18:51:32 +00:00
* @return int Return integer <0 if KO, >0 if OK
2015-05-03 09:51:54 +00:00
*/
2019-02-25 21:27:04 +00:00
public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0)
2015-05-03 09:51:54 +00:00
{
2024-03-31 21:48:29 +00:00
global $conf, $langs;
// Force value of temp directory because we may call this even if module barcode is disabled
if (empty($conf->barcode)) {
$conf->barcode = new stdClass();
}
if (empty($conf->barcode->dir_temp)) {
$conf->barcode->dir_temp = DOL_DATA_ROOT.'/barcode/temp';
}
dol_mkdir($conf->barcode->dir_temp);
if (!is_writable($conf->barcode->dir_temp)) {
2024-03-31 21:48:29 +00:00
if ($langs instanceof Translate) {
$this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
} else {
$this->error = "ErrorFailedToWriteInTempDirectory ".$conf->barcode->dir_temp;
}
2022-08-02 10:14:32 +00:00
dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
return -1;
}
2024-03-31 21:48:29 +00:00
$newcode = $code;
if (!preg_match('/^\w+$/', $code) || dol_strlen($code) > 32) {
$newcode = dol_hash($newcode, 'md5'); // No need for security here, we can use md5
}
2024-05-22 13:49:33 +00:00
$filebarcode = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png';
$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
2021-02-23 21:03:23 +00:00
if (empty($tcpdfEncoding)) {
return -1;
}
$color = array(0, 0, 0);
$_GET["code"] = $code;
$_GET["type"] = $encoding;
$_GET["readable"] = $readable;
2015-05-03 09:51:54 +00:00
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);
2018-07-26 17:05:34 +00:00
}
2024-05-22 13:49:33 +00:00
dol_syslog("writeBarCode::TCPDF.getBarcodePngData file=".$filebarcode);
$imageData = (string) $barcodeobj->getBarcodePngData($width, $height, $color);
// Note: We can avoid to generate an image and add it into PDF by using vectorial instructions directly into PDF with TCPDF->write2DBarcode()
2024-03-31 21:48:29 +00:00
2024-05-22 13:49:33 +00:00
if ($imageData) {
2015-05-03 09:51:54 +00:00
if (function_exists('imagecreate')) {
$imageData = imagecreatefromstring($imageData);
}
2024-05-22 13:49:33 +00:00
if (imagepng($imageData, $filebarcode)) {
2015-05-03 09:51:54 +00:00
return 1;
} else {
return -3;
}
} else {
return -4;
2018-07-26 17:05:34 +00:00
}
} else {
2015-05-03 09:51:54 +00:00
return -2;
}
2015-05-03 09:51:54 +00:00
}
2018-07-26 17:05:34 +00:00
2015-05-03 09:51:54 +00:00
/**
* get available output_modes for tcpdf class with its translated description
2015-05-03 09:51:54 +00:00
*
2018-07-26 17:05:34 +00:00
* @param string $dolEncodingType dolibarr barcode encoding type
2015-05-03 09:51:54 +00:00
* @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'
);
2018-07-26 17:05:34 +00:00
2015-05-03 09:51:54 +00:00
$tcpdf2dEncodingTypes = array(
'DATAMATRIX' => 'DATAMATRIX',
'PDF417' => 'PDF417',
'QRCODE' => 'QRCODE,L',
'QRCODE,L' => 'QRCODE,L',
'QRCODE,M' => 'QRCODE,M',
'QRCODE,Q' => 'QRCODE,Q',
2018-07-26 17:05:34 +00:00
'QRCODE,H' => 'QRCODE,H'
2015-05-03 09:51:54 +00:00
);
2018-07-26 17:05:34 +00:00
2015-05-03 09:51:54 +00:00
if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
$this->is2d = false;
return $tcpdf1dEncodingTypes[$dolEncodingType];
2019-01-27 09:49:34 +00:00
} elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
2015-05-03 09:51:54 +00:00
$this->is2d = true;
return $tcpdf2dEncodingTypes[$dolEncodingType];
} else {
return '';
2018-07-26 17:05:34 +00:00
}
2015-05-03 09:51:54 +00:00
}
2015-05-03 08:26:12 +00:00
}