Matt
I'll answer your questions best I can ...
1.....
I currently already use the email notifications for updates ....
Well this changes things then. If you're already using the auto-email functionality, then the manual link/button will need to be revisited. If it was set up to send email based on the email field, then it would send it everytime that record was updated - even if the update was not to that field. I'll have to look at the other code again to see if I can get it to work.
2.....
Unless you don't think it's that big a task to send 2 different emails?
It really depends on the amount of change you need. Details, details, details. Who knows?
Before that, we should get the email links working though .....
Try this code to test the mail functionality when clicking on the links (add part NOT in bold and update the red items to match what you have in your own DB):
[pre]
echo $form;
if ($table_name == 'customer_booking_form') {
$email_details = execute_db($sql, $conn);
$emaildet = fetch_row_db ($email_details);
$emailto = $emaildet['
textemailfield'];
$orderno = $emaildet['
orderNoFld'];
// build the reminder / overdue message - just using this to test with for now
$reminder_email = 'Testing reminder email variable';//build_insert_update_notice_email_record_details($fields_labels_ar, $email_details);
$to_addresses = '';
$cc_addresses = '';
$bcc_addresses = '';
$to_addresses = $emailto; // this is from the db query above (below echo $form
- use your own email to test email sending
foreach ($update_notice_email_cc_recipients_ar as $update_notice_email_cc_recipient){
$cc_addresses .= $update_notice_email_cc_recipient.', ';
} // end foreach
// you could put your email address in the $update_notice_email_cc_recipients_ar part of config.php OR hardcode your email address here if you want to get a cc on these mailings - leave as is / blank in config if you don't want cc on email - this you will need to decide how you want to use ...
$cc_addresses = substr($cc_addresses, 0, -2); // delete the last ', '
foreach ($update_notice_email_bcc_recipients_ar as $update_notice_email_bcc_recipient){
$bcc_addresses .= $update_notice_email_bcc_recipient.', ';
} // end foreach
$bcc_addresses = substr($bcc_addresses, 0, -2); // delete the last ', '
$additional_headers = '';
if ($cc_addresses != '') {
$additional_headers .= "Cc:".$cc_addresses."\n";
} // end if
if ($bcc_addresses != '') {
$additional_headers .= "Bcc:".$bcc_addresses;
} // end if
// modify the text below which will go into your subject line:
if (isset($_GET["receipt"]) && ($_GET["receipt"] != '')) {
$msgset = $_GET["receipt"];
$msgtype = 'Your Receipt';
//mail(TO, SUBJECT, MESSAGE, HEADERS(CC, BCC, etc));
//make adjustments as needed to the mail line:
if (mail($to_addresses, $msgtype.' - '.$orderno, $reminder_email, $additional_headers)) {
$msgsent = ' - Receipt email sent';
}
} elseif (isset($_GET["latepmt"]) && ($_GET["latepmt"] != '')) {
$msgset = $_GET["latepmt"];
$msgtype = 'Payment Overdue';
if (mail($to_addresses, $msgtype.' - '.$orderno, $reminder_email, $additional_headers)) {
$msgsent = ' - Late Payment email sent';
}
} else {
$msgset = '';
$msgtype = '';
$msgsent = '';
}
txt_out('<ul type="disc"><b>Email actions on current record:</b><ul type="disc">');
//receipt email link
txt_out('<li>[url='.preg_replace(]Send Receipt Email[/url] - '.$to_addresses.$msgsent);
// late payment reminder
txt_out('<li>[url='.preg_replace(]Send Late Payment Reminder Email[/url]'.$msgsent);
txt_out('</ul></ul>'); // closes the list
} // end code for email links in customer_booking_form table edit pages
reset($fields_labels_ar);
foreach($fields_labels_ar as $field_label){ // for each field of this table
[/pre]
Try this to confirm the email gets sent (to test, just put your email address in the $to_addresses field). Once we can confirm that the basic email works, then send me what you want to have in each email message (include field names you need included) and we can look at customizing the email message being delivered.
Of course, you could still add the Receipt sent and Late Pmt email sent to the list of status messages (or a new field) if you want to track that.