Hello all,
I would like to select records from a Parent view and have the email button include all child records in the email. The code I currently have works but only sends the first child record of each parent I select.
Can anyone see what I am missing to have the email include ALL the child records? Any and all help is appreciated.
I created a button on the Parent View list page with the following code:
SERVER TAB:
global $dal;
$dal_TableName = $dal->Table("TABLE1");
$body=""; 
foreach(@$keys as $keyblock){ 
 $arr=split("&",refine($keyblock["TABLE1_ID"]));
 if(count($arr)<1)
 continue;
 $arr2=array();
 $arr2["TABLE1_ID"]=urldecode(@$arr[0]);
 $where = KeyWhere($arr2);
 $rstmp = $dal_TableName->Query($where,"");
 $datatmp=db_fetch_array($rstmp );
 
 $body .= $datatmp['FROM_CITY'] ." Manifest ID: " .$datatmp['TABLE1_ID'] ."\n";
 $body .= $datatmp['PALLET'] ." " .$datatmp['T_TAG'] ." " .$datatmp['MODEL_DESC'] ."\n-----------\n\n";
} 
// send the email 
$email="test@test.com"; 
$subject="Manifest Shipment"; 
$arr = runner_mail(array('to' => $email, 'subject' => $subject,
'body' => $body));
// if error happened print a message, else complete
if (!$arr["mailed"]){ 
 $errmsg = "Error happened: 
";
 $errmsg.= "File: " . $arr["errors"][0]["file"] . "
";
 $errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";
 $errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";
 $result["txt"] = $errmsg;
}else{
 $result["txt"] = "Email sent."; 
}
CLIENT AFTER TAB:
var message = result["txt"];
ctrl.setMessage(message);
CLIENT BEFORE TAB IS BLANK