/** * Return a 2D barcode for the asset * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @since [v1.0] * @return Response */ public function getBarCode($assetId = null) { $settings = Setting::getSettings(); $asset = Asset::find($assetId); $barcode_file = public_path() . '/uploads/barcodes/' . str_slug($settings->alt_barcode) . '-' . str_slug($asset->asset_tag) . '.png'; if (isset($asset->id, $asset->asset_tag)) { if (file_exists($barcode_file)) { $header = ['Content-type' => 'image/png']; return response()->file($barcode_file, $header); } else { $barcode = new \Com\Tecnick\Barcode\Barcode(); $barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode, $asset->asset_tag, 250, 20); file_put_contents($barcode_file, $barcode_obj->getPngData()); return response($barcode_obj->getPngData())->header('Content-type', 'image/png'); } } }
/** * Get the QR code representing the asset * * @param int $assetId * @return View **/ public function getQrCode($assetId = null) { $settings = Setting::getSettings(); if ($settings->qr_code == '1') { $asset = Asset::find($assetId); $size = barcodeDimensions($settings->barcode_type); if (isset($asset->id, $asset->asset_tag)) { $barcode = new \Com\Tecnick\Barcode\Barcode(); $barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('view/hardware', $asset->id), $size['height'], $size['width'], 'black', array(-2, -2, -2, -2)); return $barcode_obj->getPngData(); } } }
/** * Get the QR code representing the asset * * @param int $assetId * @return View **/ public function getQrCode($assetId = null) { $settings = Setting::getSettings(); if ($settings->qr_code == '1') { $asset = Asset::find($assetId); $size = barcodeDimensions($settings->barcode_type); if (!Company::isCurrentUserHasAccess($asset)) { return Redirect::to('hardware')->with('error', Lang::get('general.insufficient_permissions')); } if (isset($asset->id, $asset->asset_tag)) { $barcode = new \Com\Tecnick\Barcode\Barcode(); $barcode_obj = $barcode->getBarcodeObj($settings->barcode_type, route('view/hardware', $asset->id), $size['height'], $size['width'], 'black', array(-2, -2, -2, -2)); return $barcode_obj->getPngData(); } } }
* * @since 2015-02-21 * @category Library * @package Barcode * @author Nicola Asuni <*****@*****.**> * @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnick.com/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ // autoloader when using Composer require '../vendor/autoload.php'; // autoloader when using RPM or DEB package installation //require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php'); // data to generate for each barcode type $linear = array('C128A' => array('0123456789', 'CODE 128 A'), 'C128B' => array('0123456789', 'CODE 128 B'), 'C128C' => array('0123456789', 'CODE 128 C'), 'C128' => array('0123456789', 'CODE 128'), 'C39E+' => array('0123456789', 'CODE 39 EXTENDED + CHECKSUM'), 'C39E' => array('0123456789', 'CODE 39 EXTENDED'), 'C39+' => array('0123456789', 'CODE 39 + CHECKSUM'), 'C39' => array('0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'), 'C93' => array('0123456789', 'CODE 93 - USS-93'), 'CODABAR' => array('0123456789', 'CODABAR'), 'CODE11' => array('0123456789', 'CODE 11'), 'EAN13' => array('0123456789', 'EAN 13'), 'EAN2' => array('12', 'EAN 2-Digits UPC-Based Extension'), 'EAN5' => array('12345', 'EAN 5-Digits UPC-Based Extension'), 'EAN8' => array('1234567', 'EAN 8'), 'I25+' => array('0123456789', 'Interleaved 2 of 5 + CHECKSUM'), 'I25' => array('0123456789', 'Interleaved 2 of 5'), 'IMB' => array('0123456789', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'), 'IMBPRE' => array('fatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdf', 'IMB pre-processed'), 'KIX' => array('0123456789', 'KIX (Klant index - Customer index)'), 'MSI+' => array('0123456789', 'MSI + CHECKSUM (modulo 11)'), 'MSI' => array('0123456789', 'MSI (Variation of Plessey code)'), 'PHARMA2T' => array('0123456789', 'PHARMACODE TWO-TRACKS'), 'PHARMA' => array('0123456789', 'PHARMACODE'), 'PLANET' => array('0123456789', 'PLANET'), 'POSTNET' => array('0123456789', 'POSTNET'), 'RMS4CC' => array('0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'), 'S25+' => array('0123456789', 'Standard 2 of 5 + CHECKSUM'), 'S25' => array('0123456789', 'Standard 2 of 5'), 'UPCA' => array('0123456789', 'UPC-A'), 'UPCE' => array('0123456789', 'UPC-E')); $square = array('DATAMATRIX' => array('0123456789', 'DATAMATRIX (ISO/IEC 16022)'), 'PDF417' => array('0123456789', 'PDF417 (ISO/IEC 15438:2006)'), 'QRCODE' => array('0123456789', 'QR-CODE'), 'LRAW' => array('0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'), 'SRAW' => array('0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)')); $barcode = new \Com\Tecnick\Barcode\Barcode(); $examples = '<h3>Linear</h3>' . "\n"; foreach ($linear as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', array(0, 0, 0, 0)); $examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n"; } $examples .= '<h3>Square</h3>' . "\n"; foreach ($square as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', array(0, 0, 0, 0)); $examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n"; } $bobj = $barcode->getBarcodeObj('QRCODE,H', 'http://www.tecnick.com', -4, -4, 'black', array(-2, -2, -2, -2)); echo "\n<!DOCTYPE html>\n<html>\n <head>\n <title>Usage example of tc-lib-barcode library</title>\n <meta charset=\"utf-8\">\n <style>\n body {font-family:Arial, Helvetica, sans-serif;margin:30px;}\n table {border: 1px solid black;}\n th {border: 1px solid black;padding:4px;background-barcode:cornsilk;}\n td {border: 1px solid black;padding:4px;}\n h3 {color:darkblue;}\n h4 {color:darkgreen;}\n h4 span {color:firebrick;}\n </style>\n </head>\n <body>\n <h1>Usage example of tc-lib-barcode library</h1>\n <p>This is an usage example of <a href=\"https://github.com/tecnickcom/tc-lib-barcode\" title=\"tc-lib-barcode: PHP library to generate linear and bidimensional barcodes\">tc-lib-barcode</a> library.</p>\n <h2>Output Formats</h2>\n <h3>PNG Image</h3>\n <p><img alt=\"Embedded Image\" src=\"data:image/png;base64," . base64_encode($bobj->getPngData()) . "\" /></p>\n <h3>SVG Image</h3>\n <p style=\"font-family:monospace;\">" . $bobj->getSvgCode() . "</p>\n <h3>HTML DIV</h3>\n <p style=\"font-family:monospace;\">" . $bobj->getHtmlDiv() . "</p>\n <h3>Unicode String</h3>\n <pre style=\"font-family:monospace;line-height:0.61em;font-size:6px;\">" . $bobj->getGrid(json_decode('"\\u00A0"'), json_decode('"\\u2b1b"')) . "</pre>\n <h3>Binary String</h3>\n <pre style=\"font-family:monospace;\">" . $bobj->getGrid() . "</pre>\n <h2>Barcode Types</h2>\n " . $examples . "\n </body>\n</html>\n";
* * @since 2015-02-21 * @category Library * @package Barcode * @author Nicola Asuni <*****@*****.**> * @copyright 2015-2016 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnickcom/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ // autoloader when using Composer require '../vendor/autoload.php'; // autoloader when using RPM or DEB package installation //require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php'); // data to generate for each barcode type $linear = array('C128A' => array('0123456789', 'CODE 128 A'), 'C128B' => array('0123456789', 'CODE 128 B'), 'C128C' => array('0123456789', 'CODE 128 C'), 'C128' => array('0123456789', 'CODE 128'), 'C39E+' => array('0123456789', 'CODE 39 EXTENDED + CHECKSUM'), 'C39E' => array('0123456789', 'CODE 39 EXTENDED'), 'C39+' => array('0123456789', 'CODE 39 + CHECKSUM'), 'C39' => array('0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'), 'C93' => array('0123456789', 'CODE 93 - USS-93'), 'CODABAR' => array('0123456789', 'CODABAR'), 'CODE11' => array('0123456789', 'CODE 11'), 'EAN13' => array('0123456789', 'EAN 13'), 'EAN2' => array('12', 'EAN 2-Digits UPC-Based Extension'), 'EAN5' => array('12345', 'EAN 5-Digits UPC-Based Extension'), 'EAN8' => array('1234567', 'EAN 8'), 'I25+' => array('0123456789', 'Interleaved 2 of 5 + CHECKSUM'), 'I25' => array('0123456789', 'Interleaved 2 of 5'), 'IMB' => array('00040123456123456789-12345', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'), 'IMBPRE' => array('fatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdf', 'IMB pre-processed'), 'KIX' => array('0123456789', 'KIX (Klant index - Customer index)'), 'MSI+' => array('0123456789', 'MSI + CHECKSUM (modulo 11)'), 'MSI' => array('0123456789', 'MSI (Variation of Plessey code)'), 'PHARMA2T' => array('0123456789', 'PHARMACODE TWO-TRACKS'), 'PHARMA' => array('0123456789', 'PHARMACODE'), 'PLANET' => array('0123456789', 'PLANET'), 'POSTNET' => array('0123456789', 'POSTNET'), 'RMS4CC' => array('0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'), 'S25+' => array('0123456789', 'Standard 2 of 5 + CHECKSUM'), 'S25' => array('0123456789', 'Standard 2 of 5'), 'UPCA' => array('0123456789', 'UPC-A'), 'UPCE' => array('0123456789', 'UPC-E')); $square = array('DATAMATRIX' => array('0123456789', 'DATAMATRIX (ISO/IEC 16022)'), 'PDF417' => array('0123456789', 'PDF417 (ISO/IEC 15438:2006)'), 'QRCODE' => array('0123456789', 'QR-CODE'), 'LRAW' => array('0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'), 'SRAW' => array('0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)')); $barcode = new \Com\Tecnick\Barcode\Barcode(); $examples = '<h3>Linear</h3>' . "\n"; foreach ($linear as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30, 'black', array(0, 0, 0, 0)); $examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n"; } $examples .= '<h3>Square</h3>' . "\n"; foreach ($square as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4, 'black', array(0, 0, 0, 0)); $examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n"; } $bobj = $barcode->getBarcodeObj('QRCODE,H', 'https://tecnick.com', -4, -4, 'black', array(-2, -2, -2, -2))->setBackgroundColor('#f0f0f0'); echo "\n<!DOCTYPE html>\n<html>\n <head>\n <title>Usage example of tc-lib-barcode library</title>\n <meta charset=\"utf-8\">\n <style>\n body {font-family:Arial, Helvetica, sans-serif;margin:30px;}\n table {border: 1px solid black;}\n th {border: 1px solid black;padding:4px;background-barcode:cornsilk;}\n td {border: 1px solid black;padding:4px;}\n h3 {color:darkblue;}\n h4 {color:darkgreen;}\n h4 span {color:firebrick;}\n </style>\n </head>\n <body>\n <h1>Usage example of tc-lib-barcode library</h1>\n <p>This is an usage example of <a href=\"https://github.com/tecnickcom/tc-lib-barcode\" title=\"tc-lib-barcode: PHP library to generate linear and bidimensional barcodes\">tc-lib-barcode</a> library.</p>\n <h2>Output Formats</h2>\n <h3>PNG Image</h3>\n <p><img alt=\"Embedded Image\" src=\"data:image/png;base64," . base64_encode($bobj->getPngData()) . "\" /></p>\n <h3>SVG Image</h3>\n <p style=\"font-family:monospace;\">" . $bobj->getSvgCode() . "</p>\n <h3>HTML DIV</h3>\n <p style=\"font-family:monospace;\">" . $bobj->getHtmlDiv() . "</p>\n <h3>Unicode String</h3>\n <pre style=\"font-family:monospace;line-height:0.61em;font-size:6px;\">" . $bobj->getGrid(json_decode('"\\u00A0"'), json_decode('"\\u2584"')) . "</pre>\n <h3>Binary String</h3>\n <pre style=\"font-family:monospace;\">" . $bobj->getGrid() . "</pre>\n <h2>Barcode Types</h2>\n " . $examples . "\n </body>\n</html>\n";
/** * Return a 2D barcode for the asset * * @author [A. Gianotto] [<*****@*****.**>] * @param int $assetId * @since [v1.0] * @return Response */ public function getBarCode($assetId = null) { $settings = Setting::getSettings(); $asset = Asset::find($assetId); if (isset($asset->id, $asset->asset_tag)) { $barcode = new \Com\Tecnick\Barcode\Barcode(); $barcode_obj = $barcode->getBarcodeObj($settings->alt_barcode, $asset->asset_tag, 250, 20); return response($barcode_obj->getPngData())->header('Content-type', 'image/png'); } }
//==================================================================================== // OCS INVENTORY REPORTS // Copyleft Erwan GOALOU 2010 (erwan(at)ocsinventory-ng(pt)org) // Web: http://www.ocsinventory-ng.org // // This code is open source and may be copied and modified as long as the source // code is always made freely available. // Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt //==================================================================================== require_once TC_LIB_BARCODE; require_once 'require/function_admininfo.php'; if (is_numeric($protectedGet['systemid']) and array_key_exists($protectedGet['default_value'], $array_qr_action)) { if ($array_qr_action[$protectedGet['default_value']]['TYPE'] == 'url') { $msg = $array_qr_action[$protectedGet['default_value']]['VALUE']; } else { $fields_info = explode('.', $array_qr_action[$protectedGet['default_value']]['VALUE']); if ($fields_info[0] == 'hardware') { $hardware_id = 'id'; } else { $hardware_id = 'hardware_id'; } $sql = "select %s from %s where %s='%s'"; $arg = array($fields_info[1], $fields_info[0], $hardware_id, $protectedGet['systemid']); $res = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg); $val = mysqli_fetch_array($res); $msg = $val[$fields_info[1]]; } $barcode = new \Com\Tecnick\Barcode\Barcode(); $qrcode = $barcode->getBarcodeObj('QRCODE,H', $msg, 400, 400, 'black', array(20, 20, 20, 20)); $qrcode->getPng(); }
* * @since 2015-02-21 * @category Library * @package Barcode * @author Nicola Asuni <*****@*****.**> * @copyright 2015-2015 Nicola Asuni - Tecnick.com LTD * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) * @link https://github.com/tecnick.com/tc-lib-barcode * * This file is part of tc-lib-barcode software library. */ // autoloader when using Composer require '../vendor/autoload.php'; // autoloader when using RPM or DEB package installation //require ('/usr/share/php/Com/Tecnick/Barcode/autoload.php'); // data to generate for each barcode type $linear = array('C128A' => array('0123456789', 'CODE 128 A'), 'C128B' => array('0123456789', 'CODE 128 B'), 'C128C' => array('0123456789', 'CODE 128 C'), 'C128' => array('0123456789', 'CODE 128'), 'C39E+' => array('0123456789', 'CODE 39 EXTENDED + CHECKSUM'), 'C39E' => array('0123456789', 'CODE 39 EXTENDED'), 'C39+' => array('0123456789', 'CODE 39 + CHECKSUM'), 'C39' => array('0123456789', 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9'), 'C93' => array('0123456789', 'CODE 93 - USS-93'), 'CODABAR' => array('0123456789', 'CODABAR'), 'CODE11' => array('0123456789', 'CODE 11'), 'EAN13' => array('0123456789', 'EAN 13'), 'EAN2' => array('12', 'EAN 2-Digits UPC-Based Extension'), 'EAN5' => array('12345', 'EAN 5-Digits UPC-Based Extension'), 'EAN8' => array('1234567', 'EAN 8'), 'I25+' => array('0123456789', 'Interleaved 2 of 5 + CHECKSUM'), 'I25' => array('0123456789', 'Interleaved 2 of 5'), 'IMB' => array('0123456789', 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200'), 'IMBPRE' => array('fatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdfatdf', 'IMB pre-processed'), 'KIX' => array('0123456789', 'KIX (Klant index - Customer index)'), 'MSI+' => array('0123456789', 'MSI + CHECKSUM (modulo 11)'), 'MSI' => array('0123456789', 'MSI (Variation of Plessey code)'), 'PHARMA2T' => array('0123456789', 'PHARMACODE TWO-TRACKS'), 'PHARMA' => array('0123456789', 'PHARMACODE'), 'PLANET' => array('0123456789', 'PLANET'), 'POSTNET' => array('0123456789', 'POSTNET'), 'RMS4CC' => array('0123456789', 'RMS4CC (Royal Mail 4-state Customer Bar Code)'), 'S25+' => array('0123456789', 'Standard 2 of 5 + CHECKSUM'), 'S25' => array('0123456789', 'Standard 2 of 5'), 'UPCA' => array('0123456789', 'UPC-A'), 'UPCE' => array('0123456789', 'UPC-E')); $square = array('DATAMATRIX' => array('0123456789', 'DATAMATRIX (ISO/IEC 16022)'), 'PDF417' => array('0123456789', 'PDF417 (ISO/IEC 15438:2006)'), 'QRCODE' => array('0123456789', 'QR-CODE'), 'LRAW' => array('0101010101', '1D RAW MODE (comma-separated rows of 01 strings)'), 'SRAW' => array('0101,1010', '2D RAW MODE (comma-separated rows of 01 strings)')); $barcode = new \Com\Tecnick\Barcode\Barcode(); $examples = '<h3>Linear</h3>' . "\n"; foreach ($linear as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -3, -30); $examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n"; } $examples .= '<h3>Square</h3>' . "\n"; foreach ($square as $type => $code) { $bobj = $barcode->getBarcodeObj($type, $code[0], -4, -4); $examples .= '<h4>[<span>' . $type . '</span>] ' . $code[1] . '</h4><p style="font-family:monospace;">' . $bobj->getHtmlDiv() . '</p>' . "\n"; } $bobj = $barcode->getBarcodeObj('QRCODE,H', 'http://www.tecnick.com', -4, -4, 'black'); echo "\n<!DOCTYPE html>\n<html>\n <head>\n <title>Usage example of tc-lib-barcode library</title>\n <meta charset=\"utf-8\">\n <style>\n body {font-family:Arial, Helvetica, sans-serif;margin:30px;}\n table {border: 1px solid black;}\n th {border: 1px solid black;padding:4px;background-barcode:cornsilk;}\n td {border: 1px solid black;padding:4px;}\n h3 {color:darkblue;}\n h4 {color:darkgreen;}\n h4 span {color:firebrick;}\n </style>\n </head>\n <body>\n <h1>Usage example of tc-lib-barcode library</h1>\n <p>This is an usage example of <a href=\"https://github.com/tecnickcom/tc-lib-barcode\" title=\"tc-lib-barcode: PHP library to generate linear and bidimensional barcodes\">tc-lib-barcode</a> library.</p>\n <h2>Output Formats</h2>\n <h3>PNG Image</h3>\n <p><img alt=\"Embedded Image\" src=\"data:image/png;base64," . base64_encode($bobj->getPngData()) . "\" /></p>\n <h3>SVG Image</h3>\n <p style=\"font-family:monospace;\">" . $bobj->getSvgCode() . "</p>\n <h3>HTML DIV</h3>\n <p style=\"font-family:monospace;\">" . $bobj->getHtmlDiv() . "</p>\n <h3>Unicode String</h3>\n <pre style=\"font-family:monospace;line-height:0.61em;font-size:6px;\">" . $bobj->getGrid(json_decode('"\\u00A0"'), json_decode('"\\u2b1b"')) . "</pre>\n <h3>Binary String</h3>\n <pre style=\"font-family:monospace;\">" . $bobj->getGrid() . "</pre>\n <h2>Barcode Types</h2>\n " . $examples . "\n </body>\n</html>\n";