CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • CiviEvent barcodes
Pages: [1]

Author Topic: CiviEvent barcodes  (Read 2065 times)

Infinium

  • Guest
CiviEvent barcodes
October 27, 2009, 12:00:21 pm
Hi again everyone.

We've recently revived our little project. The old thread can be found here: http://forum.civicrm.org/index.php/topic,8442.0.html

It was decided that we would build a Drupal (v6) module; we'd like to avoid changing any CiviCRM code, if possible. Thus far, our module can only check-in/validate participants. The barcode scanner works fine. We also have the code ready for generating barcodes.


These are the issues we're facing:

-Is there a Drupal API function to know the existing databases and how do we know which one is used for CiviCRM? How do we know which is the default for Drupal? Currently, we are working with two databases (though our client may have a different database structure).

-Consider this: An admin hosts a new event and checks the "Embed barcodes" option, which allows barcodes to be generated and sent along with confirmation e-mails to users who register for said event. Our problem: We need a way to modify that e-mail to include the barcode, but without touching any code in the CiviCRM module. Is there any way our module can "intercept" the e-mail before it is sent, modify it, then mail it out?

Thanks for your support, and sorry if this isn't the appropriate forum to ask Drupal questions.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviEvent barcodes
October 27, 2009, 12:53:29 pm

1. use drupal's api to query drupal's db (db_query?) and civicrm's api to query civicrm's db (CRM_Core_DAO::executeQuery( ) )

2. u cant intercept an email currently in CiviCRM. You can however customize the email template and figure out how to generate a barcode in there directly (might not be too hard, u can use some smarty functions that hook into your php functions)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Infinium

  • Guest
Re: CiviEvent barcodes
October 27, 2009, 01:58:15 pm
Quote from: Donald Lobo on October 27, 2009, 12:53:29 pm
2. u cant intercept an email currently in CiviCRM. You can however customize the email template and figure out how to generate a barcode in there directly (might not be too hard, u can use some smarty functions that hook into your php functions)

I took a look at the template I need. It looks pretty scary. Is there any documentation on how to customize these templates? Also, what are smarty functions and where can I read more about them?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviEvent barcodes
October 27, 2009, 02:03:16 pm

http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in,+Profile,+Contribution+and+Event+Registration+Screens

http://www.smarty.net/manual/en/

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Infinium

  • Guest
Re: CiviEvent barcodes
October 29, 2009, 05:00:06 pm
We've been trying to add the barcode image as an attachment to an email by fiddling with CRM_Utils_Mail::send(). We've been getting a "File not readable" error (reported from civicrm/packages/Mail/mime.php). We know that our file path is correct, same with our permissions, but somehow it's receiving weird strings like "/" or "m". After hardcoding the value inside the function, we managed to get the file attached. (But with the weird single-character name)

Problems:
-Instead of seeing a barcode, we're seeing segments of junk (b64 encoded data?). We need to be able to actually see the barcode image so that it's printable straight from the email.
-After downloading an attachment and opening it with an image viewer, it turns out to be a perfectly fine barcode... again, we need to be able to see that barcode inside the email.

On a side note we're also looking into modifying the .tpl, although it would be much better if we could just modify CRM_Event_Bao_Event::sendMail(). We are very short on time and the quickest solution would probably be best for us.

Thanks!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviEvent barcodes
October 29, 2009, 05:56:09 pm

1. i would spend some time with the PEAR mail and mime package and figure out what needs to be done to achieve what you want. you might first want to write a small script using those packages and get that to work before trying to get it to work within CiviCRM

2. did not really understand the tpl vs code question. If you can localize your changes to the tpl only that would be great

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Infinium

  • Guest
Re: CiviEvent barcodes
October 30, 2009, 05:51:09 pm
We now have our template responsible for generating barcodes and are trying to insert it into the email, but the result is garbage. Here's what we're using:

Code: [Select]
$file = 'barcode.jpeg';
$image = imagecreatefromjpeg($file);
imagealphablending($image, false);
imagesavealpha($image, true);

// start buffering
ob_start();
imagejpeg($image);
$contents =  ob_get_contents();
ob_end_clean();

echo "<img src='data:image/jpeg;base64,".base64_encode($contents)."' />";

imagedestroy($image);

Inside the email we're getting: <img src='data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQA.....followed by the rest of (what we assume to be) the file. Changing the header's content-type doesn't have any effect.

We're trying to inject this image directly into the email rather than include it as an attachment, but at this point any solution would be nice. We're running out of time.

Thanks!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviEvent barcodes
October 30, 2009, 09:06:38 pm

u might be better off seeking help on the PEAR forums. none of us here are experts with the PEAR Mail package, we look in and figure out things when we need to :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • CiviEvent barcodes

This forum was archived on 2017-11-26.