28require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/barcode.lib.php';
40 public $version =
'dolibarr';
58 public function info($langs)
60 return 'TCPDF-barcode';
94 if (empty($tcpdfEncoding)) {
112 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0, $filebarcode =
'')
115 if (empty($tcpdfEncoding)) {
119 $color = array(0, 0, 0);
121 $_GET[
"code"] = $code;
122 $_GET[
"type"] = $encoding;
123 $_GET[
"readable"] = $readable;
130 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
131 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
135 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
136 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
139 if (empty($barcodeobj->getBarcodeArray())) {
142 $this->error =
'Value "'.dol_escape_htmltag($code).
'" is not valid for encoding "'.
dol_escape_htmltag($encoding).
'"';
143 dol_syslog(
"buildBarCode::".$this->error, LOG_WARNING);
147 dol_syslog(
"buildBarCode::TCPDF.getBarcodePNG");
148 $barcodeobj->getBarcodePNG($width, $height, $color);
166 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
168 global
$conf, $langs;
171 if (empty(
$conf->barcode)) {
174 if (empty(
$conf->barcode->dir_temp)) {
175 $conf->barcode->dir_temp = DOL_DATA_ROOT.
'/barcode/temp';
179 if (!is_writable(
$conf->barcode->dir_temp)) {
181 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory",
$conf->barcode->dir_temp);
183 $this->error =
"ErrorFailedToWriteInTempDirectory ".$conf->barcode->dir_temp;
185 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
190 if (!preg_match(
'/^\w+$/', $code) ||
dol_strlen($code) > 32) {
191 $newcode =
dol_hash($newcode,
'md5');
194 $filebarcode =
$conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
197 if (empty($tcpdfEncoding)) {
201 $color = array(0, 0, 0);
203 $_GET[
"code"] = $code;
204 $_GET[
"type"] = $encoding;
205 $_GET[
"readable"] = $readable;
212 require_once TCPDF_PATH.
'tcpdf_barcodes_2d.php';
213 $barcodeobj =
new TCPDF2DBarcode($code, $tcpdfEncoding);
217 require_once TCPDF_PATH.
'tcpdf_barcodes_1d.php';
218 $barcodeobj =
new TCPDFBarcode($code, $tcpdfEncoding);
221 if (empty($barcodeobj->getBarcodeArray())) {
224 $this->error =
'Value "'.dol_escape_htmltag($code).
'" is not valid for encoding "'.
dol_escape_htmltag($encoding).
'"';
225 dol_syslog(
"writeBarCode::".$this->error, LOG_WARNING);
229 dol_syslog(
"writeBarCode::TCPDF.getBarcodePngData file=".$filebarcode);
231 $imageData = (
string) $barcodeobj->getBarcodePngData($width, $height, $color);
235 if (function_exists(
'imagecreate')) {
236 $imageData = imagecreatefromstring($imageData);
238 if (imagepng($imageData, $filebarcode)) {
259 $tcpdf1dEncodingTypes = array(
281 'POSTNET' =>
'POSTNET',
282 'PLANET' =>
'PLANET',
283 'RMS4CC' =>
'RMS4CC',
286 'CODABAR' =>
'CODABAR',
287 'CODE11' =>
'CODE11',
288 'PHARMA' =>
'PHARMA',
289 'PHARMA2T' =>
'PHARMA2T'
292 $tcpdf2dEncodingTypes = array(
293 'DATAMATRIX' =>
'DATAMATRIX',
294 'PDF417' =>
'PDF417',
295 'QRCODE' =>
'QRCODE,L',
296 'QRCODE,L' =>
'QRCODE,L',
297 'QRCODE,M' =>
'QRCODE,M',
298 'QRCODE,Q' =>
'QRCODE,Q',
299 'QRCODE,H' =>
'QRCODE,H'
302 if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
304 return $tcpdf1dEncodingTypes[$dolEncodingType];
305 } elseif (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
307 return $tcpdf2dEncodingTypes[$dolEncodingType];
if(! $sortfield) if(! $sortorder) $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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.