* * @author The-eh * * This script implements Code 39 barcodes. A Code 39 barcode can encode a string with the following characters: digits (0 to 9), uppercase letters (A to Z) and 8 additional characters (- . space $ / + % *). * Code39(float xpos, float ypos, string code [, float baseline [, float height]]) * xpos: abscissa of barcode * ypos: ordinate of barcode * code: value of barcode * height: bar height * baseline: corresponds to the width of a wide bar ************************************************************************/ if (!defined('__CLASS_FPDF_CODEBAR__')) { define('__CLASS_FPDF_CODEBAR__', true); //require_once(dirname(__FILE__).'/../_fpdf/fpdf.php'); // require_once(dirname(__FILE__).'/../../fpdf/fpdf.php'); USES_lglib_class_fpdf(); class FPDF_Codebar extends FPDF { var $footer_param = array(); function FPDF_Codebar($sens = 'P', $unit = 'mm', $format = 'A4') { $this->FPDF($sens, $unit, $format); } function BARCODE_EAN13($x, $y, $w, $h, $barcode, $label = true) { return $this->Barcode($x, $y, $w, $h, $barcode, 13, $label); } function BARCODE_UPC_A($x, $y, $w, $h, $barcode, $label = true) { return $this->Barcode($x, $y, $w, $h, $barcode, 12, $label); }
<?php //HTML2PDF by Clént Lavoillotte //ac.lavoillotte@noos.fr //webmaster@streetpc.tk //http://www.streetpc.tk //require('fpdf.php'); //require('FPDF2File.php'); USES_lglib_class_fpdf('FPDF2File'); //function hex2dec //returns an associative array (keys: R,G,B) from //a hex html code (e.g. #3FE5AA) function hex2dec($couleur = "#000000") { $R = substr($couleur, 1, 2); $rouge = hexdec($R); $V = substr($couleur, 3, 2); $vert = hexdec($V); $B = substr($couleur, 5, 2); $bleu = hexdec($B); $tbl_couleur = array(); $tbl_couleur['R'] = $rouge; $tbl_couleur['V'] = $vert; $tbl_couleur['B'] = $bleu; return $tbl_couleur; } //conversion pixel -> millimeter at 72 dpi function px2mm($px) { return $px * 25.4 / 72; }
/** * Print tickets as PDF documents * Tickets can be printed for an event, a single occurrence, * or all tickets for a user ID. * * @param string $ev_id Event ID * @param integer $rp_id Repeat ID * @param integer $uid User ID * @return string PDF Document containing tickets */ public static function PrintTickets($ev_id = '', $rp_id = 0, $uid = 0) { global $_CONF; $checkin_url = $_CONF['site_admin_url'] . '/plugins/evlist/checkin.php?tic='; // get the tickets, paid and unpaid. Need event id and uid. $tickets = self::GetTickets($ev_id, $rp_id, $uid); // The PDF functions in lgLib are a recent addition. Make sure that // the lgLib version supports PDF creation since we can't yet check // the lglib version during installation if (empty($tickets) || !function_exists('USES_lglib_class_fpdf')) { return "There are no tickets available to print"; } USES_lglib_class_fpdf(); USES_evlist_class_repeat(); USES_evlist_class_tickettype(); $ev_id = NULL; // create params array for qrcode, if used $params = array('module_size' => 5); $pdf = new FPDF(); $pdf->SetLeftMargin(20); $pdf->AddPage(); $tic_types = array(); foreach ($tickets as $tic_id => $ticket) { if (!isset($tick_types[$ticket->tic_type])) { $tick_types[$ticket->tic_type] = new evTicketType($ticket->tic_type); } // If we don't already have the event info, get it and construct // the address string if ($ev_id != $ticket->ev_id) { $Ev = new evEvent($ticket->ev_id); $ev_id = $Ev->id; $addr = array(); if ($Ev->Detail->street != '') { $addr[] = $Ev->Detail->street; } if ($Ev->Detail->city != '') { $addr[] = $Ev->Detail->city; } if ($Ev->Detail->province != '') { $addr[] = $Ev->Detail->province; } if ($Ev->Detail->country != '') { $addr[] = $Ev->Detail->country; } if ($Ev->Detail->postal != '') { $addr[] = $Ev->Detail->postal; } $address = implode(' ', $addr); } // Get the repeat(s) for the ticket(s) to print a ticket for each // occurrence. $repeats = evRepeat::GetRepeats($ticket->ev_id, $ticket->rp_id); foreach ($repeats as $rp_id => $event) { $ev_date = $event->date_start; $ev_time = $event->time_start1 . ' - ' . $event->time_end1; if (!empty($event->time_start2)) { $ev_time .= '; ' . $event->time_start1 . ' - ' . $event->time_end2; } $fee = self::formatAmount($ticket->fee); // Get the veritcal position of the current ticket // for positioning the qrcode $y = $pdf->GetY(); // Title $pdf->SetFont('Times', 'B', 12); $pdf->Cell(130, 10, "{$tick_types[$ticket->tic_type]->description}: {$Ev->Detail->title}", 1, 0, 'C'); $pdf->Ln(13); $pdf->SetFont('Times', '', 12); $pdf->SetX(-40); $pdf->Cell(0, 30, 'Fee: ' . $fee); if ($ticket->fee > 0) { $pdf->Ln(5); if ($ticket->paid >= $ticket->fee) { $pdf->SetX(-40); $pdf->Cell(0, 30, 'Paid'); } else { $pdf->SetX(-55); $due = $ticket->fee - $ticket->paid; $pdf->Cell(0, 30, 'Balance Due: ' . self::formatAmount($due)); } } $pdf->SetX(20); $pdf->Cell(0, 8, "Date:", 0, 0); $pdf->setX(40); $pdf->Cell(0, 8, $ev_date, 0, 1); $pdf->Cell(0, 6, "Time:", 0, 0); $pdf->SetX(40); $pdf->Cell(0, 6, $ev_time, 0, 1); if ($Ev->Detail->location != '') { $pdf->Ln(5); $pdf->Cell(0, 2, 'Where: ', 0, 0); $pdf->SetX(40); $pdf->Cell(0, 2, $Ev->Detail->location, 0, 1); } if (!empty($address)) { if ($Ev->Detail->location == '') { $pdf->Ln(5); $pdf->Cell(0, 2, 'Where: ', 0, 0); } $pdf->Ln(4); $pdf->SetX(40); $pdf->Cell(0, 2, $address, 0, 1); } // Footer $pdf->Ln(6); $pdf->setFont('Times', 'I', 10); $pdf->Cell(0, 10, $_CONF['site_name'], 0, 0); $pdf->Ln(6); $pdf->Cell(0, 10, $ticket->tic_id); // print qrcode if possible $params['data'] = $checkin_url . $tic_id . '&rp=' . $rp_id; $qrc_status = LGLIB_invokeService('qrcode', 'getcode', $params, $qrcode, $svc_msg); if ($qrc_status == PLG_RET_OK) { $pdf->SetX(-40); $pdf->Image($qrcode['path'], null, $y, 25); } $pdf->Ln(); $y = $pdf->GetY(); $pdf->Line(10, $y, 200, $y); $pdf->Ln(); } } $pdf->Output(); }