TOPIC:

PDF attachment on condition of value 5 days 2 hours ago #281370

  • Topic Author
  • jdwires
  • Offline
  • Junior Member
  • Junior Member
  • Registered
  • Posts: 41
  • Thanks: 0
I have customized a PDF attachment template for a form, but I would like to only have the PDF attachment created and sent if specific criteria are met.

If I leave the Mailback attachment option set to "no" can I somehow change the setting of the mailback attachment in the submit pieces> begin submit, or do I have to use the end submit?

For simplicity, if possible, I'd like to use the layout from the Custom Mailback WYSIWYG editor.

Please Log in or Create an account to join the conversation.

PDF attachment on condition of value 4 days 18 hours ago #281395

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Administrator
  • Administrator
  • Super Users
  • Posts: 10331
  • Thanks: 827
Hi,

what criteria should match exactly? I couldn't extract that information from your post.

Regards,
Markus

Please Log in or Create an account to join the conversation.

PDF attachment on condition of value 4 days 12 hours ago #281404

  • Topic Author
  • jdwires
  • Offline
  • Junior Member
  • Junior Member
  • Registered
  • Posts: 41
  • Thanks: 0
As a simple example, let's say I have a select list element named paymentOption with the possible values of online or invoice.

If paymentOption = online, send the mailback email template, but DON'T send the PDF attachment with the custom template

If paymentOption = invoice, send the mailback email template, DO send the PDF attachment with the custom template

Thanks,
Joel

Please Log in or Create an account to join the conversation.

PDF attachment on condition of value 3 days 11 hours ago #281443

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Administrator
  • Administrator
  • Super Users
  • Posts: 10331
  • Thanks: 827
Alright, I believe this will help you. You basically need to adjust this a little based on the input in the if-conditions.

You will need to turn off the regular mailback or admin mails, depending which you want to use this for. Otherwise you'll receive too many emails.

crosstec.org/en/forums/15-usage/125018-c...backfile.html#230236

Regards,
Markus

Please Log in or Create an account to join the conversation.

PDF attachment on condition of value 3 days 6 hours ago #281468

  • Topic Author
  • jdwires
  • Offline
  • Junior Member
  • Junior Member
  • Registered
  • Posts: 41
  • Thanks: 0
I think I'm missing something. I have modified the code to fit my criteria. Although, it appears this method is for attaching static PDF files that have already been uploaded to the media directory. The invoice that I'm trying to send is a generated PDF from the _pdf_attachment.php template file.
$this->execPieceByName('ff_InitLib');

$from = 'xxxxxxxx@xxxxxxx.xxxx'; //change to wanted email
$fromname = 'xxxxxxxxxx'; //change to wanted from name
$subject = 'Registration Invoice'; // Change to your preferred Email subject
$attachment = [];

$body = '';

$paymentMethod = ff_getSubmit('paymentOption');

if($paymentMethod == 'online'){
            array_push($attachment , JPATH_SITE.'/media/breezingforms/pdftpl/myformName_pdf_attachment.php'); }

    $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
$this->sendMail($from, $fromname, 'wires@swcciowa.edu', $subject, $body, $attachment);  

$paymentMethod = ff_getSubmit('paymentOption');

  exit;
}

Also, an email was indeed sent out but the content was blank. Is there a way to use the content from the form settings > mailback emails > custom to populate the $body?

Please Log in or Create an account to join the conversation.

PDF attachment on condition of value 2 days 6 hours ago #281494

  • TheMuffinMan's Avatar
  • TheMuffinMan
  • Offline
  • Administrator
  • Administrator
  • Super Users
  • Posts: 10331
  • Thanks: 827
Hi,

yes, there are a couple of things to add. In order to not make this is a super long thread, I attached an example form that you can import in BF => Configuration => Package Installer (first unzip the file below).

This example let's a user decide if he wants to receive a PDF or not and you should be able to adjust this for your needs.
The "magic" is going on in the form => advanced => more options => submit pieces => end submit.

I left a few comments for you to see what needs to be edited. But in principle it checks for the receipient's email address given with the submission, creates a new PDF that is goin to be attached and else than that, prints the remaining fields into the email body:
$this->execPieceByName('ff_InitLib');
global $ff_processor;

$from = 'noreply@crosstec.org'; //change to wanted email
$fromname = 'Crosstec'; //change to wanted from name
$subject = 'Your PDF'; // Change to your preferred Email subject
$receipient = ''; // will be populated below
$attachment = [];

$body = '';
foreach ($this->maildata as $data) {
 
	// for the field "pdfornot", create the PDF and attach
  	if($data[_FF_DATA_NAME] == 'pdfornot' && $data[_FF_DATA_VALUE] == '1'){
		
		$attachment[] = $ff_processor->exppdf();
	}  
	// determine the receipient for the "email" field
	else if($data[_FF_DATA_NAME] == 'email'){

		$receipient = $data[_FF_DATA_VALUE];
	}
	// else print the remaining field values in the email body
	else
	{
		$body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n";
	}
}

$this->sendMail($from, $fromname, $receipient, $subject, $body, $attachment);

Please let me know if this helps!

File Attachment:

File Name: pdfornot.zip
File Size:7 KB


Regards,
Markus
Attachments:

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.059 seconds

Support Discord

Join our Discord and enter the Crosstec channels for live-support, chat forums and directly interacting with the community!

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Subscribe to news and updates!

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here and enter the Crosstec channels to receive live support and talk directly to the team!