add attachment to email if it exists

This commit is contained in:
Nathan Coad
2018-06-16 20:10:28 +10:00
parent 04fc135818
commit 84fcd20507
2 changed files with 26 additions and 26 deletions

View File

@@ -442,7 +442,9 @@ function booking_manual_email_from_validation($form, &$form_state) {
*/
function booking_manual_email_form_submit($form, &$form_state) {
$counter = 0;
$update_messages = array();
$message = "";
$attachment = NULL;
$update_messages = array();
$checkboxes = $form_state['values']['table']; //$values['booking_price_active'];
//watchdog('booking', 'Formstate when setting buttons: @info', array ('@info' => var_export($form_state['values'], TRUE)));
//watchdog('booking', 'Checkboxes when setting buttons: @info', array ('@info' => var_export($checkboxes, TRUE)));
@@ -452,22 +454,17 @@ function booking_manual_email_form_submit($form, &$form_state) {
watchdog('booking_debug', 'File attachment detected: @info', array ('@info' => print_r($attachment, TRUE)));
}
foreach($checkboxes as $key => $value)
{
$message = "";
foreach($checkboxes as $key => $value) {
//do a sanity check on the key => value pair from the form submission
if (is_numeric($key) && $value != 0)
{
if (is_numeric($key) && $value != 0) {
//check the person exists in the database
$person = db_query("SELECT person.nid " .
"FROM {booking_person} person " .
"WHERE nid = :nid",
array(':nid' => $key))
->fetchObject();
$person = db_query("SELECT person.nid " .
"FROM {booking_person} person " .
"WHERE nid = :nid",
array(':nid' => $key))
->fetchObject();
if ($person)
{
if ($person) {
if ($form_state['values']['email-type'] == 'registration') {
$message = t('Processing a manual registration email to id @info', array ('@info' => $key));
_booking_registration_email($key, false, true);
@@ -510,11 +507,11 @@ function booking_manual_email_form_submit($form, &$form_state) {
}
elseif (strpos($form_state['values']['email-type'], 'customlogistics') !== false) {
$message = t('Processing a @custom type email from logistics to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
_booking_custom_email($key, $form_state['values']['email-type'], 'logistics');
_booking_custom_email($key, $form_state['values']['email-type'], 'logistics', $attachment);
}
elseif (strpos($form_state['values']['email-type'], 'custom') !== false) {
$message = t('Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
_booking_custom_email($key, $form_state['values']['email-type'], 'contact');
_booking_custom_email($key, $form_state['values']['email-type'], 'contact', $attachment);
}
//increase the counter of people we've emailed
$counter++;