mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-17 04:18:41 +00:00
Fixing C128c bug (checksum) and adding future member variables
This commit is contained in:
parent
2df3111c2b
commit
7ea0b17a6a
|
|
@ -15,7 +15,12 @@ abstract class C128Abstract
|
|||
|
||||
protected $orientation = 0;
|
||||
protected $size = 0;
|
||||
protected $dimension = ['width' => 0, 'height' => 0];
|
||||
protected $content = 0;
|
||||
protected $showText = true;
|
||||
protected $margin = ['top' => 0.0, 'right' => 0.0, 'bottom' => 0.0, 'left' => 0.0];
|
||||
protected $background = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0];
|
||||
protected $front = ['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0];
|
||||
|
||||
public function __construct(string $content = '', int $size = 20, int $orientation = 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
namespace phpOMS\Utils\Barcode;
|
||||
|
||||
/**
|
||||
* Class C128c
|
||||
* @fixme: here is still a small error. It has a minor deviation to a correct 128c code. WHY?
|
||||
*/
|
||||
class C128c extends C128Abstract
|
||||
{
|
||||
protected static $CHECKSUM = 105;
|
||||
|
|
@ -34,7 +30,7 @@ class C128c extends C128Abstract
|
|||
|
||||
protected static $CODE_START = '211232';
|
||||
|
||||
protected static $CODE_END = '2331112';
|
||||
protected static $CODE_END = '2331112';
|
||||
|
||||
protected function generateCodeString()
|
||||
{
|
||||
|
|
@ -43,6 +39,7 @@ class C128c extends C128Abstract
|
|||
$codeString = '';
|
||||
$length = strlen($this->content);
|
||||
$checksum = self::$CHECKSUM;
|
||||
$checkPos = 1;
|
||||
|
||||
for ($pos = 1; $pos <= $length; $pos += 2) {
|
||||
if ($pos + 1 <= $length) {
|
||||
|
|
@ -52,7 +49,8 @@ class C128c extends C128Abstract
|
|||
}
|
||||
|
||||
$codeString .= self::$CODEARRAY[$activeKey];
|
||||
$checksum = ($checksum + ($values[$activeKey] * $pos));
|
||||
$checksum = ($checksum + ($values[$activeKey] * $checkPos));
|
||||
$checkPos++;
|
||||
}
|
||||
|
||||
$codeString .= self::$CODEARRAY[$keys[($checksum - (intval($checksum / 103) * 103))]];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user