Barcodes

More
4 years 8 months ago #126988 by Wol
Barcodes was created by Wol
I have just finished implementing barcodes into this plugin, using the existing TCPDF library already included. This new functionality will save out a barcode png that can be called with the [BARCODE] tag. It currently uses barcode 39 but can easily be changed within the code below.

two files need to be edited to implement this functionality.

components/com_eventbooking/helper/registration.php

I have added this to line 3905
Code:
/** * Generate BARCODE for a ticket number * * @param string $ticketNumber */ public static function generateTicketNumberBarcode($ticketNumber) { $filename = $ticketNumber . 'barcode.png'; if (!file_exists(JPATH_ROOT . '/media/com_eventbooking/qrcodes/' . $filename)) { require_once JPATH_ROOT . "/components/com_eventbooking/tcpdf/tcpdf_barcodes_1d.php"; // set the barcode content and type $barcodeobj = new TCPDFBarcode($ticketNumber, 'C39'); // output the barcode as PNG image imagepng($barcodeobj->getBarcodePNG(2, 30, array(0,0,0))); $img = ob_get_clean(); file_put_contents(JPATH_ROOT . '/media/com_eventbooking/qrcodes/' . $filename, $img); } }

components/com_eventbooking/helper/ticket.php

I have added this to line 335
Code:
if (strpos($ticketLayout, '[BARCODE]') !== false) { EventbookingHelperRegistration::generateTicketNumberBarcode($replaces['ticket_number']); $imgTag = '<img src="media/com_eventbooking/qrcodes/' . $replaces['ticket_number'] . 'barcode.png" border="0" alt="BARCODE" />'; $ticketLayout = str_ireplace("[BARCODE]", $imgTag, $ticketLayout); }
The following user(s) said Thank You: Tuan Pham Ngoc, StreetSportService, Annamarie Hessman

Please Log in or Create an account to join the conversation.

  • Tuan Pham Ngoc
  • Away
  • Administrator
  • Administrator
More
4 years 8 months ago #127004 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Barcodes
Thanks for sharing the code Wol

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc