26require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/barcode.lib.php';
39 public $version =
'dolibarr';
64 public function info($langs)
68 $key =
'BarcodeInternalEngine';
69 $trans = $langs->trans(
'BarcodeInternalEngine');
71 return ($trans != $key) ? $trans :
'Internal engine';
97 global $genbarcode_loc;
101 if ($encoding ==
'EAN13') {
104 if ($encoding ==
'ISBN') {
107 if ($encoding ==
'UPC') {
112 if (file_exists($genbarcode_loc) && empty($_SERVER[
"WINDIR"])) {
113 if ($encoding ==
'EAN8') {
116 if ($encoding ==
'C39') {
119 if ($encoding ==
'C128') {
136 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
142 if ($encoding ==
'EAN8' || $encoding ==
'EAN13') {
145 if ($encoding ==
'C39' || $encoding ==
'C128') {
146 $encoding = substr($encoding, 1);
151 $_GET[
"code"] = $code;
152 $_GET[
"encoding"] = $encoding;
153 $_GET[
"scale"] = $scale;
154 $_GET[
"mode"] = $mode;
157 if (empty($filebarcode)) {
161 dol_syslog(get_class($this).
"::buildBarCode $code,$encoding,$scale,$mode,$filebarcode");
163 $result =
barcode_print($code, $encoding, $scale, $mode, $filebarcode);
166 if (!is_array($result)) {
167 $this->error = $result;
168 if (empty($nooutputiferror)) {
187 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
189 global $conf, $langs;
192 if (!is_writable($conf->barcode->dir_temp)) {
194 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
196 $this->error =
"ErrorFailedToWriteInTempDirectory ".$conf->barcode->dir_temp;
198 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
203 if (!preg_match(
'/^\w+$/', $code) ||
dol_strlen($code) > 32) {
204 $newcode =
dol_hash($newcode,
'md5');
208 $filebarcode = $conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
210 $result = $this->
buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(getDolGlobalString( 'GENBARCODE_LOCATION')) barcode_print($code, $encoding="ANY", $scale=2, $mode="png", $filebarcode='')
Print barcode.
Parent class for barcode document generators (image)
Class to manage translations.
Class to generate barcode images using php barcode generator.
encodingIsSupported($encoding)
Return true if encoding is supported.
isEnabled()
Return if a module can be used or not.
buildBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Return an image file on the fly (no need to write on disk) with the HTTP content-type of image.
info($langs)
Return description.
canBeActivated($object)
Checks if the numbers already in the database do not cause conflicts that would prevent this numberin...
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...
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.