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)
138 global $_GET, $_SERVER;
140 global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
146 if ($encoding ==
'EAN8' || $encoding ==
'EAN13') {
149 if ($encoding ==
'C39' || $encoding ==
'C128') {
150 $encoding = substr($encoding, 1);
155 $_GET[
"code"] = $code;
156 $_GET[
"encoding"] = $encoding;
157 $_GET[
"scale"] = $scale;
158 $_GET[
"mode"] = $mode;
160 dol_syslog(get_class($this).
"::buildBarCode $code,$encoding,$scale,$mode");
165 if (!is_array($result)) {
166 $this->error = $result;
167 if (empty($nooutputiferror)) {
186 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
188 global $conf, $filebarcode, $langs;
191 if (!is_writable($conf->barcode->dir_temp)) {
192 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
193 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
197 $file = $conf->barcode->dir_temp .
'/barcode_' . $code .
'_' . $encoding .
'.png';
199 $filebarcode = $file;
201 $result = $this->
buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror);
if(getDolGlobalString( 'GENBARCODE_LOCATION')) barcode_print($code, $encoding="ANY", $scale=2, $mode="png")
Print barcode.
Parent class for barcode document models.
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)
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_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...