This topic is locked

Database driven letters with phprunner

2/20/2009 11:18:58 AM
PHPRunner General questions
E
emdee author

Hi,

Does phprunner support the use of forms?

I can only find the option for reports.

I like to generate letters for a mailing ( true real mail not email) and i want the names of all my members ( in the database) to be on the letters.

The report generator does not seem to support this. Is there a way to do so with phprunner.

kind regards,

M Donners

Sergey Kornilov admin 2/20/2009

I would suggest to use mail merge function in Microsoft Word for this purpose.

E
emdee author 2/21/2009

I know about mail merge in word.

The thing is that my Hosting provider does not support access to database from external source.

I need to connect to the database true the provider.

That is why i like to create the forms online.

Also, I like to give access to many people and they should be able to generate the forms. I dont like them to use mail merge.

T
thesofa 2/23/2009

OK, I have had to do this for the detention system at school, the letter is a fixed format, so I have made a page for printing, cleared all the variables from it and in the printer friendly page I have set up the data from the current record into variables, then I use the concatenation function in php to build up the content of the letter.

Finally I use echo statements to place the content on the page.

I then Print the page using the File Print menu

here is the code

function BeforeProcessRowPrint(&$data)

{

global $conn;

$b="</big><p><big></b>";

$given=date("l, F j, Y");

$dep=$data["Department"];

$pup="<b>".$data["Pupil"]."</b>";

$d4d=$data["Day for Detention"];
// this bit of code blagged from http://www.webmasterworld.com/forum88/1132.htm with thanks

$stringArray = explode("-", $d4d);
$date = mktime(0,0,0,$stringArray[1],$stringArray[2],$stringArray[0]);
$converteddate = date("l, F j, Y", $date);

$why="<b>".$data["Reason"].".</b> ".$data["Comments"];

$giver=$data["Teacher"];

$open=$given."<p><p><p><big>Dear Parent/Carer of ".$pup.",<p><big><b>School Detention for ".$dep."</b></big></p>";
$a="In line with school policy, which applies the 1997 Education Act regarding the legalities of detention, I am writing to give you the required 24 hours notice that I shall be detaining ".$pup." from 3.00pm to 4.00pm on <b>".$converteddate."</b>.";

$a1="The reason for detention is: ".$why.".";

$c="Transport home is the responsibility of parents so you may need to arrange suitable alternative transport home if he/she normally travels on a school bus. (There is a late bus in operation which leaves school at 4.30pm prompt to most local areas).";

$d="The decision to place pupils in detention is not taken lightly and the offence is deemed serious. It is hoped that you will work with the school in the attempt to correct breaches of discipline.";

$e="Yours sincerely,";

$f="<b>Teacher: ".$giver."</b>";

echo "<IMG src=images/head.jpg width =667 height = 144 border=0>";

echo $b;

echo $open;

echo $b;

echo $b;

echo $b;

echo $a;

echo $b;

echo $a1;

echo $b;

echo $c;

echo $b;

echo $d;

echo $b;

echo $e;

echo $b;

echo $b;

echo $b;

echo $b;

echo $f;

echo $b;

return true;
// return true if you like to display row on in the list

// return false otherwise

} // function BeforeProcessRowPrint


REMEMBER that the page you produce is a web page, so it is no where as easy to format as a word doc.

HTH

E
emdee author 2/23/2009

Thanks for that code!

Actually, yesterday, I came up with a simular solution.

I modified the export page by changing the code for export to word document.
I did something simular with the variables, I also put it in between text And all if it I echo'd to the word doc.

What it accualy does is creating a HTML page in word. B adding a page break in the code, Word moves to a new page for every record. ( word has to be in "Print view" mode to see it.
The only thing it does not do is adding pictures. In my php code, if if put something like:

echo "<IMG src=images/head.jpg width =667 height = 144 border=0>";

Word will change the path to something like: src= ../../../bla bla / windows temporder/ DFDFFDF/images/head.jpg

I can not figure out a way to prevent this from happening.

So by lack of better, i made a workaround with a macro in word.

After the document is generated, I start a macro to put a logo on every page.

The only thing is that all users need to install this macro.

E
emdee author 3/5/2009

Anyone an idee on how to solve the issue with the Automaticly changing path ?

See previous post in this topic.