Hello everyone.

We're a small team of student developers new to Drupal. We have been designing a module that will:
-Interact with the CiviCRM (CiviEvent) module
-Give event hosts the option to embed barcodes within confirmation e-mails sent to folks who register for the event
-Registered participants may print off the e-mail and check-in to an event by scaning the attached barcode

In the beginning we wanted to modify the CiviEvent code. Eventually it was decided that we would build a Drupal module. 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.

Comments

Question 1) Not that I know

Question 1)
Not that I know of. I recently had to write a database transfer script from one Drupal database to another that was completely different. The fields were all the same, but the original database was a compilation of about 50 modules, while the new one held one module that combined all the bits and pieces that the 50 modules were doing on the other database. To do this, I did a couple of things:
- I installed a fresh Drupal installation. I looked at the database and how many rows were in each table, and I then created a node, and compared how many rows were in each table. This allowed me to tell which tables were affected when creating nodes
- I then created nodes, using dummy values with words that didn't exist. After that I ran a search on the entire database to see where these values ended up. In this way I was able to map the Drupal system to the tables and columns of the database

There may very well be a different way to do this, but if you don't find one, then the above method is tested and true, though it takes a fair bit of time and work to analyze.

Question 2)
hook_mail_alter()

Full-time freelancer, always looking for work.
jaypan.com (my portfolio)

Is it possible to make

Is it possible to make hook_mail_alter() work on e-mails being sent out by other modules?

Yes, it works on any mail.

Yes, it works on any mail. You just need to find out the ID of the mail being sent (this will be the same each time a particular mail is sent).

I usually do something like this. To get the ID, I will create the alter function like this:

<?php
function modulename_mail_alter(&$message)
{
  die(
$message['id']);
}
?>

Then I trigger whichever mail in particular it is that you want to alter. The system then dies and outputs the ID to the screen. So lets say that the id is 'modulename_mymail'. Next I will change my function to this:

<?php
function modulename_mail_alter(&$message)
{
  if(
$message['id'] == modulename_mymail)
  {
   
// make your changes to $message here. This will change the mail being sent.
 
}
}
?>

If you need to see the contents of $message so you can know exactly what to change, a good piece of code is this:

<?php
function modulename_mail_alter(&$message)
{
  echo
'<pre>', print_r($message), '</pre>';
  die;
}
?>

This gives you the contents of $message laid out in an easy to read format.

Full-time freelancer, always looking for work.
jaypan.com (my portfolio)

Thanks! On a side note, we're

Thanks!

On a side note, we're trying to add the functionality so that when our barcode module is enabled it automatically creates a custom field for the "Embed barcode?" checkbox option, along with the new tables in the database etc.

Is there a set of Drupal API functions to assist us with this?

you can use hook_install(),

you can use hook_install(), hook_uninstall() and hook_schema() for creating your database tables (and deleting them when the module is uninstalled). You can use hook_form_alter() to add a checkbox to whatever forms you want to add it to.

Full-time freelancer, always looking for work.
jaypan.com (my portfolio)

any progress? Hi I would be

any progress?

Hi I would be intrested in purchasing this setup.

This system is open source,

This system is open source, so once it's finished it will be available for anyone use. I believe it's worth mentioning that this module is only designed to function as an extension to CiviCRM (Events, specifically).

For the heck of it, here's a summary of our progress and who we are:

We're a small team of college students developing a Drupal module which allows participants to check-in at events using a barcode (or, if a scanner is unavailable, the barcode's numeral code). This barcode, which is generated at the point of a participant registering for an event through a web application, is attached to confirmation e-mails and sent to the newly-registered users.

Currently we have a working demo which does everything noted above. The problem is that the current solution is a little hacked up by us, so we need to clean it up (so that critical code is moved out of their source, and in to a smarty template).

We still have yet to implement a useful feature that automatically adds an "Embed barcode" checkbox in the administrator's "Create a new event" page. It's possible to add this manually though a custom data field, but we can do something much more elegant than that.

Subscribing

This was on my "to do" list!

Need help?

---------------------

"He's said to be outspoken, but nobody's actually seen anyone do it"

Sure. Do you know anything

Sure. Do you know anything about Smarty templates?

We're trying to attach the barcode to the e-mail by modifying the existing template, but it's giving some resistance... ideally the barcode would either be an attachment, or embedded directly into the e-mail. We're waiting for response from the folks in the Smarty forums.

Any ideas? Alternatives?

Wow! I know nothing about

Wow!

I know nothing about Smarty Templates!

I assume, however, that the barcode is rendered as an image and only needs embedding, yes?

---------------------

"He's said to be outspoken, but nobody's actually seen anyone do it"

Bingo. Our present solution

Bingo.

Our present solution is that we're modifying existing source files within CiviCRM to make their own API calls to attach an image to an email, but this isn't as elegant as only modifying the template alone.

One of the problems is that their API calls make use of the PEAR mailing package. This is an issue for us because:
- We're short on time (code freeze on the 20th!)
- We've got midterms and assignments due in other classes this and next week
- We're suffering from information overload... Drupal, SQL, PHP, CiviCRM/CiviEvent, Apache/SMTP server setup... all picked up within about 30 days alongside material from other classes

We've posted in the Smarty and PEAR forums without any response. Our client doesn't care whether or not we modify their files, but we'd like to keep the scope of our little project strictly within new files.

as far as I know the smarty

as far as I know the smarty problem is the least. If you succeed in generating a barcode as a jpg.
You store it somewhere - somehow and then you make reference to this picture in smarty. If you want I can have a look.
Just describe clearly what the actual setup is in order to loose the minimum of time.

we can synchronise via skype / msn /

kind regards,

Stijn

Other Modules you may want to check out

Another Module that may help you, although I guess how much help will be provided depend on how much you want to work on the Drupal side and how much you want to work on the CiviCRM side, is Barcode which makes barcodes and provides a cck type and display widget for those barcodes. This is better than upcfield module which requires an external python program.

Another module, uCount also provides a checkin system designed for afterschool and senior centers. it is not connected to CiviCRM, but it has a multipage form and a bunch of javascript to allow a kiosk with no keyboard or mouse (just a scanner) to check people in. You need barcodes for people, activities and hours (if you are collecting volunteer hours). uCount relies on upcfield at present, we have been thinking about putting up a reverse bounty to convert to the barcode module.

As for your civicrm database issue. Look at

http://drupal.org/node/18429

and also
http://drupal.org/node/265367

Here is some php that when pasted into a Drupal page (filter set to php) generates a table from civicrm. The problem was that the custom fields were not showing up for inclusion in custom reports. I think the more elegant way is to get the custom fields into the reports, but this way has the advantage of being straightforward (if you like lots of SQL joins). Using phpmyadmin and just looking at the tables was an OK way to figure out the relationships. CiviCRM tends to have tables with reasonable names (and put documentation on each field!!). They also create new tables with which have all the relevant fields which makes things less of a puzzle. Jay's method is more careful, I think.

<?php

// see also http://drupal.org/node/265367

db_set_active('civicrm');

$campers_q = db_query('SELECT CONCAT(c.first_name, " ", c.last_name) as "Camper Name", (
YEAR( CURDATE( ) ) - YEAR( c.birth_date )
) - ( RIGHT( CURDATE( ) , 5 ) < RIGHT( c.birth_date, 5 ) ) AS age, m.primary_disability_111, m.mobility_113, m.room_requirement_122, m.diet_123, m.photo_release_124, DATE(p.register_date) AS "Reg Date",
CONCAT(staff.first_name, " ",staff.last_name) as s_name
FROM {civicrm_event} e
LEFT JOIN civicrm_participant p ON ( p.event_id = e.id )
LEFT JOIN civicrm_contact c ON ( p.contact_id = c.id )
LEFT JOIN civicrm_value_miscellaneous_5 m ON ( m.entity_id = c.id )
LEFT JOIN civicrm_value_staff_contract_19 glue ON ( glue.assigned_to_camper_119 = c.id )
LEFT JOIN civicrm_participant p2 ON ( glue.entity_id = p2.id )
LEFT JOIN civicrm_contact staff ON ( p2.contact_id = staff.id )
WHERE e.id =4
AND p.role_id =6
'
);

$rows[] = array();


while (
$in = db_fetch_array($campers_q)) {
 
$rows[] = $in;
 
$test = $in;
}
//Switch back to the default connection when finished.
db_set_active('default');

$header = array("c.first_name"," c.last_name"," age"," m.primary_disability_111"," m.mobility_113",
"m.room_requirement_122"," m.diet_123"," m.photo_release_124"," p.register_date","staff.first_name",
"staff.last_name");


$output = theme('table', $headers, $rows);

drupal_set_message('<pre>'.print_r($test).'</pre>');

echo
$output;

?>

Barcode generator/reader for CiviEvent

Hello,
I'm new to Drupal and CiviCRM. Me and another friend have been using Drupal and CiviCRM for designing couple of web-sites for non-profit cultural organizations. In one of the sites, we have utilized CiviEvent for online event registrations and payments, so that part is fine. But now one of the client wants to incorporate a barcode generator for the online event registration. So basically a barcode gets generated, when someone pays and registers for an event, which gets sent through the automatic confirmation e-mail, so the attendee just needs to print the e-mail and bring it to the venue, where the organizers scan it using a barcode reader and the status gets updated as "scanned" in the database.
SO in short, what the client wants is exactly same as you guys were trying last year, so I was wondering if you were able to finish that project or not. Even if you were not able to finish it, please give us some advice as to how to approach this problem and how much coding do you think might be involved?
I would appreciate any help in this matter from anybody.
Thanks.

Subscribe

Subscribe

I don't understand. Subscribe

I don't understand. Subscribe to what?

Because I don't have an

Because I don't have an adequate solution to barcode check-in at an event without paying lots of money to custom development I had to use Event Brite which turns out for my situation to be a frigging disaster making me look like an ass to my employer. This was in the past week. I see this thread since I like to read the forums just to learn and don't really have anything to add but still want to track it. You will see the word subscribe or even just ..... which then allows the Drupal user to track via their user account any additions or changes to the thread. It's fun you should try it :)

this is something that interests me too

A quick search turned up several modules for drupal 5,6 and 7 which do most of the jobs, with the only feature I couldn't find being something to plugin at the scanner end.

However, a QR code could easily be used with a QR code reader to implement that end of functionality.

I did a similar thing

I did a similar thing recently for a site. It wasn't a bar-code reader, it was a Felica IC chip reader (smart cards - I don't know what these are called outside Japan or if they are even used anywhere else in the world). Essentially they do the same thing as a bar code reader - they scan a card for the number contained within the card, and send it through the network.

The way it worked for my system was that the machine itself was a network device. It plugged in with a LAN cable, and was able to be accessed on the LAN by it's network IP address. When accessing it, it had some software contained inside that let me set a few options. One of the options was to choose a URL to send the data to. So when someone scanned a card, it hit the URL with the submitted data (the data was POST data. I then build a Drupal module that created the URL which I set inside the machine. This URL took the POST data, and parsed it for the information it needed. First it checked that the machine's ID was correct (to prevent data spoofing), and then checked the time, and logged in the user (this was a timecard system).

I've never seen a module for this, and indeed, it would be hard to write a module for it as each barcode reader/chip reader etc. would have a different protocol, but if you get one of the machines and look at how it deals with the data it receives, it shouldn't be ridiculously hard to create a module to deal with that data. I had absolutely zero experience working with card readers when I set up my system, and it only took me a few days to put together a fully functional time card system.

Full-time freelancer, always looking for work.
jaypan.com (my portfolio)