function BARCODE::ConvertUPCAtoUPCE in Barcode 6
1 call to BARCODE::ConvertUPCAtoUPCE()
File
- ./
barcode.inc.php, line 1224
Class
Code
function ConvertUPCAtoUPCE($upca) {
$csumTotal = 0;
// The checksum working variable starts at zero
$upce = "";
// If the source message string is less than 12 characters long, we make it 12 characters
if (strlen($upca) < 12) {
$barnumber = str_pad($barnumber, 12, "0", STR_PAD_LEFT);
}
if (substr($upca, 0, 1) != '0' && substr($upca, 0, 1) != '1') {
$this->_error = 'Invalid Number System (only 0 & 1 are valid)';
return false;
}
else {
if (substr($upca, 3, 3) == '000' || substr($upca, 3, 3) == '100' || substr($upca, 3, 3) == '200') {
$upce = substr($upca, 1, 2) . substr($upca, 8, 3) . substr($upca, 3, 1);
}
else {
if (substr($upca, 4, 2) == '00') {
$upce = substr($upca, 1, 2) . substr($upca, 9, 2) . '3';
}
else {
if (substr($upca, 5, 1) == '0') {
$upce = substr($upca, 1, 4) . substr($upca, 10, 1) . '4';
}
else {
if (substr($upca, 10, 1) >= '5') {
$upce = substr($upca, 1, 5) . substr($upca, 10, 1);
}
else {
$this->_error = 'Invalid product code (00005 to 00009 are valid)';
return false;
}
}
}
}
}
return $upce;
}