Fix: Fix GNU address
Doxygen
This commit is contained in:
parent
4bf7706e38
commit
b736dac1c2
@ -12,8 +12,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
* or see http://www.gnu.org/
|
* or see http://www.gnu.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -31,183 +30,189 @@ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/barcode/modules_barcode.php")
|
|||||||
*/
|
*/
|
||||||
class modBarcodeCoder extends ModeleBarCode
|
class modBarcodeCoder extends ModeleBarCode
|
||||||
{
|
{
|
||||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||||
var $error='';
|
var $error='';
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return if a module can be used or not
|
|
||||||
* @return boolean true if module can be used
|
|
||||||
*/
|
|
||||||
function isEnabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return description
|
|
||||||
* @return string Texte descripif
|
|
||||||
*/
|
|
||||||
function info()
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
|
|
||||||
return 'Barcode Coder';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
|
||||||
* de conflits qui empechera cette numerotation de fonctionner.
|
|
||||||
* @return boolean false si conflit, true si ok
|
|
||||||
*/
|
|
||||||
function canBeActivated()
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return true if encodinf is supported
|
|
||||||
* @return int >0 if supported, 0 if not
|
|
||||||
*/
|
|
||||||
function encodingIsSupported($encoding)
|
|
||||||
{
|
|
||||||
global $genbarcode_loc;
|
|
||||||
|
|
||||||
$supported=0;
|
|
||||||
if ($encoding == 'EAN13') $supported=1;
|
|
||||||
if ($encoding == 'ISBN') $supported=1;
|
|
||||||
if ($encoding == 'EAN8') $supported=1;
|
|
||||||
if ($encoding == 'UPC') $supported=1;
|
|
||||||
if ($encoding == 'C39') $supported=1;
|
|
||||||
if ($encoding == 'C128') $supported=1;
|
|
||||||
|
|
||||||
return $supported;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an image file on the fly (no need to write on disk)
|
* Return if a module can be used or not
|
||||||
* @param $code Value to encode
|
*
|
||||||
* @param $encoding Mode of encoding
|
* @return boolean true if module can be used
|
||||||
* @param $readable Code can be read
|
|
||||||
*/
|
*/
|
||||||
function buildBarCode($code,$encoding,$readable='Y')
|
function isEnabled()
|
||||||
{
|
{
|
||||||
global $_GET,$_SERVER;
|
return true;
|
||||||
global $conf;
|
}
|
||||||
global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
|
|
||||||
|
|
||||||
if (! $this->encodingIsSupported($encoding)) return -1;
|
|
||||||
|
|
||||||
if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN';
|
|
||||||
if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1);
|
|
||||||
|
|
||||||
$scale=1; $mode='png';
|
|
||||||
|
|
||||||
$_GET["code"]=$code;
|
|
||||||
$_GET["encoding"]=$encoding;
|
|
||||||
$_GET["scale"]=$scale;
|
|
||||||
$_GET["mode"]=$mode;
|
|
||||||
|
|
||||||
$font = DOL_DOCUMENT_ROOT.'/includes/barcode/barcode-coder/NOTTB___.TTF';
|
|
||||||
|
|
||||||
$fontSize = 10; // GD1 in px ; GD2 in point
|
|
||||||
$marge = 10; // between barcode and hri in pixel
|
|
||||||
$x = 125; // barcode center
|
|
||||||
$y = 125; // barcode center
|
|
||||||
$height = 50; // barcode height in 1D ; module size in 2D
|
|
||||||
$width = 2; // barcode height in 1D ; not use in 2D
|
|
||||||
$angle = 90; // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
|
|
||||||
$type = 'ean13';
|
|
||||||
|
|
||||||
$im = imagecreatetruecolor(300, 300);
|
|
||||||
$black = ImageColorAllocate($im,0x00,0x00,0x00);
|
|
||||||
$white = ImageColorAllocate($im,0xff,0xff,0xff);
|
|
||||||
$red = ImageColorAllocate($im,0xff,0x00,0x00);
|
|
||||||
$blue = ImageColorAllocate($im,0x00,0x00,0xff);
|
|
||||||
imagefilledrectangle($im, 0, 0, 300, 300, $white);
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/barcode-coder/php-barcode-latest.php');
|
|
||||||
dol_syslog("modBarcodeCoder::buildBarCode $code,$encoding,$scale,$mode");
|
|
||||||
|
|
||||||
|
|
||||||
if ($code) $data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
|
/**
|
||||||
if ( isset($font) ){
|
* Return description
|
||||||
$box = imagettfbbox($fontSize, 0, $font, $data['hri']);
|
*
|
||||||
$len = $box[2] - $box[0];
|
* @return string Texte descripif
|
||||||
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
|
*/
|
||||||
imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
|
function info()
|
||||||
}
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
return 'Barcode Coder';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||||
|
* de conflits qui empechera cette numerotation de fonctionner
|
||||||
|
*
|
||||||
|
* @return boolean false si conflit, true si ok
|
||||||
|
*/
|
||||||
|
function canBeActivated()
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$rot = imagerotate($im, 45, $white);
|
/**
|
||||||
//imagedestroy($im);
|
* Return true if encodinf is supported
|
||||||
$im = imagecreatetruecolor(900, 300);
|
*
|
||||||
$black = ImageColorAllocate($im,0x00,0x00,0x00);
|
* @return int >0 if supported, 0 if not
|
||||||
$white = ImageColorAllocate($im,0xff,0xff,0xff);
|
*/
|
||||||
$red = ImageColorAllocate($im,0xff,0x00,0x00);
|
function encodingIsSupported($encoding)
|
||||||
$blue = ImageColorAllocate($im,0x00,0x00,0xff);
|
{
|
||||||
imagefilledrectangle($im, 0, 0, 900, 300, $white);
|
global $genbarcode_loc;
|
||||||
|
|
||||||
// Barcode rotation : 90°
|
$supported=0;
|
||||||
$angle = 90;
|
if ($encoding == 'EAN13') $supported=1;
|
||||||
$data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
|
if ($encoding == 'ISBN') $supported=1;
|
||||||
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
|
if ($encoding == 'EAN8') $supported=1;
|
||||||
imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
|
if ($encoding == 'UPC') $supported=1;
|
||||||
imagettftext($im, 10, 0, 60, 290, $black, $font, 'BARCODE ROTATION : 90°');
|
if ($encoding == 'C39') $supported=1;
|
||||||
|
if ($encoding == 'C128') $supported=1;
|
||||||
|
|
||||||
// barcode rotation : 135
|
return $supported;
|
||||||
$angle = 135;
|
}
|
||||||
Barcode::gd($im, $black, $x+300, $y, $angle, $type, array('code'=>$code), $width, $height);
|
|
||||||
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
|
|
||||||
imagettftext($im, $fontSize, $angle, $x + 300 + $xt, $y + $yt, $blue, $font, $data['hri']);
|
|
||||||
imagettftext($im, 10, 0, 360, 290, $black, $font, 'BARCODE ROTATION : 135°');
|
|
||||||
|
|
||||||
// last one : image rotation
|
/**
|
||||||
imagecopy($im, $rot, 580, -50, 0, 0, 300, 300);
|
* Return an image file on the fly (no need to write on disk)
|
||||||
imagerectangle($im, 0, 0, 299, 299, $black);
|
*
|
||||||
imagerectangle($im, 299, 0, 599, 299, $black);
|
* @param $code Value to encode
|
||||||
imagerectangle($im, 599, 0, 899, 299, $black);
|
* @param $encoding Mode of encoding
|
||||||
imagettftext($im, 10, 0, 690, 290, $black, $font, 'IMAGE ROTATION');
|
* @param $readable Code can be read
|
||||||
|
*/
|
||||||
|
function buildBarCode($code,$encoding,$readable='Y')
|
||||||
|
{
|
||||||
|
global $_GET,$_SERVER;
|
||||||
|
global $conf;
|
||||||
|
global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc;
|
||||||
|
|
||||||
/*
|
if (! $this->encodingIsSupported($encoding)) return -1;
|
||||||
if (! is_array($result))
|
|
||||||
{
|
|
||||||
$this->error=$result;
|
|
||||||
print $this->error;exit;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
imagepng($im);
|
if ($encoding == 'EAN8' || $encoding == 'EAN13') $encoding = 'EAN';
|
||||||
imagedestroy($im);
|
if ($encoding == 'C39' || $encoding == 'C128') $encoding = substr($encoding,1);
|
||||||
|
|
||||||
return 1;
|
$scale=1; $mode='png';
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
$_GET["code"]=$code;
|
||||||
* Save an image file on disk (with no output)
|
$_GET["encoding"]=$encoding;
|
||||||
* @param $code Value to encode
|
$_GET["scale"]=$scale;
|
||||||
* @param $encoding Mode of encoding
|
$_GET["mode"]=$mode;
|
||||||
* @param $readable Code can be read
|
|
||||||
*/
|
|
||||||
function writeBarCode($code,$encoding,$readable='Y')
|
|
||||||
{
|
|
||||||
global $conf,$filebarcode;
|
|
||||||
|
|
||||||
create_exdir($conf->barcode->dir_temp);
|
$font = DOL_DOCUMENT_ROOT.'/includes/barcode/barcode-coder/NOTTB___.TTF';
|
||||||
|
|
||||||
$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
|
$fontSize = 10; // GD1 in px ; GD2 in point
|
||||||
|
$marge = 10; // between barcode and hri in pixel
|
||||||
|
$x = 125; // barcode center
|
||||||
|
$y = 125; // barcode center
|
||||||
|
$height = 50; // barcode height in 1D ; module size in 2D
|
||||||
|
$width = 2; // barcode height in 1D ; not use in 2D
|
||||||
|
$angle = 90; // rotation in degrees : nb : non horizontable barcode might not be usable because of pixelisation
|
||||||
|
$type = 'ean13';
|
||||||
|
|
||||||
$filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode
|
$im = imagecreatetruecolor(300, 300);
|
||||||
|
$black = ImageColorAllocate($im,0x00,0x00,0x00);
|
||||||
|
$white = ImageColorAllocate($im,0xff,0xff,0xff);
|
||||||
|
$red = ImageColorAllocate($im,0xff,0x00,0x00);
|
||||||
|
$blue = ImageColorAllocate($im,0x00,0x00,0xff);
|
||||||
|
imagefilledrectangle($im, 0, 0, 300, 300, $white);
|
||||||
|
|
||||||
$result=$this->buildBarCode($code,$encoding,$readable);
|
require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/barcode-coder/php-barcode-latest.php');
|
||||||
|
dol_syslog("modBarcodeCoder::buildBarCode $code,$encoding,$scale,$mode");
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
if ($code) $data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
|
||||||
|
if ( isset($font) ){
|
||||||
|
$box = imagettfbbox($fontSize, 0, $font, $data['hri']);
|
||||||
|
$len = $box[2] - $box[0];
|
||||||
|
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
|
||||||
|
imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$rot = imagerotate($im, 45, $white);
|
||||||
|
//imagedestroy($im);
|
||||||
|
$im = imagecreatetruecolor(900, 300);
|
||||||
|
$black = ImageColorAllocate($im,0x00,0x00,0x00);
|
||||||
|
$white = ImageColorAllocate($im,0xff,0xff,0xff);
|
||||||
|
$red = ImageColorAllocate($im,0xff,0x00,0x00);
|
||||||
|
$blue = ImageColorAllocate($im,0x00,0x00,0xff);
|
||||||
|
imagefilledrectangle($im, 0, 0, 900, 300, $white);
|
||||||
|
|
||||||
|
// Barcode rotation : 90°
|
||||||
|
$angle = 90;
|
||||||
|
$data = Barcode::gd($im, $black, $x, $y, $angle, $type, array('code'=>$code), $width, $height);
|
||||||
|
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
|
||||||
|
imagettftext($im, $fontSize, $angle, $x + $xt, $y + $yt, $blue, $font, $data['hri']);
|
||||||
|
imagettftext($im, 10, 0, 60, 290, $black, $font, 'BARCODE ROTATION : 90°');
|
||||||
|
|
||||||
|
// barcode rotation : 135
|
||||||
|
$angle = 135;
|
||||||
|
Barcode::gd($im, $black, $x+300, $y, $angle, $type, array('code'=>$code), $width, $height);
|
||||||
|
Barcode::rotate(-$len / 2, ($data['height'] / 2) + $fontSize + $marge, $angle, $xt, $yt);
|
||||||
|
imagettftext($im, $fontSize, $angle, $x + 300 + $xt, $y + $yt, $blue, $font, $data['hri']);
|
||||||
|
imagettftext($im, 10, 0, 360, 290, $black, $font, 'BARCODE ROTATION : 135°');
|
||||||
|
|
||||||
|
// last one : image rotation
|
||||||
|
imagecopy($im, $rot, 580, -50, 0, 0, 300, 300);
|
||||||
|
imagerectangle($im, 0, 0, 299, 299, $black);
|
||||||
|
imagerectangle($im, 299, 0, 599, 299, $black);
|
||||||
|
imagerectangle($im, 599, 0, 899, 299, $black);
|
||||||
|
imagettftext($im, 10, 0, 690, 290, $black, $font, 'IMAGE ROTATION');
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (! is_array($result))
|
||||||
|
{
|
||||||
|
$this->error=$result;
|
||||||
|
print $this->error;exit;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
imagepng($im);
|
||||||
|
imagedestroy($im);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save an image file on disk (with no output)
|
||||||
|
*
|
||||||
|
* @param $code Value to encode
|
||||||
|
* @param $encoding Mode of encoding
|
||||||
|
* @param $readable Code can be read
|
||||||
|
*/
|
||||||
|
function writeBarCode($code,$encoding,$readable='Y')
|
||||||
|
{
|
||||||
|
global $conf,$filebarcode;
|
||||||
|
|
||||||
|
create_exdir($conf->barcode->dir_temp);
|
||||||
|
|
||||||
|
$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
|
||||||
|
|
||||||
|
$filebarcode=$file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode
|
||||||
|
|
||||||
|
$result=$this->buildBarCode($code,$encoding,$readable);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user