Topic: Numeric BarCode restriction / Valid Alphanumeric filter
A recent commit restricts BarCodes to be generated only if the stock_id is an integer.
This was done since the Barcode generation routine generated errors on malformed input as a stop-gap arrangement since the auto generation of Barcode stock_id was restricted to a random / sequential available number.
The file /reporting/includes/barcodes.php manages Barcode generation and is taken from the TCPDF Library.
In the said library above, each type of barcode is properly generated with the appropriate methods listing the valid ASCII codes and size range / limits along with check-digit computations and verification where enabled.
The following links in reference are in order:
1. Make BarCode
2. BarCode Resource
3. Keyence
Clearly, the stock_id and item_code fields are VARCHAR in the FA DB and several BarCode formats support alphanumeric characters (CODE128, Codabar, etc) and some even symbols too.
Currently available libraries:
1. A Zend Library Validation of BarCode "code" input is also available.
2. A JavaScript Validation of a few barcode formats are available here.
The need now is to hammer out a function to validate the stock_id before allowing the generation of the barcode in pure PHP without external dependancies so that errors don't get generated while doing so during generation.
Any suggestions?
Blindly suppressing all errors during Barcode generation and leaving it blank when not possible to generate on for whatever reason is a simplistic but effective choice for many.