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';
67 $key =
'BarcodeInternalEngine';
68 $trans = $langs->trans(
'BarcodeInternalEngine');
70 return ($trans != $key) ? $trans :
'Internal engine';
95 global $genbarcode_loc;
99 if ($encoding ==
'EAN13') {
102 if ($encoding ==
'ISBN') {
105 if ($encoding ==
'UPC') {
110 if (file_exists($genbarcode_loc) && empty($_SERVER[
"WINDIR"])) {
111 if ($encoding ==
'EAN8') {
114 if ($encoding ==
'C39') {
117 if ($encoding ==
'C128') {
134 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
136 global $_GET, $_SERVER;
138 global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
144 if ($encoding ==
'EAN8' || $encoding ==
'EAN13') {
147 if ($encoding ==
'C39' || $encoding ==
'C128') {
148 $encoding = substr($encoding, 1);
153 $_GET[
"code"] = $code;
154 $_GET[
"encoding"] = $encoding;
155 $_GET[
"scale"] = $scale;
156 $_GET[
"mode"] = $mode;
158 dol_syslog(get_class($this).
"::buildBarCode $code,$encoding,$scale,$mode");
163 if (!is_array($result)) {
164 $this->error = $result;
165 if (empty($nooutputiferror)) {
184 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
186 global $conf, $filebarcode, $langs;
189 if (!is_writable($conf->barcode->dir_temp)) {
190 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->barcode->dir_temp);
191 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
195 $file = $conf->barcode->dir_temp .
'/barcode_' . $code .
'_' . $encoding .
'.png';
197 $filebarcode = $file;
199 $result = $this->
buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror);
if(!empty( $conf->global->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.
info()
Return description.
buildBarCode($code, $encoding, $readable='Y', $scale=1, $nooutputiferror=0)
Return an image file on the fly (no need to write on disk)
canBeActivated()
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...