27require_once DOL_DOCUMENT_ROOT.
'/core/modules/barcode/modules_barcode.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/barcode.lib.php';
40 public $version =
'dolibarr';
65 public function info($langs)
69 $key =
'BarcodeInternalEngine';
70 $trans = $langs->trans(
'BarcodeInternalEngine');
72 return ($trans != $key) ? $trans :
'Internal engine';
98 global $genbarcode_loc;
102 if ($encoding ==
'EAN13') {
105 if ($encoding ==
'ISBN') {
108 if ($encoding ==
'UPC') {
113 if (file_exists($genbarcode_loc) && empty($_SERVER[
"WINDIR"])) {
114 if ($encoding ==
'EAN8') {
117 if ($encoding ==
'C39') {
120 if ($encoding ==
'C128') {
137 public function buildBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
143 if ($encoding ==
'EAN8' || $encoding ==
'EAN13') {
146 if ($encoding ==
'C39' || $encoding ==
'C128') {
147 $encoding = substr($encoding, 1);
152 $_GET[
"code"] = $code;
153 $_GET[
"encoding"] = $encoding;
154 $_GET[
"scale"] = $scale;
155 $_GET[
"mode"] = $mode;
158 if (empty($filebarcode)) {
162 dol_syslog(get_class($this).
"::buildBarCode $code,$encoding,$scale,$mode,$filebarcode");
164 $result =
barcode_print($code, $encoding, $scale, $mode, $filebarcode);
167 if (!is_array($result)) {
168 $this->error = $result;
169 if (empty($nooutputiferror)) {
188 public function writeBarCode($code, $encoding, $readable =
'Y', $scale = 1, $nooutputiferror = 0)
190 global
$conf, $langs;
193 if (!is_writable(
$conf->barcode->dir_temp)) {
195 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory",
$conf->barcode->dir_temp);
197 $this->error =
"ErrorFailedToWriteInTempDirectory ".$conf->barcode->dir_temp;
199 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
204 if (!preg_match(
'/^\w+$/', $code) ||
dol_strlen($code) > 32) {
205 $newcode =
dol_hash($newcode,
'md5');
209 $filebarcode =
$conf->barcode->dir_temp .
'/barcode_' . $newcode .
'_' . $encoding .
'.png';
211 $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.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.