Clean code for generating sheet of barcode. Can choose output filename.

This commit is contained in:
Laurent Destailleur
2016-02-08 16:42:34 +01:00
parent 404663472a
commit 7445a0f71c
9 changed files with 87 additions and 66 deletions

View File

@@ -105,13 +105,14 @@ class modPhpbarcode extends ModeleBarCode
/**
* Return an image file on the fly (no need to write on disk)
*
* @param string $code Value to encode
* @param string $encoding Mode of encoding
* @param string $readable Code can be read
* @param integer $scale Scale
* @return int <0 if KO, >0 if OK
* @param string $code Value to encode
* @param string $encoding Mode of encoding
* @param string $readable Code can be read
* @param integer $scale Scale
* @param integer $nooutputiferror No output if error
* @return int <0 if KO, >0 if OK
*/
function buildBarCode($code,$encoding,$readable='Y',$scale=1)
function buildBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
{
global $_GET,$_SERVER;
global $conf;
@@ -135,7 +136,7 @@ class modPhpbarcode extends ModeleBarCode
if (! is_array($result))
{
$this->error=$result;
print $this->error;
if (empty($nooutputiferror)) print $this->error;
return -1;
}
@@ -145,13 +146,14 @@ class modPhpbarcode extends ModeleBarCode
/**
* Save an image file on disk (with no output)
*
* @param string $code Value to encode
* @param string $encoding Mode of encoding
* @param string $readable Code can be read
* @param integer $scale Scale
* @return int <0 if KO, >0 if OK
* @param string $code Value to encode
* @param string $encoding Mode of encoding
* @param string $readable Code can be read
* @param integer $scale Scale
* @param integer $nooutputiferror No output if error
* @return int <0 if KO, >0 if OK
*/
function writeBarCode($code,$encoding,$readable='Y',$scale=1)
function writeBarCode($code,$encoding,$readable='Y',$scale=1,$nooutputiferror=0)
{
global $conf,$filebarcode;
@@ -161,7 +163,7 @@ class modPhpbarcode extends ModeleBarCode
$filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode
$result=$this->buildBarCode($code,$encoding,$readable,$scale);
$result=$this->buildBarCode($code,$encoding,$readable,$scale,$nooutputiferror);
return $result;
}