27require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/barcode.lib.php';
39 public $version =
'dolibarr';
54 public function info($langs)
56 return 'TCPDF-barcode';
90 if (empty($tcpdfEncoding)) {
108 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0, $filebarcode =
'')
111 if (empty($tcpdfEncoding)) {
115 $color = array(0, 0, 0);
117 $_GET[
"code"] = $code;
118 $_GET[
"type"] = $encoding;
119 $_GET[
"readable"] = $readable;
126 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
127 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
131 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
132 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
135 dol_syslog(
"buildBarCode::TCPDF.getBarcodePNG");
136 $barcodeobj->getBarcodePNG($width, $height, $color);
154 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
156 global $conf, $langs;
159 if (empty($conf->barcode)) {
162 if (empty($conf->barcode->dir_temp)) {
163 $conf->barcode->dir_temp = DOL_DATA_ROOT.
'/barcode/temp';
167 if (!is_writable($conf->barcode->dir_temp)) {
169 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
171 $this->error =
"ErrorFailedToWriteInTempDirectory ".$conf->barcode->dir_temp;
173 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
178 if (!preg_match(
'/^\w+$/', $code) ||
dol_strlen($code) > 32) {
179 $newcode =
dol_hash($newcode,
'md5');
182 $filebarcode = $conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
185 if (empty($tcpdfEncoding)) {
189 $color = array(0, 0, 0);
191 $_GET[
"code"] = $code;
192 $_GET[
"type"] = $encoding;
193 $_GET[
"readable"] = $readable;
200 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
201 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
205 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
206 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
209 dol_syslog(
"writeBarCode::TCPDF.getBarcodePngData file=".$filebarcode);
211 $imageData = (string) $barcodeobj->getBarcodePngData($width, $height, $color);
215 if (function_exists(
'imagecreate')) {
216 $imageData = imagecreatefromstring($imageData);
218 if (imagepng($imageData, $filebarcode)) {
239 $tcpdf1dEncodingTypes = array(
261 'POSTNET' =>
'POSTNET',
262 'PLANET' =>
'PLANET',
263 'RMS4CC' =>
'RMS4CC',
266 'CODABAR' =>
'CODABAR',
267 'CODE11' =>
'CODE11',
268 'PHARMA' =>
'PHARMA',
269 'PHARMA2T' =>
'PHARMA2T'
272 $tcpdf2dEncodingTypes = array(
273 'DATAMATRIX' =>
'DATAMATRIX',
274 'PDF417' =>
'PDF417',
275 'QRCODE' =>
'QRCODE,L',
276 'QRCODE,L' =>
'QRCODE,L',
277 'QRCODE,M' =>
'QRCODE,M',
278 'QRCODE,Q' =>
'QRCODE,Q',
279 'QRCODE,H' =>
'QRCODE,H'
282 if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
284 return $tcpdf1dEncodingTypes[$dolEncodingType];
285 } elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
287 return $tcpdf2dEncodingTypes[$dolEncodingType];
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage translations.
Class to generate barcode images using tcpdf barcode generator.
getTcpdfEncodingType($dolEncodingType)
get available output_modes for tcpdf class with its translated description
buildBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0, $filebarcode='')
Return an image file on the fly (no need to write on disk) with the HTTP content-type (generated by T...
encodingIsSupported($encoding)
Return true if encoding is supported.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
info($langs)
Return description of numbering model.
isEnabled()
Return if a module can be used or not.
writeBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Save an image file on disk (with no output)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.