| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- // Copyright (C) 2002-2015 Nicola Asuni - Tecnick.com LTD
- //
- // This file was part of TCPDF software library.
- //
- // TCPDF is free software: you can redistribute it and/or modify it
- // under the terms of the GNU Lesser General Public License as
- // published by the Free Software Foundation, either version 3 of the
- // License, or (at your option) any later version.
- //
- // TCPDF is distributed in the hope that it will be useful, but
- // WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // See the GNU Lesser General Public License for more details.
- //
- // You should have received a copy of the License
- // along with TCPDF. If not, see
- // <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
- //
- // See LICENSE.TXT file for more information.
- namespace app\librarys\Picqer\Barcode;
- use app\librarys\Picqer\Barcode\Exceptions\UnknownTypeException;
- use app\librarys\Picqer\Barcode\Types\TypeCodabar;
- use app\librarys\Picqer\Barcode\Types\TypeCode11;
- use app\librarys\Picqer\Barcode\Types\TypeCode128;
- use app\librarys\Picqer\Barcode\Types\TypeCode128A;
- use app\librarys\Picqer\Barcode\Types\TypeCode128B;
- use app\librarys\Picqer\Barcode\Types\TypeCode128C;
- use app\librarys\Picqer\Barcode\Types\TypeCode32;
- use app\librarys\Picqer\Barcode\Types\TypeCode39;
- use app\librarys\Picqer\Barcode\Types\TypeCode39Checksum;
- use app\librarys\Picqer\Barcode\Types\TypeCode39Extended;
- use app\librarys\Picqer\Barcode\Types\TypeCode39ExtendedChecksum;
- use app\librarys\Picqer\Barcode\Types\TypeCode93;
- use app\librarys\Picqer\Barcode\Types\TypeEan13;
- use app\librarys\Picqer\Barcode\Types\TypeEan8;
- use app\librarys\Picqer\Barcode\Types\TypeIntelligentMailBarcode;
- use app\librarys\Picqer\Barcode\Types\TypeInterleaved25;
- use app\librarys\Picqer\Barcode\Types\TypeInterleaved25Checksum;
- use app\librarys\Picqer\Barcode\Types\TypeKix;
- use app\librarys\Picqer\Barcode\Types\TypeMsi;
- use app\librarys\Picqer\Barcode\Types\TypeMsiChecksum;
- use app\librarys\Picqer\Barcode\Types\TypePharmacode;
- use app\librarys\Picqer\Barcode\Types\TypePharmacodeTwoCode;
- use app\librarys\Picqer\Barcode\Types\TypePlanet;
- use app\librarys\Picqer\Barcode\Types\TypePostnet;
- use app\librarys\Picqer\Barcode\Types\TypeRms4cc;
- use app\librarys\Picqer\Barcode\Types\TypeStandard2of5;
- use app\librarys\Picqer\Barcode\Types\TypeStandard2of5Checksum;
- use app\librarys\Picqer\Barcode\Types\TypeUpcA;
- use app\librarys\Picqer\Barcode\Types\TypeUpcE;
- use app\librarys\Picqer\Barcode\Types\TypeUpcExtension2;
- use app\librarys\Picqer\Barcode\Types\TypeUpcExtension5;
- abstract class BarcodeGenerator
- {
- const TYPE_CODE_32 = 'C32';
- const TYPE_CODE_39 = 'C39';
- const TYPE_CODE_39_CHECKSUM = 'C39+';
- const TYPE_CODE_39E = 'C39E'; // CODE 39 EXTENDED
- const TYPE_CODE_39E_CHECKSUM = 'C39E+'; // CODE 39 EXTENDED + CHECKSUM
- const TYPE_CODE_93 = 'C93';
- const TYPE_STANDARD_2_5 = 'S25';
- const TYPE_STANDARD_2_5_CHECKSUM = 'S25+';
- const TYPE_INTERLEAVED_2_5 = 'I25';
- const TYPE_INTERLEAVED_2_5_CHECKSUM = 'I25+';
- const TYPE_CODE_128 = 'C128';
- const TYPE_CODE_128_A = 'C128A';
- const TYPE_CODE_128_B = 'C128B';
- const TYPE_CODE_128_C = 'C128C';
- const TYPE_EAN_2 = 'EAN2'; // 2-Digits UPC-Based Extention
- const TYPE_EAN_5 = 'EAN5'; // 5-Digits UPC-Based Extention
- const TYPE_EAN_8 = 'EAN8';
- const TYPE_EAN_13 = 'EAN13';
- const TYPE_UPC_A = 'UPCA';
- const TYPE_UPC_E = 'UPCE';
- const TYPE_MSI = 'MSI'; // MSI (Variation of Plessey code)
- const TYPE_MSI_CHECKSUM = 'MSI+'; // MSI + CHECKSUM (modulo 11)
- const TYPE_POSTNET = 'POSTNET';
- const TYPE_PLANET = 'PLANET';
- const TYPE_RMS4CC = 'RMS4CC'; // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
- const TYPE_KIX = 'KIX'; // KIX (Klant index - Customer index)
- const TYPE_IMB = 'IMB'; // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
- const TYPE_CODABAR = 'CODABAR';
- const TYPE_CODE_11 = 'CODE11';
- const TYPE_PHARMA_CODE = 'PHARMA';
- const TYPE_PHARMA_CODE_TWO_TRACKS = 'PHARMA2T';
- protected function getBarcodeData(string $code, string $type): Barcode
- {
- $barcodeDataBuilder = $this->createDataBuilderForType($type);
- return $barcodeDataBuilder->getBarcodeData($code);
- }
- protected function createDataBuilderForType(string $type)
- {
- switch (strtoupper($type)) {
- case self::TYPE_CODE_32:
- return new TypeCode32();
-
- case self::TYPE_CODE_39:
- return new TypeCode39();
- case self::TYPE_CODE_39_CHECKSUM:
- return new TypeCode39Checksum();
- case self::TYPE_CODE_39E:
- return new TypeCode39Extended();
- case self::TYPE_CODE_39E_CHECKSUM:
- return new TypeCode39ExtendedChecksum();
- case self::TYPE_CODE_93:
- return new TypeCode93();
- case self::TYPE_STANDARD_2_5:
- return new TypeStandard2of5();
- case self::TYPE_STANDARD_2_5_CHECKSUM:
- return new TypeStandard2of5Checksum();
- case self::TYPE_INTERLEAVED_2_5:
- return new TypeInterleaved25();
- case self::TYPE_INTERLEAVED_2_5_CHECKSUM:
- return new TypeInterleaved25Checksum();
- case self::TYPE_CODE_128:
- return new TypeCode128();
- case self::TYPE_CODE_128_A:
- return new TypeCode128A();
- case self::TYPE_CODE_128_B:
- return new TypeCode128B();
- case self::TYPE_CODE_128_C:
- return new TypeCode128C();
- case self::TYPE_EAN_2:
- return new TypeUpcExtension2();
- case self::TYPE_EAN_5:
- return new TypeUpcExtension5();
- case self::TYPE_EAN_8:
- return new TypeEan8();
- case self::TYPE_EAN_13:
- return new TypeEan13();
- case self::TYPE_UPC_A:
- return new TypeUpcA();
- case self::TYPE_UPC_E:
- return new TypeUpcE();
- case self::TYPE_MSI:
- return new TypeMsi();
- case self::TYPE_MSI_CHECKSUM:
- return new TypeMsiChecksum();
- case self::TYPE_POSTNET:
- return new TypePostnet();
- case self::TYPE_PLANET:
- return new TypePlanet();
- case self::TYPE_RMS4CC:
- return new TypeRms4cc();
- case self::TYPE_KIX:
- return new TypeKix();
- case self::TYPE_IMB:
- return new TypeIntelligentMailBarcode();
- case self::TYPE_CODABAR:
- return new TypeCodabar();
- case self::TYPE_CODE_11:
- return new TypeCode11();
- case self::TYPE_PHARMA_CODE:
- return new TypePharmacode();
- case self::TYPE_PHARMA_CODE_TWO_TRACKS:
- return new TypePharmacodeTwoCode();
- }
- throw new UnknownTypeException();
- }
- }
|