Lines Matching refs:code

65 	 * <li>$arrcode['code'] code to be printed on text label</li>
73 * @param $code (string) code to print
74 * @param $type (string) type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128 : CODE 128</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extension</li><li>EAN5 : 5-Digits UPC-Based Extension</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
77 public function __construct($code, $type) {
78 $this->setBarcode($code, $type);
92 * @param $code (string) code to print
93 * @param $type (string) type of barcode: <ul><li>C39 : CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.</li><li>C39+ : CODE 39 with checksum</li><li>C39E : CODE 39 EXTENDED</li><li>C39E+ : CODE 39 EXTENDED + CHECKSUM</li><li>C93 : CODE 93 - USS-93</li><li>S25 : Standard 2 of 5</li><li>S25+ : Standard 2 of 5 + CHECKSUM</li><li>I25 : Interleaved 2 of 5</li><li>I25+ : Interleaved 2 of 5 + CHECKSUM</li><li>C128 : CODE 128</li><li>C128A : CODE 128 A</li><li>C128B : CODE 128 B</li><li>C128C : CODE 128 C</li><li>EAN2 : 2-Digits UPC-Based Extension</li><li>EAN5 : 5-Digits UPC-Based Extension</li><li>EAN8 : EAN 8</li><li>EAN13 : EAN 13</li><li>UPCA : UPC-A</li><li>UPCE : UPC-E</li><li>MSI : MSI (Variation of Plessey code)</li><li>MSI+ : MSI + CHECKSUM (modulo 11)</li><li>POSTNET : POSTNET</li><li>PLANET : PLANET</li><li>RMS4CC : RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)</li><li>KIX : KIX (Klant index - Customer index)</li><li>IMB: Intelligent Mail Barcode - Onecode - USPS-B-3200</li><li>IMBPRE: Pre-processed Intelligent Mail Barcode - Onecode - USPS-B-3200, using only F,A,D,T letters</li><li>CODABAR : CODABAR</li><li>CODE11 : CODE 11</li><li>PHARMA : PHARMACODE</li><li>PHARMA2T : PHARMACODE TWO-TRACKS</li></ul>
97 public function setBarcode($code, $type) {
100 $arrcode = $this->barcode_code39($code, false, false);
104 $arrcode = $this->barcode_code39($code, false, true);
108 $arrcode = $this->barcode_code39($code, true, false);
112 $arrcode = $this->barcode_code39($code, true, true);
116 $arrcode = $this->barcode_code93($code);
120 $arrcode = $this->barcode_s25($code, false);
124 $arrcode = $this->barcode_s25($code, true);
128 $arrcode = $this->barcode_i25($code, false);
132 $arrcode = $this->barcode_i25($code, true);
136 $arrcode = $this->barcode_c128($code, '');
140 $arrcode = $this->barcode_c128($code, 'A');
144 $arrcode = $this->barcode_c128($code, 'B');
148 $arrcode = $this->barcode_c128($code, 'C');
152 $arrcode = $this->barcode_eanext($code, 2);
156 $arrcode = $this->barcode_eanext($code, 5);
160 $arrcode = $this->barcode_eanupc($code, 8);
164 $arrcode = $this->barcode_eanupc($code, 13);
168 $arrcode = $this->barcode_eanupc($code, 12);
172 $arrcode = $this->barcode_eanupc($code, 6);
175 case 'MSI': { // MSI (Variation of Plessey code)
176 $arrcode = $this->barcode_msi($code, false);
180 $arrcode = $this->barcode_msi($code, true);
184 $arrcode = $this->barcode_postnet($code, false);
188 $arrcode = $this->barcode_postnet($code, true);
192 $arrcode = $this->barcode_rms4cc($code, false);
196 $arrcode = $this->barcode_rms4cc($code, true);
200 $arrcode = $this->barcode_imb($code);
204 $arrcode = $this->barcode_imb_pre($code);
208 $arrcode = $this->barcode_codabar($code);
212 $arrcode = $this->barcode_code11($code);
216 $arrcode = $this->barcode_pharmacode($code);
220 $arrcode = $this->barcode_pharmacode2t($code);
234 * General-purpose code in very wide use world-wide
235 * @param $code (string) code to represent.
237 * @param $checksum (boolean) if true add a checksum to the code.
241 protected function barcode_code39($code, $extended=false, $checksum=false) {
286 $code = strtoupper($code);
289 $code = $this->encode_code39_ext($code);
291 if ($code === false) {
296 $code .= $this->checksum_code39($code);
299 $code = '*'.$code.'*';
300 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
302 $clen = strlen($code);
304 $char = $code[$i];
330 * @param $code (string) code to represent.
334 protected function encode_code39_ext($code) {
369 $clen = strlen($code);
371 if (ord($code[$i]) > 127) {
374 $code_ext .= $encode[$code[$i]];
381 * @param $code (string) code to represent.
385 protected function checksum_code39($code) {
392 $clen = strlen($code);
394 $k = array_keys($chars, $code[$i]);
403 * Compact code similar to Code 39
404 * @param $code (string) code to represent.
408 protected function barcode_code93($code) {
457 $code = strtoupper($code);
492 $clen = strlen($code);
494 if (ord($code[$i]) > 127) {
497 $code_ext .= $encode[$code[$i]];
502 $code = '*'.$code_ext.'*';
503 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
505 $clen = strlen($code);
507 $char = ord($code[$i]);
532 * @param $code (string) code to represent.
533 * @return string checksum code.
536 protected function checksum_code93($code) {
544 $code = strtr($code, chr(128).chr(131).chr(129).chr(130), '<=>?');
545 $len = strlen($code);
550 $k = array_keys($chars, $code[$i]);
559 $code .= $c;
564 $k = array_keys($chars, $code[$i]);
581 * @param $code (string) code to process.
585 protected function checksum_s25($code) {
586 $len = strlen($code);
589 $sum += $code[$i];
593 $sum += ($code[$i]);
604 * Variation of Plessey code, with similar applications
606 * @param $code (string) code to represent.
607 * @param $checksum (boolean) if true add a checksum to the code (modulo 11)
611 protected function barcode_msi($code, $checksum=false) {
630 $clen = strlen($code);
634 $check += (hexdec($code[$i]) * $p);
644 $code .= $check;
647 $clen = strlen($code);
649 $digit = $code[$i];
657 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
665 * @param $code (string) code to represent.
666 * @param $checksum (boolean) if true add a checksum to the code
670 protected function barcode_s25($code, $checksum=false) {
683 $code .= $this->checksum_s25($code);
685 if((strlen($code) % 2) != 0) {
686 // add leading zero if code-length is odd
687 $code = '0'.$code;
690 $clen = strlen($code);
692 $digit = $code[$i];
700 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
735 * Compact numeric code, widely used in industry, air cargo
737 * @param $code (string) code to represent.
738 * @param $checksum (boolean) if true add a checksum to the code
742 protected function barcode_i25($code, $checksum=false) {
757 $code .= $this->checksum_s25($code);
759 if((strlen($code) % 2) != 0) {
760 // add leading zero if code-length is odd
761 $code = '0'.$code;
764 $code = 'AA'.strtolower($code).'ZA';
766 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
768 $clen = strlen($code);
770 $char_bar = $code[$i];
771 $char_space = $code[$i+1];
800 * Very capable code, excellent density, high reliability; in very wide use world-wide
801 * @param $code (string) code to represent.
806 protected function barcode_c128($code, $type='') {
917 // ASCII characters for code A (ASCII 00 - 95)
923 // ASCII characters for code B (ASCII 32 - 127)
930 // length of the code
931 $len = strlen($code);
936 $char = $code[$i];
951 $char = $code[$i];
965 if (ord($code[0]) == 241) {
967 $code = substr($code, 1);
975 $chrnum = $code[$i].$code[$i+1];
985 // split code into sequences
989 preg_match_all('/([0-9]{4,})/', $code, $numseq, PREG_OFFSET_CAPTURE);
996 $sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset, ($offset - $end_offset))));
1004 $sequence[] = array('C', substr($code, $offset, $slen), $slen);
1008 $sequence = array_merge($sequence, $this->get128ABsequence(substr($code, $end_offset)));
1011 // text code (non C mode)
1012 $sequence = array_merge($sequence, $this->get128ABsequence($code));
1110 // add start code at the beginning
1113 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1131 * Split text code in A/B sequence for 128 code
1132 * @param $code (string) code to split.
1136 protected function get128ABsequence($code) {
1137 $len = strlen($code);
1141 preg_match_all('/([\0-\31])/', $code, $numseq, PREG_OFFSET_CAPTURE);
1148 $sequence[] = array('B', substr($code, $end_offset, ($offset - $end_offset)), ($offset - $end_offset));
1152 $sequence[] = array('A', substr($code, $offset, $slen), $slen);
1156 $sequence[] = array('B', substr($code, $end_offset), ($len - $end_offset));
1160 $sequence[] = array('B', $code, $len);
1167 * EAN13: European Article Numbering international retail product code
1168 * UPC-A: Universal product code seen on almost all retail products in the USA and Canada
1170 * @param $code (string) code to represent.
1175 protected function barcode_eanupc($code, $len=13) {
1183 $code = str_pad($code, $data_len, '0', STR_PAD_LEFT);
1184 $code_len = strlen($code);
1188 $sum_a += $code[$i];
1195 $sum_b += ($code[$i]);
1206 $code .= $r;
1207 } elseif ($r !== intval($code[$data_len])) {
1213 $code = '0'.$code;
1218 $tmp = substr($code, 4, 3);
1220 // manufacturer code ends in 000, 100, or 200
1221 $upce_code = substr($code, 2, 2).substr($code, 9, 3).substr($code, 4, 1);
1223 $tmp = substr($code, 5, 2);
1225 // manufacturer code ends in 00
1226 $upce_code = substr($code, 2, 3).substr($code, 10, 2).'3';
1228 $tmp = substr($code, 6, 1);
1230 // manufacturer code ends in 0
1231 $upce_code = substr($code, 2, 4).substr($code, 11, 1).'4';
1233 // manufacturer code does not end in zero
1234 $upce_code = substr($code, 2, 5).substr($code, 11, 1);
1315 $bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1316 $p = $upce_parities[$code[1]][$r];
1322 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1326 $seq .= $codes['A'][$code[$i]];
1329 $p = $parities[$code[0]];
1331 $seq .= $codes[$p[$i-1]][$code[$i]];
1336 $seq .= $codes['C'][$code[$i]];
1363 * @param $code (string) code to represent.
1368 protected function barcode_eanext($code, $len=5) {
1370 $code = str_pad($code, $len, '0', STR_PAD_LEFT);
1373 $r = $code % 4;
1375 $r = (3 * ($code[0] + $code[2] + $code[4])) + (9 * ($code[1] + $code[3]));
1426 $seq .= $codes[$p[0]][$code[0]];
1429 $seq .= $codes[$p[$i]][$code[$i]];
1431 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1438 * @param $code (string) zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD.
1443 protected function barcode_postnet($code, $planet=false) {
1472 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
1474 $code = str_replace('-', '', $code);
1475 $code = str_replace(' ', '', $code);
1476 $len = strlen($code);
1480 $sum += intval($code[$i]);
1486 $code .= $chkd;
1487 $len = strlen($code);
1494 $h = $barlen[$code[$i]][$j];
1511 * @param $code (string) code to print
1512 * @param $kix (boolean) if true prints the KIX variation (doesn't use the start and end symbols, and the checksum) - in this case the house number must be sufficed with an X and placed at the end of the code.
1516 protected function barcode_rms4cc($code, $kix=false) {
1561 $code = strtoupper($code);
1562 $len = strlen($code);
1563 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
1607 $row += $checktable[$code[$i]][0];
1608 $col += $checktable[$code[$i]][1];
1613 $code .= $chk[0];
1625 switch ($barmode[$code[$i]][$j]) {
1662 * Older code often used in library systems, sometimes in blood banks
1663 * @param $code (string) code to represent.
1667 protected function barcode_codabar($code) {
1690 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1694 $code = 'A'.strtoupper($code).'A';
1695 $len = strlen($code);
1697 if (!isset($chr[$code[$i]])) {
1700 $seq = $chr[$code[$i]];
1719 * @param $code (string) code to represent.
1723 protected function barcode_code11($code) {
1738 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1742 $len = strlen($code);
1747 $digit = $code[$i];
1763 $code .= $check;
1769 $digit = $code[$i];
1782 $code .= $check;
1785 $code = 'S'.$code.'S';
1788 if (!isset($chr[$code[$i]])) {
1791 $seq = $chr[$code[$i]];
1810 * @param $code (string) code to represent.
1814 protected function barcode_pharmacode($code) {
1816 $code = intval($code);
1817 while ($code > 0) {
1818 if (($code % 2) == 0) {
1820 $code -= 2;
1823 $code -= 1;
1825 $code /= 2;
1829 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array());
1836 * @param $code (string) code to represent.
1840 protected function barcode_pharmacode2t($code) {
1842 $code = intval($code);
1844 switch ($code % 3) {
1847 $code = ($code - 3) / 3;
1852 $code = ($code - 1) / 3;
1857 $code = ($code - 2) / 3;
1861 } while($code != 0);
1864 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 2, 'bcode' => array());
1896 * Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
1898 * @param $code (string) code to print, separate the ZIP (routing code) from the rest using a minus char '-' (BarcodeID_ServiceTypeID_MailerID_SerialNumber-RoutingCode)
1902 protected function barcode_imb($code) {
1907 $code_arr = explode('-', $code);
1990 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());
2023 * @param $code (string) pre-formatted IMB barcode (65 chars "FADT")
2027 protected function barcode_imb_pre($code) {
2028 if (!preg_match('/^[fadtFADT]{65}$/', $code) == 1) {
2031 $characters = str_split(strtolower($code), 1);
2034 $bararray = array('code' => $code, 'maxw' => 0, 'maxh' => 3, 'bcode' => array());