diff --git a/booking.admin.inc b/booking.admin.inc index b09a901..2cfc782 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -399,213 +399,3 @@ drupal_set_message( t('Conference date range: "!date"', array ('!date' => _date_ */ } - - -function booking_manual_email() -{ - global $event; - //see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios - $form = array (); - $options = array (); - $group_text = ""; - $prefix = t("
Send a manual email to people registered for this event.
"); - $email_options_array = array(); - $email_options_array['registration'] = 'Registration Successful Email'; - $email_options_array['balance'] = 'Balance Outstanding Email'; - $email_options_array['complete'] = 'Payment Complete Email'; - $email_options_array['withdrawal'] = 'Withdrawal Processed Email'; - $email_options_array['missedpayment'] = 'Missed Payment Email'; - $email_options_array['travelrequired'] = 'Travel Form Required Email'; - $email_options_array['travelcomplete'] = 'Travel Form Complete Email'; - - //add in the custom email types - for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) - { - $email_options_array['custom' . $i] = variable_get('booking_email_subject_custom' . $i, $event->booking_eventname . ' custom ' . $i); - } - - $form['email-type'] = array( - '#type' => 'select', - '#title' => t('Email Type'), - '#required' => TRUE, - '#default_value' => '', - '#options' => $email_options_array, - ); - - /* - $header = array ( - 'booking_nid' => array('data' => t('Booking ID')), - 'booking_name' => array('data' => t('Name')), - 'booking_email' => array('data' => t('Email Address')), - 'amount_paid' => array('data' => t('Amount Paid To Date')), - 'amount_reqd' => array('data' => t('Gross Payment Required')), - 'booking_status' => t('Status'), - 'booking_fully_paid' => t('Fully Paid?'), - 'welfare_required' => t('Welfare Required?'), - ); - */ - - $header = array( - 'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'), - 'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'), - 'booking_gender' => array('data' => t('Gender'), 'field' => 'booking_gender'), - 'booking_email' => array('data' => t('Email'), 'field' => 'booking_email'), - 'booking_state' => array('data' => t('State'), 'field' => 'booking_state'), - 'booking_status' => array('data' => t('Status'), 'field' => 'booking_status'), - 'amount_paid' => array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'), - 'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'), - 'booking_fully_paid' => array('data' => t('Fully paid?'), 'field' => 'booking_payment_complete'), - 'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'), - 'travel_form' => array('data' => t('Travel Submitted?'), 'field' => 'tid'), - ); - - if (variable_get('booking_enable_studygroups', 0) == 1) - { - //select entries from the study groups mapping table - $group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid)); - $group_mapping = $group_mapping_query->fetchAllAssoc('sid'); - $header['group_roles'] = array('data' => t('Group Role')); - } - - $query = db_select('booking_person', 'p'); - $query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id'); - $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); - - $query->fields('p') - ->fields('pr', array('booking_price', 'booking_late_price')) - ->fields('t') - ->condition('p.booking_event_id', $event->eid, '='); - - $table_sort = $query->extend('TableSort')->orderbyHeader($header); - $result = $table_sort->execute(); - - //$result = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid", - // array(':eid' => $event->eid)); - - foreach($result as $data) - { - $group_text = ""; - //$paid = _booking_amount_owing($data); - //$paid = _booking_amount_owing($data->nid); - $options[$data->nid] = array ( - 'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))), - 'booking_name' => $data->booking_firstname . " " . $data->booking_lastname, - 'booking_gender' => $data->booking_gender == 'M' ? 'Male' : 'Female', - 'booking_email' => $data->booking_email, - 'booking_state' => $data->booking_state, - 'booking_status' => _booking_status_generate($data->booking_status), - 'amount_paid' => $data->booking_amount_paid, - 'amount_reqd' => $data->booking_total_pay_reqd, - 'booking_fully_paid' => $data->booking_payment_complete == 'Y' ? 'Yes' : 'No', - 'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No', - 'travel_form' => $data->tid > 0 ? 'Yes' : 'No', - ); - - if (variable_get('booking_enable_studygroups', 0) == 1) - { - foreach ($group_mapping as $group) - { - $role = $group->booking_studygroup_role; - - if ($group->booking_node_id == $data->nid && $role > 0) - { - $text = _booking_studygroup_role_lookup($role); - $group_text .= "" . $text . " group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; "; - } - } - $options[$data->nid]['group_roles'] = $group_text; - } - - //$values[$data->nid] = ($paid == 0 || $data->booking_status != 1) ? FALSE : TRUE; - } - - $form['table'] = array ( - '#type' => 'tableselect', - '#header' => $header, - '#options' => $options, - //'#default_value' => $values, - '#empty' => t('No attendees found.'), - '#attributes' => array('id' => 'sort-table'), - ); - - $form['submit'] = array ( - '#type' => 'submit', - '#value' => t('Send Email'), - ); - - return array ( - 'first_para' => array ( - '#type' => 'markup', - '#markup' => $prefix, - ), - 'form' => $form, - ); -} - -function booking_manual_email_submit($form, &$form_state) { - $counter = 0; - $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))); - - foreach($checkboxes as $key => $value) - { - if (is_numeric($key) && $value != 0) - { - //check if they exist in the database first - $person = db_query("SELECT person.nid " . - "FROM {booking_person} person " . - "WHERE nid = :nid", - array(':nid' => $key)) - ->fetchObject(); - - if ($person) - { - if ($form_state['values']['email-type'] == 'registration') - { - watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key)); - _booking_registration_email($key, false, true); - } - elseif ($form_state['values']['email-type'] == 'travelrequired') - { - watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key)); - _booking_travelform_request_email($key); - } - elseif ($form_state['values']['email-type'] == 'balance') - { - watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key)); - _booking_balance_payment_email($key); - } - elseif ($form_state['values']['email-type'] == 'complete') - { - watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key)); - _booking_registration_email($key, true, true); - } - elseif ($form_state['values']['email-type'] == 'travelcomplete') - { - watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key)); - _booking_travelform_confirmation_email($key); - } - elseif ($form_state['values']['email-type'] == 'withdrawal') - { - watchdog('booking', 'Processing a manual withdrawal email to id @info', array ('@info' => $key)); - _booking_demoted_to_notcoming_email($key); - } - elseif ($form_state['values']['email-type'] == 'missedpayment') - { - watchdog('booking', 'Processing a manual missedpayment email to id @info', array ('@info' => $key)); - _booking_missedpayment_email($key); - } - 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)); - _booking_custom_email($key, $form_state['values']['email-type']); - } - //increase the counter of people we've emailed - $counter++; - } - } - } - drupal_set_message("Sent manual email for $counter people.", 'status', FALSE); - //watchdog('booking', "Sent manual email for $counter people."); -} \ No newline at end of file diff --git a/booking.emails.inc b/booking.emails.inc index 99f9690..2ca15a6 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -1,5 +1,214 @@ Send a manual email to people registered for this event."); + $email_options_array = array(); + $email_options_array['registration'] = 'Registration Successful Email'; + $email_options_array['balance'] = 'Balance Outstanding Email'; + $email_options_array['complete'] = 'Payment Complete Email'; + $email_options_array['withdrawal'] = 'Withdrawal Processed Email'; + $email_options_array['missedpayment'] = 'Missed Payment Email'; + $email_options_array['travelrequired'] = 'Travel Form Required Email'; + $email_options_array['travelcomplete'] = 'Travel Form Complete Email'; + + //add in the custom email types + for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) + { + $email_options_array['custom' . $i] = variable_get('booking_email_subject_custom' . $i, $event->booking_eventname . ' custom ' . $i); + } + + $form['email-type'] = array( + '#type' => 'select', + '#title' => t('Email Type'), + '#required' => TRUE, + '#default_value' => '', + '#options' => $email_options_array, + ); + + /* + $header = array ( + 'booking_nid' => array('data' => t('Booking ID')), + 'booking_name' => array('data' => t('Name')), + 'booking_email' => array('data' => t('Email Address')), + 'amount_paid' => array('data' => t('Amount Paid To Date')), + 'amount_reqd' => array('data' => t('Gross Payment Required')), + 'booking_status' => t('Status'), + 'booking_fully_paid' => t('Fully Paid?'), + 'welfare_required' => t('Welfare Required?'), + ); + */ + + $header = array( + 'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'), + 'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'), + 'booking_gender' => array('data' => t('Gender'), 'field' => 'booking_gender'), + 'booking_email' => array('data' => t('Email'), 'field' => 'booking_email'), + 'booking_state' => array('data' => t('State'), 'field' => 'booking_state'), + 'booking_status' => array('data' => t('Status'), 'field' => 'booking_status'), + 'amount_paid' => array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'), + 'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'), + 'booking_fully_paid' => array('data' => t('Fully paid?'), 'field' => 'booking_payment_complete'), + 'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'), + 'travel_form' => array('data' => t('Travel Submitted?'), 'field' => 'tid'), + ); + + if (variable_get('booking_enable_studygroups', 0) == 1) + { + //select entries from the study groups mapping table + $group_mapping_query = db_query("SELECT * FROM {booking_studygroup_mapping} WHERE booking_eventid = :eid", array(':eid' => $event->eid)); + $group_mapping = $group_mapping_query->fetchAllAssoc('sid'); + $header['group_roles'] = array('data' => t('Group Role')); + } + + $query = db_select('booking_person', 'p'); + $query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id'); + $query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid'); + + $query->fields('p') + ->fields('pr', array('booking_price', 'booking_late_price')) + ->fields('t') + ->condition('p.booking_event_id', $event->eid, '='); + + $table_sort = $query->extend('TableSort')->orderbyHeader($header); + $result = $table_sort->execute(); + + //$result = db_query("SELECT * FROM {booking_person} WHERE booking_event_id = :eid", + // array(':eid' => $event->eid)); + + foreach($result as $data) + { + $group_text = ""; + //$paid = _booking_amount_owing($data); + //$paid = _booking_amount_owing($data->nid); + $options[$data->nid] = array ( + 'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))), + 'booking_name' => $data->booking_firstname . " " . $data->booking_lastname, + 'booking_gender' => $data->booking_gender == 'M' ? 'Male' : 'Female', + 'booking_email' => $data->booking_email, + 'booking_state' => $data->booking_state, + 'booking_status' => _booking_status_generate($data->booking_status), + 'amount_paid' => $data->booking_amount_paid, + 'amount_reqd' => $data->booking_total_pay_reqd, + 'booking_fully_paid' => $data->booking_payment_complete == 'Y' ? 'Yes' : 'No', + 'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No', + 'travel_form' => $data->tid > 0 ? 'Yes' : 'No', + ); + + if (variable_get('booking_enable_studygroups', 0) == 1) + { + foreach ($group_mapping as $group) + { + $role = $group->booking_studygroup_role; + + if ($group->booking_node_id == $data->nid && $role > 0) + { + $text = _booking_studygroup_role_lookup($role); + $group_text .= "" . $text . " group " . $group->booking_studygroup_id . " #" . $group->booking_session_id . "; "; + } + } + $options[$data->nid]['group_roles'] = $group_text; + } + + //$values[$data->nid] = ($paid == 0 || $data->booking_status != 1) ? FALSE : TRUE; + } + + $form['table'] = array ( + '#type' => 'tableselect', + '#header' => $header, + '#options' => $options, + //'#default_value' => $values, + '#empty' => t('No attendees found.'), + '#attributes' => array('id' => 'sort-table'), + ); + + $form['submit'] = array ( + '#type' => 'submit', + '#value' => t('Send Email'), + ); + + return array ( + 'first_para' => array ( + '#type' => 'markup', + '#markup' => $prefix, + ), + 'form' => $form, + ); +} + +function booking_manual_email_submit($form, &$form_state) { + $counter = 0; + $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))); + + foreach($checkboxes as $key => $value) + { + if (is_numeric($key) && $value != 0) + { + //check if they exist in the database first + $person = db_query("SELECT person.nid " . + "FROM {booking_person} person " . + "WHERE nid = :nid", + array(':nid' => $key)) + ->fetchObject(); + + if ($person) + { + if ($form_state['values']['email-type'] == 'registration') + { + watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key)); + _booking_registration_email($key, false, true); + } + elseif ($form_state['values']['email-type'] == 'travelrequired') + { + watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key)); + _booking_travelform_request_email($key); + } + elseif ($form_state['values']['email-type'] == 'balance') + { + watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key)); + _booking_balance_payment_email($key); + } + elseif ($form_state['values']['email-type'] == 'complete') + { + watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key)); + _booking_registration_email($key, true, true); + } + elseif ($form_state['values']['email-type'] == 'travelcomplete') + { + watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key)); + _booking_travelform_confirmation_email($key); + } + elseif ($form_state['values']['email-type'] == 'withdrawal') + { + watchdog('booking', 'Processing a manual withdrawal email to id @info', array ('@info' => $key)); + _booking_demoted_to_notcoming_email($key); + } + elseif ($form_state['values']['email-type'] == 'missedpayment') + { + watchdog('booking', 'Processing a manual missedpayment email to id @info', array ('@info' => $key)); + _booking_missedpayment_email($key); + } + 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)); + _booking_custom_email($key, $form_state['values']['email-type']); + } + //increase the counter of people we've emailed + $counter++; + } + } + } + drupal_set_message("Sent manual email for $counter people.", 'status', FALSE); + //watchdog('booking', "Sent manual email for $counter people."); +} + /** * Function to send email to registrant after completing registration process diff --git a/booking.reports.inc b/booking.reports.inc index 08b71be..5ad1b24 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -223,18 +223,18 @@ function booking_report_summary() { //output everything $output .= t("There are !boys males and !girls females currently booked in. Of these, !baptised are baptised and !married are married.
", - array('!boys' => $male_count, '!girls' => $female_count, '!baptised' => $baptised_count, '!married' => $married_count - )); - $output .= t("The combined average age at the start of the week will be !average.
The male average age will be !maleaverage.
The female average age will be !femaleaverage.
There are !bookedin registrations currently booked in, !waiting on waiting list, !notpaid haven't paid, !hosts are hosts, " . "and !notcoming are no longer coming, which comes to a total of !total people who have filled in the registration form. !travel people have filled in their travel form.
", array('!bookedin' => $bookedin_counter, '!waiting' => $waiting_counter, '!notpaid' => $notpaid_counter, '!total' => $person_count, '!travel' => $travelform_count, '!notcoming' => $notcoming_counter, '!hosts' => $hosts_counter)); + $output .= t("There are !boys males and !girls females currently booked in. Of these, !baptised are baptised and !married are married.
", + array('!boys' => $male_count, '!girls' => $female_count, '!baptised' => $baptised_count, '!married' => $married_count + )); + $output .= t("The combined average age at the start of the week will be !average.
The male average age will be !maleaverage.
The female average age will be !femaleaverage.
There are !welfare people with special financial consideration approved, and !committee people on the committee. " . "!fullypaid people have completed their payments.
",