Barcode in email

rogeranton 23 Mar, 2012
I've been trying to implement a barcode in the confirmation email using Pear Image_Barcode2. This has not run as smoothly as I hoped. After working through several different errors related to path issues, I now get this error "500 - code39 barcode is not supported" in a nice red heading.

I'm stuck and I hope someone here can tell me what to do now?

Regards,
Roger
GreyHead 23 Mar, 2012
Hi Roger,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6/1.7/2.5.

There's an article here about doing this with CFv3. It will probably work in CFv4 with minor changes.

Bob
rogeranton 04 Apr, 2012
Thanks a lot again Bob

This worked great. I'm using CFv4 so I had to do some changes:

1. The includes folder I created in [root]/components/com_chronoforms
2. Instead of using the code for random identifier I installed your Unique ID [GH] action, and placed it before email.
3. I then copied the code from point 8 in the article to the email template.

Roger
GreyHead 05 Apr, 2012
Hi Roger,

Great to know that it worked. Thank you. I've linked to your post from the article.

Bob
amheng5 11 Jan, 2014
Hi, is it possible to create the barcode from a custom field rather than create a random code? I have a member ID field and want to create a barcode based on the member ID entered for each submission.

Thanks
GreyHead 11 Jan, 2014
Hi amheng5,

Yes, that should be OK; you'd just need to replace the part of the code used to generate the random string and replace it with your code to get the member ID.

Bob
amheng5 12 Jan, 2014
Ok, I was able to get the barcode to work; then I tried to remove the autogen code with the custom field. Here's my code.

<?php
if ( !$mainframe->isSite() ) { return; }
/*
function to generate a random alpha-numeric code
using a specified pattern
*
* @param $pattern string
* @return string
*/
function generateIdent($pattern='AA9999A')
{
$alpha = array("A","B","C","D","E","F","G","H",
"J","K","L","M","N","P","Q","R","S","T","U","V","W",
"X","Y","Z");
$digit = array("1","2","3","4","5","6","7","8","9");
$return = "";
$pattern_array = str_split($pattern, 1);
foreach ( $pattern_array as $v ) {
if ( is_numeric($v) ) {
$return .= $digit[array_rand($digit)];
} elseif ( in_array(strtoupper($v), $alpha) ) {
$return .= $alpha[array_rand($alpha)];
} else {
$return .= " ";
}
}
return $return;
}
?>

<?php
$ident = (studentID);
echo "<img src='".JURI::base()
."components/com_chronoforms/includes/barcode.php?barcode="
.$ident."&width=320&height=80' />";
?>


Here's the page link for the form in question:
http://ptsa.westfieldhs.org/student-volunteer-form.html

I tried to remove the autogen code but killed my page. If I enter a student ID, it doesn't show. Please advise on what I should do to correct the coding.

Also the email notice doesn't show correctly so I assume this will correct once I get the regular form code to work. (see attached file)
amheng5 06 Feb, 2014
Ok I can get this to work in the form but I enter the following in the email template html code view (I use Version 4) and the code gets jumbled when I save and the code and so the barcode never shows in the email notification up when I complete the form.

You can see the screenshot of the email notification. Also the screen shot of the code enter correctly but upon saving, the code gets changed. Any advice.
amheng5 07 Feb, 2014
Add on comment: When I try to enter this code into my email template HTML mode and then save, the code is changed. It won't keep the original php coding. The instructions say to go to "Email Setup/Properties" and set "Use Template Editor" to no. But I can't see this anywhere to change this setting. [attachment=0]screenshot.jpg[/attachment]

You'll see the 2nd screenshot shows the code get changed.[attachment=1]screenshot1.jpg[/attachment]

<img src="<?php echo JURI::base().'components/com_chronocontact/
includes/'; ?>barcode.php?barcode={ident}&width=280&height=100"
/>


Please advise on what I am doing wrong. Thanks
This topic is locked and no more replies can be posted.