Add comment field and tweak email logging

This commit is contained in:
2015-09-17 09:44:47 +10:00
parent 512366deb9
commit 270dd5b43f
5 changed files with 60 additions and 20 deletions

View File

@@ -143,15 +143,19 @@ function booking_manual_email()
function booking_manual_email_submit($form, &$form_state) { function booking_manual_email_submit($form, &$form_state) {
$counter = 0; $counter = 0;
$update_messages = array();
$checkboxes = $form_state['values']['table']; //$values['booking_price_active']; $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', '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))); //watchdog('booking', 'Checkboxes when setting buttons: @info', array ('@info' => var_export($checkboxes, TRUE)));
foreach($checkboxes as $key => $value) foreach($checkboxes as $key => $value)
{ {
$message = "";
//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 if they exist in the database first //check the person exists in the database
$person = db_query("SELECT person.nid " . $person = db_query("SELECT person.nid " .
"FROM {booking_person} person " . "FROM {booking_person} person " .
"WHERE nid = :nid", "WHERE nid = :nid",
@@ -162,50 +166,63 @@ function booking_manual_email_submit($form, &$form_state) {
{ {
if ($form_state['values']['email-type'] == 'registration') if ($form_state['values']['email-type'] == 'registration')
{ {
watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key)); $message = t('Processing a manual registration email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key));
_booking_registration_email($key, false, true); _booking_registration_email($key, false, true);
} }
elseif ($form_state['values']['email-type'] == 'travelrequired') elseif ($form_state['values']['email-type'] == 'travelrequired')
{ {
watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key)); $message = t('Processing a manual travel form request email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key));
_booking_travelform_request_email($key); _booking_travelform_request_email($key);
} }
elseif ($form_state['values']['email-type'] == 'balance') elseif ($form_state['values']['email-type'] == 'balance')
{ {
watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key)); $message = t('Processing a manual outstanding balance email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key));
_booking_balance_payment_email($key); _booking_balance_payment_email($key);
} }
elseif ($form_state['values']['email-type'] == 'complete') elseif ($form_state['values']['email-type'] == 'complete')
{ {
watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key)); $message = t('Processing a manual registration complete email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key));
_booking_registration_email($key, true, true); _booking_registration_email($key, true, true);
} }
elseif ($form_state['values']['email-type'] == 'travelcomplete') elseif ($form_state['values']['email-type'] == 'travelcomplete')
{ {
watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key)); $message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key));
_booking_travelform_confirmation_email($key); _booking_travelform_confirmation_email($key);
} }
elseif ($form_state['values']['email-type'] == 'withdrawal') elseif ($form_state['values']['email-type'] == 'withdrawal')
{ {
watchdog('booking', 'Processing a manual withdrawal email to id @info', array ('@info' => $key)); $message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual withdrawal email to id @info', array ('@info' => $key));
_booking_demoted_to_notcoming_email($key); _booking_demoted_to_notcoming_email($key);
} }
elseif ($form_state['values']['email-type'] == 'missedpayment') elseif ($form_state['values']['email-type'] == 'missedpayment')
{ {
watchdog('booking', 'Processing a manual missedpayment email to id @info', array ('@info' => $key)); $message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
//watchdog('booking', 'Processing a manual missedpayment email to id @info', array ('@info' => $key));
_booking_missedpayment_email($key); _booking_missedpayment_email($key);
} }
elseif (strpos($form_state['values']['email-type'], 'custom') !== false) elseif (strpos($form_state['values']['email-type'], 'custom') !== false)
{ {
watchdog('booking', 'Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key)); $message = t('Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
//watchdog('booking', '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']); _booking_custom_email($key, $form_state['values']['email-type']);
} }
//increase the counter of people we've emailed //increase the counter of people we've emailed
$counter++; $counter++;
//store info about the email
$update_messages[] = $message;
} }
} }
} }
drupal_set_message("Sent manual email for $counter people.", 'status', FALSE); $final_message = "Sent manual email for $counter people.";
drupal_set_message($final_message, 'status', FALSE);
watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>");
//watchdog('booking', "Sent manual email for $counter people."); //watchdog('booking', "Sent manual email for $counter people.");
} }

View File

@@ -105,8 +105,7 @@ function _valid_australian_mobile_number($input)
{ {
if (preg_match('/^\s*(?:\+61|61|0061|0)(\d{3})\s*(\d{3})\s*(\d{3})\s*$/', $input, $matches)) if (preg_match('/^\s*(?:\+61|61|0061|0)(\d{3})\s*(\d{3})\s*(\d{3})\s*$/', $input, $matches))
{ {
watchdog('booking', 'Australian Mobile Number "!passnum" validates since it passed our regexp', //watchdog('booking', 'Australian Mobile Number "!passnum" validates since it passed our regexp', array('!passnum' => $input));
array('!passnum' => $input));
return TRUE; return TRUE;
} }
else else
@@ -126,14 +125,14 @@ function _booking_check_bookings_full()
//check the number of people registered against the defined max //check the number of people registered against the defined max
if ($waitinglist_query->num_ppl >= variable_get('booking_regn_limit', 350)) if ($waitinglist_query->num_ppl >= variable_get('booking_regn_limit', 350))
{ {
watchdog('booking', 'There are !num people booked in, which is greater than or equal to the limit of !limit.', //watchdog('booking', 'There are !num people booked in, which is greater than or equal to the limit of !limit.',
array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) )); // array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) ));
return true; return true;
} }
else else
{ {
watchdog('booking', 'There are !num people booked in, which is less than the limit of !limit.', //watchdog('booking', 'There are !num people booked in, which is less than the limit of !limit.',
array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) )); // array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) ));
return false; return false;
} }
} }

View File

@@ -515,6 +515,14 @@ function booking_update_7230() {
db_add_field('booking_person', 'booking_dependant_children', $spec); db_add_field('booking_person', 'booking_dependant_children', $spec);
} }
/**
* Add comment field to registration record
*/
function booking_update_7231() {
$spec = array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE);
db_add_field('booking_person', 'booking_comment_field', $spec);
}
/** /**
* Implementation of hook_install(). * Implementation of hook_install().
*/ */
@@ -600,6 +608,7 @@ function booking_schema() {
'booking_dietary' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE), 'booking_dietary' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
'booking_medical_conditions' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE), 'booking_medical_conditions' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
'booking_random_facts' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE), 'booking_random_facts' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
'booking_comment_field' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
//address details //address details
'booking_street' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE), 'booking_street' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),

View File

@@ -164,6 +164,18 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
// The status field should not be visible unless this registration is being updated...i.e. not at actual registration time... // The status field should not be visible unless this registration is being updated...i.e. not at actual registration time...
if ($inserting != TRUE) { if ($inserting != TRUE) {
$form['your-details']['booking_comment_field'] = array(
'#type' => 'textarea',
'#title' => t('Comments relating to this registration. Internal only.'),
'#cols' => 60,
'#rows' => 5,
'#resizable' => TRUE,
'#required' => FALSE,
'#attributes' => array('maxlength' => 1000),
'#default_value' => !empty($data->booking_comment_field) ? $data->booking_comment_field : '',
);
$form['your-details']['booking_status'] = array( $form['your-details']['booking_status'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Registration Status'), '#title' => t('Registration Status'),
@@ -221,7 +233,7 @@ function booking_form($node, &$form_state, $inserting = FALSE) {
'#default_value' => !empty($data->booking_refund_due) ? $data->booking_refund_due : '0.00' '#default_value' => !empty($data->booking_refund_due) ? $data->booking_refund_due : '0.00'
); );
} //end inserting check for booking status } //end inserting check for admin-only fields
//tshirts //tshirts
if (variable_get('booking_enable_tshirts', 0) == 1) if (variable_get('booking_enable_tshirts', 0) == 1)
@@ -1348,6 +1360,7 @@ function booking_form_submit($form, &$form_state) {
$node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details']; $node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details'];
$node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N'); $node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N');
$node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details']; $node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details'];
$node->booking_comment_field = empty($values['booking_comment_field']) ? '' : $values['booking_comment_field'];
//potential fields for future //potential fields for future
//$node->booking_payment_method = $payment_method; //$node->booking_payment_method = $payment_method;

View File

@@ -237,6 +237,7 @@ function booking_insert($node) {
'booking_refund_processed' => $node->booking_refund_processed, 'booking_refund_processed' => $node->booking_refund_processed,
'booking_committee_member' => $node->booking_committee_member, 'booking_committee_member' => $node->booking_committee_member,
'booking_random_facts' => $node->booking_random_facts, 'booking_random_facts' => $node->booking_random_facts,
'booking_comment_field' => $node->booking_comment_field,
)) ))
->execute(); ->execute();
} }
@@ -344,7 +345,7 @@ function booking_update($node) {
'booking_committee_member' => ($node->booking_committee_member == 1 ? 'Y' : 'N'), 'booking_committee_member' => ($node->booking_committee_member == 1 ? 'Y' : 'N'),
'booking_random_facts' => $node->booking_random_facts, 'booking_random_facts' => $node->booking_random_facts,
'booking_status' => $node->booking_status, 'booking_status' => $node->booking_status,
'booking_comment_field' => $node->booking_comment_field,
)) ))
->condition('nid', $node->nid) ->condition('nid', $node->nid)
->execute(); ->execute();
@@ -641,6 +642,7 @@ function booking_view($node, $view_mode) {
$rows[] = array(t('Name:'), t('!first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname))); $rows[] = array(t('Name:'), t('!first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)));
$rows[] = array(t('Gender:'), t('!gender', array('!gender' => $node->booking_gender == 'M' ? 'Male' : 'Female'))); $rows[] = array(t('Gender:'), t('!gender', array('!gender' => $node->booking_gender == 'M' ? 'Male' : 'Female')));
$rows[] = array(t('Status:'), t('!status', array('!status' => _booking_status_generate($node->booking_status)))); $rows[] = array(t('Status:'), t('!status', array('!status' => _booking_status_generate($node->booking_status))));
$rows[] = array(t('Internal comments on this registration:'), $node->booking_comment_field);
$rows[] = array(t('Committee Member:'), t('!ans', array('!ans' => ($node->booking_committee_member == 'Y' ? '<b>Yes</b>' : 'No')))); $rows[] = array(t('Committee Member:'), t('!ans', array('!ans' => ($node->booking_committee_member == 'Y' ? '<b>Yes</b>' : 'No'))));
$rows[] = array(t('Welfare Required:'), $node->booking_welfare_required == 'Y' ? 'Yes' : 'No'); $rows[] = array(t('Welfare Required:'), $node->booking_welfare_required == 'Y' ? 'Yes' : 'No');
$rows[] = array(t('Barcode:'), t('!id', array('!id' => $node->booking_barcode))); $rows[] = array(t('Barcode:'), t('!id', array('!id' => $node->booking_barcode)));