This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Codabar.php'
<?php
/**
* Codabar.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Codabar;
*
* Codabar Barcode type class
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Codabar extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'CODABAR';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '11111221',
'1' => '11112211',
'2' => '11121121',
'3' => '22111111',
'4' => '11211211',
'5' => '21111211',
'6' => '12111121',
'7' => '12112111',
'8' => '12211111',
'9' => '21121111',
'-' => '11122111',
'$' => '11221111',
':' => '21112121',
'/' => '21211121',
'.' => '21212111',
'+' => '11222221',
'A' => '11221211',
'B' => '12121121',
'C' => '11121221',
'D' => '11122211'
);
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = 'A'.strtoupper($this->code).'A';
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->ncols = 0;
$this->nrows = 1;
$this->bars = array();
$this->formatCode();
$clen = strlen($this->extcode);
for ($chr = 0; $chr < $clen; ++$chr) {
$char = $this->extcode[$chr];
if (!isset($this->chbar[$char])) {
throw new BarcodeException('Invalid character: chr('.ord($char).')');
}
for ($pos = 0; $pos < 8; ++$pos) {
$bar_width = intval($this->chbar[$char][$pos]);
if (($pos % 2) == 0) {
$this->bars[] = array($this->ncols, 0, $bar_width, 1);
}
$this->ncols += $bar_width;
}
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeNineThree.php'
<?php
/**
* CodeNineThree.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\CodeNineThree;
*
* CodeNineThree Barcode type class
* CODE 93 - USS-93
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeNineThree extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'C93';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
32 => '311211', // space
36 => '321111', // $
37 => '211131', // %
42 => '111141', // start-stop
43 => '113121', // +
45 => '121131', // -
46 => '311112', // .
47 => '112131', // /
48 => '131112', // 0
49 => '111213', // 1
50 => '111312', // 2
51 => '111411', // 3
52 => '121113', // 4
53 => '121212', // 5
54 => '121311', // 6
55 => '111114', // 7
56 => '131211', // 8
57 => '141111', // 9
65 => '211113', // A
66 => '211212', // B
67 => '211311', // C
68 => '221112', // D
69 => '221211', // E
70 => '231111', // F
71 => '112113', // G
72 => '112212', // H
73 => '112311', // I
74 => '122112', // J
75 => '132111', // K
76 => '111123', // L
77 => '111222', // M
78 => '111321', // N
79 => '121122', // O
80 => '131121', // P
81 => '212112', // Q
82 => '212211', // R
83 => '211122', // S
84 => '211221', // T
85 => '221121', // U
86 => '222111', // V
87 => '112122', // W
88 => '112221', // X
89 => '122121', // Y
90 => '123111', // Z
128 => '121221', // ($)
129 => '311121', // (/)
130 => '122211', // (+)
131 => '312111' // (%)
);
/**
* Map for extended characters
*
* @var array
*/
protected $extcodes = array();
/**
* Characters used for checksum
*
* @var array
*/
protected $chksum = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%',
'<', '=', '>', '?'
);
/**
* Calculate CODE 93 checksum (modulo 47).
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
// translate special characters
$code = strtr($code, chr(128).chr(131).chr(129).chr(130), '<=>?');
$clen = strlen($code);
// calculate check digit C
$pck = 1;
$check = 0;
for ($idx = ($clen - 1); $idx >= 0; --$idx) {
$key = array_keys($this->chksum, $code[$idx]);
$check += ($key[0] * $pck);
++$pck;
if ($pck > 20) {
$pck = 1;
}
}
$check %= 47;
$chk = $this->chksum[$check];
$code .= $chk;
// calculate check digit K
$pck = 1;
$check = 0;
for ($idx = $clen; $idx >= 0; --$idx) {
$key = array_keys($this->chksum, $code[$idx]);
$check += ($key[0] * $pck);
++$pck;
if ($pck > 15) {
$pck = 1;
}
}
$check %= 47;
$key = $this->chksum[$check];
$checksum = $chk.$key;
// restore special characters
$checksum = strtr($checksum, '<=>?', chr(128).chr(131).chr(129).chr(130));
return $checksum;
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->extcodes = array(
chr(131).'U', chr(128).'A', chr(128).'B', chr(128).'C', chr(128).'D', chr(128).'E', chr(128).'F',
chr(128).'G', chr(128).'H', chr(128).'I', chr(128).'J', chr(128).'K', chr(128).'L', chr(128).'M',
chr(128).'N', chr(128).'O', chr(128).'P', chr(128).'Q', chr(128).'R', chr(128).'S', chr(128).'T',
chr(128).'U', chr(128).'V', chr(128).'W', chr(128).'X', chr(128).'Y', chr(128).'Z', chr(131).'A',
chr(131).'B', chr(131).'C', chr(131).'D', chr(131).'E', ' ', chr(129).'A', chr(129).'B',
chr(129).'C', chr(129).'D', chr(129).'E', chr(129).'F', chr(129).'G', chr(129).'H', chr(129).'I',
chr(129).'J', chr(129).'K', chr(129).'L', '-', '.', chr(129).'O', '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', chr(129).'Z', chr(131).'F', chr(131).'G', chr(131).'H', chr(131).'I',
chr(131).'J', chr(131).'V', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', chr(131).'K', chr(131).'L',
chr(131).'M', chr(131).'N', chr(131).'O', chr(131).'W', chr(130).'A',
chr(130).'B', chr(130).'C', chr(130).'D', chr(130).'E', chr(130).'F', chr(130).'G', chr(130).'H',
chr(130).'I', chr(130).'J', chr(130).'K', chr(130).'L', chr(130).'M', chr(130).'N', chr(130).'O',
chr(130).'P', chr(130).'Q', chr(130).'R', chr(130).'S', chr(130).'T', chr(130).'U', chr(130).'V',
chr(130).'W', chr(130).'X', chr(130).'Y', chr(130).'Z', chr(131).'P', chr(131).'Q', chr(131).'R',
chr(131).'S', chr(131).'T'
);
$this->ncols = 0;
$this->nrows = 1;
$this->bars = array();
$this->formatCode();
$clen = strlen($this->extcode);
for ($chr = 0; $chr < $clen; ++$chr) {
$char = ord($this->extcode[$chr]);
for ($pos = 0; $pos < 6; ++$pos) {
$bar_width = intval($this->chbar[$char][$pos]);
if (($pos % 2) == 0) {
$this->bars[] = array($this->ncols, 0, $bar_width, 1);
}
$this->ncols += $bar_width;
}
}
$this->bars[] = array($this->ncols, 0, 1, 1);
$this->ncols += 1;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeOneOne.php'
<?php
/**
* CodeOneOne.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\CodeOneOne;
*
* CodeOneOne Barcode type class
* CODE 11
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeOneOne extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'CODE11';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '111121',
'1' => '211121',
'2' => '121121',
'3' => '221111',
'4' => '112121',
'5' => '212111',
'6' => '122111',
'7' => '111221',
'8' => '211211',
'9' => '211111',
'-' => '112111',
'S' => '112211'
);
/**
* Calculate the checksum.
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
$len = strlen($code);
// calculate check digit C
$ptr = 1;
$ccheck = 0;
for ($pos = ($len - 1); $pos >= 0; --$pos) {
$digit = $code[$pos];
if ($digit == '-') {
$dval = 10;
} else {
$dval = intval($digit);
}
$ccheck += ($dval * $ptr);
++$ptr;
if ($ptr > 10) {
$ptr = 1;
}
}
$ccheck %= 11;
if ($ccheck == 10) {
$ccheck = '-';
}
if ($len <= 10) {
return $ccheck;
}
// calculate check digit K
$code .= $ccheck;
$ptr = 1;
$kcheck = 0;
for ($pos = $len; $pos >= 0; --$pos) {
$digit = $code[$pos];
if ($digit == '-') {
$dval = 10;
} else {
$dval = intval($digit);
}
$kcheck += ($dval * $ptr);
++$ptr;
if ($ptr > 9) {
$ptr = 1;
}
}
$kcheck %= 11;
return $ccheck.$kcheck;
}
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = 'S'.$this->code.$this->getChecksum($this->code).'S';
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->ncols = 0;
$this->nrows = 1;
$this->bars = array();
$this->formatCode();
$clen = strlen($this->extcode);
for ($chr = 0; $chr < $clen; ++$chr) {
$char = $this->extcode[$chr];
if (!isset($this->chbar[$char])) {
throw new BarcodeException('Invalid character: chr('.ord($char).')');
}
for ($pos = 0; $pos < 6; ++$pos) {
$bar_width = intval($this->chbar[$char][$pos]);
if ((($pos % 2) == 0) && ($bar_width > 0)) {
$this->bars[] = array($this->ncols, 0, $bar_width, 1);
}
$this->ncols += $bar_width;
}
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeOneTwoEight.php'
<?php
/**
* CodeOneTwoEight.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight;
*
* CodeOneTwoEight Barcode type class
* CODE 128
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeOneTwoEight extends \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight\Process
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'C128';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'212222', // 00
'222122', // 01
'222221', // 02
'121223', // 03
'121322', // 04
'131222', // 05
'122213', // 06
'122312', // 07
'132212', // 08
'221213', // 09
'221312', // 10
'231212', // 11
'112232', // 12
'122132', // 13
'122231', // 14
'113222', // 15
'123122', // 16
'123221', // 17
'223211', // 18
'221132', // 19
'221231', // 20
'213212', // 21
'223112', // 22
'312131', // 23
'311222', // 24
'321122', // 25
'321221', // 26
'312212', // 27
'322112', // 28
'322211', // 29
'212123', // 30
'212321', // 31
'232121', // 32
'111323', // 33
'131123', // 34
'131321', // 35
'112313', // 36
'132113', // 37
'132311', // 38
'211313', // 39
'231113', // 40
'231311', // 41
'112133', // 42
'112331', // 43
'132131', // 44
'113123', // 45
'113321', // 46
'133121', // 47
'313121', // 48
'211331', // 49
'231131', // 50
'213113', // 51
'213311', // 52
'213131', // 53
'311123', // 54
'311321', // 55
'331121', // 56
'312113', // 57
'312311', // 58
'332111', // 59
'314111', // 60
'221411', // 61
'431111', // 62
'111224', // 63
'111422', // 64
'121124', // 65
'121421', // 66
'141122', // 67
'141221', // 68
'112214', // 69
'112412', // 70
'122114', // 71
'122411', // 72
'142112', // 73
'142211', // 74
'241211', // 75
'221114', // 76
'413111', // 77
'241112', // 78
'134111', // 79
'111242', // 80
'121142', // 81
'121241', // 82
'114212', // 83
'124112', // 84
'124211', // 85
'411212', // 86
'421112', // 87
'421211', // 88
'212141', // 89
'214121', // 90
'412121', // 91
'111143', // 92
'111341', // 93
'131141', // 94
'114113', // 95
'114311', // 96
'411113', // 97
'411311', // 98
'113141', // 99
'114131', // 100
'311141', // 101
'411131', // 102
'211412', // 103 START A
'211214', // 104 START B
'211232', // 105 START C
'233111', // STOP
'200000' // END
);
/**
* Map ASCII characters for code A (ASCII 00 - 95)
*
* @var array
*/
protected $keys_a = '';
/**
* Map ASCII characters for code B (ASCII 32 - 127)
*
* @var array
*/
protected $keys_b = '';
/**
* Map special FNC codes for Code Set A (FNC 1-4)
*
* @var array
*/
protected $fnc_a = array(241 => 102, 242 => 97, 243 => 96, 244 => 101);
/**
* Map special FNC codes for Code Set B (FNC 1-4)
*
* @var array
*/
protected $fnc_b = array(241 => 102, 242 => 97, 243 => 96, 244 => 100);
/**
* Set the ASCII maps values
*/
protected function setAsciiMaps()
{
// 128A (Code Set A) - ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters
$this->keys_a = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'
.chr(0).chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8).chr(9)
.chr(10).chr(11).chr(12).chr(13).chr(14).chr(15).chr(16).chr(17).chr(18).chr(19)
.chr(20).chr(21).chr(22).chr(23).chr(24).chr(25).chr(26).chr(27).chr(28).chr(29)
.chr(30).chr(31);
// 128B (Code Set B) - ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters
$this->keys_b = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]'
.'^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127);
}
/**
* Get the coe point array
*
* @throws BarcodeException in case of error
*/
protected function getCodeData()
{
$code = $this->code;
// array of symbols
$code_data = array();
// split code into sequences
$sequence = $this->getNumericSequence($code);
// process the sequence
$startid = 0;
foreach ($sequence as $key => $seq) {
$processMethod = 'processSequence'.$seq[0];
$this->$processMethod($sequence, $code_data, $startid, $key, $seq);
}
return $this->finalizeCodeData($code_data, $startid);
}
/**
* Process the A sequence
*
* @param array $sequence Sequence to process
* @param array $code_data Array of codepoints to alter
* @param string $code Code to process
* @param int $startid Start ID
* @param int $key Sequence current key
* @param string $seq Sequence current value
*
* @throws BarcodeException in case of error
*/
protected function processSequenceA(&$sequence, &$code_data, &$startid, $key, $seq)
{
if ($key == 0) {
$startid = 103;
} elseif ($sequence[($key - 1)][0] != 'A') {
if (($seq[2] == 1)
&& ($key > 0)
&& ($sequence[($key - 1)][0] == 'B')
&& (!isset($sequence[($key - 1)][3]))
) {
// single character shift
$code_data[] = 98;
// mark shift
$sequence[$key][3] = true;
} elseif (!isset($sequence[($key - 1)][3])) {
$code_data[] = 101;
}
}
$this->getCodeDataA($code_data, $seq[1], $seq[2]);
}
/**
* Process the B sequence
*
* @param array $sequence Sequence to process
* @param array $code_data Array of codepoints to alter
* @param string $code Code to process
* @param int $startid Start ID
* @param int $key Sequence current key
* @param string $seq Sequence current value
*
* @throws BarcodeException in case of error
*/
protected function processSequenceB(&$sequence, &$code_data, &$startid, $key, $seq)
{
if ($key == 0) {
$this->processSequenceBA($sequence, $code_data, $startid, $key, $seq);
} elseif ($sequence[($key - 1)][0] != 'B') {
$this->processSequenceBB($sequence, $code_data, $key, $seq);
}
$this->getCodeDataB($code_data, $seq[1], $seq[2]);
}
/**
* Process the B-A sequence
*
* @param array $sequence Sequence to process
* @param array $code_data Array of codepoints to alter
* @param string $code Code to process
* @param int $startid Start ID
* @param int $key Sequence current key
* @param string $seq Sequence current value
*
* @throws BarcodeException in case of error
*/
protected function processSequenceBA(&$sequence, &$code_data, &$startid, $key, $seq)
{
$tmpchr = ord($seq[1][0]);
if (($seq[2] == 1)
&& ($tmpchr >= 241)
&& ($tmpchr <= 244)
&& isset($sequence[($key + 1)])
&& ($sequence[($key + 1)][0] != 'B')
) {
switch ($sequence[($key + 1)][0]) {
case 'A':
$startid = 103;
$sequence[$key][0] = 'A';
$code_data[] = $this->fnc_a[$tmpchr];
break;
case 'C':
$startid = 105;
$sequence[$key][0] = 'C';
$code_data[] = $this->fnc_a[$tmpchr];
break;
}
} else {
$startid = 104;
}
}
/**
* Process the B-B sequence
*
* @param array $sequence Sequence to process
* @param array $code_data Array of codepoints to alter
* @param string $code Code to process
* @param int $key Sequence current key
* @param string $seq Sequence current value
*
* @throws BarcodeException in case of error
*/
protected function processSequenceBB(&$sequence, &$code_data, $key, $seq)
{
if (($seq[2] == 1)
&& ($key > 0)
&& ($sequence[($key - 1)][0] == 'A')
&& (!isset($sequence[($key - 1)][3]))
) {
// single character shift
$code_data[] = 98;
// mark shift
$sequence[$key][3] = true;
} elseif (!isset($sequence[($key - 1)][3])) {
$code_data[] = 100;
}
}
/**
* Process the C sequence
*
* @param array $sequence Sequence to process
* @param array $code_data Array of codepoints to alter
* @param string $code Code to process
* @param int $startid Start ID
* @param int $key Sequence current key
* @param string $seq Sequence current value
*
* @throws BarcodeException in case of error
*/
protected function processSequenceC(&$sequence, &$code_data, &$startid, $key, $seq)
{
if ($key == 0) {
$startid = 105;
} elseif ($sequence[($key - 1)][0] != 'C') {
$code_data[] = 99;
}
$this->getCodeDataC($code_data, $seq[1]);
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->setAsciiMaps();
$code_data = $this->getCodeData();
$this->ncols = 0;
$this->nrows = 1;
$this->bars = array();
foreach ($code_data as $val) {
$seq = $this->chbar[$val];
for ($pos = 0; $pos < 6; ++$pos) {
$bar_width = intval($seq[$pos]);
if ((($pos % 2) == 0) && ($bar_width > 0)) {
$this->bars[] = array($this->ncols, 0, $bar_width, 1);
}
$this->ncols += $bar_width;
}
}
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeThreeNine.php'
<?php
/**
* CodeThreeNine.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\CodeThreeNine
*
* CodeThreeNine Barcode type class
* CODE 39
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeThreeNine extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'C39';
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = '*'.strtoupper($this->code).'*';
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeThreeNineCheck.php'
<?php
/**
* CodeThreeNineCheck.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\CodeThreeNineCheck
*
* CodeThreeNineCheck Barcode type class
* CODE 39 + CHECKSUM
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeThreeNineCheck extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'C39+';
/**
* Format code
*/
protected function formatCode()
{
$code = strtoupper($this->code);
$this->extcode = '*'.$code.$this->getChecksum($code).'*';
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeThreeNineExt.php'
<?php
/**
* CodeThreeNineExt.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\CodeThreeNineExt
*
* CodeThreeNineExt Barcode type class
* CODE 39 EXTENDED
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeThreeNineExt extends \Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'C39E';
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = '*'.$this->getExtendCode(strtoupper($this->code)).'*';
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/CodeThreeNineExtCheck.php'
<?php
/**
* CodeThreeNineExtCheck.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExtCheck
*
* CodeThreeNineExtCheck Barcode type class
* CODE 39 EXTENDED + CHECKSUM
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class CodeThreeNineExtCheck extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'C39E+';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '111331311',
'1' => '311311113',
'2' => '113311113',
'3' => '313311111',
'4' => '111331113',
'5' => '311331111',
'6' => '113331111',
'7' => '111311313',
'8' => '311311311',
'9' => '113311311',
'A' => '311113113',
'B' => '113113113',
'C' => '313113111',
'D' => '111133113',
'E' => '311133111',
'F' => '113133111',
'G' => '111113313',
'H' => '311113311',
'I' => '113113311',
'J' => '111133311',
'K' => '311111133',
'L' => '113111133',
'M' => '313111131',
'N' => '111131133',
'O' => '311131131',
'P' => '113131131',
'Q' => '111111333',
'R' => '311111331',
'S' => '113111331',
'T' => '111131331',
'U' => '331111113',
'V' => '133111113',
'W' => '333111111',
'X' => '131131113',
'Y' => '331131111',
'Z' => '133131111',
'-' => '131111313',
'.' => '331111311',
' ' => '133111311',
'$' => '131313111',
'/' => '131311131',
'+' => '131113131',
'%' => '111313131',
'*' => '131131311'
);
/**
* Map for extended characters
*
* @var array
*/
protected $extcodes = array(
'%U', '$A', '$B', '$C',
'$D', '$E', '$F', '$G',
'$H', '$I', '$J', '$K',
'$L', '$M', '$N', '$O',
'$P', '$Q', '$R', '$S',
'$T', '$U', '$V', '$W',
'$X', '$Y', '$Z', '%A',
'%B', '%C', '%D', '%E',
' ', '/A', '/B', '/C',
'/D', '/E', '/F', '/G',
'/H', '/I', '/J', '/K',
'/L', '-', '.', '/O',
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', '/Z', '%F',
'%G', '%H', '%I', '%J',
'%V', 'A', 'B', 'C',
'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '%K',
'%L', '%M', '%N', '%O',
'%W', '+A', '+B', '+C',
'+D', '+E', '+F', '+G',
'+H', '+I', '+J', '+K',
'+L', '+M', '+N', '+O',
'+P', '+Q', '+R', '+S',
'+T', '+U', '+V', '+W',
'+X', '+Y', '+Z', '%P',
'%Q', '%R', '%S', '%T'
);
/**
* Characters used for checksum
*
* @var array
*/
protected $chksum = array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%'
);
/**
* Encode a string to be used for CODE 39 Extended mode.
*
* @param string $code Code to extend
*
* @return encoded string.
*
* @throws BarcodeException in case of error
*/
protected function getExtendCode($code)
{
$ext = '';
$clen = strlen($code);
for ($chr = 0; $chr < $clen; ++$chr) {
$item = ord($code[$chr]);
if ($item > 127) {
throw new BarcodeException('Invalid character: chr('.$item.')');
}
$ext .= $this->extcodes[$item];
}
return $ext;
}
/**
* Calculate CODE 39 checksum (modulo 43).
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
$sum = 0;
$clen = strlen($code);
for ($chr = 0; $chr < $clen; ++$chr) {
$key = array_keys($this->chksum, $code[$chr]);
$sum += $key[0];
}
$idx = ($sum % 43);
return $this->chksum[$idx];
}
/**
* Format code
*/
protected function formatCode()
{
$code = $this->getExtendCode(strtoupper($this->code));
$this->extcode = '*'.$code.$this->getChecksum($code).'*';
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->ncols = 0;
$this->nrows = 1;
$this->bars = array();
$this->formatCode();
$clen = strlen($this->extcode);
for ($chr = 0; $chr < $clen; ++$chr) {
$char = $this->extcode[$chr];
if (!isset($this->chbar[$char])) {
throw new BarcodeException('Invalid character: chr('.ord($char).')');
}
for ($pos = 0; $pos < 9; ++$pos) {
$bar_width = intval($this->chbar[$char][$pos]);
if ((($pos % 2) == 0) && ($bar_width > 0)) {
$this->bars[] = array($this->ncols, 0, $bar_width, 1);
}
$this->ncols += $bar_width;
}
// intercharacter gap
$this->ncols += 1;
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/EanEight.php'
<?php
/**
* EanEight.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\EanEight;
*
* EanEight Barcode type class
* EAN 8
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class EanEight extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'EAN8';
/**
* Fixed code length
*
* @var int
*/
protected $code_length = 8;
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->formatCode();
$seq = '101'; // left guard bar
$half_len = intval(ceil($this->code_length / 2));
for ($pos = 0; $pos < $half_len; ++$pos) {
$seq .= $this->chbar['A'][$this->extcode[$pos]];
}
$seq .= '01010'; // center guard bar
for ($pos = $half_len; $pos < $this->code_length; ++$pos) {
$seq .= $this->chbar['C'][$this->extcode[$pos]];
}
$seq .= '101'; // right guard bar
$this->processBinarySequence($seq);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/EanFive.php'
<?php
/**
* EanFive.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\EanFive;
*
* EanFive Barcode type class
* EAN 5-Digits UPC-Based Extension
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class EanFive extends \Com\Tecnick\Barcode\Type\Linear\EanTwo
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'EAN5';
/**
* Fixed code length
*
* @var int
*/
protected $code_length = 5;
/**
* Map parities
*
* @var array
*/
protected $parities = array(
'0' => array('B','B','A','A','A'),
'1' => array('B','A','B','A','A'),
'2' => array('B','A','A','B','A'),
'3' => array('B','A','A','A','B'),
'4' => array('A','B','B','A','A'),
'5' => array('A','A','B','B','A'),
'6' => array('A','A','A','B','B'),
'7' => array('A','B','A','B','A'),
'8' => array('A','B','A','A','B'),
'9' => array('A','A','B','A','B')
);
/**
* Calculate checksum
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
return (((3 * (intval($code[0]) + intval($code[2]) + intval($code[4])))
+ (9 * (intval($code[1]) + intval($code[3])))) % 10);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/EanOneThree.php'
<?php
/**
* EanOneThree.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\EanOneThree;
*
* EanOneThree Barcode type class
* EAN 13
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class EanOneThree extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'EAN13';
/**
* Fixed code length
*
* @var int
*/
protected $code_length = 13;
/**
* Check digit
*
* @var int
*/
protected $check = '';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'A' => array( // left odd parity
'0' => '0001101',
'1' => '0011001',
'2' => '0010011',
'3' => '0111101',
'4' => '0100011',
'5' => '0110001',
'6' => '0101111',
'7' => '0111011',
'8' => '0110111',
'9' => '0001011'
),
'B' => array( // left even parity
'0' => '0100111',
'1' => '0110011',
'2' => '0011011',
'3' => '0100001',
'4' => '0011101',
'5' => '0111001',
'6' => '0000101',
'7' => '0010001',
'8' => '0001001',
'9' => '0010111'
),
'C' => array( // right
'0' => '1110010',
'1' => '1100110',
'2' => '1101100',
'3' => '1000010',
'4' => '1011100',
'5' => '1001110',
'6' => '1010000',
'7' => '1000100',
'8' => '1001000',
'9' => '1110100'
)
);
/**
* Map parities
*
* @var array
*/
protected $parities = array(
'0' => 'AAAAAA',
'1' => 'AABABB',
'2' => 'AABBAB',
'3' => 'AABBBA',
'4' => 'ABAABB',
'5' => 'ABBAAB',
'6' => 'ABBBAA',
'7' => 'ABABAB',
'8' => 'ABABBA',
'9' => 'ABBABA'
);
/**
* Calculate checksum
*
* @param $code (string) code to represent.
*
* @return char checksum.
*
* @throws BarcodeException in case of error
*/
protected function getChecksum($code)
{
$data_len = ($this->code_length - 1);
$code_len = strlen($code);
$sum_a = 0;
for ($pos = 1; $pos < $data_len; $pos += 2) {
$sum_a += $code[$pos];
}
if ($this->code_length > 12) {
$sum_a *= 3;
}
$sum_b = 0;
for ($pos = 0; $pos < $data_len; $pos += 2) {
$sum_b += ($code[$pos]);
}
if ($this->code_length < 13) {
$sum_b *= 3;
}
$this->check = ($sum_a + $sum_b) % 10;
if ($this->check > 0) {
$this->check = (10 - $this->check);
}
if ($code_len == $data_len) {
// add check digit
return $this->check;
} elseif ($this->check !== intval($code[$data_len])) {
// wrong check digit
throw new BarcodeException('Invalid check digit: '.$this->check);
}
return '';
}
/**
* Format code
*/
protected function formatCode()
{
$code = str_pad($this->code, ($this->code_length - 1), '0', STR_PAD_LEFT);
$this->extcode = $code.$this->getChecksum($code);
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
if (!is_numeric($this->code)) {
throw new BarcodeException('Input code must be a number');
}
$this->formatCode();
$seq = '101'; // left guard bar
$half_len = intval(ceil($this->code_length / 2));
$parity = $this->parities[$this->extcode[0]];
for ($pos = 1; $pos < $half_len; ++$pos) {
$seq .= $this->chbar[$parity[($pos - 1)]][$this->extcode[$pos]];
}
$seq .= '01010'; // center guard bar
for ($pos = $half_len; $pos < $this->code_length; ++$pos) {
$seq .= $this->chbar['C'][$this->extcode[$pos]];
}
$seq .= '101'; // right guard bar
$this->processBinarySequence($seq);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/EanTwo.php'
<?php
/**
* EanTwo.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\EanTwo;
*
* EanTwo Barcode type class
* EAN 2-Digits UPC-Based Extension
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class EanTwo extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'EAN2';
/**
* Fixed code length
*
* @var int
*/
protected $code_length = 2;
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'A' => array( // left odd parity
'0'=>'0001101',
'1'=>'0011001',
'2'=>'0010011',
'3'=>'0111101',
'4'=>'0100011',
'5'=>'0110001',
'6'=>'0101111',
'7'=>'0111011',
'8'=>'0110111',
'9'=>'0001011'
),
'B' => array( // left even parity
'0'=>'0100111',
'1'=>'0110011',
'2'=>'0011011',
'3'=>'0100001',
'4'=>'0011101',
'5'=>'0111001',
'6'=>'0000101',
'7'=>'0010001',
'8'=>'0001001',
'9'=>'0010111'
)
);
/**
* Map parities
*
* @var array
*/
protected $parities = array(
'0' => array('A','A'),
'1' => array('A','B'),
'2' => array('B','A'),
'3' => array('B','B')
);
/**
* Calculate checksum
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
return (intval($code) % 4);
}
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = str_pad($this->code, $this->code_length, '0', STR_PAD_LEFT);
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->formatCode();
$chk = $this->getChecksum($this->extcode);
$parity = $this->parities[$chk];
$seq = '1011'; // left guard bar
$seq .= $this->chbar[$parity[0]][$this->extcode[0]];
$len = strlen($this->extcode);
for ($pos = 1; $pos < $len; ++$pos) {
$seq .= '01'; // separator
$seq .= $this->chbar[$parity[$pos]][$this->extcode[$pos]];
}
$this->processBinarySequence($seq);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Imb.php'
<?php
/**
* Imb.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Imb;
*
* Imb Barcode type class
* IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
*
* Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
* The fields are described as follows:
* * The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently
* printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use.
* This shall be two digits, with the second digit in the range of 0–4. The allowable encoding ranges shall be
* 00–04, 10–14, 20–24, 30–34, 40–44, 50–54, 60–64, 70–74, 80–84, and 90–94.
* * The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece.
* The allowable encoding range shall be 000http://it2.php.net/manual/en/function.dechex.php–999.
* Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s).
* Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier
* values.
* * The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies
* a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000- 899999, while the
* allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999. The Serial or
* Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces.
* The allowable encoding range shall be 000000000–999999999 when used with a 6 digit Mailer ID and 000000-999999
* when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing
* the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point.
* The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000–99999,
* 000000000–999999999, and 00000000000–99999999999. An hyphen '-' is required before the zip/delivery point.
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Imb extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'IMB';
/**
* ASC characters
*
* @var array
*/
protected static $asc_chr = array(
4,0,2,6,3,5,1,9,8,7,
1,2,0,6,4,8,2,9,5,3,
0,1,3,7,4,6,8,9,2,0,
5,1,9,4,3,8,6,7,1,2,
4,3,9,5,7,8,3,0,2,1,
4,0,9,1,7,0,2,4,6,3,
7,1,9,5,8
);
/**
* DSC characters
*
* @var array
*/
protected static $dsc_chr = array(
7,1,9,5,8,0,2,4,6,3,
5,8,9,7,3,0,6,1,7,4,
6,8,9,2,5,1,7,5,4,3,
8,7,6,0,2,5,4,9,3,0,
1,6,8,2,0,4,5,9,6,7,
5,2,6,3,8,5,1,9,8,7,
4,0,2,6,3);
/**
* ASC positions
*
* @var array
*/
protected static $asc_pos = array(
3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,
6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
/**
* DSC positions
*
* @var array
*/
protected static $dsc_pos = array(
2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,
0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
/**
* Reverse unsigned short value
*
* @param int $num Value to reversr
*
* @return int reversed value
*/
protected function getReversedUnsignedShort($num)
{
$rev = 0;
for ($pos = 0; $pos < 16; ++$pos) {
$rev <<= 1;
$rev |= ($num & 1);
$num >>= 1;
}
return $rev;
}
/**
* Get the Frame Check Sequence
*
* @param array $code_arr Array of hexadecimal values (13 bytes holding 102 bits right justified).
*
* @return int 11 bit Frame Check Sequence as integer (decimal base)
*/
protected function getFrameCheckSequence($code_arr)
{
$genpoly = 0x0F35; // generator polynomial
$fcs = 0x07FF; // Frame Check Sequence
// do most significant byte skipping the 2 most significant bits
$data = hexdec($code_arr[0]) << 5;
for ($bit = 2; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = ($fcs << 1) ^ $genpoly;
} else {
$fcs = ($fcs << 1);
}
$fcs &= 0x7FF;
$data <<= 1;
}
// do rest of bytes
for ($byte = 1; $byte < 13; ++$byte) {
$data = hexdec($code_arr[$byte]) << 3;
for ($bit = 0; $bit < 8; ++$bit) {
if (($fcs ^ $data) & 0x400) {
$fcs = ($fcs << 1) ^ $genpoly;
} else {
$fcs = ($fcs << 1);
}
$fcs &= 0x7FF;
$data <<= 1;
}
}
return $fcs;
}
/**
* Get the Nof13 tables
*
* @param int $type Table type: 2 for 2of13 table, 5 for 5of13table
* @param int $size Table size (78 for n=2 and 1287 for n=5)
*
* @return array requested table
*/
protected function getTables($type, $size)
{
$table = array();
$lli = 0; // LUT lower index
$lui = $size - 1; // LUT upper index
for ($count = 0; $count < 8192; ++$count) {
$bit_count = 0;
for ($bit_index = 0; $bit_index < 13; ++$bit_index) {
$bit_count += intval(($count & (1 << $bit_index)) != 0);
}
// if we don't have the right number of bits on, go on to the next value
if ($bit_count == $type) {
$reverse = ($this->getReversedUnsignedShort($count) >> 3);
// if the reverse is less than count, we have already visited this pair before
if ($reverse >= $count) {
// If count is symmetric, place it at the first free slot from the end of the list.
// Otherwise, place it at the first free slot from the beginning of the list AND place
// $reverse ath the next free slot from the beginning of the list
if ($reverse == $count) {
$table[$lui] = $count;
--$lui;
} else {
$table[$lli] = $count;
++$lli;
$table[$lli] = $reverse;
++$lli;
}
}
}
}
return $table;
}
/**
* Get the routing code binary block
*
* @param string $routing_code the routing code
*
* @return string
*
* @throws BarcodeException in case of error
*/
protected function getRoutingCode($routing_code)
{
// Conversion of Routing Code
switch (strlen($routing_code)) {
case 0:
return 0;
case 5:
return bcadd($routing_code, '1');
case 9:
return bcadd($routing_code, '100001');
case 11:
return bcadd($routing_code, '1000100001');
}
throw new BarcodeException('Invalid routing code');
}
/**
* Get the processed array of characters
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function getCharsArray()
{
$this->ncols = 0;
$this->nrows = 3;
$this->bars = array();
$code_arr = explode('-', $this->code);
$tracking_number = $code_arr[0];
$binary_code = 0;
if (isset($code_arr[1])) {
$binary_code = $this->getRoutingCode($code_arr[1]);
}
$binary_code = bcmul($binary_code, 10);
$binary_code = bcadd($binary_code, $tracking_number[0]);
$binary_code = bcmul($binary_code, 5);
$binary_code = bcadd($binary_code, $tracking_number[1]);
$binary_code .= substr($tracking_number, 2, 18);
// convert to hexadecimal
$binary_code = $this->convertDecToHex($binary_code);
// pad to get 13 bytes
$binary_code = str_pad($binary_code, 26, '0', STR_PAD_LEFT);
// convert string to array of bytes
$binary_code_arr = chunk_split($binary_code, 2, "\r");
$binary_code_arr = substr($binary_code_arr, 0, -1);
$binary_code_arr = explode("\r", $binary_code_arr);
// calculate frame check sequence
$fcs = $this->getFrameCheckSequence($binary_code_arr);
// exclude first 2 bits from first byte
$first_byte = sprintf('%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
$binary_code_102bit = $first_byte.substr($binary_code, 2);
// convert binary data to codewords
$codewords = array();
$data = $this->convertHexToDec($binary_code_102bit);
$codewords[0] = bcmod($data, 636) * 2;
$data = bcdiv($data, 636);
for ($pos = 1; $pos < 9; ++$pos) {
$codewords[$pos] = bcmod($data, 1365);
$data = bcdiv($data, 1365);
}
$codewords[9] = $data;
if (($fcs >> 10) == 1) {
$codewords[9] += 659;
}
// generate lookup tables
$table2of13 = $this->getTables(2, 78);
$table5of13 = $this->getTables(5, 1287);
// convert codewords to characters
$characters = array();
$bitmask = 512;
foreach ($codewords as $val) {
if ($val <= 1286) {
$chrcode = $table5of13[$val];
} else {
$chrcode = $table2of13[($val - 1287)];
}
if (($fcs & $bitmask) > 0) {
// bitwise invert
$chrcode = ((~$chrcode) & 8191);
}
$characters[] = $chrcode;
$bitmask /= 2;
}
return array_reverse($characters);
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$chars = $this->getCharsArray();
for ($pos = 0; $pos < 65; ++$pos) {
$asc = (($chars[self::$asc_chr[$pos]] & pow(2, self::$asc_pos[$pos])) > 0);
$dsc = (($chars[self::$dsc_chr[$pos]] & pow(2, self::$dsc_pos[$pos])) > 0);
if ($asc and $dsc) {
// full bar (F)
$this->bars[] = array($this->ncols, 0, 1, 3);
} elseif ($asc) {
// ascender (A)
$this->bars[] = array($this->ncols, 0, 1, 2);
} elseif ($dsc) {
// descender (D)
$this->bars[] = array($this->ncols, 1, 1, 2);
} else {
// tracker (T)
$this->bars[] = array($this->ncols, 1, 1, 1);
}
$this->ncols += 2;
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/ImbPre.php'
<?php
/**
* ImbPre.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\ImbPre;
*
* ImbPre Barcode type class
* IMB - Intelligent Mail Barcode pre-processed (USPS-B-3200)
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class ImbPre extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'IMBPRE';
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$code = strtolower($this->code);
if (preg_match('/^[fadt]{65}$/', $code) != 1) {
throw new BarcodeException('Invalid character sequence');
}
$this->ncols = 0;
$this->nrows = 3;
$this->bars = array();
for ($pos = 0; $pos < 65; ++$pos) {
switch ($code[$pos]) {
case 'f':
// full bar
$this->bars[] = array($this->ncols, 0, 1, 3);
break;
case 'a':
// ascender
$this->bars[] = array($this->ncols, 0, 1, 2);
break;
case 'd':
// descender
$this->bars[] = array($this->ncols, 1, 1, 2);
break;
case 't':
// tracker (short)
$this->bars[] = array($this->ncols, 1, 1, 1);
break;
}
$this->ncols += 2;
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/InterleavedTwoOfFive.php'
<?php
/**
* InterleavedTwoOfFive.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFive;
*
* InterleavedTwoOfFive Barcode type class
* Interleaved 2 of 5
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class InterleavedTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFiveCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'I25';
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = $this->code;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/InterleavedTwoOfFiveCheck.php'
<?php
/**
* InterleavedTwoOfFiveCheck.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFiveCheck;
*
* InterleavedTwoOfFiveCheck Barcode type class
* Interleaved 2 of 5 + CHECKSUM
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class InterleavedTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFiveCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'I25+';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '11221',
'1' => '21112',
'2' => '12112',
'3' => '22111',
'4' => '11212',
'5' => '21211',
'6' => '12211',
'7' => '11122',
'8' => '21121',
'9' => '12121',
'A' => '11',
'Z' => '21'
);
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = $this->code.$this->getChecksum($this->code);
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->formatCode();
if ((strlen($this->extcode) % 2) != 0) {
// add leading zero if code-length is odd
$this->extcode = '0'.$this->extcode;
}
// add start and stop codes
$this->extcode = 'AA'.strtolower($this->extcode).'ZA';
$this->ncols = 0;
$this->nrows = 1;
$this->bars = array();
$clen = strlen($this->extcode);
for ($idx = 0; $idx < $clen; $idx = ($idx + 2)) {
$char_bar = $this->extcode[$idx];
$char_space = $this->extcode[($idx + 1)];
if ((!isset($this->chbar[$char_bar])) || (!isset($this->chbar[$char_space]))) {
throw new BarcodeException('Invalid character sequence: '.$char_bar.$char_space);
}
// create a bar-space sequence
$seq = '';
$chrlen = strlen($this->chbar[$char_bar]);
for ($pos = 0; $pos < $chrlen; ++$pos) {
$seq .= $this->chbar[$char_bar][$pos].$this->chbar[$char_space][$pos];
}
$seqlen = strlen($seq);
for ($pos = 0; $pos < $seqlen; ++$pos) {
$bar_width = intval($seq[$pos]);
if ((($pos % 2) == 0) && ($bar_width > 0)) {
$this->bars[] = array($this->ncols, 0, $bar_width, 1);
}
$this->ncols += $bar_width;
}
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/KlantIndex.php'
<?php
/**
* KlantIndex.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\KlantIndex;
*
* KlantIndex Barcode type class
* KIX (Klant index - Customer index)
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class KlantIndex extends \Com\Tecnick\Barcode\Type\Linear\RoyalMailFourCc
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'KIX';
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = strtoupper($this->code);
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->ncols = 0;
$this->nrows = 3;
$this->bars = array();
$this->getCoreBars();
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Msi.php'
<?php
/**
* Msi.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Msi;
*
* Msi Barcode type class
* MSI (Variation of Plessey code)
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Msi extends \Com\Tecnick\Barcode\Type\Linear\MsiCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'MSI';
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = $this->code;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/MsiCheck.php'
<?php
/**
* MsiCheck.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2020 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\MsiCheck;
*
* MsiCheck Barcode type class
* MSI + CHECKSUM (modulo 11)
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2020 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class MsiCheck extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'MSI+';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '100100100100',
'1' => '100100100110',
'2' => '100100110100',
'3' => '100100110110',
'4' => '100110100100',
'5' => '100110100110',
'6' => '100110110100',
'7' => '100110110110',
'8' => '110100100100',
'9' => '110100100110',
'A' => '110100110100',
'B' => '110100110110',
'C' => '110110100100',
'D' => '110110100110',
'E' => '110110110100',
'F' => '110110110110'
);
/**
* Calculate the checksum
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
$clen = strlen($code);
$pix = 2;
$check = 0;
for ($pos = ($clen - 1); $pos >= 0; --$pos) {
$hex = $code[$pos];
if (!ctype_xdigit($hex)) {
continue;
}
$check += (hexdec($hex) * $pix);
++$pix;
if ($pix > 7) {
$pix = 2;
}
}
$check %= 11;
if ($check > 0) {
$check = (11 - $check);
}
return $check;
}
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = $this->code.$this->getChecksum($this->code);
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->formatCode();
$seq = '110'; // left guard
$clen = strlen($this->extcode);
for ($pos = 0; $pos < $clen; ++$pos) {
$digit = $this->extcode[$pos];
if (!isset($this->chbar[$digit])) {
throw new BarcodeException('Invalid character: chr('.ord($digit).')');
}
$seq .= $this->chbar[$digit];
}
$seq .= '1001'; // right guard
$this->processBinarySequence($seq);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Pharma.php'
<?php
/**
* Pharma.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Pharma;
*
* Pharma Barcode type class
* PHARMACODE
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Pharma extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'PHARMA';
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$seq = '';
$code = intval($this->code);
while ($code > 0) {
if (($code % 2) == 0) {
$seq .= '11100';
$code -= 2;
} else {
$seq .= '100';
$code -= 1;
}
$code /= 2;
}
$seq = substr($seq, 0, -2);
$seq = strrev($seq);
$this->processBinarySequence($seq);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/PharmaTwoTracks.php'
<?php
/**
* PharmaTwoTracks.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\PharmaTwoTracks;
*
* PharmaTwoTracks Barcode type class
* PHARMACODE TWO-TRACKS
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class PharmaTwoTracks extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'PHARMA2T';
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$seq = '';
$code = intval($this->code);
do {
switch ($code % 3) {
case 0:
$seq .= '3';
$code = (($code - 3) / 3);
break;
case 1:
$seq .= '1';
$code = (($code - 1) / 3);
break;
case 2:
$seq .= '2';
$code = (($code - 2) / 3);
}
} while ($code != 0);
$seq = strrev($seq);
$this->ncols = 0;
$this->nrows = 2;
$this->bars = array();
$len = strlen($seq);
for ($pos = 0; $pos < $len; ++$pos) {
switch ($seq[$pos]) {
case '1':
$this->bars[] = array($this->ncols, 1, 1, 1);
break;
case '2':
$this->bars[] = array($this->ncols, 0, 1, 1);
break;
case '3':
$this->bars[] = array($this->ncols, 0, 1, 2);
break;
}
$this->ncols += 2;
}
--$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Planet.php'
<?php
/**
* Planet.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Planet;
*
* Planet Barcode type class
* PLANET
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Planet extends \Com\Tecnick\Barcode\Type\Linear\Postnet
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'PLANET';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '11222',
'1' => '22211',
'2' => '22121',
'3' => '22112',
'4' => '21221',
'5' => '21212',
'6' => '21122',
'7' => '12221',
'8' => '12212',
'9' => '12122'
);
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Postnet.php'
<?php
/**
* Postnet.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Postnet;
*
* Postnet Barcode type class
* POSTNET
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Postnet extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'POSTNET';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '22111',
'1' => '11122',
'2' => '11212',
'3' => '11221',
'4' => '12112',
'5' => '12121',
'6' => '12211',
'7' => '21112',
'8' => '21121',
'9' => '21211'
);
/**
* Calculate the checksum.
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
$sum = 0;
$len = strlen($code);
for ($pos = 0; $pos < $len; ++$pos) {
$sum += intval($code[$pos]);
}
$check = ($sum % 10);
if ($check > 0) {
$check = (10 - $check);
}
return $check;
}
/**
* Format code
*/
protected function formatCode()
{
$code = preg_replace('/[-\s]+/', '', $this->code);
$this->extcode = $code.$this->getChecksum($code);
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->ncols = 0;
$this->nrows = 2;
$this->bars = array();
$this->formatCode();
$clen = strlen($this->extcode);
// start bar
$this->bars[] = array($this->ncols, 0, 1, 2);
$this->ncols += 2;
for ($chr = 0; $chr < $clen; ++$chr) {
$char = $this->extcode[$chr];
if (!isset($this->chbar[$char])) {
throw new BarcodeException('Invalid character: chr('.ord($char).')');
}
for ($pos = 0; $pos < 5; ++$pos) {
$bar_height = intval($this->chbar[$char][$pos]);
$this->bars[] = array($this->ncols, floor(1 / $bar_height), 1, $bar_height);
$this->ncols += 2;
}
}
// end bar
$this->bars[] = array($this->ncols, 0, 1, 2);
++$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/Raw.php'
<?php
/**
* Raw.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\Raw
*
* Raw Barcode type class
* RAW MODE (comma-separated rows)
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class Raw extends \Com\Tecnick\Barcode\Type\Raw
{
/**
* Barcode type
*
* @var string
*/
protected $type = 'linear';
/**
* Barcode format
*
* @var string
*/
protected $format = 'LRAW';
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/RoyalMailFourCc.php'
<?php
/**
* RoyalMailFourCC.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\RoyalMailFourCc;
*
* RoyalMailFourCC Barcode type class
* RMS4CC (Royal Mail 4-state Customer Bar Code)
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class RoyalMailFourCc extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'RMS4CC';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '3322',
'1' => '3412',
'2' => '3421',
'3' => '4312',
'4' => '4321',
'5' => '4411',
'6' => '3142',
'7' => '3232',
'8' => '3241',
'9' => '4132',
'A' => '4141',
'B' => '4231',
'C' => '3124',
'D' => '3214',
'E' => '3223',
'F' => '4114',
'G' => '4123',
'H' => '4213',
'I' => '1342',
'J' => '1432',
'K' => '1441',
'L' => '2332',
'M' => '2341',
'N' => '2431',
'O' => '1324',
'P' => '1414',
'Q' => '1423',
'R' => '2314',
'S' => '2323',
'T' => '2413',
'U' => '1144',
'V' => '1234',
'W' => '1243',
'X' => '2134',
'Y' => '2143',
'Z' => '2233'
);
/**
* Characters used for checksum
*
* @var array
*/
protected $chksum = array(
'0' => '11',
'1' => '12',
'2' => '13',
'3' => '14',
'4' => '15',
'5' => '10',
'6' => '21',
'7' => '22',
'8' => '23',
'9' => '24',
'A' => '25',
'B' => '20',
'C' => '31',
'D' => '32',
'E' => '33',
'F' => '34',
'G' => '35',
'H' => '30',
'I' => '41',
'J' => '42',
'K' => '43',
'L' => '44',
'M' => '45',
'N' => '40',
'O' => '51',
'P' => '52',
'Q' => '53',
'R' => '54',
'S' => '55',
'T' => '50',
'U' => '01',
'V' => '02',
'W' => '03',
'X' => '04',
'Y' => '05',
'Z' => '00'
);
/**
* Calculate the checksum.
*
* @param $code (string) code to represent.
*
* @return char checksum.
*
* @throws BarcodeException in case of error
*/
protected function getChecksum($code)
{
$row = 0;
$col = 0;
$len = strlen($code);
for ($pos = 0; $pos < $len; ++$pos) {
$char = $code[$pos];
if (!isset($this->chksum[$char])) {
throw new BarcodeException('Invalid character: chr('.ord($char).')');
}
$row += intval($this->chksum[$char][0]);
$col += intval($this->chksum[$char][1]);
}
$row %= 6;
$col %= 6;
$check = array_keys($this->chksum, $row.$col);
return $check[0];
}
/**
* Format code
*/
protected function formatCode()
{
$code = strtoupper($this->code);
$this->extcode = $code.$this->getChecksum($code);
}
/**
* Get the central bars
*
* @throws BarcodeException in case of error
*/
protected function getCoreBars()
{
$this->formatCode();
$clen = strlen($this->extcode);
for ($chr = 0; $chr < $clen; ++$chr) {
$char = $this->extcode[$chr];
for ($pos = 0; $pos < 4; ++$pos) {
switch ($this->chbar[$char][$pos]) {
case '1':
$this->bars[] = array($this->ncols, 0, 1, 2);
break;
case '2':
$this->bars[] = array($this->ncols, 0, 1, 3);
break;
case '3':
$this->bars[] = array($this->ncols, 1, 1, 1);
break;
case '4':
$this->bars[] = array($this->ncols, 1, 1, 2);
break;
}
$this->ncols +=2;
}
}
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->ncols = 0;
$this->nrows = 3;
$this->bars = array();
// start bar
$this->bars[] = array($this->ncols, 0, 1, 2);
$this->ncols += 2;
$this->getCoreBars();
// stop bar
$this->bars[] = array($this->ncols, 0, 1, 3);
++$this->ncols;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/StandardTwoOfFive.php'
<?php
/**
* StandardTwoOfFive.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFive;
*
* StandardTwoOfFive Barcode type class
* Standard 2 of 5
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class StandardTwoOfFive extends \Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFiveCheck
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'S25';
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = $this->code;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/StandardTwoOfFiveCheck.php'
<?php
/**
* StandardTwoOfFiveCheck.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\StandardTwoOfFiveCheck;
*
* StandardTwoOfFiveCheck Barcode type class
* Standard 2 of 5 + CHECKSUM
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class StandardTwoOfFiveCheck extends \Com\Tecnick\Barcode\Type\Linear
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'S25+';
/**
* Map characters to barcodes
*
* @var array
*/
protected $chbar = array(
'0' => '10101110111010',
'1' => '11101010101110',
'2' => '10111010101110',
'3' => '11101110101010',
'4' => '10101110101110',
'5' => '11101011101010',
'6' => '10111011101010',
'7' => '10101011101110',
'8' => '11101010111010',
'9' => '10111010111010'
);
/**
* Calculate the checksum
*
* @param $code (string) code to represent.
*
* @return char checksum.
*/
protected function getChecksum($code)
{
$clen = strlen($code);
$sum = 0;
for ($idx = 0; $idx < $clen; $idx+=2) {
$sum += intval($code[$idx]);
}
$sum *= 3;
for ($idx = 1; $idx < $clen; $idx+=2) {
$sum += intval($code[$idx]);
}
$check = $sum % 10;
if ($check > 0) {
$check = (10 - $check);
}
return $check;
}
/**
* Format code
*/
protected function formatCode()
{
$this->extcode = $this->code.$this->getChecksum($this->code);
}
/**
* Get the bars array
*
* @return array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->formatCode();
if ((strlen($this->extcode) % 2) != 0) {
// add leading zero if code-length is odd
$this->extcode = '0'.$this->extcode;
}
$seq = '1110111010';
$clen = strlen($this->extcode);
for ($idx = 0; $idx < $clen; ++$idx) {
$digit = $this->extcode[$idx];
if (!isset($this->chbar[$digit])) {
throw new BarcodeException('Invalid character: chr('.ord($digit).')');
}
$seq .= $this->chbar[$digit];
}
$seq .= '111010111';
$this->processBinarySequence($seq);
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/UpcA.php'
<?php
/**
* UpcA.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\UpcA;
*
* UpcA Barcode type class
* UPC-A
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2016 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class UpcA extends \Com\Tecnick\Barcode\Type\Linear\EanOneThree
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'UPCA';
/**
* Fixed code length
*
* @var int
*/
protected $code_length = 12;
/**
* Format the code
*/
protected function formatCode()
{
$code = str_pad($this->code, ($this->code_length - 1), '0', STR_PAD_LEFT);
$code .= $this->getChecksum($code);
++$this->code_length;
$this->extcode = '0'.$code;
}
}
wget 'https://lists2.roe3.org/hesk/inc/tecnick/Barcode/Type/Linear/UpcE.php'
<?php
/**
* UpcE.php
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2019 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*
* This file is part of tc-lib-barcode software library.
*/
namespace Com\Tecnick\Barcode\Type\Linear;
use \Com\Tecnick\Barcode\Exception as BarcodeException;
/**
* Com\Tecnick\Barcode\Type\Linear\UpcE;
*
* UpcE Barcode type class
* UPC-E
*
* UPC-E is a variation of UPC-A which allows for a more compact barcode by eliminating "extra" zeros.
* Since the resulting UPC-E barcode is about half the size as an UPC-A barcode, UPC-E is generally used on products
* with very small packaging where a full UPC-A barcode couldn't reasonably fit.
*
* @since 2015-02-21
* @category Library
* @package Barcode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2010-2019 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-barcode
*/
class UpcE extends \Com\Tecnick\Barcode\Type\Linear\UpcA
{
/**
* Barcode format
*
* @var string
*/
protected $format = 'UPCE';
/**
* Fixed code length
*
* @var int
*/
protected $code_length = 12;
/**
* Map parities
*
* @var array
*/
protected $parities = array(
0 => array(
'0' => array('B','B','B','A','A','A'),
'1' => array('B','B','A','B','A','A'),
'2' => array('B','B','A','A','B','A'),
'3' => array('B','B','A','A','A','B'),
'4' => array('B','A','B','B','A','A'),
'5' => array('B','A','A','B','B','A'),
'6' => array('B','A','A','A','B','B'),
'7' => array('B','A','B','A','B','A'),
'8' => array('B','A','B','A','A','B'),
'9' => array('B','A','A','B','A','B')
),
1 => array(
'0' => array('A','A','A','B','B','B'),
'1' => array('A','A','B','A','B','B'),
'2' => array('A','A','B','B','A','B'),
'3' => array('A','A','B','B','B','A'),
'4' => array('A','B','A','A','B','B'),
'5' => array('A','B','B','A','A','B'),
'6' => array('A','B','B','B','A','A'),
'7' => array('A','B','A','B','A','B'),
'8' => array('A','B','A','B','B','A'),
'9' => array('A','B','B','A','B','A')
)
);
/**
* Convert UPC-E code to UPC-A
*
* @param string $code Code to convert.
*
* @return string
*/
protected function convertUpceToUpca($code)
{
if ($code[5] < 3) {
return '0'.$code[0].$code[1].$code[5].'0000'.$code[2].$code[3].$code[4];
}
if ($code[5] == 3) {
return '0'.$code[0].$code[1].$code[2].'00000'.$code[3].$code[4];
}
if ($code[5] == 4) {
return '0'.$code[0].$code[1].$code[2].$code[3].'00000'.$code[4];
}
return '0'.$code[0].$code[1].$code[2].$code[3].$code[4].'0000'.$code[5];
}
/**
* Convert UPC-A code to UPC-E
*
* @param string $code Code to convert.
*
* @return string
*/
protected function convertUpcaToUpce($code)
{
$tmp = substr($code, 4, 3);
if (($tmp == '000') || ($tmp == '100') || ($tmp == '200')) {
// manufacturer code ends in 000, 100, or 200
return substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
}
$tmp = substr($code, 5, 2);
if ($tmp == '00') {
// manufacturer code ends in 00
return substr($code, 2, 3).substr($code, 10, 2).'3';
}
$tmp = substr($code, 6, 1);
if ($tmp == '0') {
// manufacturer code ends in 0
return substr($code, 2, 4).substr($code, 11, 1).'4';
}
// manufacturer code does not end in zero
return substr($code, 2, 5).substr($code, 11, 1);
}
/**
* Format the code
*/
protected function formatCode()
{
$code = $this->code;
if (strlen($code) == 6) {
$code = $this->convertUpceToUpca($code);
}
$code = str_pad($code, ($this->code_length - 1), '0', STR_PAD_LEFT);
$code .= $this->getChecksum($code);
++$this->code_length;
$this->extcode = '0'.$code;
}
/**
* Get the bars array
*
* @throws BarcodeException in case of error
*/
protected function setBars()
{
$this->formatCode();
$upce_code = $this->convertUpcaToUpce($this->extcode);
$seq = '101'; // left guard bar
$parity = $this->parities[$this->extcode[1]][$this->check];
for ($pos = 0; $pos < 6; ++$pos) {
$seq .= $this->chbar[$parity[$pos]][$upce_code[$pos]];
}
$seq .= '010101'; // right guard bar
$this->processBinarySequence($seq);
}
}