Hi,
I have 2 tables: Flights(Master) and Flight Rows(Details).
On insert, I have some code sending email on the master table Email_Sending event as below:
//Get Job ID
$SoNo = ew_ExecuteScalar("select Code from [dbo].[@FLIGHTROWS] where U_DocEntry =
".$Args["rsnew"]["DocEntry"]."");
//Get Customer
$Cust = ew_ExecuteScalar("select U_CustomerName from [dbo].[@FLIGHTROWS] where U_DocEntry =
".$Args["rsnew"]["DocEntry"]."");
//Get Cargo Type
$Ctype = ew_ExecuteScalar("select U_CargoType from [dbo].[@FLIGHTROWS] where U_DocEntry =
".$Args["rsnew"]["DocEntry"]."");
//Get Weight
$Weight = ew_ExecuteScalar("select U_Weight from [dbo].[@FLIGHTROWS] where U_DocEntry =
".$Args["rsnew"]["DocEntry"]."");
//$Email -> ReplaceRecipient("onyangomeister@gmail.com");//ReplaceRecipient (GetRecommendmail($Args["rsnew"]["country"]));
$Email -> Cc = CurrentUserInfo("email_addr");
//$Email->AddCc()
$Email -> Subject = "JOB ORDER COMPLETED" ; // Change the subject Email
$Email -> Content = "Flight Number: ".$Args["rsnew"]["DocEntry"]."<br/>";
$Email -> Content .="Sales/Job Order Number: ".$SoNo."<br/>";
$Email -> Content .="Customer: ".$Cust."<br/>";
$Email -> Content .="Cargo Type: ".$Ctype."<br/>";
$Email -> Content .="Plane Registration: ".$Args["rsnew"]["U_FlightNumber"]."<br/>";
$Email -> Content .="Rotation: ".$Args["rsnew"]["U_Source"].",".$Args["rsnew"]["U_Destination"]."<br/>";
$Email -> Content .="Weight(KG): ".$Weight."<br/>";
$Email -> Content .="Status: Ready for Invoicing";
This code works successfully when inserting only one record to the detail table, but when there are multiple detail items inserted, an email is only sent for the first item inserted.
I understand that part of the problem is that ew_ExecuteScalar() only fetches the 1st result, and I should probably change it.
My problem is how to modify this code to send emails when the items inserted in the details table are more than one.
Any assistance would be appreciated.