This topic is locked

stop email selected records if a field is different

11/11/2016 4:15:47 AM
PHPRunner General questions
F
fantasmino author

How can I stop sending email if the data of a field in one of the records it's different.

email proocedure like the example:

server tab:

$body = "";

while( $data = $button->getNextSelectedRecord() )

{

$body .= "OrderID: " . $data['OrderID'] . "\n";

$body .= "Customer: " . $data['CustomerID'] . "\n";

$body .= "Employee: " . $data['EmployeeID'] . "\n-----------\n\n";

}

// send the email

$email = "test@test.com";

$subject = "Sample subject";

$arr = runner_mail(array('to' => $email, 'subject' => $subject,'body' => $body));

$result["txt"] = "Emails were sent.";

// if error happened print a message on the web page

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;

}



if the data are like this I want to stop and get an error becouse the customer is different
Sample email message:

OrderID: 10249

Customer: TRADH

Employee: 6

-------------------

OrderID: 10251

Customer: TRADH

Employee: 3

-------------------

OrderID: 10253

Customer: HANAR

Employee: 3

-------------------

OrderID: 10251

Customer: TRADH

Employee: 3
If the selected data is like this and customer always the same it's ok and send email
Sample email message:

OrderID: 10249

Customer: TRADH

Employee: 6

-------------------

OrderID: 10251

Customer: TRADH

Employee: 3

-------------------

OrderID: 10251

Customer: TRADH

Employee: 3
Thank you

L
laonian 11/11/2016

What you can do is to add a client before event and in there check if all the selected records have the same customer value.

If it does not pass, simply alert the user to re-select the records and return false.