This topic is locked

Dynamic Form Letters (Like Ms Word Fields)

3/25/2010 12:59:52 PM
PHPRunner General questions
F
FunkDaddy author

I am trying to figure out how to do the following and can't seem to find an answer in the forums:
I have a school directory application that contains school students, teachers, and parents information. I want to enable a school teacher to create form letters that they can send to their students parents. For example, the teacher would type out a letter in a text field such as:
----

<Current Date>
Dear <Parent First Name>,
We are going on a school field trip next week. Will you please authorize <Student Name> to participate?
---
In the example above I want the teacher to be able to pick from a drop down box (in a add or edit record form) the field value they want to include in the letter. Ideally, the drop down box selection would automatically b inserted wherever their cursos is positioned in the letter text field, however, I would settle for simply giving the teacher instructions such as adding < and ? characters around the field names he/she wants to include in the letter. The idea is to generate multiple printable letters in Word that can be mailed out to each individual parent. So, in a class of 30 students, 30 separate pages would be generated in the word document. The most important thing is allowing the user to determine which fields would be included dynamically in the letter instead of having a hard-coded letter.
Can anyone point me in the right direction?

S
swanside 3/25/2010



I am trying to figure out how to do the following and can't seem to find an answer in the forums:
I have a school directory application that contains school students, teachers, and parents information. I want to enable a school teacher to create form letters that they can send to their students parents. For example, the teacher would type out a letter in a text field such as:
----

<Current Date>
Dear <Parent First Name>,
We are going on a school field trip next week. Will you please authorize <Student Name> to participate?
---
In the example above I want the teacher to be able to pick from a drop down box (in a add or edit record form) the field value they want to include in the letter. Ideally, the drop down box selection would automatically b inserted wherever their cursos is positioned in the letter text field, however, I would settle for simply giving the teacher instructions such as adding < and ? characters around the field names he/she wants to include in the letter. The idea is to generate multiple printable letters in Word that can be mailed out to each individual parent. So, in a class of 30 students, 30 separate pages would be generated in the word document. The most important thing is allowing the user to determine which fields would be included dynamically in the letter instead of having a hard-coded letter.
Can anyone point me in the right direction?


I had to do something similar for job reports from engineers, so I made my project, and found the view file in the templates of the built project, I opened it with MS Frontpage and found all the fields.

I then made a report using front page and copied the correct fields into the report I made, I then saved it as the template page.
So,

In templates, your file might be called School_Trip.view. make the form you want with frontpage and save that as SChool_Trip.view in a different folder, maybe called custom as they will not get overwritten when you build your project. Go into the templates folder and open the built file School_Trip.view copy and paste the fields required into the School_Trip.view in the custom folder then save it. Copy and paste it back to the templates folder and overight the original.

Hope that helps.

Sergey Kornilov admin 3/25/2010

We use similar approach to edit email templates in Shopping Cart admin project.
http://xlinesoft.com/templates/shoppingcart/livedemo.htm

Logon to admin demo and proceed to "Email templates".
Template example:

E-mail Address: %%User_email%%
Billing Address: %%Billing_address%% Shipping Address: %%Shipping Address%%
Order Grand Total: %%total%%


Here is the piece of code that replaces template variables with real values and sends an email:


$rs_order = $dal_shopsales_order_main->Query("Order_no=".$order_no,"");

$data_order = db_fetch_array($rs_order);
$billing_info=$data_order["Billto_name"]."".$data_order["Billto_address"]."".$data_order["Billto_city"];

$billing_info.="".$data_order["Billto_state"]."".$data_order["Billto_zip"].$data_order["Billto_country"];

$shipping_info=$data_order["shipto_name"]."".$data_order["shipto_address"]."".$data_order["shipto_city"];

$shipping_info.="".$data_order["shipto_state"]."".$data_order["shipto_zip"].$data_order["shipto_country"];

$total = $data_order["Order_total"];

//********process email body*********************************

$email_message = $data_email["email_body"];

$email_message = str_replace("%%User_name%%",$values["Cust_email"],$email_message);

$email_message = str_replace("%%User_email%%",$values["Cust_email"],$email_message);

$email_message = str_replace("%%Billing_address%%",$billing_info,$email_message);

$email_message = str_replace("%%Shipping Address%%",$shipping_info,$email_message);

$email_message = str_replace("%%total%%",$total,$email_message);
// To send HTML mail, the Content-type header must be set

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



mail($email, $subject, $email_message, $headers);


In regards to selecting template fields from dropdown and inserting into textarea - this is also possible.
Check this article that explains how to insert text into text area at cursor position:

http://www.scottklarr.com/topic/425/how-to-insert-text-into-a-textarea-where-the-cursor-is/