'fieldset', '#title' => 'Email Addresses', ); $form['email']['booking_from_email'] = array ( '#type' => 'textfield', '#title' => t('Sender Email Address'), '#description' => t("The email address used as the source of outbound emails."), '#size' => 60, '#maxlength' => 150, '#required' => TRUE, '#default_value' => variable_get('booking_from_email',variable_get('site_mail', ini_get('sendmail_from'))), ); $form['email']['booking_notify_email'] = array ( '#type' => 'textfield', '#title' => t('Notification Email Address(es)'), '#description' => t("The email addresses to which registration notifications are sent."), '#size' => 60, '#maxlength' => 200, '#required' => TRUE, '#default_value' => variable_get('booking_notify_email',variable_get('site_mail', ini_get('sendmail_from'))), ); $form['email']['booking_contact_email'] = array ( '#type' => 'textfield', '#title' => t('Contact Email Address'), '#description' => t("The email address attendees are instructed to contact for additional information."), '#size' => 60, '#maxlength' => 150, '#required' => TRUE, '#default_value' => variable_get('booking_contact_email',variable_get('site_mail', ini_get('sendmail_from'))), ); $form['email']['booking_logistics_email'] = array ( '#type' => 'textfield', '#title' => t('Logistics Email Address'), '#description' => t("The email address used for logistics information."), '#size' => 60, '#maxlength' => 150, '#required' => TRUE, '#default_value' => variable_get('booking_logistics_email',variable_get('site_mail', ini_get('sendmail_from'))), ); $form['email']['booking_custom_email_count'] = array ( '#type' => 'textfield', '#title' => t('Number of custom email definitions'), '#description' => t("Set to the number of custom email definitions to use."), '#size' => 3, '#maxlength' => 3, '#default_value' => variable_get('booking_custom_email_count','5'), ); $form['attendee'] = array ( '#type' => 'fieldset', '#title' => 'Attendee restrictions', ); $form['attendee']['booking_max_dob'] = array ( '#type' => 'date_select', '#title' => t('Maximum Date of Birth'), '#description' => t("The youngest date of birth you wish to allow into the event."), '#default_value' => variable_get('booking_max_dob','1995-04-15 00:00:00'), '#date_format' => 'd/m/Y', '#date_label_position' => 'within', '#date_year_range' => '-60:-10' ); $form['attendee']['booking_enable_min_age_restriction'] = array ( '#type' => 'radios', '#title' => t('Enable old age restriction?'), '#description' => t('Set this to Yes if you wish to prevent people over the age defined below from registering.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_min_age_restriction', 1), ); $form['attendee']['booking_min_dob'] = array ( '#type' => 'date_select', '#title' => t('Minimum Date of Birth'), '#description' => t("The oldest date of birth you wish to allow into the event. Note that only the year is taken into account."), '#default_value' => variable_get('booking_min_dob','1995-04-15 00:00:00'), '#date_format' => 'd/m/Y', '#date_label_position' => 'within', '#date_year_range' => '-60:-10' ); $form['attendee']['booking_regn_limit'] = array ( '#type' => 'textfield', '#title' => t('Registration limit'), '#description' => t("Total number of attendees permitted."), '#size' => 3, '#maxlength' => 3, '#required' => TRUE, '#default_value' => variable_get('booking_regn_limit','500'), ); $form['paypal'] = array ( '#type' => 'fieldset', '#title' => 'Paypal Settings', ); $form['paypal']['booking_use_paypal'] = array ( '#type' => 'radios', '#title' => t('Use Paypal?'), '#description' => t('Select whether to use paypal for automatic payment handling, or process payments manually.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_use_paypal', 0), ); $form['paypal']['booking_paypal_account'] = array ( '#type' => 'textfield', '#title' => t('Specify Paypal Account Address'), '#default_value' => variable_get('booking_paypal_account', ''), '#description' => '(email address)', ); $form['paypal']['booking_paypal_sandbox'] = array ( '#type' => 'radios', '#title' => t('Sandbox/Development mode'), '#description' => t('When in development mode, the payment gateway will point at sandbox.paypal.com for testing purposes. Leave this as off unless doing testing.'), '#options' => array (0 => t('Off'), t('On')), '#default_value' => variable_get('booking_paypal_sandbox', 0), ); $form['features'] = array ( '#type' => 'fieldset', '#title' => 'Enable/Disable Features', ); $form['features']['booking_enable_roomallocations'] = array ( '#type' => 'radios', '#title' => t('Enable room allocations?'), '#description' => t('Select whether to enable the management and allocation of rooms.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_roomallocations', 0), ); $form['features']['booking_enable_travelform'] = array ( '#type' => 'radios', '#title' => t('Enable travel details form?'), '#description' => t('Select whether to enable the form that allows attendees to enter their travel details.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_travelform', 0), ); $form['features']['booking_enable_studygroups'] = array ( '#type' => 'radios', '#title' => t('Enable study group calculations?'), '#description' => t('Select whether to enable the creation and management of study groups.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_studygroups', 0), ); $form['features']['booking_readinggroup_id'] = array ( '#type' => 'textfield', '#title' => t('Studygroup ID for the reading group'), '#description' => t("Set the ID for the studygroup that corresponds with the reading group. " . " This option is only applicable if study groups are enabled. Set to zero if reading groups aren't in use. " . " If in doubt, leave as zero."), '#size' => 3, '#maxlength' => 3, '#default_value' => variable_get('booking_readinggroup_id','0'), ); $form['features']['booking_enable_variety_sessions'] = array ( '#type' => 'radios', '#title' => t('Enable variety session form?'), '#description' => t('Note that this feature is still under development and cannot yet be used.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_variety_sessions', 0), ); $form['features']['booking_publish_readinggroups'] = array ( '#type' => 'radios', '#title' => t('Display reading group colours on the Who\'s Coming page?'), '#description' => t('Select whether to publish reading group colours. This option is only applicable if study groups are enabled.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_publish_readinggroups', 0), ); $form['misc'] = array ( '#type' => 'fieldset', '#title' => 'Configuration Options', ); $form['misc']['booking_auto_confirm_email'] = array ( '#type' => 'radios', '#title' => t('Send An Automatic Registration Email?'), '#description' => t('Automatically send a confirmation email to a user when they\'ve registered for an event? Set this to No if using paypal and only showing on the "whos coming" page once a person has paid. Or set to Yes if "Show on lists once booked in" is set to No and paypal is not being used. If set to No, a registration confirmation email will be sent to a user when their registration status changes to Paid, either manually or via paypal plugin. '), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_auto_confirm_email', 0), ); $form['misc']['booking_auto_workflow_email'] = array ( '#type' => 'radios', '#title' => t('Send An Automatic Workflow Email?'), '#description' => t('Automatically send workflow emails to attendee on events such as status changes, travel details received, etc'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_auto_workflow_email', 0), ); $form['misc']['booking_auto_show_on_lists'] = array ( '#type' => 'radios', '#title' => t('Show on lists once booked in?'), '#description' => t('Immediately appear on bookedin/waiting lists even before payment is received?'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_auto_show_on_lists', 0), ); $form['misc']['booking_enable_combined_pricing'] = array ( '#type' => 'radios', '#title' => t('Use Combined Pricing?'), '#description' => t('Select whether to combine pricing for married couples (Yes) or have each spouse pay separately (No).'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_combined_pricing', 0), ); $form['regn_options'] = array ( '#type' => 'fieldset', '#title' => 'Registration Form Configuration', ); $form['regn_options']['booking_default_country'] = array ( '#type' => 'select', '#title' => t('Select Default Country'), '#description' => t('Select default country for residential address.'), '#options' => _booking_country_options(), '#default_value' => variable_get('booking_default_country', 'Australia'), ); $form['regn_options']['booking_default_state'] = array ( '#type' => 'select', '#title' => t('Select Default State'), '#description' => t('Select default state for residential address.'), '#options' => _booking_state_options(), '#default_value' => variable_get('booking_default_state', 'NSW'), ); $form['regn_options']['booking_default_gender'] = array ( '#type' => 'select', '#title' => t('Select Default Gender'), '#description' => t('Select default gender for booking form.'), '#options' => _booking_gender_options(), '#default_value' => variable_get('booking_default_gender', 'M'), ); $form['regn_options']['booking_allow_couples'] = array ( '#type' => 'radios', '#title' => t('Allow married couples?'), '#description' => t('Select whether to cater for married couples in the registration form'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_allow_couples', 0), ); $form['regn_options']['booking_enable_medicare'] = array ( '#type' => 'radios', '#title' => t('Enable Medicare requirement?'), '#description' => t('Select whether to include medicare details on registration form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_medicare', 1), ); $form['regn_options']['booking_enforce_medicare_verification'] = array ( '#type' => 'radios', '#title' => t('Force Medicare verification?'), '#description' => t('Prevent people from registering if they do not enter a valid medicare card? (Only applies if medicare details are enabled).'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enforce_medicare_verification', 1), ); $form['regn_options']['booking_tshirts_text_definition'] = array ( '#type' => 'textfield', '#title' => t('Clothes Sizing Text Definition'), '#default_value' => variable_get('booking_tshirts_text_definition', 'Preferred t-shirt size'), '#description' => 'Text to use on registration form to request clothing size (eg t-shirt or hoodie).', '#size' => 150, '#maxlength' => 2000, ); $form['regn_options']['booking_enable_tshirts'] = array ( '#type' => 'radios', '#title' => t('Enable sizing information?'), '#description' => t('Select whether to include clothe sizing in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_tshirts', 0), ); $form['regn_options']['booking_enable_passport'] = array ( '#type' => 'radios', '#title' => t('Enable passport information?'), '#description' => t('Select whether to include passport details in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_passport', 0), ); $form['regn_options']['booking_enable_helpareas'] = array ( '#type' => 'radios', '#title' => t('Enable help area questions?'), '#description' => t('Select whether to include questions about areas people are willing to help with in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_helpareas', 0), ); $form['regn_options']['booking_enable_skills'] = array ( '#type' => 'radios', '#title' => t('Enable special skills information?'), '#description' => t('Select whether to include questions about special skills people have in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_skills', 0), ); $form['regn_options']['booking_enable_roommate'] = array ( '#type' => 'radios', '#title' => t('Enable room-mate selection?'), '#description' => t('Select whether to allow attendees to list a preferred room-mate in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_roommate', 0), ); $form['regn_options']['booking_enable_dietary'] = array ( '#type' => 'radios', '#title' => t('Allow attendee to specify dietary requirements?'), '#description' => t('If set to No, the following text definition will be used instead.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_dietary', 0), ); $form['regn_options']['booking_dietary_text_definition'] = array ( '#type' => 'textfield', '#title' => t('Dietary Requirements Text Definition'), '#default_value' => variable_get('booking_dietary_text_definition', 'Please use the contact us form to indicate what dietary requirements you have.'), '#description' => 'Text to use on registration form if attendee may not specify dietary requirements (as above).', '#size' => 150, '#maxlength' => 2000, ); $form['management'] = array ( '#type' => 'fieldset', '#title' => 'Data Management Options', ); $form['management']['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' => 2000, ); $form['management']['booking_import_include_fields'] = array ( '#type' => 'textfield', '#title' => t('Fields to import from an uploaded CSV file'), '#default_value' => variable_get('booking_import_include_fields', ''), '#description' => 'Separate each field with a semi-colon. Field names as per database schema, case sensitive. Nid and booking_status fields compulsory.', '#size' => 150, '#maxlength' => 2000, ); return system_settings_form($form); } function booking_admin_validate($form, $form_state) { //TODO: put back in when using booking start and end dates /* $booking_start = $form_state['values']['booking_start']; $booking_end = $form_state['values']['booking_end']; //create timestamps for comparison $booking_start_ts = _date_to_ts( $booking_start ); $booking_end_ts = _date_to_ts( $booking_end ); //validate main conference start and end dates if ($booking_start_ts > $booking_end_ts) { form_set_error('booking_date_endbeforestart', t('You have selected a Conference end date that is before the Conference start date.')); } else { variable_set('booking_conference_dates', _date_range_to_string($booking_start, $booking_end)); drupal_set_message( t('Conference date range: "!date"', array ('!date' => _date_range_to_string($booking_start, $booking_end)))); } */ } 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?')), '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' => $paid == 0 ? '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); } if ($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."); }