diff --git a/booking.admin.inc b/booking.admin.inc index b1d2f8f..52f62d6 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -194,7 +194,14 @@ function booking_admin() { '#default_value' => variable_get('booking_dietary_text_definition', ''), '#description' => 'Text to use if attendee may not specify dietary requirements (as above).', ); - + $form['misc']['booking_csv_exclude_fields'] = array ( + '#type' => 'textfield', + '#title' => t('Fields to exclude from CSV report'), + '#default_value' => variable_get('booking_csv_exclude_fields', ''), + '#description' => 'Separate each field with a semi-colon. Field names as per database schema.', + '#size' => 150, + '#maxlength' => 500, + ); return system_settings_form($form); } diff --git a/booking.emails.inc b/booking.emails.inc index 3224af5..461cc83 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -39,8 +39,9 @@ $params['subject'] = $subject; $params['body'] = $body; + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); drupal_mail('booking', 'registration_mail', $to, $language, $params, $from); - drupal_mail('booking', 'registration_mail', 'it@coadcorp.com', $language, $params, $from); + //drupal_mail('booking', 'registration_mail', 'it@coadcorp.com', $language, $params, $from); //send a notification email if we didn't automatically send one earlier if (variable_get('booking_auto_confirm_email', 0) == 1) @@ -142,6 +143,7 @@ function _booking_balance_payment_email($nid) $to = $node->booking_email; $subject = t('!event Payment Required', array('!event' => $event->booking_eventname)); $params['subject'] = $subject; + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); //retrieve the body of the email for a married couple only if we're combining pricing for couples if (variable_get('booking_enable_combined_pricing', 0) == 1 && $node->booking_partner_id > 0) @@ -157,9 +159,10 @@ function _booking_balance_payment_email($nid) //send the email drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from); - drupal_mail('booking', 'registration_mail_bal_outstanding', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), - $language, $params, $from); - drupal_mail('booking', 'registration_mail_bal_outstanding', 'it@coadcorp.com', $language, $params, $from); + $params['headers']['Bcc'] = "it@coadcorp.com"; + //drupal_mail('booking', 'registration_mail_bal_outstanding', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), + // $language, $params, $from); + //drupal_mail('booking', 'registration_mail_bal_outstanding', 'it@coadcorp.com', $language, $params, $from); } /** @@ -190,15 +193,18 @@ function _booking_custom_email($nid, $email_type) $to = $node->booking_email; $subject = token_replace(variable_get($email_subject_variable, t('!event', array('!event' => $event->booking_eventname))), $tokens); $params['subject'] = $subject; + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); //retrieve the body of the email $params['body'] = token_replace(variable_get($email_body_variable), $tokens); - //send the email + //send the email to the person drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); - drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), - $language, $params, $from); - drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from); + //send a copy to the site admins so they know it sent successfully + //$params['headers']['Bcc'] = "it@coadcorp.com"; + //drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), + // $language, $params, $from); + //drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from); } @@ -226,15 +232,16 @@ function _booking_promoted_from_waitinglist_email($nid) $to = $node->booking_email; $subject = t('!event Position Available', array('!event' => $event->booking_eventname)); $params['subject'] = $subject; + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_waitinglistpromotion'), $tokens); //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); - drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), - $language, $params, $from); - drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from); + //drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), + // $language, $params, $from); + //drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from); } @@ -263,15 +270,16 @@ function _booking_demoted_to_notcoming_email($nid) $subject = token_replace(variable_get('booking_email_notcoming_demotion_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens); //$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname)); $params['subject'] = $subject; + $params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))); //retrieve the body of the email $params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens); //send the email drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from); - drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), - $language, $params, $from); - drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from); + //drupal_mail('booking', 'booking_email_custom', variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from'))), + // $language, $params, $from); + //drupal_mail('booking', 'booking_email_custom', 'it@coadcorp.com', $language, $params, $from); } diff --git a/booking.helper.inc b/booking.helper.inc index ffcdb57..de662fa 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -425,7 +425,7 @@ function _booking_amount_paid($nid, $person = NULL) //check for a spouse if ($person->booking_partner_id > 0) { - watchdog('booking', "Checking total paid for married person"); + //watchdog('booking', "Checking total paid for married person"); //if we're combining the payment for married couples if (variable_get('booking_enable_combined_pricing', 0) == 1) @@ -446,7 +446,7 @@ function _booking_amount_paid($nid, $person = NULL) foreach ($query as $payment) $amount_paid += ($payment->booking_mc_gross - $payment->booking_mc_fee); - watchdog('booking', "Total amount paid according to paypal payments table is " . $amount_paid); + //watchdog('booking', "Total amount paid according to paypal payments table is " . $amount_paid); //if there were no results, $amount_paid will still be 0 if ($amount_paid == 0) @@ -460,12 +460,12 @@ function _booking_amount_paid($nid, $person = NULL) array(':nid' => $person->booking_partner_id)) ->fetchObject(); $amount_paid = $person->booking_amount_paid + $spouse->booking_amount_paid; - watchdog('booking', "Total combined payments for couple based on totals in booking_person table is " . $amount_paid); + //watchdog('booking', "Total combined payments for couple based on totals in booking_person table is " . $amount_paid); } else { $amount_paid = $person->booking_amount_paid; - watchdog('booking', "Total amount paid for individual based on totals in booking_person table is " . $amount_paid); + //watchdog('booking', "Total amount paid for individual based on totals in booking_person table is " . $amount_paid); } } @@ -488,7 +488,7 @@ function _booking_amount_paid($nid, $person = NULL) // $amount_paid = $person->booking_amount_paid; } - watchdog('booking', "Total amount already paid for this registration " . $nid . " is " . $amount_paid); + //watchdog('booking', "Total amount already paid for this registration " . $nid . " is " . $amount_paid); return $amount_paid; } @@ -501,7 +501,7 @@ function _booking_amount_owing($nid, $amount_paid = 0) //fetch details about the person $person = db_query("SELECT price.booking_price, price.booking_late_price, person.booking_payment_id, " . - "person.booking_total_pay_reqd, person.booking_amount_paid, person.booking_partner_id " . + "person.booking_total_pay_reqd, person.booking_amount_paid, person.booking_partner_id, person.booking_country " . "FROM {booking_person} person, {booking_price} price " . "WHERE person.nid = :nid " . "AND person.booking_payment_id = price.pid", @@ -514,12 +514,12 @@ function _booking_amount_owing($nid, $amount_paid = 0) else $total_due = $person->booking_late_price; - watchdog('booking', "Total amount due for this registration " . $nid . " is " . $total_due); + //watchdog('booking', "Total amount due for this registration " . $nid . " is " . $total_due); //if we didn't get the amount paid as a command line parameter, check it now if ($amount_paid == 0) { - watchdog('booking', "Checking total amount already paid by " . $nid); + //watchdog('booking', "Checking total amount already paid by " . $nid); $amount_paid = _booking_amount_paid($nid, $person); } @@ -595,7 +595,7 @@ function _booking_amount_owing($nid, $amount_paid = 0) if ($amount_paid >= $total_due) { - watchdog('booking', "This person doesn't owe any money: @info", array('@info' => var_export($person, TRUE))); + //watchdog('booking', "This person doesn't owe any money: @info", array('@info' => var_export($person, TRUE))); return 0; } @@ -605,7 +605,11 @@ function _booking_amount_owing($nid, $amount_paid = 0) //add the 30 cent fixed cost $amount_owing = $total_due - $amount_paid + 0.3; //and the 2.4 percent transaction fee - $amount_owing = $amount_owing / (1 - 0.024); + if ($person->booking_country === "Australia") + $amount_owing = $amount_owing / (1 - 0.024); + //paypal charges 3.4 percent if they're doing a currency conversion + else + $amount_owing = $amount_owing / (1 - 0.034); } else $amount_owing = $total_due - $amount_paid; diff --git a/booking.module b/booking.module index 19a1482..6bfecac 100644 --- a/booking.module +++ b/booking.module @@ -103,7 +103,16 @@ function booking_permission() { ), 'edit study groups' => array( 'title' => t('Edit study groups'), - ), + ), + 'create_travel_forms' => array( + 'title' => t('Create a new travel form entry'), + ), + 'view_travel_forms' => array( + 'title' => t('View all travel forms'), + ), + 'edit_travel_forms' => array( + 'title' => t('Edit all travel forms'), + ), ); } @@ -188,6 +197,7 @@ function booking_menu() { //'type' => MENU_LOCAL_TASK, ); + //pages for attendees to fill out information $items['booking'] = array( 'title' => $bookingTitle . ' Booking Form', 'page callback' => 'booking_register_page', @@ -201,7 +211,6 @@ function booking_menu() { 'access arguments' => array('access booking form'), 'type' => MENU_CALLBACK, ); - $items['balance/%'] = array( 'title' => 'Registration Final Payment', @@ -210,6 +219,15 @@ function booking_menu() { 'access arguments' => array('access booking form'), 'type' => MENU_CALLBACK, ); + + $items['travel/%'] = array( + 'title' => 'Travel Details Page', + 'page callback' => 'booking_travel_page', + 'page arguments' => array(3), //include the temporary id + 'access arguments' => array('access booking form'), + 'type' => MENU_SUGGESTED_ITEM, + ); + $items['variety'] = array( 'title' => $bookingTitle . ' Variety Sessions', 'page callback' => 'drupal_get_form', @@ -424,8 +442,13 @@ function booking_node_info() { 'booking' => array( 'name' => t('Registration'), 'base' => 'booking', - 'description' => t('This node represents a booking into an event.'), - ) + 'description' => t('This node represents a registration for an event.'), + ), + 'travel' => array( + 'name' => t('Travel Form'), + 'base' => 'travel', + 'description' => t('This node represents a travel details form for an event registration.'), + ) ); } @@ -435,7 +458,8 @@ function booking_node_info() { */ function booking_node_access($node, $op, $account) { $type = is_string($node) ? $node : $node->type; - + + //check access levels for a booking node if ($type == 'booking' && in_array($type, node_permissions_get_configured_types())) { //watchdog('booking', "Booking node_access processing user id '!account' performing operation !op for node type !type. @info", // array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE))); @@ -469,6 +493,32 @@ function booking_node_access($node, $op, $account) { array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE))); return NODE_ACCESS_DENY; } + //Check access levels for travel form node + elseif ($type == 'travel' && in_array($type, node_permissions_get_configured_types())) + { + if ($op == 'view') + { + if (user_access('view_travel_forms', $account)) + return NODE_ACCESS_ALLOW; + } + elseif ($op == 'create') + { + if (user_access('create_travel_forms', $account)) + return NODE_ACCESS_ALLOW; + } + elseif ($op == 'update' || $op == 'delete') + { + if (user_access('edit_travel_forms', $account)) + return NODE_ACCESS_ALLOW; + } + + //no permission to view this information + //watchdog('booking', "Booking node_access denying uid !account performing operation !op. @info", + // array('!account' => $account->uid, '!op' => $op, '@info' => var_export($account, TRUE))); + //watchdog('booking', "Booking node_access denying user id '!account' performing operation !op for node type !type. @info", + // array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE))); + return NODE_ACCESS_DENY; + } /* else { @@ -505,6 +555,12 @@ function booking_theme() { function booking_mail($key, &$message, $params) { $message['subject'] = $params['subject']; $message['body'][] = $params['body']; + + //reference https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_mail/7 + if (isset($params['headers']) && is_array($params['headers'])) { + $message['headers'] += $params['headers']; + } + } /** diff --git a/booking.reports.inc b/booking.reports.inc index baddf37..0c082be 100644 --- a/booking.reports.inc +++ b/booking.reports.inc @@ -399,7 +399,15 @@ function booking_csv_report() { $delimiter_esc = preg_quote($delimiter, '/'); $enclosure_esc = preg_quote($enclosure, '/'); - $fields_to_skip = array('booking_payment_id', 'booking_event_id', 'booking_tempid'); + /* + $fields_to_skip = array('booking_payment_id', 'booking_event_id', 'booking_skills_childminding', 'booking_passport_issue_date', + 'booking_passport_expiry_date', 'booking_passport_num', 'booking_passport_num', 'booking_mission_experience_details', + 'booking_passport_issue_location', 'booking_passport_issue_name', 'booking_skills_builder', 'booking_skills_cooking', + 'booking_skills_language', 'booking_skills_language_details', 'booking_skills_other', 'booking_skills_other_details'); + */ + $builtin_fields_to_skip = array('booking_event_id'); + $custom_fields_to_skip = explode(";", variable_get('booking_csv_exclude_fields', '')); + $fields_to_skip = array_merge($builtin_fields_to_skip, $custom_fields_to_skip); //query the db /* @@ -438,6 +446,9 @@ function booking_csv_report() { //add in a special column for a processed version of the date of birth if (strcmp($key,"booking_dob") == 0) $header_array[] = "booking_dob_processed"; + //add in a calculated field for amount owing + if (strcmp($key, "nid") == 0) + $header_array[] = "booking_amount_owing"; } $header = implode( $delimiter, $header_array ); @@ -488,6 +499,14 @@ function booking_csv_report() { continue; } + //add in the amount owing using the nid as the key + if ($key == 'nid') + { + $output[] = $value; + $output[] = _booking_amount_owing($value); + continue; + } + // Enclose fields containing $delimiter, $enclosure or whitespace if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $value ) ) { $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $value) . $enclosure; @@ -496,6 +515,8 @@ function booking_csv_report() { $output[] = $field; } } + + $row = implode($delimiter, $output) . "\n"; diff --git a/booking.tokens.inc b/booking.tokens.inc index be582e5..5a7cb77 100644 --- a/booking.tokens.inc +++ b/booking.tokens.inc @@ -280,7 +280,27 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text '#description' => t(''), '#default_value' => variable_get('booking_waitingpage_post_text', $booking_waitingpage_post_text), ); - + + /*Text for the Travel Form page*/ + $form['travel'] = array( + '#type' => 'fieldset', + '#title' => 'Travel Form Text Definitions', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['travel']['booking_travelform_page'] = array( + '#title' => t('Text to use at the start of the travel form.'), + '#type' => 'textarea', + '#description' => t(''), + '#default_value' => variable_get('booking_travelform_page', ''), + ); + $form['travel']['booking_travelform_completed_page'] = array( + '#title' => t('Text to use on the travel form if the form has already been submitted.'), + '#type' => 'textarea', + '#description' => t(''), + '#default_value' => variable_get('booking_travelform_completed_page', ''), + ); + /*Text for emails*/ $form['emails'] = array( '#type' => 'fieldset', diff --git a/booking.travel.inc b/booking.travel.inc new file mode 100644 index 0000000..9cc5c5d --- /dev/null +++ b/booking.travel.inc @@ -0,0 +1,495 @@ + arg(1))) + ->fetchObject(); + + if ($person) + { + $tokens = booking_define_personspecific_tokens($person); + + watchdog('booking', 'Checking for existing travel form for: @info', array('@info' => var_export($person, TRUE))); + + //check for an existing travel form + $travelform = db_query("SELECT tid " . + "FROM {booking_travel} " . + "WHERE booking_person_nid = :nid", + array(':nid' => $person->nid)) + ->fetchObject(); + + if ($travelform) + { + $output .= t("
Hi !firstname !lastname. Our records indicate you or your spouse have already completed the travel details form for !event. " .
+ "Please contact us if you need change any of your travel details.
Hi Mr and Mrs !lastname. Please enter your travel details for !event below.
Hi !firstname !lastname. Please enter your travel details for !event below.