Generating HTML-Email by script

  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle created the topic: Generating HTML-Email by script

Hello,

i created a form with x-testfield like this
  • Textfield: NAME1
  • Textfield: Name1_Min - invisible
  • Textfield: Name1_Max - invisible
  • Textfield: NAME2
  • Textfield: Name2_Min - invisible
  • Textfield: Name2_Max - invisible
  • Textfield: NAME3
  • Textfield: Name3_Min - invisible
  • Textfield: Name3_Max - invisible
  • ...
  • Textfield: NAMEx
  • Textfield: Namex_Min - invisible
  • Textfield: Namex_Max - invisible

Now i have to generate a html-Email with the following table
Name|Min|Max|Value|Result
e.g. like this:
Name1Name1-Min.valueName1-Max.valueName1.valueCalulated-Value through the formular
Name2Name2-Min.valueName2-Max.valueName2.valueCalulated-Value through the formular
Name3Name3-Min.valueName3-Max.valueName3.valueCalulated-Value through the formular
...............
NamexNamex-Min.valueNamex-Max.valueNamex.valueCalulated-Value through the formular

and the forumlar:
if(namex.value<=Namex-Max.value AND namex.value >=Namex-Min.value) {
   calculated_Namex = Namex-Max.value-Namex.value;
}
else {
   if(namex.value <= Namex-Min.value) {
      calculated_Namex = Namex-Max;
   }
   else {
      if(namex.value >= Namex-Max.value) {
         calculated_Namex = "";
      }
   }
}

i hope i can do something like this with foreach-coding? Is is possible?

Thank you for you help
#237675
  • Posts: 2734
  • Karma: 93
  • Thank you received: 369

mihaela replied the topic: Generating HTML-Email by script

Hello,

There is a way how you could make this work.

Follow these steps to create an email similar to what you want.

Turn off the "Email notification(s)" checkbox in the form's Properties.

Then go to form's Advanced properties > More options > Submit pieces and in the End Submit section set Type to Custom.

In the code area below put the following code:
$this->execPieceByName('ff_InitLib');
$from = 'test@test.com';
$fromname =  'yourname';
$subject = 'mysubject';

$recipient = 'youremail@gmail.com'; 


$attachment=null;
$isHtml = true;

$body =  "
<html><body><table style='color:blue;' border='1' >";

for ($i = 1; $i <= 3; $i++) {
   $body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('NAME'.$i) . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('Name'.$i.'_Min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('Name'.$i.'_Max') . "</strong>
</td>
</tr>";
 
}
$body .= "
</tr>
</table>
</body></html>";

$this->sendMail($from, $fromname, $recipient, $subject, $body, $attachment, $isHtml); 
NOTE: In teh code above set the following values to the values that suit your needs:
$this->execPieceByName('ff_InitLib');
$from = 'test@test.com';
$fromname =  'yourname';
$subject = 'mysubject';
$recipient = 'youremail@gmail.com';

This code will make a table in an email in the following format:
"|Name|Min|Max|".
You can adjust this so that it adds needed columns.

Let me know whether you have managed to apply this to your form and whether it is working as you wanted.

Regards,

Mihaela
#237861
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle replied the topic: Generating HTML-Email by script

Hi, Sorry, i dont write to you for a so long time.

what to do, if i dont have fields numbered :-)

There are field-names different like this type:
name|name_min|name_max
example|example_min|example_max
another|another_min|another_max

there are no numbering :-(

Also... i need the <tr>-area only in this case...
if file example < example_max
then another td-area should calculate something like this "example_max - example"

You understand what i should to calculate?

tahnk you for helping
#238230
  • Posts: 2734
  • Karma: 93
  • Thank you received: 369

mihaela replied the topic: Generating HTML-Email by script

Hello again,

In that case, you can't do this through a loop.

If you have some HTML coding knowledge, you should write row by row manually since the names do not contain numbers as I thought.

If I have understood correctly that you will have conditions row by row (to decide whether to show certain row in a table). Then the code should look something like this:
$this->execPieceByName('ff_InitLib');
$from = 'test@test.com';
$fromname =  'yourname';
$subject = 'mysubject';

$recipient = 'youremail@gmail.com'; 


$attachment=null;
$isHtml = true;

$body =  "
<html><body><table style='color:blue;' border='1' >";

if(PUT YOUR CONTIION FOR FIRST ROW HERE) {
   $body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('name') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('name_min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('name_max') . "</strong>
</td>
</tr>";
}

if(PUT YOUR CONTIION FOR SECOND ROW HERE) {
	$body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('example') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('example_min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('example_max') . "</strong>
</td>
</tr>";
}

if(PUT YOUR CONTIION FOR THIRD ROW HERE) {
	$body .= "<tr>
<td>
   <strong>". $name= ff_getSubmit('another') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('another_min') . "</strong>
</td>
<td>
   <strong>". $name= ff_getSubmit('another_max') . "</strong>
</td>
</tr>";
}

$body .= </table>
</body></html>";

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

Let me know whether I have understood your requirement properly and whetehr you have managed to set this for your form.

Regards,

Mihaela
#238244
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle replied the topic: Generating HTML-Email by script

okay, that is to much :-( because there are sometimes up to 60 rows.

So ich have to choose your first version... but with condition to show or not to show.
- FIELDmin
- FIELD_max
- FIELD_value
- FIELD_CALC = FIELD_MAX-FIELD_MIN

if (FIELD_value<FIELD_min) {
...
<td>
<strong> . FIELD_CALC </strong>
</td>
}

on which position i should calculate FIELD_CALC ... inside the condition is true i think?

Thank you for your hints.
#238269
  • Mister.Miracle
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 87
  • Thank you received: 0

Mister.Miracle replied the topic: Generating HTML-Email by script

2 Questions again:

1.) if i want to get the title of the field of ff_getSubmit("part".$i) i tried to use
ff_getElementByName('part'.$i) or ff_getElementByName('part'.$i).value but it dont works like i expected.

Maybe my coding is the wrong code?

2.) How to calculate only if something is lower than some another thing?

Thank you for helping
#238350
Moderators: ForumSupporttomeperica
Time to create page: 0.058 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

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

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

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 to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here