Send mail to a only person

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
eayvl
User
Posts: 315

Send mail to a only person

Post by eayvl »

Hi, I'm making some changes to the DEMO base in local server (localhost) I need the following please:

  • At the Base Employees says: robert reports to Buchanan Steven, i need that, when robert makes a change in base "Product" Buchanan Steven has that to receive a mail.
  • At the Base Employees says: nancy reports to Fuller Andrew, i need that, when nancy makes a change in base "Product" Fuller Andrew has that to receive a mail.

What part of the code I need to modify?

Thanks.


mobhar
User
Posts: 11726

Post by mobhar »

  1. Define your email settings from "PHP" -> "Email Settings" tab,
  2. Enable "On Edit" under "Table" setup -> "Table-Options" -> "Email Notification" that belongs to "orders" table,
  3. Write your PHP code in "Email_Sending" server event that belongs to "orders" table, in order to customize the Email content/recipient/sender, etc (read "Server Events and Client Scripts" topic from PHPMaker Help menu for more info),
  4. Regenerate ALL the script files again.

eayvl
User
Posts: 315

Post by eayvl »

I already have part of what I need, but it is possible to obtain the previous values ​​and the new values ​​when receiving the mail.

// Email Sending event
function Email_Sending(&$Email, &$Args) {
//var_dump($Email);
//var_dump($Args);
//exit();
if (CurrentPageID() == "edit") { // If edit Page
$Email->Recipient = ew_ExecuteScalar("SELECT Email FROM EMPLOYEES WHERE ReportsTo = '" . $Args["rsnew"]["EmployeeID"] ."'");
$Email->Cc = $Args["rsnew"]["Email"];
$Email->Bcc = "xxxxx@email.com";
$Email->Subject = "My New Subject";
$Email->Content .= "\nAdded by " . CurrentUserName();
$Email->Format = "HTML";
}
return TRUE;
}


mobhar
User
Posts: 11726

Post by mobhar »

If you use for Edit Page, then you should get the Employee ID from $Args["rsold"]["EmployeeID"] instead of $Args["rsnew"]["EmployeeID"].


arbei
User
Posts: 9383

Post by arbei »

Since you need to send an email to the parent user of the current user, then you need to get the email address of the parent user by their ID.

For example:
$Email->Recipient = ew_ExecuteScalar("SELECT Email FROM EMPLOYEES WHERE EmployeeID = " . CurrentUserInfo("ReportTo") ."");


eayvl
User
Posts: 315

Post by eayvl »

The solution may be in the Database tabla AUDIT Trail get old and new data, when send the mail.

Is there a catalog where i can check, query ALL tags that exist; for example "CurrentUserName(), CurrentUserInfo(), CurrentDateTime() etc.


mobhar
User
Posts: 11726

Post by mobhar »

eayvl wrote:
Is there a catalog where i can check, query ALL tags that exist; for example "CurrentUserName(),
CurrentUserInfo(), CurrentDateTime() etc.

There are some useful global functions that generated in "phpfn*.php" file for your references.


Post Reply