CiviCRM for Ticketing and Attendance

Published
2010-04-14 12:28
Written by
hershel - member of the CiviCRM community - view blog guidelines

Overview

This is a brief introduction to how CiviCRM can be used for ticketing and attendance purposes, via custom Drupal modules. The concept is to provide printable tickets for event registrants, and to put a unique UPC code on each ticket; then at the event itself, to provide a way for the event management staff to scan the UPC codes and easily take attendance using those codes. Such a system is in place on one site and has been used successfully.

Code

The flow of the code is to capture event registrations using hook_civicrm_post and then, in that function, send an email to the new registrant with a link to download his PDF ticket. The PDF ticket is generated using the TCPDF PHP class. This class is used by the Printer-friendly, e-mail and PDF versions module, but for the purposes of creating tickets we needed a custom solution. The content of the tickets is not a node--it's content generated in real time. We therefore created a small custom module called tcpdf, which essentially is just a wrapper to the TCPDF class, and which provides our civiticket module the ability to create PDF files. The UPC barcode is generated by the write1DBarcode method of the TCPDF class. There were different ideas discussed, but in the end, the contact ID value was used as the value of the barcode. Registrants can now click on the link they receive via email and download and print their PDF ticket. The PDF has a background image and custom text indicating the title, date and location of the event, and also includes the registrant's name. Ticket link clicks can of course be tracked and a cron job can be setup to remind users a few days before the event to print their tickets, if they have not yet clicked on their link. Using custom fields in the event, the administrators can indicate for each event whether or not to send ticket emails, or which background image to use etc. The attendance feature is fairly simple--the administrators have a form which allows them to select for which event to take attendance and then there is an input to allow them to enter the contact ID of an attendant. The user places the mouse in that box, scans the ticket, sees the contact ID appear in the box, and then can submit the form. The module code then updates the registration record for that contact to indicate that he has attended the event.

Disclaimer

The bulk of this functionality was implemented on very short notice and includes hard-coded references to custom fields. It also includes some other functionality not directly related the ideas discussed here or not mentioned here. That said (i.e. the code is not pretty nor well-commented) it can be downloaded as civitickets.package.tar.gz and includes three modules--one for civitickets and one called addciviparticipant which adds registrants to events via their email address and the tcpdf module. The TCPDF class itself must be downloaded using the link above and put into the tcpdf folder to create modules/tcpdf/tcpdf. The actual attendance module is not ready for sharing so I put in the addciviparticipant module instead which implements a very similar concept. One other function is required which is this: function civiutils_include($filelist=null) { if (!module_exists('civicrm')) { return FALSE; } civicrm_initialize(TRUE); foreach($filelist as $file) { if (in_array($file,array('Config','DAO'))) { require_once "CRM/Core/$file.php"; } else { require_once 'api/v2/' . $file . '.php'; } } return true; } The full civiutils module is also not yet ready for publication. If there are any questions with regard to this code, feel free to contact me via this contact form.
Filed under

Comments

Mike Hancock (not verified)
2010-04-17 - 11:49

Hi Hershel,
Hope all is well. Is there any intent to also support an integration with Joomla?

Thanks,
Mike Hancock...

This looks great! Any idea of an expected completion date? Also, how stable is the current version? Would it be safe to use the civitickets module?

scavazosm (not verified)
2010-06-30 - 11:27

quick question,

I dont understand what you mean by:

"The TCPDF class itself must be downloaded using the link above and put into the tcpdf folder to create modules/tcpdf/tcpdf"

I tried downloading the TCPDF class and placing it in that directory and got nothing...could you elaborate on this part?

Anonymous (not verified)
2010-09-30 - 07:58

Hey guys,

was wondering if there was any progress since this posting.

I'm very curious if the ticketing solution ended up working good.

Let me know!

Anonymous (not verified)
2012-05-19 - 02:45

What is the best drupal and civicrm version for this solution? Work with the newest? (4.x)? thank you