This topic is locked

Advanced mail on print page

5/19/2011 3:28:48 AM
PHPRunner General questions
M
mmponline author

The included event code is the standard way to send a mail on the add / edit pages with new data. How would I change it to send a mail on the print page that will include the data and not only send a simple mail? The print page only includes "send simple mail" events. Please assist.



//********** Send email with new data ************
$email="--rbegin--test@test.com--rend--";

$from="--rbegin--admin@test.com--rend--";

$msg="";

$subject="--rbegin--New data record--rend--";
foreach($values as $field=>$value)

{

if(!IsBinaryType(GetFieldType($field)))

$msg.= $field." : ".$value."\r\n";

}



$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
Sergey Kornilov admin 5/19/2011

There is no such thing as "new data" on printer-friendly page. This code makes sense on Edit/Add pages only where we always working with a single record.

M
mmponline author 5/19/2011

I realise that. Is there a way then to send an email that will include the data that is displayed on the printpage?

Sergey Kornilov admin 5/19/2011

Sure, you can do that.
You have access to the current SQL Query via session variable $_SESSION["<table name>_sql"]

$_SESSION["<table name>_sql"]

SQL query without WHERE and ORDER BY. Populated on the list page to be used on Print/Export pages.


More info:

http://xlinesoft.com/phprunner/docs/phprunner_session_variables.htm
Use DAL or plain SQL statement to execute this query and loop through all records crafting the email body.