'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['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 most recent 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_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_paypal_account'] = array ( '#type' => 'textfield', '#title' => t('Account'), '#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.'), '#options' => array (0 => t('Off'), t('On')), '#default_value' => variable_get('booking_paypal_sandbox', 0), ); $form['misc'] = array ( '#type' => 'fieldset', '#title' => 'Miscellaneous Settings', ); $form['misc']['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'), ); //TODO: reverse the logic of the values $form['misc']['booking_auto_confirm_email'] = array ( '#type' => 'radios', '#title' => t('Automatic Registration Email'), '#description' => t('Automatically send a confirmation email when a user registers for an event? (If No, email will be sent when status changed from Not Coming to Paid, either manually or via paypal plugin). Recommended to set this to Yes if "Show on lists once booked in" is set to No and paypal is not being used.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_auto_confirm_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_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['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['misc']['booking_enable_medicare'] = array ( '#type' => 'radios', '#title' => t('Enable Medicare requirement?'), '#description' => t('Select whether to require bookings to enter medicare details.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_medicare', 1), ); $form['misc']['booking_enable_tshirts'] = array ( '#type' => 'radios', '#title' => t('Enable t-shirt information?'), '#description' => t('Select whether to include tshirt sizing in the booking form.'), '#options' => array (0 => t('No'), t('Yes')), '#default_value' => variable_get('booking_enable_tshirts', 0), ); $form['misc']['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['misc']['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['misc']['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['misc']['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['misc']['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['misc']['booking_dietary_text_definition'] = array ( '#type' => 'textfield', '#title' => t('Dietary Requirements Text Definition'), '#default_value' => variable_get('booking_dietary_text_definition', ''), '#description' => 'Text to use if attendee may not specify dietary requirements (as above).', ); $form['misc']['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['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' => 2000, ); $form['misc']['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 (); $prefix = t("
Send a manual email to people registered for this event.
"); $email_options_array = array(); $email_options_array['registration'] = 'Manual Registration'; $email_options_array['balance'] = 'Manual Balance Outstanding'; $email_options_array['complete'] = 'Manual Payment Complete'; $email_options_array['travelcomplete'] = 'Manual Travel Form Complete'; //add in the custom email types for ($i = 1; $i <= CUSTOM_EMAIL_COUNT; $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_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'), ); $query = db_select('booking_person', 'p') ->fields('p') ->fields('pr', array('booking_price', 'booking_late_price')) ->condition('p.booking_event_id', $event->eid, '='); $query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id'); $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) { $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_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', ); //$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'] == '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 (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']); } $counter++; } } } drupal_set_message("Sent manual email for $counter people.", 'status', FALSE); //watchdog('booking', "Sent manual email for $counter people."); }