mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Add code128 as barcode_type
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
|
||||
use emberlabs\Barcode\BarcodeBase;
|
||||
require APPPATH.'/views/barcodes/BarcodeBase.php';
|
||||
require APPPATH.'/views/barcodes/Code39.php';
|
||||
require APPPATH.'/views/barcodes/Code128.php';
|
||||
|
||||
class Barcode_lib
|
||||
{
|
||||
var $CI;
|
||||
var $supported_barcodes = array(1 => 'Code 39');
|
||||
var $supported_barcodes = array(1 => 'Code 39', 2 => 'Code 128');
|
||||
|
||||
function __construct()
|
||||
{
|
||||
@@ -16,6 +22,7 @@ class Barcode_lib
|
||||
|
||||
function get_barcode_config()
|
||||
{
|
||||
$data['barcode_type'] = $this->CI->Appconfig->get('barcode_type');
|
||||
$data['barcode_font'] = $this->CI->Appconfig->get('barcode_font');
|
||||
$data['barcode_font_size'] = $this->CI->Appconfig->get('barcode_font_size');
|
||||
$data['barcode_height'] = $this->CI->Appconfig->get('barcode_height');
|
||||
@@ -30,17 +37,30 @@ class Barcode_lib
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function generate_barcode($item, $barcode_config)
|
||||
{
|
||||
if ($barcode_config['barcode_type'] == '1')
|
||||
{
|
||||
$barcode = new emberlabs\Barcode\Code39();
|
||||
}
|
||||
else
|
||||
{
|
||||
$barcode = new emberlabs\Barcode\Code128();
|
||||
}
|
||||
$barcode_content = $this->CI->Appconfig->get('barcode_content') === "id" ? $item['item_id'] : $item['item_number'];
|
||||
$barcode->setData($barcode_content);
|
||||
$barcode->setDimensions($barcode_config['barcode_width'], $barcode_config['barcode_height']);
|
||||
$barcode->draw();
|
||||
return $barcode->base64();
|
||||
}
|
||||
|
||||
function create_display_barcode($item, $barcode_config)
|
||||
{
|
||||
|
||||
$display_table = "<table>";
|
||||
$display_table .= "<tr><td align='center'>". $this->manage_display_layout($barcode_config['barcode_first_row'], $item, $barcode_config)."</td></tr>";
|
||||
$display_table .= "<tr><td align='center'><img src='".site_url()."/barcode?".
|
||||
"&width=".$barcode_config['barcode_width'].
|
||||
"&height=".$barcode_config['barcode_height'].
|
||||
"&barcode=".($this->CI->Appconfig->get('barcode_content') === "id" ? $item['item_id'] : $item['item_number']).
|
||||
"&quality=".$barcode_config['barcode_quality'].
|
||||
"&type=".$this->CI->Appconfig->get('barcode_type').
|
||||
"' onerror=\"(function(pThis){pThis.onerror = null; pThis.src = pThis.src;})(this)\" /></td></tr>";
|
||||
$barcode = $this->generate_barcode($item,$barcode_config);
|
||||
$display_table .= "<tr><td align='center'><img src='data:image/png;base64,$barcode' /></td></tr>";
|
||||
$display_table .= "<tr><td align='center'>". $this->manage_display_layout($barcode_config['barcode_second_row'], $item, $barcode_config)."</td></tr>";
|
||||
$display_table .= "<tr><td align='center'>". $this->manage_display_layout($barcode_config['barcode_third_row'], $item, $barcode_config)."</td></tr>";
|
||||
$display_table .= "</table>";
|
||||
|
||||
Reference in New Issue
Block a user