Compare commits
242 Commits
Author | SHA1 | Date | |
---|---|---|---|
1258fcdb7c | |||
c662567384 | |||
dce1865955 | |||
4460f7e91c | |||
ff9021ace0 | |||
78445e3d45 | |||
7b7fe113a8 | |||
c979522c5f | |||
32dfbdd76b | |||
52cda1cb78 | |||
5c4f9029eb | |||
36f31fa0fc | |||
494b6dfe2b | |||
b470e309b3 | |||
7a5f6e2d3c | |||
2631bd7858 | |||
|
cb29873efa | ||
|
f79f298978 | ||
|
b11ce79cd7 | ||
|
bac7acafc5 | ||
|
e2eb730d19 | ||
|
907d4a0a82 | ||
|
4d5fa31fc8 | ||
|
e8673e423e | ||
|
29238335ab | ||
|
82a39e44e3 | ||
|
02fc8b393d | ||
|
11fa3f4549 | ||
|
884397a726 | ||
|
e29e2d9f60 | ||
|
20a2984f49 | ||
|
37a1d6867d | ||
|
ac8e1d1657 | ||
|
58d786bd32 | ||
|
bc5a59604e | ||
|
78f98b3a5d | ||
|
4ce3df3339 | ||
|
7eb77b042f | ||
|
a0397fba7e | ||
|
e353371af9 | ||
|
0cb58768c3 | ||
|
a3472d6fb4 | ||
|
e8df551c94 | ||
|
10c098a7b6 | ||
|
683a47ec5e | ||
|
9e72fca856 | ||
|
92dba91b02 | ||
|
01a02a7fb8 | ||
|
752a44cb09 | ||
|
248a9691cd | ||
|
37a138ba46 | ||
|
86c4b7fcb3 | ||
|
47fcbd04f2 | ||
|
5d848794b9 | ||
|
cf2d40033a | ||
|
aa1f0aa403 | ||
|
1aa709fe54 | ||
|
7869a9be5b | ||
|
22bad5d8ef | ||
|
5276e4bca1 | ||
|
fcfa97ff91 | ||
|
aebd90ee33 | ||
|
572cf2797c | ||
|
7938449565 | ||
|
06d5f608b9 | ||
|
c293b5423b | ||
|
2f2dd62443 | ||
|
be4854d933 | ||
|
d6cb41ad64 | ||
|
a2542c02e4 | ||
|
5c00b5a345 | ||
|
cea5e644c4 | ||
|
6f23e54dff | ||
|
dbee106fbc | ||
|
939f336489 | ||
|
9c8ff253e4 | ||
|
5020b3466e | ||
71d92a4081 | |||
0ede0d0677 | |||
27629729ca | |||
f83e3a4b09 | |||
8327c33a3a | |||
683df04783 | |||
42a91a9d7f | |||
2f83967ba7 | |||
05d8e97edd | |||
930c0ec7ff | |||
1ee6d8e7c0 | |||
12cc3d33c9 | |||
90f0488448 | |||
b9b2f88299 | |||
2480c13641 | |||
3bead3ad21 | |||
feae543cf4 | |||
c5e1decb04 | |||
536546b7f9 | |||
a6781e0475 | |||
c1d6b05167 | |||
b8e2f852af | |||
62ae5d89a4 | |||
90de779c0c | |||
|
202d882bd6 | ||
|
62be5346fb | ||
|
ccedba7b46 | ||
|
ede732c310 | ||
|
cc8c326753 | ||
|
ed6679c37b | ||
|
c77e077c29 | ||
|
ae9b61828c | ||
|
6754b1f997 | ||
|
bc0cee9a9e | ||
|
00fdb80b15 | ||
|
ae5b86a8a9 | ||
|
c17e2025a3 | ||
|
a30cb2c88c | ||
|
647a44e0ab | ||
|
b71e61dcca | ||
|
3069c1a4c2 | ||
|
ca551094fd | ||
|
d88a73f713 | ||
|
4431fc6e0c | ||
|
c0322bb593 | ||
|
388ff80268 | ||
|
598b6f653f | ||
|
01b0b05428 | ||
|
7e4f90cc54 | ||
|
fde5a01781 | ||
|
33f5dcf34f | ||
|
a634b85608 | ||
|
ce0b3792ba | ||
|
ee95126760 | ||
|
3379d34ee5 | ||
|
a01f955915 | ||
|
b083776c08 | ||
|
16b0f6ee76 | ||
|
d3dbe66fcc | ||
|
516a119952 | ||
|
3811a181b3 | ||
|
26a43d620d | ||
|
1ab47f50b4 | ||
|
192032bab6 | ||
|
94cf7b89b5 | ||
|
8d83e08419 | ||
|
58d486dea9 | ||
|
9cf693585d | ||
|
638e0807ac | ||
|
33899cc483 | ||
|
37c3a3cc02 | ||
|
28191d64d3 | ||
|
eca4508853 | ||
|
4bad8b2d46 | ||
|
138f608a26 | ||
|
fb59029be1 | ||
|
f672e32ba0 | ||
|
af942dadd4 | ||
|
dee1438cf6 | ||
|
181645ecfb | ||
|
ea9ed2abf3 | ||
|
0e7d9a215a | ||
|
ce2a9242e5 | ||
|
5fe2d8d88d | ||
|
6f971767f0 | ||
|
08e9d220d6 | ||
|
84fcd20507 | ||
|
04fc135818 | ||
|
39449c2cad | ||
|
b0ea07b789 | ||
|
53d8919064 | ||
|
48dbb98c32 | ||
|
2e828060d0 | ||
|
ed45d52007 | ||
|
be5d1e8c2f | ||
|
e86ec94bb3 | ||
|
0e35a832c1 | ||
|
855c114b2b | ||
|
8156084537 | ||
|
e9de00f774 | ||
|
cf726772d6 | ||
|
d1629c05ee | ||
|
8a83a55160 | ||
|
c774c17c2d | ||
|
5720f3150f | ||
|
03e6b91b2d | ||
|
ceeef4837c | ||
|
75033a6735 | ||
|
e436f54974 | ||
|
697d7d6b6a | ||
|
412167ff46 | ||
|
de6874c169 | ||
|
319c65ccda | ||
|
23f837b7ac | ||
|
b0d25348ca | ||
|
b6680c22b3 | ||
|
5054a241b0 | ||
|
93881117e8 | ||
|
476140d6bc | ||
|
9e87ed88df | ||
|
bec6253981 | ||
|
9f1a07e2fc | ||
|
1501d6bd63 | ||
|
10dc8b6f38 | ||
|
8fcec6e7f2 | ||
|
5f98a72b69 | ||
|
3948a8bcd9 | ||
|
dfa6aa2314 | ||
|
ad87aaac72 | ||
|
cdc3347e45 | ||
|
d68a57f64a | ||
|
ddc5618101 | ||
|
0ceecdc0f1 | ||
|
c5179b059e | ||
|
9e20d49304 | ||
|
c4a90e8776 | ||
|
8309c5d37b | ||
|
65463ecb76 | ||
|
d75667d32e | ||
|
c4d2173794 | ||
|
0607a562c2 | ||
|
928c9a320f | ||
|
5121216f66 | ||
|
cddaadb2ff | ||
|
b6b17de5b8 | ||
|
4874ad650f | ||
|
5246897238 | ||
|
bc4820c0a8 | ||
|
fa213595f8 | ||
|
5ca13ca6a5 | ||
|
d80ee5dc3d | ||
|
85194238bd | ||
|
3ca14dbd34 | ||
|
38e32a1e58 | ||
|
edcf3d36bf | ||
|
4ffef1a6c4 | ||
|
272094e27e | ||
|
292725233f | ||
|
80f911f9af | ||
|
684f66c5d4 | ||
|
a9065a28b7 | ||
|
e5dd203d1d | ||
|
a951c033ee | ||
|
69fd7f9541 | ||
|
c4c47dd8a8 |
19
README.md
19
README.md
@@ -1,7 +1,18 @@
|
||||
Drupal 7 module for managing event bookings.
|
||||
Drupal 7 module for managing event bookings. Originally designed for use with the biennial Christadelphian event known as Study Week.
|
||||
|
||||
To install:
|
||||
## Pre-installation
|
||||
Before installation, download and install the following pre-requisite modules:
|
||||
- [libraries](http://drupal.org/project/libraries) module
|
||||
- [token](http://drupal.org/project/token) module
|
||||
- [date](http://drupal.org/project/date) module
|
||||
- [mimemail](http://drupal.org/project/mimemail) module
|
||||
- [mailsystem](http://drupal.org/project/mailsystem) module
|
||||
|
||||
If you plan to use Stripe for payment integration, download the [Stripe API Library for PHP](https://github.com/stripe/stripe-php) and install in your sites libraries folder (usually sites/all/libraries). The folder should be renamed to stripe (ie sites/all/libraries/stripe/lib/Stripe.php).
|
||||
|
||||
## Installation
|
||||
- Clone (or download & unpack) this module into your site's module directory (usually sites/all/modules)
|
||||
- If not installed, download the [libraries](http://drupal.org/project/libraries) module, the [token](http://drupal.org/project/token) module and the [date](http://drupal.org/project/date) module
|
||||
- Download the [Stripe API Library for PHP](https://stripe.com/docs/libraries) and install in your sites libraries folder (usually sites/all/libraries). The folder should be renamed to stripe (ie sites/all/libraries/stripe/lib/Stripe.php).
|
||||
- Enable the booking module, and visit the [configuration page](http://your.site.com/admin/config/booking/general) to set initial values and save prior to using module
|
||||
|
||||
## Configuration
|
||||
In addition to the main configuration page, you will need to set up [text definitions](http://your.site.com/admin/config/booking/text) for various built-in pages, as well as update [email definitions](http://your.site.com/admin/config/booking/emails) for automatically generated emails.
|
||||
|
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
// @deprecated
|
||||
// Use MimeMail module instead of this class
|
||||
// Since this class doesn't handle attaching files
|
||||
|
||||
/**
|
||||
* Implements MailSystemInterface
|
||||
|
@@ -84,6 +84,15 @@ function booking_admin() {
|
||||
'#maxlength' => 3,
|
||||
'#default_value' => variable_get('booking_custom_email_count', '5')
|
||||
);
|
||||
$form['email']['booking_email_allowed_attachments'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Allowed email attachments'),
|
||||
'#description' => t("File extensions to allow as email attachments for the manual email page."),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => variable_get('booking_email_allowed_attachments', 'pdf docx'),
|
||||
);
|
||||
|
||||
$form['attendee'] = array(
|
||||
'#type' => 'fieldset',
|
||||
@@ -575,26 +584,6 @@ function booking_admin() {
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_roommate', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_songchoice'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable attendee to specify song choice?'),
|
||||
'#description' => t('Select whether to include questions about song choice in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_songchoice', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_freestyle'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable attendee to enter freestyle text'),
|
||||
'#description' => t('Select whether to include freestyle text field in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_freestyle', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_dietary'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Allow attendee to specify dietary requirements?'),
|
||||
@@ -667,7 +656,66 @@ function booking_admin() {
|
||||
'#maxlength' => 3,
|
||||
'#default_value' => variable_get('booking_earlyaccess_codes_count', '0'),
|
||||
);
|
||||
|
||||
$form['regn_options']['booking_enable_songchoice'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable attendee to specify song choice?'),
|
||||
'#description' => t('Select whether to include questions about song choice in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_songchoice', 0)
|
||||
);
|
||||
$form['regn_options']['booking_require_songchoice'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Require attendees to enter a song?'),
|
||||
'#description' => t('Select whether to require attendees to enter a song choice for the week when they register. Doesn\'t have any effect if song choice is not enabled above.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_require_songchoice', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_freestyle'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable attendee to enter freestyle text'),
|
||||
'#description' => t('Select whether to include freestyle text field in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_freestyle', 0)
|
||||
);
|
||||
$form['regn_options']['booking_require_freestyle'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Require attendees to enter some freestyle text?'),
|
||||
'#description' => t('Select whether to require attendees to enter some freestyle text when they register. Doesn\'t have any effect if freestyle text is not enabled above.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_require_freestyle', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_previous_studyweeks'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Ask attendee to specify previous study weeks?'),
|
||||
'#description' => t('Select whether to ask the attendee how many study weeks they\'ve been to previously in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_previous_studyweeks', 0)
|
||||
);
|
||||
$form['regn_options']['booking_require_previous_sw'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Require attendees to select number of previous study weeks?'),
|
||||
'#description' => t('Select whether to require attendees to choose the number of study weeks they previously attended. Doesn\'t have any effect if previous studyweek question is not enabled above.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_require_previous_sw', 0)
|
||||
);
|
||||
$form['management'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Data Management Options',
|
||||
@@ -708,6 +756,37 @@ $form['management']['booking_import_include_fields_dynamic'] = array(
|
||||
'#default_value' => variable_get('booking_import_include_fields_dynamic', ''),
|
||||
);
|
||||
|
||||
$form['meta-tokens'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Meta Token Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
$form['meta-tokens']['booking_studygroup_summary_li_text'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Study Group Summary Format'),
|
||||
'#default_value' => variable_get('booking_studygroup_summary_li_text',
|
||||
'You are a <b>[meta-booking:studygroup-role]</b> for group <b>[meta-booking:studygroup-descrip]</b>, which will occur on [meta-booking:studygroup-weekday].' .
|
||||
'<br /><b>[meta-booking:studygroup-explan]</b>'
|
||||
),
|
||||
'#description' => 'List element definition (using tokens) for token [booking:studygroup-summary], which is the study group summary in emails. ' .
|
||||
'Note: Don\'t add the li tags, they will be added automatically.',
|
||||
'#size' => 150,
|
||||
'#maxlength' => 2000,
|
||||
);
|
||||
$form['meta-tokens']['booking_studygroup_leaderhelperpair_text'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Leader/Helper Pair Format'),
|
||||
'#default_value' => variable_get('booking_studygroup_leaderhelperpair_text',
|
||||
'<b>[meta-booking:studygroup-role]</b> for <b>[meta-booking:studygroup-descrip]</b>. ' .
|
||||
'Your [meta-booking:studygroup-otherrole] is <b>[meta-booking:studygroup-othername]</b>. ' .
|
||||
'You can contact them on [meta-booking:studygroup-otherphone] or [meta-booking:studygroup-otheremail].'
|
||||
),
|
||||
'#description' => 'List element definition (using tokens) for token [booking:leaderhelper-pair], which is the study group leader/helper pair information in emails. ' .
|
||||
'Note: Don\'t add the li tags, they will be added automatically.',
|
||||
'#size' => 150,
|
||||
'#maxlength' => 2000,
|
||||
);
|
||||
|
||||
//return system_settings_form($form);
|
||||
//make sure we update our custom sql view every time we change something on the admin page
|
||||
$form = system_settings_form($form);
|
||||
|
@@ -14,6 +14,7 @@ function booking_balance_page() {
|
||||
//verify that arg(1) is a uuid
|
||||
if (! preg_match('/^[0-9A-Fa-f\-]+$/', arg(1))) {
|
||||
//parameter from url is not what we were expecting
|
||||
watchdog('booking', "Invalid token supplied to the balance payment page.");
|
||||
drupal_set_message("Error: Invalid token supplied to the balance payment page. Please use the contact us form to let us know.", 'error', FALSE);
|
||||
drupal_goto('<front>');
|
||||
return "";
|
||||
@@ -24,10 +25,20 @@ function booking_balance_page() {
|
||||
|
||||
//work out the node id from the session id
|
||||
$query = db_select('booking_person', 'p');
|
||||
$db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')
|
||||
->condition('p.booking_tempid', arg(1), '=');
|
||||
$query->condition($db_and);
|
||||
$query->fields('p', array('nid'));
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
/*
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition('p.booking_tempid', arg(1), '=')
|
||||
->fields('p', array('nid'));
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
*/
|
||||
|
||||
if ($person) {
|
||||
//load all the fields
|
||||
@@ -37,6 +48,9 @@ function booking_balance_page() {
|
||||
//maximum length for invoice id in paypal is 127 characters so truncate if necessary
|
||||
$invoiceid = substr($invoiceid, 0, 126);
|
||||
} else {
|
||||
watchdog('booking', "<pre>Unmatched token supplied to the balance payment page:\n@info</pre>", array(
|
||||
'@info' => print_r(arg(1), true)
|
||||
));
|
||||
drupal_set_message("Error: Invalid token supplied to the balance payment page. Please use the contact us form to let us know.", 'error', FALSE);
|
||||
drupal_goto('<front>');
|
||||
return "";
|
||||
|
@@ -33,6 +33,8 @@ function booking_confirm_page() {
|
||||
if ($person) {
|
||||
//load all the fields
|
||||
$node = node_load($person->nid);
|
||||
//watchdog('booking_debug', 'booking_confirm_page node: <pre>@info</pre>', array('@info' => print_r( $node, true)));
|
||||
|
||||
//maximum length for invoice id is 127 characters
|
||||
$invoiceid = $person->nid . '_' . $node->booking_eventid . '_' . $node->booking_lastname . '-' . $node->booking_firstname;
|
||||
$invoiceid = substr($invoiceid, 0, 126);
|
||||
|
@@ -1,5 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper function to provide a list of custom email types for editing/sending manually
|
||||
*/
|
||||
function _booking_custom_email_types() {
|
||||
$email_options_array = array();
|
||||
$email_options_array['NULL'] = "---";
|
||||
$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['waitinglistpromotion'] = 'Position Available (Balance outstanding)';
|
||||
$email_options_array['waitinglistpromotionfullypaid'] = 'Position Available (Fully Paid)';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment Email';
|
||||
$email_options_array['initialtravelrequired'] = 'Initial Travel Form Required Email';
|
||||
$email_options_array['remindertravelrequired'] = 'Reminder 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);
|
||||
}
|
||||
//add in the custom email types from logistics
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i,
|
||||
$event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**";
|
||||
}
|
||||
|
||||
return $email_options_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to provide a list of options for the state field of the registration form
|
||||
*/
|
||||
@@ -101,7 +130,19 @@ function _get_tshirt_options() {
|
||||
return $options_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to provide a list of options for the previous study week count field of the registration form
|
||||
*/
|
||||
function _get_previous_sw_options() {
|
||||
$options_array = array();
|
||||
$options_array[''] = '';
|
||||
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
$options_array[$i] = $i;
|
||||
}
|
||||
|
||||
return $options_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to look up description of studygroup role
|
||||
@@ -187,12 +228,12 @@ function _booking_readinggroup_colour_lookup($input = NULL)
|
||||
$group[] = t('Maroon');
|
||||
$group[] = t('Pink');
|
||||
$group[] = t('Black');
|
||||
$group[] = t('Checks');
|
||||
$group[] = t('Yellow');
|
||||
$group[] = t('Purple');
|
||||
$group[] = t('White');
|
||||
$group[] = t('Red');
|
||||
$group[] = t('Orange');
|
||||
$group[] = t('Checks');
|
||||
$group[] = t('Green');
|
||||
$group[] = t('Blue');
|
||||
$group[] = t('Brown');
|
||||
|
594
booking.email_manually.inc
Normal file
594
booking.email_manually.inc
Normal file
@@ -0,0 +1,594 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Function to allow admin user to manually generate and send a workflow or custom email
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_manual_email_form($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
/*
|
||||
create hidden form element that we will populate with JSON data via ajax
|
||||
create select element defining the pre-selections available
|
||||
create submit button that calls ajax to update hidden form element, then calls ajax to check the checkboxes based on the hidden form element
|
||||
|
||||
info on turning JSON data back to array
|
||||
http://stackoverflow.com/questions/29076219/javascript-storing-array-of-objects-in-hidden-field
|
||||
|
||||
ajax references:
|
||||
http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
https://www.drupal.org/node/1028410
|
||||
https://www.drupal.org/node/2046693
|
||||
|
||||
jquery to check the checkboxes:
|
||||
http://jsfiddle.net/nanoquantumtech/dnhwz/
|
||||
*/
|
||||
$form = array();
|
||||
$options = array();
|
||||
$preselection_options = array();
|
||||
$values = array();
|
||||
$group_text = "";
|
||||
$prefix = t("<p>Send a manual email to people registered for this event. ");
|
||||
$prefix .= t("Click !workflow to update builtin-workflow emails, or click !custom to update custom email definitions.</p>",
|
||||
array ('!workflow' => l('here', 'admin/config/booking/emails'), '!custom' => l('here', 'admin/config/booking/emails/definitions')));
|
||||
$prefix .= t("<p>Highlighted rows have welfare requirements.</p>");
|
||||
|
||||
$email_options_array = array();
|
||||
$email_options_array['NULL'] = "---";
|
||||
$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['waitinglistpromotion'] = 'Position Available (Balance outstanding)';
|
||||
$email_options_array['waitinglistpromotionfullypaid'] = 'Position Available (Fully Paid)';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment Email';
|
||||
$email_options_array['initialtravelrequired'] = 'Initial Travel Form Required Email';
|
||||
$email_options_array['remindertravelrequired'] = 'Reminder Travel Form Required Email';
|
||||
$email_options_array['travelcomplete'] = 'Travel Form Complete Email';
|
||||
|
||||
$preselection_options['---'] = "---";
|
||||
$preselection_options['notpaid'] = 'People who have not yet paid';
|
||||
$preselection_options['bookedin'] = 'People who are booked-in';
|
||||
$preselection_options['waitinglist'] = 'People on waiting list';
|
||||
$preselection_options['unpaid'] = 'People booked-in with outstanding balance';
|
||||
$preselection_options['refundreqd'] = 'Refund Required';
|
||||
$preselection_options['notravelform'] = "People booked-in no travel form received";
|
||||
$preselection_options['notravelforminclwaiting'] = "People booked-in/waiting no travel form received";
|
||||
$preselection_options['leaderhelper'] = "Leaders/Helpers";
|
||||
$preselection_options['readinggroup-leader'] = "Reading Group Leaders";
|
||||
|
||||
$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'),
|
||||
);
|
||||
|
||||
//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);
|
||||
}
|
||||
//add in the custom email types from logistics
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i,
|
||||
$event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**";
|
||||
}
|
||||
|
||||
//attach css so we can customise colours for some people
|
||||
$form['#attached']['css'] = array(
|
||||
drupal_get_path('module', 'booking') . '/booking.css',
|
||||
);
|
||||
//attach js for dynamically setting checkboxes
|
||||
$form['#attached']['js'][] = drupal_get_path("module", "booking")."/booking.js";
|
||||
|
||||
$form['pretext'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => $prefix,
|
||||
);
|
||||
|
||||
//@todo add booking prefix
|
||||
$form['email-type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email Type'),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => 'NULL',
|
||||
'#options' => $email_options_array,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_preview_callback',
|
||||
'wrapper' => 'booking_email_preview_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => "[]",
|
||||
'#prefix' => '<div id="booking_email_default_ids_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#attributes' => array('id' => 'booking_email_default_ids'),
|
||||
);
|
||||
|
||||
$form['booking-email-preselection'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Pre-select attendees from list'),
|
||||
'#description' => t('Use this to select a large group of people based on pre-defined criteria.'),
|
||||
'#options' => $preselection_options,
|
||||
'#default_value' => '---',
|
||||
'#suffix' => '<div id="booking_email_preselection_suffix_wrapper"></div>',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_default_selection_callback',
|
||||
'wrapper' => 'booking_email_default_ids_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking-email-preview'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => "<h3>Email Preview</h3><pre>No email type selected.</pre>",
|
||||
'#prefix' => '<div id="booking_email_preview_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['attachments'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Attach Files',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
$form['attachments']['booking-email-attachment-1'] = array(
|
||||
'#type' => 'managed_file',
|
||||
'#title' => t('Email attachment 1'),
|
||||
'#description' => t('Attach a file to be emailed. Note that this only works with custom email types. File must be 10MB or less, and extension must be one of: ' . variable_get('booking_email_allowed_attachments', 'pdf docx')),
|
||||
'#upload_location' => 'public://bookings/emails',
|
||||
'#upload_validators' => array(
|
||||
'file_validate_size' => array(10*1024*1024),
|
||||
'file_validate_extensions' => array(variable_get('booking_email_allowed_attachments', 'pdf docx')),
|
||||
),
|
||||
);
|
||||
$form['attachments']['booking-email-attachment-2'] = array(
|
||||
'#type' => 'managed_file',
|
||||
'#title' => t('Email attachment 2'),
|
||||
'#description' => t('Attach a file to be emailed. Note that this only works with custom email types. File must be 10MB or less, and extension must be one of: ' . variable_get('booking_email_allowed_attachments', 'pdf docx')),
|
||||
'#upload_location' => 'public://bookings/emails',
|
||||
'#upload_validators' => array(
|
||||
'file_validate_size' => array(10*1024*1024),
|
||||
'file_validate_extensions' => array(variable_get('booking_email_allowed_attachments', 'pdf docx')),
|
||||
),
|
||||
);
|
||||
|
||||
/*
|
||||
// See https://drupal.stackexchange.com/questions/108583/how-to-save-file-uploaded-with-plupload-integration-module-and-make-it-managed
|
||||
// For info on saving the attachments from plupload
|
||||
|
||||
// Submit handler:
|
||||
if (!empty($form_state['values']['upload'])) {
|
||||
$form_state['uploaded_files'] = quotes_file_save_files($form_state['values']['upload']);
|
||||
}
|
||||
|
||||
function quotes_file_save_files($files) {
|
||||
$saved_files = array();
|
||||
$scheme = 'private://'; // Change to "public://" if you want to move to public files folder.
|
||||
foreach ($files as $uploaded_file) {
|
||||
if ($uploaded_file['status'] == 'done') {
|
||||
$source = $uploaded_file['tmppath'];
|
||||
$destination = file_stream_wrapper_uri_normalize($scheme . $uploaded_file['name']);
|
||||
$destination = file_unmanaged_move($source, $destination, FILE_EXISTS_RENAME);
|
||||
$file = plupload_file_uri_to_object($destination);
|
||||
file_save($file);
|
||||
// Check the $file object to see if all necessary properties are set. Otherwise, use file_load($file->fid) to populate all of them.
|
||||
// $file = file_load($file->fid);
|
||||
$saved_files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
return $saved_files;
|
||||
}
|
||||
|
||||
$form['booking-email-attachment'] = array(
|
||||
'#type' => 'plupload',
|
||||
'#title' => t('Email attachment'),
|
||||
'#description' => t('Attach any files to be attached to email. Note that this only works with custom email types.'),
|
||||
'#upload_validators' => array(
|
||||
'file_validate_size' => array(10*1024*1024),
|
||||
'file_validate_extensions' => array(variable_get('booking_email_allowed_attachments', 'pdf docx')),
|
||||
),
|
||||
'#plupload_settings' => array(
|
||||
'runtimes' => 'html5',
|
||||
'chunk_size' => '1mb',
|
||||
),
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$header['travel_form'] = array('data' => t('Travel Submitted?'), 'field' => 'tid');
|
||||
}
|
||||
|
||||
//query the database for studygroup info if it is enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
//select entries from the study groups mapping table
|
||||
$query = db_select('booking_studygroup_mapping', 'm');
|
||||
$query->join('booking_studygroup_list', 's', 's.sid = m.booking_studygroup_id');
|
||||
$query->condition('m.booking_eventid', $event->eid, '=');
|
||||
$query->fields('m')->fields('s', array('booking_studygroup_descrip'));
|
||||
$group_mapping = $query->execute()->fetchAllAssoc('sid');
|
||||
//add a column to the table header
|
||||
$header['group_roles'] = array('data' => t('Group Role'));
|
||||
}
|
||||
|
||||
//query for attendee data
|
||||
$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_eventid', $event->eid, '=');
|
||||
//make the result user-sortable
|
||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||
$result = $table_sort->execute();
|
||||
|
||||
//generate the tableselect data
|
||||
foreach($result as $data) {
|
||||
$group_text = "";
|
||||
$class = $data->booking_welfare_required == 'Y' ? "welfare-row" : "normal-row";
|
||||
$options[$data->nid] = array (
|
||||
'#attributes' => array('class' => array($class)),
|
||||
'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',
|
||||
);
|
||||
|
||||
//add optional columns if those features are enabled
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$options[$data->nid]['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 .= "<b>" . $text . "</b> for " . $group->booking_studygroup_descrip . " #" . $group->booking_session_id . "; ";
|
||||
}
|
||||
}
|
||||
$options[$data->nid]['group_roles'] = $group_text;
|
||||
}
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
//'#multiple' => TRUE,
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#default_value' => $values,
|
||||
'#empty' => t('No attendees found.'),
|
||||
'#attributes' => array('id' => 'sort-table'),
|
||||
);
|
||||
//watchdog('booking_debug', "<pre>Manual email form default values\n@info</pre>", array('@info' => print_r( $values, true)));
|
||||
//watchdog('booking_debug', "<pre>Manual email form table\n@info</pre>", array('@info' => print_r( $form['table'], true)));
|
||||
|
||||
$form['submit-bottom'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
return array (
|
||||
/*
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
*/
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update preview of email that will be sent
|
||||
*
|
||||
*/
|
||||
function _booking_email_get_preview_callback($form, $form_state) {
|
||||
global $event;
|
||||
$text = "";
|
||||
$emailtype = $form_state['values']['email-type'];
|
||||
|
||||
switch ($emailtype) {
|
||||
case "registration":
|
||||
$text = variable_get('booking_email_bookedin_text');
|
||||
break;
|
||||
case "balance":
|
||||
$text = variable_get('booking_email_paymentoutstanding_text');
|
||||
// perform the checking of HTML value now since we're pre-pending text to it
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1) {
|
||||
// no <pre> tags necessary if its a HTML mail
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$text .= "\n<h3>If married</h3>\n";
|
||||
}
|
||||
else {
|
||||
$text .= "\n</pre><h3>If married</h3>\n<pre>";
|
||||
}
|
||||
$married_text = variable_get('booking_email_paymentoutstanding_married_text');
|
||||
// repeat HTML check for rest of preview
|
||||
$text .= isset($married_text['format']) ? $married_text['value'] : $married_text;
|
||||
}
|
||||
break;
|
||||
case "complete":
|
||||
$text = variable_get('booking_email_regn_complete_text');
|
||||
break;
|
||||
case "withdrawal":
|
||||
$text = variable_get('booking_email_notcoming_demotion');
|
||||
break;
|
||||
case "missedpayment":
|
||||
$text = variable_get('booking_email_missedpayment');
|
||||
break;
|
||||
case "initialtravelrequired":
|
||||
$text = variable_get('booking_email_travel_initial_email_text');
|
||||
break;
|
||||
case "remindertravelrequired":
|
||||
$text = variable_get('booking_email_travel_reminder_email_text');
|
||||
break;
|
||||
case "travelcomplete":
|
||||
$text = variable_get('booking_email_travel_complete_text');
|
||||
break;
|
||||
case "waitinglistpromotion":
|
||||
$text = variable_get('booking_email_waitinglistpromotion');
|
||||
break;
|
||||
case "waitinglistpromotionfullypaid":
|
||||
$text = variable_get('booking_email_waitinglistpromotion_fullypaid');
|
||||
break;
|
||||
}
|
||||
//handle custom email types
|
||||
if (strpos($emailtype, 'custom') !== false) {
|
||||
$text = variable_get('booking_email_' . $form_state['values']['email-type']);
|
||||
}
|
||||
|
||||
//use the html value if it is set, otherwise use the plaintext input which is just a string
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
//watchdog('booking_debug', "<pre>Email generation:\n@info</pre>", array('@info' => print_r( $text, true)));
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3>";
|
||||
$markup_post = "<br /><br /></div>";
|
||||
}
|
||||
else {
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3><pre>";
|
||||
$markup_post = "</pre><br /><br /></div>";
|
||||
}
|
||||
|
||||
//generate html that will be used to update div booking_email_preview_wrapper
|
||||
return $markup_pre . $text . $markup_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update hidden form value with default checkbox details
|
||||
*
|
||||
* Callback element needs only select the portion of the form to be updated.
|
||||
* Since #ajax['callback'] return can be HTML or a renderable array (or an
|
||||
* array of commands), we can just return a piece of the form.
|
||||
* Source: http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
*/
|
||||
function _booking_email_get_default_selection_callback($form, $form_state) {
|
||||
global $event;
|
||||
$defaults = array();
|
||||
$replacementform_data = array();
|
||||
|
||||
//get type of selection from $form_state['values']['booking-email-preselection']
|
||||
$selection = $form_state['values']['booking-email-preselection'];
|
||||
//load nodes
|
||||
$people = booking_load_query(NULL, TRUE);
|
||||
|
||||
// Check for the reading group ID
|
||||
$readinggroup_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid AND booking_is_readinggroup = 'Y'",
|
||||
array(':eid' => $event->eid));
|
||||
$readinggroups = $readinggroup_query->fetchObject();
|
||||
//watchdog('booking_debug', "<pre>Reading Group ID is :\n@info</pre>", array('@info' => print_r($readinggroups, true)));
|
||||
$readinggroup_regex = '/^session' . $readinggroups->sid . '_role/';
|
||||
|
||||
//populate $defaults based on type of selection
|
||||
foreach ($people as $person) {
|
||||
switch ($selection) {
|
||||
case 'notpaid':
|
||||
if ($person->booking_status == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'bookedin':
|
||||
if ($person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'waitinglist':
|
||||
if ($person->booking_status == 2) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'refundreqd':
|
||||
if ($person->booking_status == 3 && $person->booking_refund_processed == 'N') {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'unpaid':
|
||||
if ($person->booking_payment_complete == 'N' && $person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'notravelform':
|
||||
if ($person->booking_status == 1 && $person->tid == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'notravelforminclwaiting':
|
||||
if (($person->booking_status == 1 || $person->booking_status == 2) && $person->tid == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'leaderhelper':
|
||||
foreach ($person as $key => $value) {
|
||||
if (preg_match('/^session(\d+)_role/', $key, $matches) && $value > 0) {
|
||||
//don't add the person multiple times if they're leading/helping multiple groups
|
||||
if (! in_array($person->nid, $defaults)) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'readinggroup-leader':
|
||||
foreach ($person as $key => $value) {
|
||||
if (preg_match($readinggroup_regex, $key, $matches) && $value == 1) {
|
||||
//don't add the person multiple times if they're leading/helping multiple groups
|
||||
if (! in_array($person->nid, $defaults)) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} //end switch
|
||||
} //loop attendees
|
||||
|
||||
//create new hidden form element to return
|
||||
$replacementform_data['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => drupal_json_encode($defaults), //encode the data as json so we can process it with jQuery
|
||||
'#prefix' => '<div id="booking_email_default_ids_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#attributes' => array('id' => 'booking_email_default_ids'),
|
||||
);
|
||||
|
||||
$output_html = render($replacementform_data['booking-email-default-ids']);
|
||||
$feedback_html = t("<div id=\"booking_email_preselection_suffix_wrapper\">Number of people selected: <b>!num</b></div>",
|
||||
array('!num' => count($defaults)));
|
||||
//watchdog('booking_debug', "<pre>Manual Email ajax html\n@info</pre>", array('@info' => print_r( $output_html, true)));
|
||||
|
||||
//return a sequence of commands to run
|
||||
return array(
|
||||
'#type' => 'ajax',
|
||||
'#commands' => array(
|
||||
ajax_command_replace("#booking_email_default_ids_wrapper", $output_html),
|
||||
ajax_command_replace("#booking_email_preselection_suffix_wrapper", $feedback_html),
|
||||
// This will call the command bookingEmailIDs in our custom JS file.
|
||||
array('command' => 'bookingAjaxCheckboxes',
|
||||
'formDataElement' => 'booking_email_default_ids', //name of the hidden form element that contains the json data
|
||||
'formName' => 'booking-manual-email-form', //note the dashes instead of underscores!
|
||||
'checkboxName' => 'table', //form element for tableselect
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to handle sending the manual emails
|
||||
*/
|
||||
function booking_manual_email_form_submit($form, &$form_state) {
|
||||
$counter = 0;
|
||||
$message = "";
|
||||
$attachments = array();
|
||||
$update_messages = array();
|
||||
$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)));
|
||||
|
||||
// Add attachments if present
|
||||
if (isset($form_state['values']['booking-email-attachment-1']) && $form_state['values']['booking-email-attachment-1'] != 0) {
|
||||
$attachments[] = file_load($form_state['values']['booking-email-attachment-1']);
|
||||
watchdog('booking_debug', 'File attachment 1 detected: @info', array ('@info' => print_r($attachments, TRUE)));
|
||||
// NOTE: Since we do nothing to save this file, it should get cleaned up by cron
|
||||
// As per https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x#managed_file
|
||||
}
|
||||
if (isset($form_state['values']['booking-email-attachment-2']) && $form_state['values']['booking-email-attachment-2'] != 0) {
|
||||
$attachments[] = file_load($form_state['values']['booking-email-attachment-2']);
|
||||
watchdog('booking_debug', 'File attachment 2 detected: @info', array ('@info' => print_r($attachments, TRUE)));
|
||||
}
|
||||
|
||||
foreach($checkboxes as $key => $value) {
|
||||
//do a sanity check on the key => value pair from the form submission
|
||||
if (is_numeric($key) && $value != 0) {
|
||||
//check the person exists in the database
|
||||
$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') {
|
||||
$message = t('Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, false, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'initialtravelrequired') {
|
||||
$message = t('Processing a manual initial travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_initial_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'remindertravelrequired') {
|
||||
$message = t('Processing a manual reminder travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_reminder_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'balance') {
|
||||
$message = t('Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
_booking_balance_payment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'complete') {
|
||||
$message = t('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') {
|
||||
$message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_confirmation_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal') {
|
||||
$message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
_booking_demoted_to_notcoming_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment') {
|
||||
$message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
_booking_missedpayment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'waitinglistpromotion') {
|
||||
$message = t('Processing a manual waitinglistpromotion email to id @info', array ('@info' => $key));
|
||||
_booking_promoted_from_waitinglist_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'waitinglistpromotionfullypaid') {
|
||||
$message = t('Processing a manual waitinglistpromotionfullypaid email to id @info', array ('@info' => $key));
|
||||
_booking_promoted_from_waitinglist_email($key);
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'customlogistics') !== false) {
|
||||
$message = t('Processing a @custom type email from logistics to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'logistics', $attachment);
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'custom') !== false) {
|
||||
$message = t('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'], 'contact', $attachments);
|
||||
}
|
||||
//increase the counter of people we've emailed
|
||||
$counter++;
|
||||
//store info about the email
|
||||
$update_messages[] = $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
$final_message = "Sent manual email for $counter people of type " . $form_state['values']['email-type'];
|
||||
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.");
|
||||
}
|
@@ -303,10 +303,11 @@ function _booking_partialbalance_payment_email($nid) {
|
||||
* @param $email_type - select which custom email template to use
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_custom_email($nid, $email_type, $sender = 'contact') {
|
||||
function _booking_custom_email($nid, $email_type, $sender = 'contact', $attachments = NULL) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
$params = array();
|
||||
|
||||
//calculate the drupal variables to use
|
||||
$email_subject_variable = 'booking_email_subject_' . $email_type;
|
||||
@@ -350,6 +351,16 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact') {
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
// If there was an attachment, then add it
|
||||
foreach ($attachments as $attachment) {
|
||||
$file_uri = drupal_realpath($attachment->uri);
|
||||
// Make sure we can still access the file
|
||||
if (file_exists($file_uri) && fopen($file_uri, 'r') !== false) {
|
||||
watchdog('booking_debug', "Adding attachment !name to custom email.", array('!name' => $attachment->filename));
|
||||
$params['attachment'][] = file_load($attachment->fid);
|
||||
}
|
||||
}
|
||||
|
||||
//send the email to the person
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -391,7 +402,7 @@ function _booking_promoted_from_waitinglist_email($nid) {
|
||||
}
|
||||
|
||||
if ($tokens['payment-required'] == 0) {
|
||||
watchdog('booking_debug', 'This person has fully paid so sending Not sending promoted-from-waitinglist-fullypaid email.');
|
||||
watchdog('booking_debug', 'This person has fully paid so sending promoted-from-waitinglist-fullypaid email.');
|
||||
$message_body = variable_get('booking_email_waitinglistpromotion_fullypaid');
|
||||
}
|
||||
else {
|
||||
|
@@ -248,6 +248,183 @@ function booking_emails_workflow_admin() {
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook form() to use ajax to allow admin user to define custom emails that can be sent by Bookings module
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_emails_custom_ajax_form($node, &$form_state) {
|
||||
global $event;
|
||||
$form = array();
|
||||
$email_options_array = array();
|
||||
$data = $node;
|
||||
$submit_button_disabled = TRUE;
|
||||
|
||||
//$email_options_array = _booking_custom_email_types();
|
||||
$email_options_array['NULL'] = "---";
|
||||
//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);
|
||||
}
|
||||
//add in the custom email types from logistics
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i,
|
||||
$event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**";
|
||||
}
|
||||
|
||||
// Populate some default values if a selection has already been made
|
||||
//watchdog('booking_debug', 'booking_emails_custom_ajax_form state: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||
|
||||
if (!isset($form_state['input']['email-type'])) {
|
||||
$subject_value = "";
|
||||
$body_value = "";
|
||||
}
|
||||
else {
|
||||
//watchdog('booking_debug', 'booking_emails_custom_ajax_form user has selected email type ' . $form_state['input']['email-type']);
|
||||
$emailtype = $form_state['input']['email-type'];
|
||||
$subject_value = $form_state['input']['booking_email_subjectline_custom'];
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$body_value = $form_state['input']['booking_email_body_custom']['value'];
|
||||
}
|
||||
else {
|
||||
$body_value = $form_state['input']['booking_email_body_custom'];
|
||||
}
|
||||
|
||||
// only enable the submit button if the email type is not the initial empty one
|
||||
if ($form_state['input']['email-type'] !== 'NULL') {
|
||||
$submit_button_disabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Define the textareas in the form differently if HTML emails are enabled
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form_type = 'text_format';
|
||||
$form_format = 'full_html';
|
||||
}
|
||||
else {
|
||||
$form_type = 'textarea';
|
||||
$form_format = NULL;
|
||||
}
|
||||
|
||||
$form['#prefix'] = '<div id="booking_emails_custom_fieldset_wrapper">';
|
||||
$form['#suffix'] = '</div>';
|
||||
|
||||
//include the token definitions
|
||||
$form['tokens'] = array(
|
||||
'#theme' => 'token_tree',
|
||||
'#token_types' => array('booking'),
|
||||
);
|
||||
|
||||
$form['email-type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email Type'),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => 'NULL',
|
||||
'#options' => $email_options_array,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => 'booking_emails_custom_ajax_form_callback',
|
||||
'wrapper' => 'booking_emails_custom_fieldset_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['email-definition'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Email Definition',
|
||||
//'#prefix' => '<div id="booking_emails_custom_fieldset_wrapper">',
|
||||
//'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
$form['email-definition']['booking_email_subjectline_custom'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Custom Email'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#value' => $subject_value,
|
||||
//'#value' => isset($form_state['values']['booking_email_subjectline_custom']) ? $form_state['values']['booking_email_subjectline_custom'] : '',
|
||||
);
|
||||
$form['email-definition']['booking_email_body_custom'] = array(
|
||||
'#title' => t('Email text for custom email'),
|
||||
'#description' => t(''),
|
||||
'#value' => $body_value,
|
||||
//'#value' => isset($form_state['values']['booking_email_body_custom']) ? $form_state['values']['booking_email_body_custom'] : '',
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
'#rows' => 20,
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#disabled' => $submit_button_disabled,
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to display the custom email definition for form booking_emails_custom_ajax_form
|
||||
*/
|
||||
function booking_emails_custom_ajax_form_callback($form, &$form_state) {
|
||||
global $event;
|
||||
$text = "";
|
||||
$data = $form_state['input'];
|
||||
|
||||
//check the selected email type
|
||||
$emailtype = $form_state['input']['email-type'];
|
||||
|
||||
//configure the input text field and textarea based on select field
|
||||
if (strpos($emailtype, 'custom') !== false) {
|
||||
$subject = variable_get('booking_email_subject_' . $emailtype, '');
|
||||
$form['form']['email-definition']['booking_email_subjectline_custom']['#value'] = $subject;
|
||||
|
||||
$text = variable_get('booking_email_' . $emailtype, '');
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
//watchdog('booking_debug', 'custom text: <pre>@info</pre>', array('@info' => print_r( $text, true)));
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form['form']['email-definition']['booking_email_body_custom']['value']['#value'] = $text;
|
||||
}
|
||||
else {
|
||||
$form['form']['email-definition']['booking_email_body_custom']['#value'] = $text;
|
||||
}
|
||||
// TODO : Does changing submit button state here do anything?
|
||||
$form['form']['submit']['#disabled'] = FALSE;
|
||||
}
|
||||
else {
|
||||
$form['form']['email-definition']['booking_email_subjectline_custom']['#value'] = '';
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form['form']['email-definition']['booking_email_body_custom']['value']['#value'] = '';
|
||||
}
|
||||
else {
|
||||
$form['form']['email-definition']['booking_email_body_custom']['#value'] = '';
|
||||
}
|
||||
// TODO : Does changing submit button state here do anything?
|
||||
$form['form']['submit']['#disabled'] = TRUE;
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', 'booking_emails_custom_ajax_form_callback: <pre>@info</pre>', array('@info' => print_r( $form, true)));
|
||||
|
||||
// Rebuild the form
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return $form['form'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the submission for the custom email definition form
|
||||
*/
|
||||
function booking_emails_custom_ajax_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
|
||||
$emailtype = $values['email-type'];
|
||||
variable_set('booking_email_subject_' . $emailtype, $values['booking_email_subjectline_custom']);
|
||||
variable_set('booking_email_' . $emailtype, $values['booking_email_body_custom']);
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to allow admin user to define custom emails that can be sent by Bookings module
|
||||
*
|
||||
@@ -360,498 +537,3 @@ function booking_emails_customlogistics_admin() {
|
||||
//let the builtin hook do all the hard work
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to allow admin user to manually generate and send a workflow or custom email
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_manual_email_form($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
/*
|
||||
create hidden form element that we will populate with JSON data via ajax
|
||||
create select element defining the pre-selections available
|
||||
create submit button that calls ajax to update hidden form element, then calls ajax to check the checkboxes based on the hidden form element
|
||||
|
||||
info on turning JSON data back to array
|
||||
http://stackoverflow.com/questions/29076219/javascript-storing-array-of-objects-in-hidden-field
|
||||
|
||||
ajax references:
|
||||
http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
https://www.drupal.org/node/1028410
|
||||
https://www.drupal.org/node/2046693
|
||||
|
||||
jquery to check the checkboxes:
|
||||
http://jsfiddle.net/nanoquantumtech/dnhwz/
|
||||
*/
|
||||
$form = array();
|
||||
$options = array();
|
||||
$preselection_options = array();
|
||||
$values = array();
|
||||
$group_text = "";
|
||||
$prefix = t("<p>Send a manual email to people registered for this event.</p>");
|
||||
$email_options_array = array();
|
||||
$email_options_array['NULL'] = "---";
|
||||
$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['waitinglistpromotion'] = 'Position Available (Balance outstanding)';
|
||||
$email_options_array['waitinglistpromotionfullypaid'] = 'Position Available (Fully Paid)';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment Email';
|
||||
$email_options_array['initialtravelrequired'] = 'Initial Travel Form Required Email';
|
||||
$email_options_array['remindertravelrequired'] = 'Reminder Travel Form Required Email';
|
||||
$email_options_array['travelcomplete'] = 'Travel Form Complete Email';
|
||||
|
||||
$preselection_options['---'] = "---";
|
||||
$preselection_options['notpaid'] = 'People who have not yet paid';
|
||||
$preselection_options['bookedin'] = 'People who are booked-in';
|
||||
$preselection_options['waitinglist'] = 'People on waiting list';
|
||||
$preselection_options['unpaid'] = 'People booked-in with outstanding balance';
|
||||
$preselection_options['refundreqd'] = 'Refund Required';
|
||||
$preselection_options['notravelform'] = "People booked-in no travel form received";
|
||||
$preselection_options['notravelforminclwaiting'] = "People booked-in/waiting no travel form received";
|
||||
$preselection_options['leaderhelper'] = "Leaders/Helpers";
|
||||
|
||||
$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'),
|
||||
);
|
||||
|
||||
//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);
|
||||
}
|
||||
//add in the custom email types from logistics
|
||||
for ($i = 1; $i <= 5; $i++)
|
||||
{
|
||||
$email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i,
|
||||
$event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**";
|
||||
}
|
||||
|
||||
//attach css so we can customise colours for some people
|
||||
$form['#attached']['css'] = array(
|
||||
drupal_get_path('module', 'booking') . '/booking.css',
|
||||
);
|
||||
//attach js for dynamically setting checkboxes
|
||||
$form['#attached']['js'][] = drupal_get_path("module", "booking")."/booking.js";
|
||||
|
||||
$form['pretext'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => $prefix,
|
||||
);
|
||||
|
||||
//@todo add booking prefix
|
||||
$form['email-type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email Type'),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => 'NULL',
|
||||
'#options' => $email_options_array,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_preview_callback',
|
||||
'wrapper' => 'booking_email_preview_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => "[]",
|
||||
'#prefix' => '<div id="booking_email_default_ids_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#attributes' => array('id' => 'booking_email_default_ids'),
|
||||
);
|
||||
|
||||
$form['booking-email-preselection'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Pre-select attendees from list'),
|
||||
'#description' => t('Use this to select a large group of people based on pre-defined criteria.'),
|
||||
'#options' => $preselection_options,
|
||||
'#default_value' => '---',
|
||||
'#suffix' => '<div id="booking_email_preselection_suffix_wrapper"></div>',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_default_selection_callback',
|
||||
'wrapper' => 'booking_email_default_ids_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking-email-preview'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => "<h3>Email Preview</h3><pre>No email type selected.</pre>",
|
||||
'#prefix' => '<div id="booking_email_preview_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$header['travel_form'] = array('data' => t('Travel Submitted?'), 'field' => 'tid');
|
||||
}
|
||||
|
||||
|
||||
//query the database for studygroup info if it is enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
//select entries from the study groups mapping table
|
||||
$query = db_select('booking_studygroup_mapping', 'm');
|
||||
$query->join('booking_studygroup_list', 's', 's.sid = m.booking_studygroup_id');
|
||||
$query->condition('m.booking_eventid', $event->eid, '=');
|
||||
$query->fields('m')->fields('s', array('booking_studygroup_descrip'));
|
||||
$group_mapping = $query->execute()->fetchAllAssoc('sid');
|
||||
//add a column to the table header
|
||||
$header['group_roles'] = array('data' => t('Group Role'));
|
||||
}
|
||||
|
||||
//query for attendee data
|
||||
$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_eventid', $event->eid, '=');
|
||||
//make the result user-sortable
|
||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||
$result = $table_sort->execute();
|
||||
|
||||
//generate the tableselect data
|
||||
foreach($result as $data) {
|
||||
$group_text = "";
|
||||
$class = $data->booking_welfare_required == 'Y' ? "welfare-row" : "normal-row";
|
||||
$options[$data->nid] = array (
|
||||
'#attributes' => array('class' => array($class)),
|
||||
'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',
|
||||
);
|
||||
|
||||
//add optional columns if those features are enabled
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$options[$data->nid]['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 .= "<b>" . $text . "</b> for " . $group->booking_studygroup_descrip . " #" . $group->booking_session_id . "; ";
|
||||
}
|
||||
}
|
||||
$options[$data->nid]['group_roles'] = $group_text;
|
||||
}
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
//'#multiple' => TRUE,
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#default_value' => $values,
|
||||
'#empty' => t('No attendees found.'),
|
||||
'#attributes' => array('id' => 'sort-table'),
|
||||
);
|
||||
//watchdog('booking_debug', "<pre>Manual email form default values\n@info</pre>", array('@info' => print_r( $values, true)));
|
||||
//watchdog('booking_debug', "<pre>Manual email form table\n@info</pre>", array('@info' => print_r( $form['table'], true)));
|
||||
|
||||
$form['submit-bottom'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
return array (
|
||||
/*
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
*/
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update preview of email that will be sent
|
||||
*
|
||||
*/
|
||||
function _booking_email_get_preview_callback($form, $form_state) {
|
||||
global $event;
|
||||
$text = "";
|
||||
$emailtype = $form_state['values']['email-type'];
|
||||
|
||||
switch ($emailtype) {
|
||||
case "registration":
|
||||
$text = variable_get('booking_email_bookedin_text');
|
||||
break;
|
||||
case "balance":
|
||||
$text = variable_get('booking_email_paymentoutstanding_text');
|
||||
// perform the checking of HTML value now since we're pre-pending text to it
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1) {
|
||||
// no <pre> tags necessary if its a HTML mail
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$text .= "\n<h3>If married</h3>\n";
|
||||
}
|
||||
else {
|
||||
$text .= "\n</pre><h3>If married</h3>\n<pre>";
|
||||
}
|
||||
$married_text = variable_get('booking_email_paymentoutstanding_married_text');
|
||||
// repeat HTML check for rest of preview
|
||||
$text .= isset($married_text['format']) ? $married_text['value'] : $married_text;
|
||||
}
|
||||
break;
|
||||
case "complete":
|
||||
$text = variable_get('booking_email_regn_complete_text');
|
||||
break;
|
||||
case "withdrawal":
|
||||
$text = variable_get('booking_email_notcoming_demotion');
|
||||
break;
|
||||
case "missedpayment":
|
||||
$text = variable_get('booking_email_missedpayment');
|
||||
break;
|
||||
case "initialtravelrequired":
|
||||
$text = variable_get('booking_email_travel_initial_email_text');
|
||||
break;
|
||||
case "remindertravelrequired":
|
||||
$text = variable_get('booking_email_travel_reminder_email_text');
|
||||
break;
|
||||
case "travelcomplete":
|
||||
$text = variable_get('booking_email_travel_complete_text');
|
||||
break;
|
||||
case "waitinglistpromotion":
|
||||
$text = variable_get('booking_email_waitinglistpromotion');
|
||||
break;
|
||||
case "waitinglistpromotionfullypaid":
|
||||
$text = variable_get('booking_email_waitinglistpromotion_fullypaid');
|
||||
break;
|
||||
}
|
||||
//handle custom email types
|
||||
if (strpos($emailtype, 'custom') !== false) {
|
||||
$text = variable_get('booking_email_' . $form_state['values']['email-type']);
|
||||
}
|
||||
|
||||
//use the html value if it is set, otherwise use the plaintext input which is just a string
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
//watchdog('booking_debug', "<pre>Email generation:\n@info</pre>", array('@info' => print_r( $text, true)));
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3>";
|
||||
$markup_post = "<br /><br /></div>";
|
||||
}
|
||||
else {
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3><pre>";
|
||||
$markup_post = "</pre><br /><br /></div>";
|
||||
}
|
||||
|
||||
//generate html that will be used to update div booking_email_preview_wrapper
|
||||
return $markup_pre . $text . $markup_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update hidden form value with default checkbox details
|
||||
*
|
||||
* Callback element needs only select the portion of the form to be updated.
|
||||
* Since #ajax['callback'] return can be HTML or a renderable array (or an
|
||||
* array of commands), we can just return a piece of the form.
|
||||
* Source: http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
*/
|
||||
function _booking_email_get_default_selection_callback($form, $form_state) {
|
||||
global $event;
|
||||
$defaults = array();
|
||||
$replacementform_data = array();
|
||||
|
||||
//get type of selection from $form_state['values']['booking-email-preselection']
|
||||
$selection = $form_state['values']['booking-email-preselection'];
|
||||
//load nodes
|
||||
$people = booking_load_query(NULL, TRUE);
|
||||
|
||||
//populate $defaults based on type of selection
|
||||
foreach ($people as $person) {
|
||||
switch ($selection) {
|
||||
case 'notpaid':
|
||||
if ($person->booking_status == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'bookedin':
|
||||
if ($person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'waitinglist':
|
||||
if ($person->booking_status == 2) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'refundreqd':
|
||||
if ($person->booking_status == 3 && $person->booking_refund_processed == 'N') {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'unpaid':
|
||||
if ($person->booking_payment_complete == 'N' && $person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'notravelform':
|
||||
if ($person->booking_status == 1 && $person->tid == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'notravelforminclwaiting':
|
||||
if (($person->booking_status == 1 || $person->booking_status == 2) && $person->tid == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'leaderhelper':
|
||||
foreach ($person as $key => $value) {
|
||||
if (preg_match('/^session(\d+)_role/', $key, $matches) && $value > 0) {
|
||||
//don't add the person multiple times if they're leading/helping multiple groups
|
||||
if (! in_array($person->nid, $defaults)) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} //end switch
|
||||
} //loop attendees
|
||||
|
||||
//create new hidden form element to return
|
||||
$replacementform_data['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => drupal_json_encode($defaults), //encode the data as json so we can process it with jQuery
|
||||
'#prefix' => '<div id="booking_email_default_ids_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#attributes' => array('id' => 'booking_email_default_ids'),
|
||||
);
|
||||
|
||||
$output_html = render($replacementform_data['booking-email-default-ids']);
|
||||
$feedback_html = t("<div id=\"booking_email_preselection_suffix_wrapper\">Number of people selected: <b>!num</b></div>",
|
||||
array('!num' => count($defaults)));
|
||||
//watchdog('booking_debug', "<pre>Manual Email ajax html\n@info</pre>", array('@info' => print_r( $output_html, true)));
|
||||
|
||||
//return a sequence of commands to run
|
||||
return array(
|
||||
'#type' => 'ajax',
|
||||
'#commands' => array(
|
||||
ajax_command_replace("#booking_email_default_ids_wrapper", $output_html),
|
||||
ajax_command_replace("#booking_email_preselection_suffix_wrapper", $feedback_html),
|
||||
// This will call the command bookingEmailIDs in our custom JS file.
|
||||
array('command' => 'bookingAjaxCheckboxes',
|
||||
'formDataElement' => 'booking_email_default_ids', //name of the hidden form element that contains the json data
|
||||
'formName' => 'booking-manual-email-form', //note the dashes instead of underscores!
|
||||
'checkboxName' => 'table', //form element for tableselect
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to handle sending the manual emails
|
||||
*/
|
||||
function booking_manual_email_form_submit($form, &$form_state) {
|
||||
$counter = 0;
|
||||
$update_messages = array();
|
||||
$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)
|
||||
{
|
||||
$message = "";
|
||||
|
||||
//do a sanity check on the key => value pair from the form submission
|
||||
if (is_numeric($key) && $value != 0)
|
||||
{
|
||||
//check the person exists in the database
|
||||
$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') {
|
||||
$message = t('Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, false, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'initialtravelrequired') {
|
||||
$message = t('Processing a manual initial travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_initial_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'remindertravelrequired') {
|
||||
$message = t('Processing a manual reminder travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_reminder_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'balance') {
|
||||
$message = t('Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
_booking_balance_payment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'complete') {
|
||||
$message = t('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') {
|
||||
$message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_confirmation_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal') {
|
||||
$message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
_booking_demoted_to_notcoming_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment') {
|
||||
$message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
_booking_missedpayment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'waitinglistpromotion') {
|
||||
$message = t('Processing a manual waitinglistpromotion email to id @info', array ('@info' => $key));
|
||||
_booking_promoted_from_waitinglist_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'waitinglistpromotionfullypaid') {
|
||||
$message = t('Processing a manual waitinglistpromotionfullypaid email to id @info', array ('@info' => $key));
|
||||
_booking_promoted_from_waitinglist_email($key);
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'customlogistics') !== false) {
|
||||
$message = t('Processing a @custom type email from logistics to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'logistics');
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'custom') !== false) {
|
||||
$message = t('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'], 'contact');
|
||||
}
|
||||
//increase the counter of people we've emailed
|
||||
$counter++;
|
||||
//store info about the email
|
||||
$update_messages[] = $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
$final_message = "Sent manual email for $counter people of type " . $form_state['values']['email-type'];
|
||||
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.");
|
||||
}
|
||||
|
@@ -85,6 +85,14 @@ function booking_event_admin_submit($form, &$form_state) {
|
||||
->condition('eid', $selected_event, '!=')
|
||||
->execute();
|
||||
|
||||
// Disable variety session timeslots not belonging to target event id
|
||||
db_update('booking_variety_timeslots')
|
||||
->fields(array (
|
||||
'booking_variety_status' => 0,
|
||||
))
|
||||
->condition('booking_eventid', $selected_event, '!=')
|
||||
->execute();
|
||||
|
||||
//then set our target event id to be active
|
||||
db_update('booking_event')
|
||||
->fields(array (
|
||||
@@ -99,6 +107,8 @@ function booking_event_admin_submit($form, &$form_state) {
|
||||
menu_cache_clear_all();
|
||||
menu_rebuild();
|
||||
|
||||
// update SQL view
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
|
||||
@@ -294,5 +304,8 @@ function booking_event_form_submit($form, &$form_state) {
|
||||
->execute();
|
||||
}
|
||||
|
||||
// update SQL view
|
||||
_booking_node_create_mysqlview();
|
||||
|
||||
$form_state['redirect'] = array('admin/config/booking/events');
|
||||
}
|
@@ -748,9 +748,9 @@ function _booking_room_capacity_check($room_id, $room_bedtype, $room_definition_
|
||||
//check that there is sufficient capacity to allocate another person to this room and bed type
|
||||
if ($mappings->num < $max_beds)
|
||||
{
|
||||
watchdog('booking','Sufficient capacity is available in location !id, room !room, with bed type !type. !count beds remaining of this type',
|
||||
array('!id' => $details->booking_room_location_id, '!room' => $details->booking_room_number,
|
||||
'!type' => _booking_room_bedtype_lookup($room_bedtype), '!count' => $max_beds - $mappings->num));
|
||||
//watchdog('booking','Sufficient capacity is available in location !id, room !room, with bed type !type. !count beds remaining of this type',
|
||||
// array('!id' => $details->booking_room_location_id, '!room' => $details->booking_room_number,
|
||||
// '!type' => _booking_room_bedtype_lookup($room_bedtype), '!count' => $max_beds - $mappings->num));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1475,7 +1475,9 @@ function _booking_details_email_summary($node) {
|
||||
if (variable_get('booking_enable_tshirts', 0) == 1) {
|
||||
$rows[] = t('Hoodie Size: !size', array('!size' => $node->booking_shirt_size));
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_previous_studyweeks', 0) == 1) {
|
||||
$rows[] = t('Previous SWs: !sw', array('!sw' => $node->booking_prev_sw_count));
|
||||
}
|
||||
$rows[] = t('Emergency Contact Name: !contact', array('!contact' => $node->booking_guardian_name));
|
||||
$rows[] = t('Emergency Contact Relationship: !relationship', array('!relationship' => $node->booking_guardian_type));
|
||||
$rows[] = t('Emergency Contact Phone: !phone', array('!phone' => $node->booking_guardian_phone));
|
||||
@@ -1604,6 +1606,69 @@ function _booking_travelform_email_summary($node) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to format summary of reading group members, to be used as a token
|
||||
*/
|
||||
function _booking_readinggroup_email_listing($node) {
|
||||
global $event;
|
||||
$rows = array();
|
||||
$header = array("First Name", "Last Name", "Phone Number");
|
||||
$attributes = array("style" => "border-collapse: separate; border-spacing: 20px 0;");
|
||||
|
||||
//display study session data if enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 0) {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
|
||||
// Check for the reading group
|
||||
$readinggroup_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid AND booking_is_readinggroup = 'Y'",
|
||||
array(':eid' => $event->eid));
|
||||
$readinggroups = $readinggroup_query->fetchAllAssoc('sid');
|
||||
|
||||
if (! $readinggroups) {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
|
||||
foreach ($readinggroups as $readinggroup) {
|
||||
//calculate the session references
|
||||
$sessionid = "session" . $readinggroup->sid;
|
||||
$roleid = $sessionid . "_role";
|
||||
|
||||
//check that this reading group session has been defined for this attendee and that they're a leader
|
||||
if (!empty($node->$sessionid) && $node->$roleid == 1) {
|
||||
watchdog('booking_debug', "<pre>Person is a leader of reading group @id \n@info</pre>",
|
||||
array('@id' => $node->$sessionid, '@info' => print_r($readinggroup, true)));
|
||||
|
||||
$member_query = db_query("SELECT * FROM {booking_person_view} WHERE $sessionid = :sid ", array(':sid' => $node->$sessionid))->fetchAllAssoc('nid');
|
||||
//watchdog('booking_debug', "<pre>Other people in reading group @id \n@info</pre>",
|
||||
// array('@id' => $node->$sessionid, '@info' => print_r($member_query, true)));
|
||||
|
||||
foreach ($member_query as $member) {
|
||||
$rows[] = array(
|
||||
$member->booking_firstname,
|
||||
$member->booking_lastname,
|
||||
$member->booking_mobile,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't show an empty header row if there was no-one in the group
|
||||
if (count($rows) < 1) {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
|
||||
// Use Drupal's table theming function to build the table if HTML email is enabled
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$table = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
watchdog('booking_debug', "<pre>Reading group table\n@info</pre>", array('@info' => print_r($table, true)));
|
||||
return $table;
|
||||
}
|
||||
else {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to format summary of studygroup sessions to be used as a token
|
||||
*/
|
||||
@@ -1612,36 +1677,55 @@ function _booking_studygroup_email_summary($node) {
|
||||
$rows = array();
|
||||
|
||||
//display study session data if enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_studygroups', 0) == 0) {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
|
||||
//look up the titles of the study groups
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid AND booking_is_readinggroup = 'N'",
|
||||
array(':eid' => $event->eid));
|
||||
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||
|
||||
//for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||
foreach ($studygroups as $studygroup)
|
||||
{
|
||||
foreach ($studygroups as $studygroup) {
|
||||
//calculate the session references
|
||||
$sessionid = "session" . $studygroup->sid;
|
||||
$roleid = $sessionid . "_role";
|
||||
|
||||
//check that this study group session has been defined for this attendee
|
||||
if (!empty($node->$sessionid))
|
||||
{
|
||||
$rows[] = t($studygroup->booking_studygroup_descrip . ": Group " . $node->$sessionid . ", " . _booking_studygroup_role_lookup($node->$roleid));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($node->$sessionid)) {
|
||||
//$rows[] = t($studygroup->booking_studygroup_descrip . ": Group " . $node->$sessionid . ", " . _booking_studygroup_role_lookup($node->$roleid));
|
||||
|
||||
$tokens = array(
|
||||
'studygroup-descrip' => $studygroup->booking_studygroup_descrip,
|
||||
'studygroup-weekday' => $studygroup->booking_studygroup_weekday,
|
||||
'studygroup-explan' => $studygroup->booking_studygroup_explanation,
|
||||
'studygroup-role' => _booking_studygroup_role_lookup($node->$roleid),
|
||||
);
|
||||
|
||||
$list_element_text = variable_get('booking_studygroup_summary_li_text',
|
||||
'You are a <b>[meta-booking:studygroup-role]</b> for group <b>[meta-booking:studygroup-descrip]</b>, which will occur on [meta-booking:studygroup-weekday]. ' .
|
||||
'<br /><b>[meta-booking:studygroup-explan]</b>');
|
||||
// Make sure there is only HTML in the admin-entered text
|
||||
//$list_element_text = check_markup($list_element_text, 'full_html', '', FALSE);
|
||||
$rows[] = token_replace($list_element_text, $tokens);
|
||||
} // End checking for empty studygroup session
|
||||
} // End foreach loop
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
}
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
return implode("\n<br />", $rows);
|
||||
// Turn the rows into an unordered list
|
||||
$output = "\n<ul>\n";
|
||||
foreach ($rows as $row) {
|
||||
$output .= "\t<li>$row</li>\n";
|
||||
}
|
||||
$output .= "</ul>\n";
|
||||
return $output;
|
||||
}
|
||||
else {
|
||||
// Plain text so just separate by newline
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
@@ -1652,17 +1736,16 @@ function _booking_studygroup_email_summary($node) {
|
||||
function _booking_leader_helper_email_summary($node) {
|
||||
global $event;
|
||||
$rows = array();
|
||||
$tokens = array();
|
||||
$found = FALSE;
|
||||
|
||||
//display study session data if enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
//look up the titles of the study groups
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid AND booking_is_readinggroup = 'N'",
|
||||
array(':eid' => $event->eid));
|
||||
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||
|
||||
$rows[] = "<ul>";
|
||||
|
||||
foreach ($studygroups as $studygroup) {
|
||||
//don't print info about the readings groups
|
||||
if ($studygroup->booking_is_readinggroup == 'Y') {
|
||||
@@ -1678,7 +1761,7 @@ function _booking_leader_helper_email_summary($node) {
|
||||
|
||||
//check that this study group session has been defined for this attendee and that they have a role to perform
|
||||
if (!empty($node->$sessionid) && $node->$roleid > 0) {
|
||||
//if they're a leader or reserver leader, then the matching person is the helper
|
||||
//if they're a leader or reserve leader, then the matching person is the helper
|
||||
if ($node->$roleid == 1 || $node->$roleid == 3) {
|
||||
$role = "Leader";
|
||||
$otherrole = "Helper";
|
||||
@@ -1710,24 +1793,45 @@ function _booking_leader_helper_email_summary($node) {
|
||||
$otherperson_phone = $other->booking_mobile;
|
||||
}
|
||||
|
||||
$rows[] = t('<li>!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.</li>',
|
||||
array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
|
||||
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Generate tokens
|
||||
$tokens = array(
|
||||
'studygroup-descrip' => $studygroup->booking_studygroup_descrip,
|
||||
'studygroup-weekday' => $studygroup->booking_studygroup_weekday,
|
||||
'studygroup-explan' => $studygroup->booking_studygroup_explanation,
|
||||
'studygroup-role' => $role,
|
||||
'studygroup-otherrole' => $otherrole,
|
||||
'studygroup-othername' => $otherperson_name,
|
||||
'studygroup-otheremail' => $otherperson_email,
|
||||
'studygroup-otherphone' => $otherperson_phone,
|
||||
);
|
||||
|
||||
$rows[] = "</ul>";
|
||||
$list_element_text = variable_get('booking_studygroup_leaderhelperpair_text',
|
||||
'<b>[meta-booking:studygroup-role]</b> for <b>[meta-booking:studygroup-descrip]</b>. ' .
|
||||
'Your [meta-booking:studygroup-otherrole] is <b>[meta-booking:studygroup-othername]</b>. ' .
|
||||
'You can contact them on [meta-booking:studygroup-otherphone] or [meta-booking:studygroup-otheremail].'
|
||||
);
|
||||
// Make sure there is only HTML in the admin-entered text
|
||||
//$list_element_text = check_markup($list_element_text, 'full_html', '', FALSE);
|
||||
$rows[] = token_replace($list_element_text, $tokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//format the output to be used in an email
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
}
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
return implode("\n<br />", $rows);
|
||||
// Turn the rows into an unordered list
|
||||
$output = "\n<ul>\n";
|
||||
foreach ($rows as $row) {
|
||||
$output .= "\t<li>$row</li>\n";
|
||||
}
|
||||
$output .= "</ul>\n";
|
||||
return $output;
|
||||
}
|
||||
else {
|
||||
// Plain text so just separate by newline
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
|
@@ -5,23 +5,40 @@
|
||||
*/
|
||||
|
||||
|
||||
function booking_import_data_admin()
|
||||
function booking_import_data_admin($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
|
||||
$prefix = t("<p>Upload csv file containing data to import. Minimum fields present should be <strong>nid</strong>, " .
|
||||
" along with user-specified fields of <strong>!config</strong>. CSV Column names should match exactly (case sensitive).</p>",
|
||||
array('!config' => variable_get('booking_import_include_fields', '')));
|
||||
$prefix .= "<p>Note that only registration specific data like phone numbers, barcodes, etc can be updated, as well as study group membership and roles. Other data like room allocations cannot be uploaded at this time.</p>";
|
||||
|
||||
$form = array();
|
||||
|
||||
$prefix = t("<p>Upload csv file containing data to import. Minimum fields present should be <strong>nid</strong> or <strong>booking_tempid</strong>, " .
|
||||
" along with fields specified below. CSV Column names should match exactly (case sensitive).</p>");
|
||||
$prefix .= "<p>Note that only registration specific data like phone numbers, barcodes, etc can be updated. Other data like room allocations cannot be uploaded at this time.</p>";
|
||||
$prefix .= "<p>Also note that updating study group membership and roles requires nid to be present in the input file.</p>";
|
||||
|
||||
$form['file'] = array(
|
||||
'#type' => 'file',
|
||||
'#title' => t('CSV data'),
|
||||
'#description' => t('Upload CSV data to be processed'),
|
||||
);
|
||||
|
||||
// Get the database fields and sort them alphabetically to make it easier to find
|
||||
$booking_view_fields = _booking_get_person_fields();
|
||||
sort($booking_view_fields, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
//$nid_index = array_search("nid", $booking_view_fields);
|
||||
$select_array = array_combine($booking_view_fields, $booking_view_fields);
|
||||
|
||||
$form['booking_import_data_fields'] = array(
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#title' => t('Select database fields for this import'),
|
||||
'#description' => t('Select database fields to import from an uploaded CSV file. Ensure you hold down control/command when selecting multiple options. ' .
|
||||
'Fields are sorted alphabetically.'),
|
||||
'#options' => $select_array,
|
||||
'#size' => 10,
|
||||
'#default_value' => isset($form_state['input']['booking_import_data_fields']) ? $form_state['input']['booking_import_data_fields'] : 'nid',
|
||||
//'#default_value' => variable_get('booking_import_include_fields_dynamic', ''),
|
||||
);
|
||||
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
@@ -59,7 +76,7 @@ function booking_import_data_admin_validate($form, &$form_state) {
|
||||
function booking_import_data_admin_submit($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
$array = array();
|
||||
$csvdata = array();
|
||||
//$expected_fields = array('nid', 'booking_amount_paid', 'booking_total_pay_reqd', 'booking_status');
|
||||
$error = false;
|
||||
$update_counter = 0;
|
||||
@@ -69,8 +86,16 @@ function booking_import_data_admin_submit($form, &$form_state)
|
||||
$datetime_fields = array('booking_outflight_origin_ts', 'booking_outflight_destination_ts', 'booking_rtrnflight_origin_ts',
|
||||
'booking_rtrnflight_destination_ts','booking_dob', 'booking_passport_expiry_date');
|
||||
$builtin_fields_to_import = array('nid');
|
||||
$custom_fields_to_import = explode(";", variable_get('booking_import_include_fields', ''));
|
||||
$fields_to_import = array_merge($builtin_fields_to_import, $custom_fields_to_import);
|
||||
|
||||
// These are fields we can use to key the update
|
||||
$unique_fields = array('nid', 'booking_tempid');
|
||||
$update_key = "";
|
||||
|
||||
//$custom_fields_to_import = explode(";", variable_get('booking_import_include_fields', ''));
|
||||
$data = $form_state['input'];
|
||||
$import_fields = $data['booking_import_data_fields'];
|
||||
$fields_to_import = array_merge($builtin_fields_to_import, $import_fields);
|
||||
watchdog('booking_debug', "<pre>CSV import fields\n@info</pre>", array('@info' => print_r($fields_to_import, true)));
|
||||
|
||||
//get the file name from temporary storage field
|
||||
$file = $form_state['storage']['file'];
|
||||
@@ -92,7 +117,7 @@ function booking_import_data_admin_submit($form, &$form_state)
|
||||
$headerRecord = $rowData;
|
||||
} else {
|
||||
foreach( $rowData as $key => $value) {
|
||||
$array[$rowCounter - 1][ $headerRecord[$key] ] = $value;
|
||||
$csvdata[$rowCounter - 1][ $headerRecord[$key] ] = $value;
|
||||
}
|
||||
}
|
||||
$rowCounter++;
|
||||
@@ -105,11 +130,10 @@ function booking_import_data_admin_submit($form, &$form_state)
|
||||
return;
|
||||
}
|
||||
|
||||
//watchdog('booking', "<pre>Import data:\n@info</pre>", array('@info' => print_r( $array, true)));
|
||||
//watchdog('booking', "<pre>Import data:\n@info</pre>", array('@info' => print_r( $csvdata, true)));
|
||||
|
||||
//process the input data
|
||||
foreach ($array as $record)
|
||||
{
|
||||
foreach ($csvdata as $record) {
|
||||
$rows = 0;
|
||||
//watchdog('booking', "<pre>Processing row data:\n@info</pre>", array('@info' => print_r( $record, true)));
|
||||
$update_counter++;
|
||||
@@ -118,119 +142,78 @@ function booking_import_data_admin_submit($form, &$form_state)
|
||||
$studygroups_update_array = array();
|
||||
$studygroup_roles_update_array = array();
|
||||
|
||||
//do some error checking
|
||||
foreach($fields_to_import as $field)
|
||||
{
|
||||
/*
|
||||
if (! isset($record[$field]))
|
||||
watchdog('booking', 'Non-set field !field: !info', array ('!field' => $field, '!info' => var_export($record, TRUE)));
|
||||
if ($record[$field] == '')
|
||||
watchdog('booking', 'Blank field !field: !info', array ('!field' => $field, '!info' => var_export($record, TRUE)));
|
||||
*/
|
||||
// Check that there is a key we can use to perform the update
|
||||
foreach ($unique_fields as $key) {
|
||||
if (array_key_exists($key, $record)) {
|
||||
$update_key = $key;
|
||||
}
|
||||
}
|
||||
|
||||
// Check that we found a key, otherwise the update can't be processed
|
||||
if ($key === "") {
|
||||
drupal_set_message("Error: Unable to locate any unique identifier in input file for record number $update_counter.", 'error', FALSE);
|
||||
break;
|
||||
}
|
||||
|
||||
// Pre-process some data
|
||||
foreach($fields_to_import as $field) {
|
||||
//make sure to skip the nid field since we can't update that
|
||||
if ($field == 'nid')
|
||||
{
|
||||
//do nothing
|
||||
if (in_array($field, $unique_fields)) {
|
||||
//Don't add this identifier to the list of updates
|
||||
}
|
||||
//convert the booking status to the number used internally
|
||||
elseif ($field == 'booking_status')
|
||||
{
|
||||
elseif ($field == 'booking_status') {
|
||||
$update_text .= " set booking status to '" . $record[$field] . "'; ";
|
||||
$update_array[$field] = _booking_status_lookup($record[$field]);
|
||||
}
|
||||
//check for fields that need to be converted to a timestamp from text
|
||||
elseif (in_array($field, $datetime_fields))
|
||||
{
|
||||
elseif (in_array($field, $datetime_fields)) {
|
||||
$update_array[$field] = _datetime_to_ts_nonstrict($record[$field]);
|
||||
$update_text .= " set '" . $field . "' to '" . $update_array[$field] . "'; ";
|
||||
}
|
||||
elseif ( (! isset($record[$field])) || $record[$field] == '' )
|
||||
{
|
||||
elseif ( (! isset($record[$field])) || $record[$field] == '') {
|
||||
//drupal_set_message("Error: Unable to locate expected field '$field' in input file for record number $update_counter.", 'error', FALSE);
|
||||
//watchdog('booking', 'Processing user record: @info', array ('@info' => $record['nid']));
|
||||
//$error = true;
|
||||
//skip to the next record
|
||||
//continue 2;
|
||||
}
|
||||
elseif (preg_match('/session(\d{1,2})_role/i', $field, $matches))
|
||||
{
|
||||
elseif (preg_match('/session(\d{1,2})_role/i', $field, $matches)) {
|
||||
$session_id = $matches[1];
|
||||
//drupal_set_message(t('Setting session id !field role to value: !info', array ('!field' => $session_id, '!info' => var_export($record[$field], TRUE))));
|
||||
$studygroup_roles_update_array[$session_id] = $record[$field];
|
||||
}
|
||||
elseif (preg_match('/session(\d{1,2})$/i', $field, $matches))
|
||||
{
|
||||
elseif (preg_match('/session(\d{1,2})$/i', $field, $matches)) {
|
||||
$session_id = $matches[1];
|
||||
//drupal_set_message(t('Setting session id !field group to value: !info', array ('!field' => $session_id, '!info' => var_export($record[$field], TRUE))));
|
||||
$studygroups_update_array[$session_id] = $record[$field];
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$update_text .= " set '" . $field . "' to '" . $record[$field] . "'; ";
|
||||
$update_array[$field] = $record[$field];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($update_array) > 0)
|
||||
{
|
||||
// Perform the actual update
|
||||
if (count($update_array) > 0) {
|
||||
$query = db_update('booking_person')
|
||||
->fields($update_array)
|
||||
->condition('nid', $record['nid']);
|
||||
->condition($key, $record[$key]);
|
||||
|
||||
$rows = $query->execute();
|
||||
|
||||
$update_messages[] = t("Update Query:<br />@info<br />Condition: @nid<br />Rows affected: @rows<br />Values: <br /><pre>@values</pre>", array('@info' => (string) $query, '@nid' => $record['nid'], '@rows' => $rows, '@values' => print_r( $update_array, true) ));
|
||||
$update_messages[] = t("Update Query:<br />@info<br />Condition: @nid<br />Rows affected: @rows<br />Values: <br /><pre>@values</pre>",
|
||||
array('@info' => (string) $query, '@nid' => $record[$key], '@rows' => $rows, '@values' => print_r( $update_array, true) ));
|
||||
}
|
||||
|
||||
//handle study group processing
|
||||
//handle study group processing only if the node id was used as a key
|
||||
if (isset($record['nid'])) {
|
||||
$update_text .= _booking_import_studygroup_info($record['nid'], $studygroups_update_array, $studygroup_roles_update_array);
|
||||
|
||||
drupal_set_message(t("Updating record !nid as follows: !update", array('!nid' => $record['nid'], '!update' => $update_text)));
|
||||
|
||||
//$args = $query->getArguments();
|
||||
/*
|
||||
watchdog('booking', "Update Query:<br />@info<br />Condition: @nid<br />Rows affected: @rows<br />Values: <br /><pre>@values</pre>",
|
||||
array('@info' => (string) $query, '@nid' => $record['nid'], '@rows' => $rows, '@values' => print_r( $update_array, true) ));
|
||||
*/
|
||||
|
||||
/*
|
||||
$result_array[] = t('Setting payment for id !nid to $!price of total required $!total and status to !status',
|
||||
array('!nid' => $record['nid'],
|
||||
'!price' => $record['booking_amount_paid'],
|
||||
'!total' => $record['booking_total_pay_reqd'],
|
||||
'!status' => _booking_status_lookup($record['booking_status'])
|
||||
)
|
||||
);
|
||||
*/
|
||||
/*
|
||||
//TODO: output this from $result_array
|
||||
drupal_set_message(t('Setting payment for id !nid to $!price of total required $!total and status to !status',
|
||||
array('!nid' => $record['nid'],
|
||||
'!price' => $record['booking_amount_paid'],
|
||||
'!total' => $record['booking_total_pay_reqd'],
|
||||
'!status' => _booking_status_lookup($record['booking_status']))
|
||||
));
|
||||
*/
|
||||
|
||||
// watchdog('booking', 'Setting payment for regn id !nid to $!price and status to !status',
|
||||
// array('!nid' => $record['nid'], '!price' => $record['booking_amount_paid'], '!status' => _booking_status_lookup($record['booking_status'])));
|
||||
|
||||
/*
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_amount_paid' => $record['booking_amount_paid'],
|
||||
'booking_total_pay_reqd' => $record['booking_total_pay_reqd'],
|
||||
'booking_status' => _booking_status_lookup($record['booking_status']),
|
||||
))
|
||||
->condition('nid', $record['nid'])
|
||||
->execute();
|
||||
*/
|
||||
|
||||
}
|
||||
drupal_set_message(t("Updating record !nid as follows: !update", array('!nid' => $record[$key], '!update' => $update_text)));
|
||||
} //end processing input data
|
||||
|
||||
//output our results to watchdog
|
||||
//watchdog('booking', '<pre>@print_r</pre>', array('@print_r', print_r( $result_array, TRUE)));
|
||||
watchdog('booking', "<pre>Processing row data:\n@info</pre>", array('@info' => print_r($update_array, true)));
|
||||
|
||||
//delete the uploaded file
|
||||
file_delete($file);
|
||||
|
@@ -4,6 +4,7 @@ package = Booking System
|
||||
dependencies[] = date
|
||||
dependencies[] = token
|
||||
dependencies[] = libraries
|
||||
version = 0.2
|
||||
dependencies[] = mimemail
|
||||
version = 0.3
|
||||
configure = admin/config/booking/general
|
||||
core = 7.x
|
@@ -800,6 +800,38 @@ function booking_update_7255() {
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add fields for study group definitions
|
||||
*/
|
||||
function booking_update_7256() {
|
||||
$spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE);
|
||||
db_add_field('booking_studygroup_list', 'booking_studygroup_weekday', $spec);
|
||||
db_add_field('booking_studygroup_list', 'booking_studygroup_explanation', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add field to store URL to QR code
|
||||
*/
|
||||
function booking_update_7257() {
|
||||
$spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_qrcode_url', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add field to store number of previous study weeks
|
||||
*/
|
||||
function booking_update_7258() {
|
||||
$spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_prev_sw_count', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
@@ -846,7 +878,10 @@ function booking_uninstall() {
|
||||
function booking_enable() {
|
||||
drupal_set_message($message = t('The Booking System module was successfully enabled.'), $type = 'status');
|
||||
$current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
|
||||
$addition = array('booking' => 'BookingMailSystem');
|
||||
//$addition = array('booking' => 'BookingMailSystem');
|
||||
// Use MimeMail module instead of our own version
|
||||
$addition = array('booking' => 'MimeMailSystem');
|
||||
|
||||
variable_set('mail_system', array_merge($current, $addition));
|
||||
}
|
||||
|
||||
@@ -885,6 +920,7 @@ function booking_schema() {
|
||||
'booking_committee_member' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_welfare_required' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_barcode' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE),
|
||||
'booking_qrcode_url' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_luckynum' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_readinggroup' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_shirt_size' => array('type' => 'varchar', 'length' => '20', 'not null' => FALSE),
|
||||
@@ -959,6 +995,9 @@ function booking_schema() {
|
||||
'booking_firstaid' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_nurse' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_doctor' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_song_choice' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_freestyle_text' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
|
||||
'booking_prev_sw_count' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
/*
|
||||
),
|
||||
'foreign keys' => array(
|
||||
@@ -1125,6 +1164,8 @@ function booking_schema() {
|
||||
'sid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_studygroup_descrip' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_studygroup_weekday' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_studygroup_explanation' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_num_group_sessions' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 1),
|
||||
'booking_is_readinggroup' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
),
|
||||
|
@@ -77,6 +77,14 @@
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_navigation_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_navigation_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_header_text_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Navigation links area Text Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_header_text_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_header_text_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_text_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Text Colour'),
|
||||
@@ -190,7 +198,7 @@ function booking_mailtemplate_form_submit($form, &$form_state)
|
||||
$values = $form_state['input'];
|
||||
$colors_variable_list = array('booking_mailtemplate_background_color', 'booking_mailtemplate_content_background_color',
|
||||
'booking_mailtemplate_navigation_background_color', 'booking_mailtemplate_subjectheading_text_color',
|
||||
'booking_mailtemplate_header_background_color', 'booking_mailtemplate_text_color',
|
||||
'booking_mailtemplate_header_background_color', 'booking_mailtemplate_header_text_color', 'booking_mailtemplate_text_color',
|
||||
'booking_mailtemplate_header_image_url', 'booking_mailtemplate_header_link_url',
|
||||
);
|
||||
//'booking_mailtemplate_link_color',
|
||||
|
@@ -18,6 +18,7 @@ function booking_manual_payment_admin($nid)
|
||||
|
||||
$payment_balance_options[0] = t('Total Payment (sets total amount paid to this value)');
|
||||
$payment_balance_options[1] = t('Balance Payment (adds this value to the total amount paid)');
|
||||
$payment_balance_options[2] = t('Manual Refund (subtracts this value from the total amount paid)');
|
||||
|
||||
//collect the various payment options
|
||||
$result = db_query("SELECT pid, booking_price_descrip, booking_price, booking_late_price FROM {booking_price} where booking_eventid = :eid " .
|
||||
@@ -163,16 +164,26 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
$person = node_load($key);
|
||||
|
||||
if ($person) {
|
||||
// Check whether this is a balance or total payment
|
||||
$payment_type = $form_state['values']['payment-balance-type'];
|
||||
|
||||
//check whether this is a balance or total payment
|
||||
$is_balance = $form_state['values']['payment-balance-type'];
|
||||
|
||||
//balance payment
|
||||
if ($is_balance == 1) {
|
||||
// Refund
|
||||
if ($payment_type == 2)
|
||||
{
|
||||
//subtract this payment to their existing balance
|
||||
$total_paid = $person->booking_amount_paid - $price;
|
||||
$invoice_type = "Refund";
|
||||
}
|
||||
// Balance payment
|
||||
elseif ($payment_type == 1)
|
||||
{
|
||||
//add this payment to their existing balance
|
||||
$total_paid = $person->booking_amount_paid + $price;
|
||||
//total payment
|
||||
} elseif ($is_balance == 0) {
|
||||
$invoice_type = "ManualPayment";
|
||||
}
|
||||
// Total payment
|
||||
elseif ($payment_type == 0)
|
||||
{
|
||||
//set this as the persons new balance
|
||||
$total_paid = $price;
|
||||
//change $price so that we add the correct dollar amount in the payment record
|
||||
@@ -181,6 +192,7 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
$newprice = $price - _booking_amount_paid($key, $person);
|
||||
watchdog('booking', 'Changing price for payment record from $!price to !newprice.', array('!price' => $price, '!newprice' => $newprice));
|
||||
$price = $newprice;
|
||||
$invoice_type = "ManualPayment";
|
||||
}
|
||||
|
||||
//check if they have now fully paid
|
||||
@@ -226,7 +238,7 @@ function booking_manual_payment_admin_submit($form, &$form_state) {
|
||||
'booking_mc_currency' => 'AUD',
|
||||
'booking_mc_fee' => '0.00',
|
||||
'booking_quantity' => 1,
|
||||
'booking_invoice' => 'ManualPayment',
|
||||
'booking_invoice' => $invoice_type,
|
||||
'booking_payer_id' => '',
|
||||
'booking_payment_date' => $payment_date,
|
||||
'booking_payment_status' => '',
|
||||
|
@@ -41,7 +41,7 @@ module_load_include('inc', 'booking', 'booking.admin');
|
||||
// Load the include for admin pages relating to events
|
||||
module_load_include('inc', 'booking', 'booking.events');
|
||||
// Load the include for admin pages relating to event pricing
|
||||
module_load_include('inc', 'booking', 'booking.prices');
|
||||
//module_load_include('inc', 'booking', 'booking.prices');
|
||||
// Load the include for admin pages relating to manual processing of payments
|
||||
module_load_include('inc', 'booking', 'booking.manual_payment');
|
||||
// Load the include for helper functions
|
||||
@@ -51,6 +51,7 @@ module_load_include('inc', 'booking', 'booking.paypal');
|
||||
// Load the include for email functions
|
||||
module_load_include('inc', 'booking', 'booking.emails');
|
||||
module_load_include('inc', 'booking', 'booking.emails_admin');
|
||||
module_load_include('inc', 'booking', 'booking.email_manually');
|
||||
// Load the include for bulk data import
|
||||
module_load_include('inc', 'booking', 'booking.import_data');
|
||||
// Load the include for variety session configuration
|
||||
@@ -75,7 +76,7 @@ module_load_include('inc', 'booking', 'booking.stripe');
|
||||
// Load the include for miscellaneous functions
|
||||
module_load_include('inc', 'booking', 'booking.misc');
|
||||
// Load the include for the extended mail system
|
||||
module_load_include('inc', 'booking', 'booking.MailSystemInterface');
|
||||
//module_load_include('inc', 'booking', 'booking.MailSystemInterface');
|
||||
|
||||
function booking_init() {
|
||||
date_default_timezone_set(date_default_timezone(FALSE));
|
||||
@@ -133,14 +134,17 @@ function booking_permission() {
|
||||
'edit room allocations' => array(
|
||||
'title' => t('Edit Room Allocations'),
|
||||
),
|
||||
'access variety session form' => array(
|
||||
'title' => t('Access the Variety Session registration form'),
|
||||
),
|
||||
'view variety sessions' => array(
|
||||
'title' => t('View Variety Sessions'),
|
||||
),
|
||||
'edit variety sessions' => array(
|
||||
'title' => t('Edit Variety Sessions'),
|
||||
),
|
||||
'create_travel_forms' => array(
|
||||
'title' => t('Create a new travel form entry'),
|
||||
'create travel entry' => array(
|
||||
'title' => t('Create a travel entry'),
|
||||
),
|
||||
'view_travel_forms' => array(
|
||||
'title' => t('View all travel forms'),
|
||||
@@ -203,6 +207,17 @@ function booking_menu() {
|
||||
'weight' => -98,
|
||||
//'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/emails/definitions'] = array(
|
||||
'title' => 'Booking module custom email definitions',
|
||||
'description' => 'Configure custom emails used by the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_emails_custom_ajax_form'),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'file' => 'booking.emails_admin.inc',
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
/*
|
||||
$items['admin/config/booking/emails/custom'] = array(
|
||||
'title' => 'Booking module custom email definitions',
|
||||
'description' => 'Configure custom emails used by the Booking module',
|
||||
@@ -221,6 +236,7 @@ function booking_menu() {
|
||||
'file' => 'booking.emails_admin.inc',
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
*/
|
||||
$items['admin/config/booking/events'] = array(
|
||||
'title' => 'Booking module event settings',
|
||||
'description' => 'Configure events for the Booking module',
|
||||
@@ -228,6 +244,7 @@ function booking_menu() {
|
||||
'page arguments' => array('booking_event_admin'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'weight' => -97,
|
||||
'file' => 'booking.events.inc',
|
||||
//'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
$items['admin/config/booking/prices'] = array(
|
||||
@@ -237,6 +254,7 @@ function booking_menu() {
|
||||
'page arguments' => array('booking_price_admin'),
|
||||
'access arguments' => array('administer site configuration'),
|
||||
'weight' => -96,
|
||||
'file' => 'booking.prices.inc',
|
||||
//'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
@@ -291,8 +309,9 @@ function booking_menu() {
|
||||
'title' => 'Travel Details Page',
|
||||
'page callback' => 'booking_travel_page',
|
||||
'page arguments' => array(3), //include the temporary id
|
||||
'access arguments' => array('access booking form'),
|
||||
'access arguments' => array('create travel entry'),
|
||||
'type' => MENU_SUGGESTED_ITEM,
|
||||
'file' => 'booking.travel.inc',
|
||||
);
|
||||
|
||||
$items['coming'] = array(
|
||||
@@ -302,6 +321,14 @@ function booking_menu() {
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
//callback for autocomplete lookup of ecclesia name
|
||||
$items['booking/ecclesia/autocomplete'] = array(
|
||||
'title' => 'Autocomplete for ecclesia lookup on registration page',
|
||||
'page callback' => '_booking_ecclesia_name_autocomplete',
|
||||
'access arguments' => array('access booking form'),
|
||||
'type' => MENU_CALLBACK
|
||||
);
|
||||
|
||||
$items['waitinglist'] = array(
|
||||
'title' => "Who's on the waiting list?",
|
||||
'page callback' => 'booking_waitinglist_page',
|
||||
@@ -388,20 +415,20 @@ function booking_menu() {
|
||||
'title' => $bookingTitle . ' Variety Sessions',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_regn_form'),
|
||||
'access arguments' => array('access booking form'),
|
||||
'access arguments' => array('access variety session form'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety'] = array(
|
||||
'title' => 'Booking module variety sessions',
|
||||
'description' => 'Configure variety sessions for the Booking module',
|
||||
$items['admin/booking/variety'] = array(
|
||||
'title' => 'View Variety Sessions',
|
||||
'description' => 'View variety sessions for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_admin'),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/create'] = array(
|
||||
$items['admin/booking/variety/create'] = array(
|
||||
'title' => 'Add New Variety Session Timeslot',
|
||||
'description' => 'Add variety session timeslot for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
@@ -411,7 +438,7 @@ function booking_menu() {
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/report'] = array(
|
||||
$items['admin/booking/variety/report'] = array(
|
||||
'title' => 'View Variety Session Registrations',
|
||||
'description' => 'View Variety Session Registrations for the Booking module',
|
||||
'page callback' => 'booking_variety_sessions_view_summary',
|
||||
@@ -419,54 +446,54 @@ function booking_menu() {
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/%/edit'] = array(
|
||||
$items['admin/booking/variety/%/edit'] = array(
|
||||
'title' => 'Edit Variety Session Timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_timeslot_form', false, 4),
|
||||
'page arguments' => array('booking_variety_timeslot_form', false, 3),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/%/csv'] = array(
|
||||
$items['admin/booking/variety/%/csv'] = array(
|
||||
'title' => 'Variety Session CSV',
|
||||
'description' => 'CSV Report of Variety Session Timeslot',
|
||||
'page callback' => 'booking_varietysessions_csv_report',
|
||||
'access arguments' => array('view variety sessions'),
|
||||
'page arguments' => array(4),
|
||||
'page arguments' => array(3),
|
||||
//'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/%/session/list'] = array(
|
||||
$items['admin/booking/variety/%/session/list'] = array(
|
||||
'title' => 'List Variety Sessions',
|
||||
'description' => 'List variety sessions for the specified timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_list_session_form', 4),
|
||||
'page arguments' => array('booking_variety_list_session_form', 3),
|
||||
'access arguments' => array('view variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/%/session/create'] = array(
|
||||
$items['admin/booking/variety/%/session/create'] = array(
|
||||
'title' => 'Add New Variety Session',
|
||||
'description' => 'Add variety session to the specified timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_create_session_form', TRUE, 4),
|
||||
'page arguments' => array('booking_variety_create_session_form', TRUE, 3),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/%/session/%/edit'] = array(
|
||||
$items['admin/booking/variety/%/session/%/edit'] = array(
|
||||
'title' => 'Edit Variety Session',
|
||||
'description' => 'Edit variety session for the specified timeslot',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_create_session_form', FALSE, 4, 6),
|
||||
'page arguments' => array('booking_variety_create_session_form', FALSE, 3, 5),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
|
||||
$items['admin/config/booking/variety/registration/%/edit'] = array(
|
||||
$items['admin/booking/variety/registration/%/edit'] = array(
|
||||
'title' => 'Edit Variety Session Registration',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_variety_regn_edit_form', 5),
|
||||
'page arguments' => array('booking_variety_regn_edit_form', 4),
|
||||
'access arguments' => array('edit variety sessions'),
|
||||
'type' => MENU_CALLBACK,
|
||||
);
|
||||
@@ -667,8 +694,8 @@ function booking_menu() {
|
||||
);
|
||||
|
||||
$items['admin/booking/rooms/report'] = array(
|
||||
'title' => 'View All Room Allocations',
|
||||
'description' => 'View All Room Allocations',
|
||||
'title' => 'View Room Mate Preferences and Room Allocations',
|
||||
'description' => 'View Room Mate Preferences and Room Allocations',
|
||||
'page callback' => 'booking_roomallocations_view_summary',
|
||||
'access arguments' => array("view room allocations"),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
@@ -728,6 +755,7 @@ function booking_menu() {
|
||||
'page arguments' => array('booking_price_form', true),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
'file' => 'booking.prices.inc',
|
||||
);
|
||||
|
||||
$items['admin/config/booking/prices/%/edit'] = array(
|
||||
@@ -736,6 +764,7 @@ function booking_menu() {
|
||||
'page arguments' => array('booking_price_form', false, 4),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'booking.prices.inc',
|
||||
);
|
||||
|
||||
//Configure events
|
||||
@@ -746,6 +775,7 @@ function booking_menu() {
|
||||
'page arguments' => array('booking_event_form', true),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'type' => MENU_LOCAL_ACTION,
|
||||
'file' => 'booking.events.inc',
|
||||
);
|
||||
|
||||
$items['admin/config/booking/events/%/edit'] = array(
|
||||
@@ -756,6 +786,7 @@ function booking_menu() {
|
||||
'page arguments' => array('booking_event_form', false, 4),
|
||||
'access arguments' => array('access administration pages'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'booking.events.inc',
|
||||
);
|
||||
|
||||
//manage early access codes
|
||||
@@ -788,7 +819,7 @@ function booking_menu() {
|
||||
if (variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$items['admin/config/booking/mailtemplate'] = array(
|
||||
'title' => 'Booking module HTML email',
|
||||
'description' => 'Configure the look of HTMl emails for the Booking module',
|
||||
'description' => 'Configure the look of HTML emails for the Booking module',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('booking_mailtemplate_form'),
|
||||
'access arguments' => array('access administration pages'),
|
||||
@@ -959,6 +990,12 @@ function booking_mail($key, &$message, $params) {
|
||||
$message['headers'] += $params['headers'];
|
||||
}
|
||||
|
||||
// Add attachment when available.
|
||||
// From https://drupal.stackexchange.com/questions/101035/send-attachments-with-drupal-mail
|
||||
if (isset($params['attachment'])) {
|
||||
$message['params']['attachments'] = $params['attachment'];
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', "<pre>Mail hook:\n@info</pre>", array('@info' => print_r( $message, true)));
|
||||
}
|
||||
|
||||
|
@@ -63,6 +63,39 @@ function booking_register_page()
|
||||
return $return_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* autocomplete helper to look up ecclesia names
|
||||
* based on https://www.drupal.org/node/854216
|
||||
* $string = string for search
|
||||
*/
|
||||
function _booking_ecclesia_name_autocomplete($string = "") {
|
||||
$matches = array();
|
||||
|
||||
if ($string === "") {
|
||||
// Return empty result to the form in json
|
||||
drupal_json_output($matches);
|
||||
return;
|
||||
}
|
||||
|
||||
$sanitised_string = preg_replace("/[^a-zA-Z0-9\s\.']/", '', $string);
|
||||
$sanitised_string .= "%";
|
||||
//watchdog('booking_debug', "<pre>Autocomplete checking for ecclesia matching:\n@info</pre>", array('@info' => print_r($sanitised_string, true)));
|
||||
|
||||
$query = db_select('booking_person', 'p')
|
||||
->distinct('p.booking_ecclesia')
|
||||
->fields('p', array('booking_ecclesia'))
|
||||
->condition('p.booking_ecclesia', $sanitised_string, 'LIKE');
|
||||
$result = $query->execute();
|
||||
|
||||
// save the query to matches
|
||||
foreach ($result as $row) {
|
||||
$matches[$row->booking_ecclesia] = $row->booking_ecclesia;
|
||||
}
|
||||
|
||||
// Return the result to the form in json
|
||||
drupal_json_output($matches);
|
||||
}
|
||||
|
||||
function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
{
|
||||
global $event;
|
||||
@@ -290,13 +323,26 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
);
|
||||
} //end enable tshirts check
|
||||
|
||||
if ($inserting == FALSE) {
|
||||
$form['your-details']['booking_ecclesia'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Ecclesia'),
|
||||
'#maxlength' => 100,
|
||||
'#autocomplete_path' => 'booking/ecclesia/autocomplete',
|
||||
//'#value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : '',
|
||||
'#default_value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : '',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['your-details']['booking_ecclesia'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Ecclesia'),
|
||||
'#maxlength' => 100,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : ''
|
||||
'#default_value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : '',
|
||||
);
|
||||
}
|
||||
|
||||
$form['your-details']['booking_baptised'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('I am baptised'),
|
||||
@@ -451,6 +497,15 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
'#default_value' => !empty($data->booking_barcode) ? $data->booking_barcode : ''
|
||||
);
|
||||
|
||||
$form['internal-details']['booking_qrcode_url'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('QR Code URL'),
|
||||
'#maxlength' => 500,
|
||||
'#size' => 100,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_qrcode_url) ? $data->booking_qrcode_url : ''
|
||||
);
|
||||
|
||||
$form['internal-details']['booking_luckynum'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Lucky Number'),
|
||||
@@ -476,6 +531,9 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
$form['contact-details']['booking_email'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('E-mail address'),
|
||||
'#description' => t('Please note that we will use this email address to contact you with important information about !event.', array(
|
||||
'!event' => $event->booking_eventname
|
||||
)),
|
||||
'#maxlength' => 100,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_email) ? $data->booking_email : ''
|
||||
@@ -586,6 +644,7 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
$form['emergency']['booking_medicare'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Your Medicare Number'),
|
||||
'#description' => t('Enter only the numbers at the top of the card (leave out the Individual Reference Number next to your name). Australian attendees must complete this field.'),
|
||||
'#maxlength' => 15,
|
||||
'#size' => 15,
|
||||
'#required' => FALSE,
|
||||
@@ -929,23 +988,35 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
);
|
||||
*/
|
||||
if (variable_get('booking_enable_songchoice', 0) == 1) {
|
||||
$songchoice_required_check = (variable_get('booking_require_songchoice', 1) == 1) && $inserting;
|
||||
$form['misc-areas']['booking_song_choice'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t("Let us know if there's a song you'd love to sing during the week"),
|
||||
'#maxlength' => 200,
|
||||
'#required' => TRUE,
|
||||
'#required' => $songchoice_required_check,
|
||||
'#default_value' => !empty($data->booking_song_choice) ? $data->booking_song_choice : ''
|
||||
);
|
||||
}
|
||||
if (variable_get('booking_enable_freestyle', 0) == 1) {
|
||||
$freestyle_required_check = (variable_get('booking_require_freestyle', 1) == 1) && $inserting;
|
||||
$form['misc-areas']['booking_freestyle_text'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t("Freestyle (optional)"),
|
||||
'#title' => t("Freestyle text (anything you'd like to share)"),
|
||||
'#maxlength' => 500,
|
||||
'#required' => FALSE,
|
||||
'#required' => $freestyle_required_check,
|
||||
'#default_value' => !empty($data->booking_freestyle_text) ? $data->booking_freestyle_text : ''
|
||||
);
|
||||
}
|
||||
if (variable_get('booking_enable_previous_studyweeks', 0) == 1) {
|
||||
$prev_sw_required_check = (variable_get('booking_require_previous_sw', 1) == 1) && $inserting;
|
||||
$form['misc-areas']['booking_prev_sw_count'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t("How many Study Weeks have you been to previously?"),
|
||||
'#required' => $prev_sw_required_check,
|
||||
'#default_value' => variable_get('booking_prev_sw_count', empty($data->booking_prev_sw_count) ? '' : $data->booking_prev_sw_count),
|
||||
'#options' => _get_previous_sw_options(),
|
||||
);
|
||||
}
|
||||
|
||||
// https://www.lullabot.com/articles/a-beginners-guide-to-caching-data-in-drupal-7
|
||||
// This code will only cache this one element
|
||||
@@ -1028,7 +1099,7 @@ function booking_form_validate($form, &$form_state) {
|
||||
global $event;
|
||||
$node = $form_state['values']['form_id'];
|
||||
$data = $form_state['input'];
|
||||
//watchdog('booking', '<pre>Booking registration form validation:\n@info</pre>', array('@info' => print_r( $data, true)));
|
||||
//watchdog('booking_debug', '<pre>Booking registration form validation:\n@info</pre>', array('@info' => print_r( $data, true)));
|
||||
|
||||
//if necessary, validate early access code
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1 && (isset($data['booking_earlyaccess']) && $data['booking_earlyaccess'] == 1)) {
|
||||
@@ -1053,9 +1124,9 @@ function booking_form_validate($form, &$form_state) {
|
||||
}
|
||||
|
||||
//in case the date of birth field hasn't been filled out
|
||||
watchdog('booking', 'Blank date of birth checking: @info', array(
|
||||
'@info' => var_export($data['booking_dob'], TRUE)
|
||||
));
|
||||
//watchdog('booking_debug', 'Blank date of birth checking: @info', array(
|
||||
// '@info' => var_export($data['booking_dob'], TRUE)
|
||||
//));
|
||||
$dob_check = $data['booking_dob']['day'] != '' && $data['booking_dob']['month'] != '' && $data['booking_dob']['year'] != '' ? _datearray_to_ts($data['booking_dob']) : 0;
|
||||
|
||||
//Verify this is not a duplicate registration
|
||||
@@ -1198,7 +1269,7 @@ function booking_form_validate($form, &$form_state) {
|
||||
//validate guardian phone number
|
||||
if ($data['booking_country'] == 'Australia') {
|
||||
if (!_valid_australian_mobile_number($data['booking_guardian_phone'])) {
|
||||
form_set_error('booking_guardian_phone', t('You have entered an invalid contact phone number for your emergency contact.'));
|
||||
form_set_error('booking_guardian_phone', t('You have entered an invalid contact phone number for your emergency contact. Please enter a mobile phone number.'));
|
||||
}
|
||||
} else {
|
||||
if (!_valid_phone_number($data['booking_guardian_phone'])) {
|
||||
@@ -1207,12 +1278,18 @@ function booking_form_validate($form, &$form_state) {
|
||||
}
|
||||
|
||||
//verify alternate guardian phone number
|
||||
if (($data['booking_guardian_phone_alt'] != '') && (!_valid_phone_number($data['booking_guardian_phone_alt'])))
|
||||
if (($data['booking_guardian_phone_alt'] != '') && (!_valid_phone_number($data['booking_guardian_phone_alt']))) {
|
||||
form_set_error('booking_guardian_phone_alt', t('You have entered an invalid alternate contact phone number for your emergency contact.'));
|
||||
}
|
||||
|
||||
//check the terms and conditions have been agreed to. Do this one last so it stands out more
|
||||
if ($data['booking_agreement'] == 0)
|
||||
if ($data['booking_agreement'] == 0) {
|
||||
form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.'));
|
||||
}
|
||||
|
||||
if (variable_get('booking_require_previous_sw', 0) == 1 && $data['booking_prev_sw_count'] == '') {
|
||||
form_set_error('booking_prev_sw_count', t('You must select the number of study weeks that you\'ve previously attended.'));
|
||||
}
|
||||
|
||||
//if there are any errors then log the data the user entered so we can check it later
|
||||
if (form_get_errors()) {
|
||||
@@ -1318,6 +1395,7 @@ function booking_form_submit($form, &$form_state)
|
||||
|
||||
//fields that may or may not have been present in the initial form
|
||||
$node->booking_barcode = empty($values['booking_barcode']) ? '' : $values['booking_barcode'];
|
||||
$node->booking_qrcode_url = empty($values['booking_qrcode_url']) ? '' : $values['booking_qrcode_url'];
|
||||
$node->booking_luckynum = empty($values['booking_luckynum']) ? 0 : $values['booking_luckynum'];
|
||||
$node->booking_random_facts = empty($values['booking_random_facts']) ? '' : $values['booking_random_facts'];
|
||||
$node->booking_welfare_required = empty($values['booking_welfare_required']) ? 'N' : ($values['booking_welfare_required'] == 1 ? 'Y' : 'N');
|
||||
@@ -1350,6 +1428,7 @@ function booking_form_submit($form, &$form_state)
|
||||
$node->booking_earlyaccess_code_id = empty($values['booking_earlyaccess_code']) ? 0 : $earlyaccess_query->cid;
|
||||
$node->booking_song_choice = empty($values['booking_song_choice']) ? '' : $values['booking_song_choice'];
|
||||
$node->booking_freestyle_text = empty($values['booking_freestyle_text']) ? '' : $values['booking_freestyle_text'];
|
||||
$node->booking_prev_sw_count = empty($values['booking_prev_sw_count']) ? '0' : $values['booking_prev_sw_count'];
|
||||
|
||||
//remove newlines from these fields so the CSV output doesn't get messed up
|
||||
$medical = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions'];
|
||||
@@ -1374,11 +1453,11 @@ function booking_form_submit($form, &$form_state)
|
||||
$node->booking_amount_paid = 0;
|
||||
$node->booking_total_pay_reqd = $payment_total_price->booking_price;
|
||||
|
||||
//watchdog('booking', 'Node data: @info', array('@info' => var_export($node, TRUE)));
|
||||
//watchdog('booking_debug', 'Node data: @info', array('@info' => var_export($node, TRUE)));
|
||||
$foo = node_submit($node);
|
||||
//watchdog('booking', 'Node data after submit: @info', array('@info' => var_export($foo, TRUE)));
|
||||
//watchdog('booking_debug', 'Node data after submit: @info', array('@info' => var_export($foo, TRUE)));
|
||||
$blah = node_save($foo);
|
||||
//watchdog('booking', 'Node data after save: @info', array('@info' => var_export($blah, TRUE)));
|
||||
//watchdog('booking_debug', 'Node data after save: @info', array('@info' => var_export($blah, TRUE)));
|
||||
|
||||
//post submission triggers
|
||||
_booking_form_submit_post_triggers($node);
|
||||
|
@@ -412,14 +412,15 @@ function booking_update($node) {
|
||||
'booking_welfare_required', 'booking_payment_complete', 'booking_refund_processed', 'booking_committee_member'
|
||||
);
|
||||
//these fields should be zero if not defined
|
||||
$default_zero_keys = array('booking_luckynum', 'booking_bf_gf_nid', 'booking_keepseparate_id', 'booking_refund_due', 'booking_earlyaccess_code_id');
|
||||
$default_zero_keys = array('booking_luckynum', 'booking_bf_gf_nid', 'booking_keepseparate_id', 'booking_refund_due', 'booking_earlyaccess_code_id',
|
||||
'booking_prev_sw_count');
|
||||
|
||||
//some fields are present in $node from the SQL view we use that don't belong in booking_person so exclude them
|
||||
$excluded_keys = array('booking_person_nid', 'booking_transport_type', 'booking_transport_from_morriset_reqd', 'booking_transport_to_morriset_reqd',
|
||||
'booking_flightnum_inbound', 'booking_flight_datetime_inbound', 'booking_flightnum_outbound', 'booking_flight_datetime_outbound', 'booking_accom_before_reqd',
|
||||
'booking_accom_before_staying_with', 'booking_accom_after_reqd', 'booking_accom_after_staying_with', 'booking_roomlocation_descrip',
|
||||
'booking_roomlocation_active', 'booking_price', 'booking_price_descrip', 'booking_late_price', 'booking_earlyaccess_code',
|
||||
'booking_room_bedtype', 'booking_room_location_id', 'booking_room_number', 'booking_agreement', 'booking_deposit_timestamp'
|
||||
'booking_room_bedtype', 'booking_room_location_id', 'booking_room_number', 'booking_agreement', 'booking_deposit_timestamp', 'booking_variety_ids'
|
||||
);
|
||||
|
||||
//before we update this user, check what their previous registration status was
|
||||
@@ -466,7 +467,8 @@ function booking_update($node) {
|
||||
$data['booking_firstname'] = _booking_ucname($data['booking_firstname']);
|
||||
$data['booking_lastname'] = _booking_ucname($data['booking_lastname']);
|
||||
|
||||
watchdog('booking', 'Updating node: @info', array('@info' => var_export($data, TRUE)));
|
||||
//watchdog('booking_debug', "<pre>Old node:\n@info</pre>", array('@info' => var_export($node, TRUE)));
|
||||
watchdog('booking_debug', "<pre>Updating node:\n@info</pre>", array('@info' => var_export($data, TRUE)));
|
||||
db_update('booking_person')->fields($data)->condition('nid', $node->nid)->execute();
|
||||
/*
|
||||
//watchdog('booking', 'Updating node: @info', array('@info' => var_export($node, TRUE)));
|
||||
@@ -823,6 +825,8 @@ function booking_view($node, $view_mode) {
|
||||
$rows = array();
|
||||
$travel_rows = array();
|
||||
|
||||
//watchdog('booking_debug', 'booking view node: <pre>@info</pre>', array('@info' => print_r( $node, true)));
|
||||
|
||||
//calculate the price owed by this person
|
||||
//if (_booking_is_earlybird() == true || _booking_amount_owing($node->nid) == 0)
|
||||
if (_booking_is_earlybird() == true || _booking_amount_owing($node) == 0 || $node->booking_committee_member == 'Y' || $node->booking_welfare_required == 'Y') {
|
||||
@@ -873,6 +877,7 @@ function booking_view($node, $view_mode) {
|
||||
$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('Barcode:'), t('!id', array('!id' => $node->booking_barcode)));
|
||||
$rows[] = array(t('QR Code:'), t('!id', array('!id' => $node->booking_qrcode_url)));
|
||||
$rows[] = array(t('Lanyard lucky number:'), $node->booking_luckynum);
|
||||
$rows[] = array(t('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
|
||||
$rows[] = array(t('Date of birth:'), t('!dob', array('!dob' => format_date($node->booking_dob, 'custom', 'd/m/Y'))));
|
||||
@@ -890,6 +895,9 @@ function booking_view($node, $view_mode) {
|
||||
if (variable_get('booking_enable_freestyle', 0) == 1) {
|
||||
$rows[] = array(t('Freestyle:'), t('!song', array('!song' => $node->booking_freestyle_text)));
|
||||
}
|
||||
if (variable_get('booking_enable_previous_studyweeks', 0) == 1) {
|
||||
$rows[] = array(t('Number of previous SW:'), t('!sw', array('!sw' => $node->booking_prev_sw_count)));
|
||||
}
|
||||
if (variable_get('booking_enable_tshirts', 0) == 1) {
|
||||
$rows[] = array(t('Hoodie Size:'), t('!size', array('!size' => $node->booking_shirt_size)));
|
||||
}
|
||||
|
@@ -38,12 +38,11 @@ function booking_report_summary() {
|
||||
$header[] = array('data' => t('Name'), 'field' => 'booking_lastname');
|
||||
$header[] = array('data' => t('Booking Status'), 'field' => 'booking_status');
|
||||
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
// Add some optional columns
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
$header[] = array('data' => t('Studygroups'));
|
||||
}
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$header[] = array('data' => t('Room'));
|
||||
}
|
||||
|
||||
@@ -141,8 +140,7 @@ function booking_report_summary() {
|
||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||
$result = $table_sort->execute();
|
||||
|
||||
foreach ($result as $person)
|
||||
{
|
||||
foreach ($result as $person) {
|
||||
$this_row = array();
|
||||
//$amount_owing = _booking_amount_owing($person->nid, 0, FALSE);
|
||||
$amount_owing = _booking_amount_owing($person, 0, FALSE);
|
||||
@@ -162,12 +160,10 @@ function booking_report_summary() {
|
||||
);
|
||||
$this_row[] = _booking_status_generate($person->booking_status);
|
||||
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
$this_row[] = l(t('Groups'), t('admin/booking/!id/edit-studygroup-membership', array('!id' => $person->nid)));
|
||||
}
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$this_row[] =l(t('Room'), t('admin/booking/!id/edit-room', array('!id' => $person->nid)));
|
||||
}
|
||||
|
||||
@@ -187,39 +183,44 @@ function booking_report_summary() {
|
||||
$total_paid += $person->booking_amount_paid;
|
||||
|
||||
//subtract any refund
|
||||
if ($person->booking_refund_processed == 'Y' && $person->booking_refund_due > 0)
|
||||
{
|
||||
if ($person->booking_refund_processed == 'Y' && $person->booking_refund_due > 0) {
|
||||
$total_refunds += $person->booking_refund_due;
|
||||
}
|
||||
|
||||
//travel form completed?
|
||||
if (! empty($person->tid))
|
||||
if (! empty($person->tid)) {
|
||||
$travelform_count++;
|
||||
}
|
||||
|
||||
//booking status
|
||||
if ($person->booking_status == 0)
|
||||
if ($person->booking_status == 0) {
|
||||
$notpaid_counter++;
|
||||
elseif ($person->booking_status == 1)
|
||||
}
|
||||
elseif ($person->booking_status == 1) {
|
||||
$bookedin_counter++;
|
||||
elseif ($person->booking_status == 2)
|
||||
}
|
||||
elseif ($person->booking_status == 2) {
|
||||
$waiting_counter++;
|
||||
elseif ($person->booking_status == 5)
|
||||
}
|
||||
elseif ($person->booking_status == 5) {
|
||||
$hosts_counter++;
|
||||
else
|
||||
}
|
||||
else {
|
||||
$notcoming_counter++;
|
||||
}
|
||||
|
||||
//welfare
|
||||
if ($person->booking_welfare_required == 'Y')
|
||||
if ($person->booking_welfare_required == 'Y') {
|
||||
$welfare_count++;
|
||||
|
||||
}
|
||||
//committee?
|
||||
if ($person->booking_committee_member == 'Y')
|
||||
if ($person->booking_committee_member == 'Y') {
|
||||
$committee_count++;
|
||||
|
||||
}
|
||||
//fully paid?
|
||||
if ($amount_owing == 0)
|
||||
if ($amount_owing == 0) {
|
||||
$fullypaid_count++;
|
||||
|
||||
}
|
||||
$person_count++;
|
||||
|
||||
$state = strcmp($person->booking_country,'Australia') == 0 ? $person->booking_state : 'International';
|
||||
@@ -230,13 +231,13 @@ function booking_report_summary() {
|
||||
$dob_total += $person->booking_dob;
|
||||
|
||||
//store data for average ages per gender and state
|
||||
if ($person->booking_gender == 'M')
|
||||
{
|
||||
if ($person->booking_gender == 'M') {
|
||||
$male_count++;
|
||||
$male_dob_total += $person->booking_dob;
|
||||
$state_statistics[$state]->male_avg += $person->booking_dob;
|
||||
$state_statistics[$state]->male_count++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$female_count++;
|
||||
$female_dob_total += $person->booking_dob;
|
||||
$state_statistics[$state]->female_avg += $person->booking_dob;
|
||||
@@ -681,6 +682,7 @@ function booking_waitinglist_page() {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/*
|
||||
function ucname($string) {
|
||||
$string =ucwords(strtolower($string));
|
||||
|
||||
@@ -691,7 +693,7 @@ function ucname($string) {
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate a CSV file as a report of all current registrations
|
||||
@@ -699,18 +701,27 @@ function ucname($string) {
|
||||
|
||||
function booking_csv_report() {
|
||||
global $event;
|
||||
$name = 'bookings-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||
$filename = file_directory_temp() . '/' . $name;
|
||||
module_load_include('php', 'booking', 'libraries/xlsxwriter.class');
|
||||
|
||||
$filename = 'bookings-' . format_date(time(), 'custom', 'Y-m-d-His') . '.xlsx';
|
||||
// List of style options at https://github.com/mk-j/PHP_XLSXWriter/issues/198
|
||||
$header_style = array( 'border'=>'bottom','border-style'=>'thin', 'border-color'=>'#000000',
|
||||
'valign'=>'top', 'font-style' => 'bold','font' => 'Calibri');
|
||||
$row_style = array('font' => 'Calibri');
|
||||
|
||||
//$filename = file_directory_temp() . '/' . $name;
|
||||
$csv = '';
|
||||
$delimiter = ',';
|
||||
$enclosure = '"';
|
||||
$encloseAll = true;
|
||||
$encloseAll = false;
|
||||
$nullToMysqlNull = true;
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
$readinggroup_id = "";
|
||||
|
||||
//$readinggroup = "session" . variable_get('booking_readinggroup_id','7');
|
||||
$studygroup_descriptions = array();
|
||||
$header_array = array();
|
||||
$rows = array();
|
||||
|
||||
//calculate fields to ignore in the output csv file
|
||||
$builtin_fields_to_skip = array('booking_eventid');
|
||||
@@ -718,12 +729,12 @@ function booking_csv_report() {
|
||||
$fields_to_skip = array_merge($builtin_fields_to_skip, $custom_fields_to_skip);
|
||||
|
||||
//keep a list of any fields that we need to handle as dates
|
||||
$date_fields = array('booking_dob');
|
||||
$datetime_fields = array('booking_outflight_origin_ts', 'booking_outflight_destination_ts', 'booking_rtrnflight_origin_ts',
|
||||
'booking_rtrnflight_destination_ts', 'booking_timestamp', 'booking_flight_datetime_inbound', 'booking_flight_datetime_outbound');
|
||||
$number_only_fields = array('booking_postcode', 'booking_mobile', 'booking_phone', 'booking_guardian_phone', 'booking_guardian_phone_alt');
|
||||
$number_only_fields = array('booking_postcode', 'booking_mobile', 'booking_phone', 'booking_guardian_phone', 'booking_guardian_phone_alt', 'booking_price');
|
||||
|
||||
//look up the titles of the study groups and add to array for updating in the header
|
||||
$studygroup_descriptions = array();
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||
@@ -749,7 +760,6 @@ function booking_csv_report() {
|
||||
//watchdog('booking', "CSV raw data: @info", array('@info' => var_export($result, TRUE)));
|
||||
|
||||
//write the header based on the first result
|
||||
$header_array = array();
|
||||
foreach (reset($result) as $key => $value) {
|
||||
if (in_array($key, $fields_to_skip)) {
|
||||
continue;
|
||||
@@ -757,27 +767,49 @@ function booking_csv_report() {
|
||||
|
||||
// Replace headings for study group sessions and roles with the name of the study group rather than just sessionN and sessionN_role etc
|
||||
if (variable_get('booking_friendly_csv_groupnames','0') == 1 && array_key_exists($key, $studygroup_descriptions)) {
|
||||
$header_array[] = $studygroup_descriptions[$key];
|
||||
//$header_array[] = $studygroup_descriptions[$key];
|
||||
$heading = $studygroup_descriptions[$key];
|
||||
$header_array[$heading] = 'string';
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
// Apply data formatting as per https://github.com/mk-j/PHP_XLSXWriter
|
||||
if (in_array($key, $datetime_fields)) {
|
||||
// 11/09/2015 22:05
|
||||
//$header_array[$key] = 'DD/MM/YYYY HH:MM';
|
||||
$header_array[$key] = 'string';
|
||||
}
|
||||
elseif (in_array($key, $date_fields)) {
|
||||
$header_array[$key] = 'string';
|
||||
}
|
||||
elseif (in_array($key, $number_only_fields)) {
|
||||
$header_array[$key] = 'integer';
|
||||
}
|
||||
else {
|
||||
$header_array[$key] = 'string';
|
||||
}
|
||||
*/
|
||||
|
||||
$header_array[$key] = 'string';
|
||||
|
||||
$header_array[] = $key;
|
||||
//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";
|
||||
$header_array["booking_dob_processed"] = 'string';
|
||||
}
|
||||
|
||||
//add in a calculated field for amount owing
|
||||
if (strcmp($key, "nid") == 0) {
|
||||
$header_array[] = "booking_amount_owing_gross";
|
||||
$header_array[] = "booking_amount_owing_net";
|
||||
}
|
||||
$header_array["booking_amount_owing_gross"] = 'dollar';
|
||||
$header_array["booking_amount_owing_net"] = 'dollar';
|
||||
}
|
||||
|
||||
$header = implode( $delimiter, $header_array );
|
||||
}
|
||||
|
||||
watchdog('booking_debug', "<pre>CSV report headers\n@info</pre>", array('@info' => print_r($header_array, true)));
|
||||
|
||||
//$header = implode( $delimiter, $header_array );
|
||||
//$csv .= $header . "\n";
|
||||
//watchdog('booking', "CSV header: @info", array('@info' => var_export($header_array, TRUE)));
|
||||
//@fwrite($handle, $header . "\n");
|
||||
$csv .= $header . "\n";
|
||||
|
||||
//each record
|
||||
foreach ($result as $record) {
|
||||
//watchdog('booking', "CSV raw data entry: @info", array('@info' => var_export($record, TRUE)));
|
||||
@@ -797,13 +829,15 @@ function booking_csv_report() {
|
||||
|
||||
//capitalise street name and suburb name
|
||||
if ($key == 'booking_street' || $key == 'booking_suburb') {
|
||||
$value = ucname($value);
|
||||
$value = _booking_ucname($value);
|
||||
}
|
||||
|
||||
//handle dates
|
||||
if ($key == 'booking_dob') {
|
||||
$output[] = format_date($value, 'custom', 'd/m/Y');
|
||||
$output[] = '"' . _booking_avg_age($value, 1, $event->booking_event_start) . '"';
|
||||
// Add in the processed DOB
|
||||
$output[] = _booking_avg_age($value, 1, $event->booking_event_start);
|
||||
//$output[] = '"' . _booking_avg_age($value, 1, $event->booking_event_start) . '"';
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -869,38 +903,47 @@ function booking_csv_report() {
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
else {
|
||||
$output[] = $field;
|
||||
//if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $value ) ) {
|
||||
// $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $value) . $enclosure;
|
||||
//}
|
||||
//else {
|
||||
$output[] = $value;
|
||||
//}
|
||||
} // End of record processing
|
||||
$rows[] = $output;
|
||||
|
||||
//$row = implode($delimiter, $output) . "\n";
|
||||
//$csv .= $row;
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', "<pre>CSV report spreadsheet rows\n@info</pre>", array('@info' => print_r( $rows, true)));
|
||||
|
||||
// Create headers for Excel spreadsheet
|
||||
header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
|
||||
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
|
||||
$sheetname = $event->booking_eventname;
|
||||
$writer = new XLSXWriter();
|
||||
$writer->setAuthor($event->booking_eventname);
|
||||
//Add the header row
|
||||
$writer->writeSheetHeader($sheetname, $header_array, $header_style);
|
||||
|
||||
//Add the data
|
||||
foreach($rows as $row) {
|
||||
$writer->writeSheetRow($sheetname, $row, $row_style);
|
||||
}
|
||||
|
||||
$row = implode($delimiter, $output) . "\n";
|
||||
|
||||
//@fwrite($handle, $row);
|
||||
$csv .= $row;
|
||||
//$index++;
|
||||
}
|
||||
|
||||
//@fclose($handle);
|
||||
$writer->writeToStdOut();
|
||||
exit(0);
|
||||
|
||||
//see http://stackoverflow.com/questions/4348802/how-can-i-output-a-utf-8-csv-in-php-that-excel-will-read-properly
|
||||
// but none of these options seem to work
|
||||
|
||||
drupal_add_http_header("Content-type", "application/octet-stream; charset=utf-8");
|
||||
//drupal_add_http_header("Content-type", "application/octet-stream; charset=UTF-16LE");
|
||||
//drupal_add_http_header("Content-Type: application/vnd.ms-excel");
|
||||
drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
|
||||
|
||||
// @readfile($filename);
|
||||
//print chr(255) . chr(254);
|
||||
//print 'sep=,' . "\n";
|
||||
print $csv;
|
||||
//print mb_convert_encoding($csv, 'UTF-16LE', 'UTF-8');
|
||||
|
||||
//@unlink($filename);
|
||||
exit(0);
|
||||
//drupal_add_http_header("Content-type", "application/octet-stream; charset=utf-8");
|
||||
//drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
|
||||
//print $csv;
|
||||
//exit(0);
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ function booking_room_view_summary() {
|
||||
|
||||
//output everything
|
||||
$output .= t("<h3>!event Room Locations</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= t("<p>Use the link above to view room mate preferences and room allocations.</p>");
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
|
||||
return $output;
|
||||
@@ -432,11 +433,15 @@ function booking_rooms_definition_form_validate($form, $form_state) {
|
||||
//make sure room number is numerical
|
||||
$values = $form_state['input'];
|
||||
|
||||
if (! is_numeric($values['booking_room_number'])) {
|
||||
if ($form_state['values']['op'] != 'Delete Room') {
|
||||
if (isset($values['booking_room_number']) && (! is_numeric($values['booking_room_number']))) {
|
||||
form_set_error('booking_room_number', t('Room number must be numeric. If you need to use a more descriptive label, please use the room label field.'));
|
||||
watchdog('booking_debug', "<pre>Room definition submission:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form for adding room definitions
|
||||
*/
|
||||
|
@@ -208,7 +208,7 @@ function booking_stripe_validate_form_payment($form, &$form_state) {
|
||||
"first_name" => $first_name,
|
||||
),
|
||||
));
|
||||
watchdog('booking_debug', "<pre>Stripe payment charge results:\n@info</pre>", array('@info' => print_r( $charge->__toJSON(), true)));
|
||||
watchdog('booking_debug', "<pre>Stripe payment charge results:\n@info</pre>", array('@info' => print_r( $charge->toJSON(), true)));
|
||||
if ($charge && $charge->paid) {
|
||||
//watchdog('booking_debug', 'Charge created successfully');
|
||||
_booking_process_stripe_payment($charge, $token);
|
||||
@@ -222,18 +222,26 @@ function booking_stripe_validate_form_payment($form, &$form_state) {
|
||||
}
|
||||
}
|
||||
catch(\Stripe\Error\Card $e) {
|
||||
$e_json = $e->getJsonBody();
|
||||
$error = $e_json['error'];
|
||||
watchdog('booking', $e->getMessage());
|
||||
drupal_set_message($error['message'], 'error');
|
||||
//$e_json = $e->getJsonBody();
|
||||
//$error = $e_json['error'];
|
||||
watchdog('booking', "<pre>Detected exception processing Stripe payment (!message)\n@info</pre>",
|
||||
array('!message' => $e->getMessage(), '@info' => $e->getTraceAsString() ));
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
}
|
||||
catch (\Stripe\Error\ApiConnection $e) {
|
||||
watchdog('booking', $e->getMessage());
|
||||
drupal_set_message($error['message'], 'error');
|
||||
watchdog('booking', "<pre>Detected exception processing Stripe payment (!message)\n@info</pre>",
|
||||
array('!message' => $e->getMessage(), '@info' => $e->getTraceAsString() ));
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
}
|
||||
catch (\Stripe\Error\Api $e) {
|
||||
watchdog('booking', $e->getMessage());
|
||||
drupal_set_message($error['message'], 'error');
|
||||
watchdog('booking', "<pre>Detected exception processing Stripe payment (!message)\n@info</pre>",
|
||||
array('!message' => $e->getMessage(), '@info' => $e->getTraceAsString() ));
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
}
|
||||
catch (\Stripe\Exception\CardException $e) {
|
||||
watchdog('booking', "<pre>Detected exception processing Stripe payment (!message)\n@info</pre>",
|
||||
array('!message' => $e->getMessage(), '@info' => $e->getTraceAsString()));
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +309,7 @@ function _booking_process_stripe_payment(&$charge, $token) {
|
||||
'booking_buyer_email' => $charge->receipt_email,
|
||||
'booking_item_name' => $charge->description,
|
||||
'booking_ipn_track_id' => $charge->id,
|
||||
'booking_stripe_response' => $charge->__toJSON(),
|
||||
'booking_stripe_response' => $charge->toJSON(),
|
||||
))
|
||||
->execute();
|
||||
|
||||
|
@@ -474,7 +474,7 @@ function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
|
||||
booking_studygroups_process_colours();
|
||||
}
|
||||
|
||||
$final_message = "Made $counter updates leader/helper roles for study group id $group_id. Changing one person to another counts as two updates.";
|
||||
$final_message = "Made $counter update(s) to leader/helper roles for study group id $group_id. Changing one person to another counts as two updates.";
|
||||
drupal_set_message($final_message, 'status', FALSE);
|
||||
watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>");
|
||||
}
|
||||
|
@@ -920,7 +920,7 @@ function _booking_studygroups_update_preallocate($group, $group_mapping, &$sessi
|
||||
}
|
||||
|
||||
//make sure the leader/helper's partner gets updated now, otherwise they could still end up in different groups
|
||||
if ($spouse_id > 0) {
|
||||
if ($spouse_id > 0 && $working_list[$spouse_id]->booking_status == 1) {
|
||||
//also mark their spouse as allocated to this group
|
||||
$calculation_messages[] = t('Spouse with id !id assigned to session !session (currently with !num people).',
|
||||
array('!id' => $spouse_id, '!session' => $person->booking_session_id,
|
||||
@@ -963,7 +963,7 @@ function _booking_studygroups_update_preallocate($group, $group_mapping, &$sessi
|
||||
_booking_assign_attendee_group($keep_separate_id, $next_session, $gender, $age, $working_list, $session_count, $calculation_messages);
|
||||
}
|
||||
//if there is a spouse or bf/gf then keep them together
|
||||
if ($spouse_id > 0) {
|
||||
if ($spouse_id > 0 && $working_list[$spouse_id]->booking_status == 1) {
|
||||
//if the spouse has already been processed due to being a leader or helper, use that session
|
||||
if ($working_list[$spouse_id]->processed == 1) {
|
||||
$session_id = $working_list[$spouse_id]->session;
|
||||
|
@@ -7,13 +7,13 @@
|
||||
|
||||
|
||||
/**
|
||||
* Function for listing the study groups and the ability to edit the group definitions
|
||||
* Function for admin page listing the study groups and the ability to edit the group definitions
|
||||
*/
|
||||
function booking_studygroups_admin() {
|
||||
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('Study Group', 'Session Count', 'Reading Group?', 'Edit Definition');
|
||||
$header = array('Study Group Day', 'Study Group Title', 'Study Group Explanation', 'Session Count', 'Reading Group?', 'Edit Definition');
|
||||
$rows = array();
|
||||
$attributes = array('style' => 'max-width:60%');
|
||||
//$attributes = array();
|
||||
@@ -26,7 +26,9 @@ function booking_studygroups_admin() {
|
||||
|
||||
foreach ($result as $group) {
|
||||
$rows[] = array(
|
||||
$group->booking_studygroup_weekday,
|
||||
$group->booking_studygroup_descrip,
|
||||
$group->booking_studygroup_explanation,
|
||||
$group->booking_num_group_sessions,
|
||||
$group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No',
|
||||
l(t('Edit Group Definition', array('!id' => $group->sid)), t('admin/config/booking/studygroups/!id/edit', array('!id' => $group->sid))),
|
||||
@@ -47,7 +49,9 @@ function booking_studygroups_view_summary() {
|
||||
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('Study Group', 'Session Count', 'Reading Group?', 'View Membership', 'Compute Membership', 'Select Leaders', 'Download CSV');
|
||||
$header = array('Study Group Day', 'Study Group Title',
|
||||
'Session Count', 'Reading Group?', 'View Membership', 'Compute Membership',
|
||||
'Select Leaders', 'Download CSV');
|
||||
//$attributes = array('style' => 'max-width:50%');
|
||||
$attributes = array();
|
||||
$rows = array();
|
||||
@@ -60,6 +64,7 @@ function booking_studygroups_view_summary() {
|
||||
|
||||
foreach ($result as $group) {
|
||||
$rows[] = array(
|
||||
$group->booking_studygroup_weekday,
|
||||
$group->booking_studygroup_descrip,
|
||||
$group->booking_num_group_sessions,
|
||||
$group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No',
|
||||
@@ -112,14 +117,33 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
}
|
||||
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
$form['booking_studygroup_weekday'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Day of the week this study group will be held'),
|
||||
'#description' => t('For example, "Monday"'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_studygroup_weekday) ? $data->booking_studygroup_weekday : '',
|
||||
);
|
||||
$form['booking_studygroup_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Description of this study group (eg Monday)'),
|
||||
'#title' => t('Description of this study group'),
|
||||
'#description' => t('For example, "Study Group 1"'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_studygroup_descrip) ? $data->booking_studygroup_descrip : '',
|
||||
);
|
||||
$form['booking_studygroup_explanation'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Explanation for this study group'),
|
||||
'#description' => t('For example, "This relates to section 1 of the notes, which covers Matthew chapter 1."'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_studygroup_explanation) ? $data->booking_studygroup_explanation : '',
|
||||
);
|
||||
|
||||
$form['booking_num_group_sessions'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -193,7 +217,9 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
db_insert('booking_studygroup_list')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_studygroup_weekday' => $values['booking_studygroup_weekday'],
|
||||
'booking_studygroup_descrip' => $values['booking_studygroup_descrip'],
|
||||
'booking_studygroup_explanation' => $values['booking_studygroup_explanation'],
|
||||
'booking_num_group_sessions' => $values['booking_num_group_sessions'],
|
||||
'booking_is_readinggroup' => $values['booking_is_readinggroup'] == 1 ? 'Y' : 'N',
|
||||
))
|
||||
@@ -234,7 +260,9 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
db_update('booking_studygroup_list')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_studygroup_weekday' => $values['booking_studygroup_weekday'],
|
||||
'booking_studygroup_descrip' => $values['booking_studygroup_descrip'],
|
||||
'booking_studygroup_explanation' => $values['booking_studygroup_explanation'],
|
||||
'booking_num_group_sessions' => $values['booking_num_group_sessions'],
|
||||
'booking_is_readinggroup' => $values['booking_is_readinggroup'] == 1 ? 'Y' : 'N',
|
||||
))
|
||||
|
@@ -19,8 +19,7 @@ function booking_studygroups_csv_report($group_id) {
|
||||
array(':eid' => $event->eid, ':sid' => $group_id))
|
||||
->fetchObject();
|
||||
|
||||
if (! $group)
|
||||
{
|
||||
if (! $group) {
|
||||
drupal_set_message("Error: Could not find matching study group ID. Unable to view group membership.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/studygroups');
|
||||
return "";
|
||||
@@ -44,6 +43,13 @@ function booking_studygroups_csv_report($group_id) {
|
||||
array(':sid' => $group_id));
|
||||
$session_members = $session_members_query->fetchAll();
|
||||
|
||||
// Check if we had no data added, that means there were no people in this study group
|
||||
if (! $session_members) {
|
||||
drupal_set_message("Error: Study group $group_id has no members assigned.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/studygroups');
|
||||
return "";
|
||||
}
|
||||
|
||||
//generate the row data
|
||||
foreach ($session_members as $member) {
|
||||
if (! isset($data[$member->booking_session_id])) {
|
||||
@@ -66,7 +72,6 @@ function booking_studygroups_csv_report($group_id) {
|
||||
}
|
||||
//add the spaces and put this element in the right array
|
||||
$data[$member->booking_session_id][] = implode(' ', $text);
|
||||
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Study Group CSV Report\n@info</pre>", array('@info' => print_r( $data_array, true)));
|
||||
|
||||
|
@@ -331,6 +331,15 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
|
||||
$form['otherpages']['booking_variety_regn_page'] = array(
|
||||
'#title' => t('Text to use at the start of the variety session registration form'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_variety_regn_page')['value']) ? variable_get('booking_variety_regn_page')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
|
||||
//see http://drupal.org/node/820816#comment-3100356
|
||||
//and http://drupal.org/node/823362
|
||||
/*
|
||||
@@ -487,7 +496,11 @@ function booking_token_info() {
|
||||
);
|
||||
$info['tokens']['booking']['leaderhelper-pair'] = array(
|
||||
'name' => t('Registration Study Group Leader-Helper Pair'),
|
||||
'description' => t('List out the leader and helper pairs, with intro text.')
|
||||
'description' => t('List out the leader and helper pairs.')
|
||||
);
|
||||
$info['tokens']['booking']['readinggroup-listing'] = array(
|
||||
'name' => t('Reading Group Membership'),
|
||||
'description' => t('Lists all the people in a Reading Group, but only for the leader.')
|
||||
);
|
||||
$info['tokens']['booking']['room-allocation'] = array(
|
||||
'name' => t('Room Allocation'),
|
||||
@@ -501,6 +514,29 @@ function booking_token_info() {
|
||||
'name' => t('Travel form Link'),
|
||||
'description' => t('Link to the person\'s travel form.')
|
||||
);
|
||||
/*
|
||||
$info['types']['meta-booking'] = array(
|
||||
'name' => t('Meta Booking Tokens'),
|
||||
'description' => t('Sub-tokens for the booking module that are used by other booking module tokens. They will only work in a very limited context.'),
|
||||
'needs-data' => 'booking',
|
||||
);
|
||||
$info['tokens']['meta-booking']['studygroup-descrip'] = array(
|
||||
'name' => t('Study Group Description'),
|
||||
'description' => t('Used in the studygroup-summary token.')
|
||||
);
|
||||
$info['tokens']['meta-booking']['studygroup-weekday'] = array(
|
||||
'name' => t('Study Group Weekday'),
|
||||
'description' => t('Used in the studygroup-summary token.')
|
||||
);
|
||||
$info['tokens']['meta-booking']['studygroup-explan'] = array(
|
||||
'name' => t('Study Group Explanation'),
|
||||
'description' => t('Used in the studygroup-summary token.')
|
||||
);
|
||||
$info['tokens']['meta-booking']['studygroup-role'] = array(
|
||||
'name' => t('Study Group Role'),
|
||||
'description' => t('Used in the studygroup-summary token.')
|
||||
);
|
||||
*/
|
||||
return $info;
|
||||
}
|
||||
|
||||
@@ -533,7 +569,7 @@ function booking_tokens($type, $tokens, array $data = array(), array $options =
|
||||
|
||||
$replacements = array();
|
||||
$sanitize = !empty($options['sanitize']);
|
||||
if ($type == 'booking') {
|
||||
if ($type == 'booking' || $type == 'meta-booking') {
|
||||
foreach ($tokens as $name => $original) {
|
||||
if (array_key_exists($name, $data)) {
|
||||
$replacements[$original] = $data[$name];
|
||||
@@ -637,7 +673,6 @@ function booking_define_personspecific_tokens($node)
|
||||
$tokens['confirm-payment-link'] = url('confirm/' . $tempid, array('absolute' => TRUE));
|
||||
}
|
||||
|
||||
|
||||
//if payment processor is set to manual then don't populate these tokens
|
||||
//if paypal is enabled
|
||||
if ($payment_processor_type == 0) {
|
||||
@@ -676,6 +711,7 @@ function booking_define_personspecific_tokens($node)
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
$tokens['studygroup-summary'] = _booking_studygroup_email_summary($node);
|
||||
$tokens['leaderhelper-pair'] = _booking_leader_helper_email_summary($node);
|
||||
$tokens['readinggroup-listing'] = _booking_readinggroup_email_listing($node);
|
||||
}
|
||||
else {
|
||||
$tokens['studygroup-summary'] = "";
|
||||
|
@@ -112,12 +112,12 @@ function travel_form($node, &$form_state, $db_node = NULL, $inserting = FALSE, $
|
||||
//there's already info in $node so use that
|
||||
if (!empty($db_node)) {
|
||||
$data = $db_node;
|
||||
watchdog('booking_debug', "<pre>Travel form loaded from travel page:\n@info</pre>", array('@info' => print_r( $data, true)));
|
||||
//watchdog('booking_debug', "<pre>Travel form loaded from travel page:\n@info</pre>", array('@info' => print_r( $data, true)));
|
||||
}
|
||||
//otherwise rely on the form state from the previous submission
|
||||
else {
|
||||
$data = $form_state['node'];
|
||||
watchdog('booking_debug', "<pre>Travel form loaded directly:\n@info</pre>", array('@info' => print_r( $data, true)));
|
||||
//watchdog('booking_debug', "<pre>Travel form loaded directly:\n@info</pre>", array('@info' => print_r( $data, true)));
|
||||
}
|
||||
|
||||
//get info from the database if we don't have it
|
||||
@@ -143,7 +143,7 @@ function travel_form($node, &$form_state, $db_node = NULL, $inserting = FALSE, $
|
||||
}
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', "<pre>Travel form not querying database for missing details</pre>");
|
||||
//watchdog('booking_debug', "<pre>Travel form not querying database for missing details</pre>");
|
||||
$booking_dietary = $data->booking_dietary;
|
||||
$booking_medical_conditions = $data->booking_medical_conditions;
|
||||
//an empty value is zero in this case
|
||||
|
@@ -14,7 +14,12 @@ function booking_variety_admin() {
|
||||
// tabledrag example http://dropbucket.org/node/204
|
||||
$form = array();
|
||||
$options = array();
|
||||
$result = db_query("SELECT * from {booking_variety_timeslots}");
|
||||
|
||||
$query = db_select('booking_variety_timeslots', 't');
|
||||
$query->leftJoin('booking_event', 'e', 't.booking_eventid = e.eid');
|
||||
$query->fields('t')
|
||||
->fields('e', array('eid', 'booking_eventname'));
|
||||
$result = $query->execute();
|
||||
|
||||
$header = array (
|
||||
'eid' => t('Event'),
|
||||
@@ -31,16 +36,16 @@ function booking_variety_admin() {
|
||||
|
||||
foreach($result as $data) {
|
||||
$options[$data->tid] = array (
|
||||
'eid' => $event->booking_eventname,
|
||||
'eid' => $data->booking_eventname,
|
||||
'tid' => $data->tid,
|
||||
'booking_variety_time_descrip' => $data->booking_variety_time_descrip,
|
||||
'booking_variety_status' => $data->booking_variety_status == 1 ? "Enabled" : "Disabled",
|
||||
'booking_variety_start' => date("Y-m-d H:i", $data->booking_variety_start),
|
||||
'booking_variety_end' => date("Y-m-d H:i", $data->booking_variety_end),
|
||||
'variety_edit' => l('Edit Timeslot', t('admin/config/booking/variety/!tid/edit', array('!tid' => $data->tid))),
|
||||
'variety_session_list' => l('List Sessions', t('admin/config/booking/variety/!tid/session/list', array('!tid' => $data->tid))),
|
||||
'variety_session_add' => l('Add Session', t('admin/config/booking/variety/!tid/session/create', array('!tid' => $data->tid))),
|
||||
'variety_session_csv' => l('CSV Report', t('admin/config/booking/variety/!tid/csv', array('!tid' => $data->tid))),
|
||||
'variety_edit' => l('Edit Timeslot', t('admin/booking/variety/!tid/edit', array('!tid' => $data->tid))),
|
||||
'variety_session_list' => l('List Sessions', t('admin/booking/variety/!tid/session/list', array('!tid' => $data->tid))),
|
||||
'variety_session_add' => l('Add Session', t('admin/booking/variety/!tid/session/create', array('!tid' => $data->tid))),
|
||||
'variety_session_csv' => l('CSV Report', t('admin/booking/variety/!tid/csv', array('!tid' => $data->tid))),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +67,7 @@ function booking_variety_admin() {
|
||||
function booking_variety_timeslot_form($node, &$form_state, $create, $editid = 0) {
|
||||
global $event;
|
||||
$form = array();
|
||||
$prefix = "<p>Add a new variety session timeslot for the bookings module.</p>";
|
||||
$prefix = t("<p>Add a new variety session timeslot for !event variety sessions.</p>", array('!event' => $event->booking_eventname));
|
||||
|
||||
if ($create == true) {
|
||||
$data = $node;
|
||||
@@ -71,7 +76,7 @@ function booking_variety_timeslot_form($node, &$form_state, $create, $editid = 0
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $editid)) {
|
||||
drupal_set_message("Error: Invalid variety ID supplied. Unable to update variety session information.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -201,7 +206,7 @@ function booking_variety_timeslot_form_submit($form, &$form_state) {
|
||||
->execute();
|
||||
}
|
||||
|
||||
$form_state['redirect'] = array('admin/config/booking/variety');
|
||||
$form_state['redirect'] = array('admin/booking/variety');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,6 +217,12 @@ function booking_variety_create_session_form($node, &$form_state, $create = TRUE
|
||||
$form = array();
|
||||
$prefix = "";
|
||||
|
||||
//add this to the form in a hidden field so we can update the right event
|
||||
$form['tid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $timeslot_id,
|
||||
);
|
||||
|
||||
if ($create == TRUE) {
|
||||
$data = $node;
|
||||
$prefix = "<p>Add a new variety session to the specified variety session timeslot for the bookings module.</p>";
|
||||
@@ -220,13 +231,13 @@ function booking_variety_create_session_form($node, &$form_state, $create = TRUE
|
||||
//verify that $timeslot_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
drupal_set_message("Error: Invalid timeslot ID supplied. Unable to update specified variety session.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
//verify that $session_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $session_id)) {
|
||||
drupal_set_message("Error: Invalid session ID supplied. Unable to update specified variety session.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
$prefix = t("<p>Update the variety session defintion.</p>");
|
||||
@@ -249,12 +260,6 @@ function booking_variety_create_session_form($node, &$form_state, $create = TRUE
|
||||
),
|
||||
);
|
||||
|
||||
//add this to the form in a hidden field so we can update the right event
|
||||
$form['tid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $timeslot_id,
|
||||
);
|
||||
|
||||
$form['booking_variety_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('The name of the variety session to add to this timeslot'),
|
||||
@@ -312,7 +317,14 @@ function booking_variety_create_session_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
$timeslot_id = $values['tid'];
|
||||
$redirect_path = "admin/config/booking/variety/$timeslot_id/session/list";
|
||||
|
||||
//verify that $timeslot_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
$redirect_path = "admin/booking/variety";
|
||||
}
|
||||
else {
|
||||
$redirect_path = "admin/booking/variety/$timeslot_id/session/list";
|
||||
}
|
||||
|
||||
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||
if($form_state['values']['op'] == 'Delete Session' && (!isset($form_state['storage']['confirm']))) {
|
||||
@@ -375,12 +387,12 @@ function booking_variety_list_session_form($node, &$form_state, $timeslot_id = 0
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
drupal_set_message("Error: Invalid variety ID supplied. Unable to select variety session information.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
$prefix = t("<p>!link</p>",
|
||||
array ('!link' => l('Add New Variety Session', "admin/config/booking/variety/$timeslot_id/session/create")));
|
||||
array('!link' => l('Add New Variety Session', "admin/booking/variety/$timeslot_id/session/create")));
|
||||
|
||||
$query = db_select ('booking_variety_sessions', 'v');
|
||||
$query->join('booking_variety_timeslots', 't', 'v.booking_variety_timeslot_id = t.tid');
|
||||
@@ -407,7 +419,7 @@ function booking_variety_list_session_form($node, &$form_state, $timeslot_id = 0
|
||||
'booking_variety_status' => $data->booking_variety_status == 1 ? 'Active' : 'Inactive',
|
||||
'booking_variety_maxsize' => $data->booking_variety_maxsize,
|
||||
'booking_variety_regncount' => $data->booking_variety_regncount,
|
||||
'variety_edit' => l('Edit Session', t('admin/config/booking/variety/!tid/session/!vid/edit',
|
||||
'variety_edit' => l('Edit Session', t('admin/booking/variety/!tid/session/!vid/edit',
|
||||
array('!tid' => $timeslot_id, '!vid' => $data->vid))),
|
||||
);
|
||||
}
|
||||
@@ -491,7 +503,7 @@ function booking_variety_sessions_view_summary() {
|
||||
$newline[] = "";
|
||||
}
|
||||
} //end iterate variety session timeslot list
|
||||
$newline[] = l('Edit', t('admin/config/booking/variety/registration/!nid/edit', array('!nid' => $person->nid)));
|
||||
$newline[] = l('Edit', t('admin/booking/variety/registration/!nid/edit', array('!nid' => $person->nid)));
|
||||
|
||||
//add the line to the array of rows
|
||||
$rows[] = $newline;
|
||||
@@ -510,17 +522,20 @@ function booking_variety_sessions_view_summary() {
|
||||
function booking_varietysessions_csv_report($timeslot_id) {
|
||||
global $event;
|
||||
$data = array();
|
||||
$rows = array();
|
||||
|
||||
module_load_include('php', 'booking', 'libraries/xlsxwriter.class');
|
||||
|
||||
//verify that $timeslot_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
drupal_set_message("Error: Invalid variety session timeslot ID '" . $group_id . "' supplied.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
drupal_set_message("Error: Invalid variety session timeslot ID '" . $timeslot_id . "' supplied.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
//retrieve the sessions for the specified timeslot
|
||||
$db_and = db_and();
|
||||
$db_and->condition('v.booking_eventid', $event->eid, '=');
|
||||
//$db_and->condition('v.booking_eventid', $event->eid, '=');
|
||||
$db_and->condition('v.booking_variety_timeslot_id', $timeslot_id, '=');
|
||||
$variety_sessions = db_select('booking_variety_sessions', 'v')
|
||||
->condition($db_and)
|
||||
@@ -531,20 +546,22 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
//watchdog('booking_debug', 'booking_varietysessions_csv_report variety sessions: <pre>@info</pre>', array('@info' => print_r( $variety_sessions, true)));
|
||||
if (! $variety_sessions) {
|
||||
drupal_set_message("Error: Could not find matching variety session timeslot. Unable to view session membership.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
//set options for the CSV file
|
||||
$name = 'bookings-timeslot-' . $timeslot_id . '-variety-sessions-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||
$filename = file_directory_temp() . '/' . $name;
|
||||
$csv = '';
|
||||
$delimiter = ',';
|
||||
$enclosure = '"';
|
||||
$encloseAll = true;
|
||||
$encloseAll = false;
|
||||
$nullToMysqlNull = true;
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
// List of style options at https://github.com/mk-j/PHP_XLSXWriter/issues/198
|
||||
$header_style = array( 'border'=>'bottom','border-style'=>'thin', 'border-color'=>'#000000',
|
||||
'valign'=>'top', 'font-style' => 'bold','font' => 'Calibri');
|
||||
$row_style = array('font' => 'Calibri');
|
||||
|
||||
//get the list of variety session memberships
|
||||
$session_members_query = db_query("SELECT r.*, p.* FROM {booking_variety_regn} r
|
||||
@@ -553,64 +570,99 @@ function booking_varietysessions_csv_report($timeslot_id) {
|
||||
array(':eid' => $event->eid));
|
||||
$session_members = $session_members_query->fetchAll();
|
||||
|
||||
watchdog('booking_debug', 'booking_varietysessions_csv_report session members: <pre>@info</pre>', array('@info' => print_r( $session_members, true)));
|
||||
// Check if we had no data added, that means there were no people in this study group
|
||||
if (! $session_members) {
|
||||
drupal_set_message("Error: Variety Session timeslot $timeslot_id has no members assigned.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
//generate the row data
|
||||
//watchdog('booking_debug', 'booking_varietysessions_csv_report session members: <pre>@info</pre>', array('@info' => print_r( $session_members, true)));
|
||||
|
||||
// Organise people by session ID
|
||||
foreach ($session_members as $member) {
|
||||
$session_ids = drupal_json_decode($member->booking_variety_ids);
|
||||
watchdog('booking_debug', 'booking_varietysessions_csv_report person session ids: <pre>@info</pre>', array('@info' => print_r( $session_ids, true)));
|
||||
//watchdog('booking_debug', 'booking_varietysessions_csv_report person session ids: <pre>@info</pre>', array('@info' => print_r( $session_ids, true)));
|
||||
|
||||
//get the session id that matches our timeslot
|
||||
//get the session id that matches our timeslot if it exists
|
||||
if (isset($session_ids[$timeslot_id])) {
|
||||
$sid = $session_ids[$timeslot_id];
|
||||
|
||||
if (! isset($data[$sid])) {
|
||||
$data[$sid] = array();
|
||||
}
|
||||
$text = array($member->booking_firstname, $member->booking_lastname);
|
||||
|
||||
//add the spaces and put this element in the right array
|
||||
$text = array($member->booking_firstname, $member->booking_lastname);
|
||||
$data[$sid][] = implode(' ', $text);
|
||||
|
||||
}
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Study Group CSV Report\n@info</pre>", array('@info' => print_r( $data_array, true)));
|
||||
|
||||
//calculate the CSV layout
|
||||
// Calculate column headings and spreadsheet layout
|
||||
$header_array = array_keys($data);
|
||||
$maximums = array();
|
||||
$column_headings = array();
|
||||
foreach ($header_array as $column) {
|
||||
$maximums[] = count($data[$column]);
|
||||
//make the column headings a bit more user friendly
|
||||
$column_headings[] = $variety_sessions[$column]->booking_variety_descrip;
|
||||
$heading = $variety_sessions[$column]->booking_variety_descrip;
|
||||
//enclose $heading if necessary
|
||||
//if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $heading ) ) {
|
||||
// $heading = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $heading) . $enclosure;
|
||||
//}
|
||||
|
||||
// Adjusted for excel, assume each column is just a string
|
||||
//$column_headings[] = array($heading => 'string');
|
||||
$column_headings[$heading] = 'string';
|
||||
}
|
||||
|
||||
//add the column headings to the CSV
|
||||
$header = implode($delimiter, $column_headings);
|
||||
$csv .= $header . "\n";
|
||||
watchdog('booking_debug', "<pre>Variety session spreadsheet columns\n@info</pre>",
|
||||
array('@info' => print_r( $column_headings, true)));
|
||||
|
||||
//generate each row for the CSV
|
||||
|
||||
// Calculate each row based on column headings
|
||||
for ($i = 0; $i < max($maximums); $i++) {
|
||||
$output = array();
|
||||
foreach ($header_array as $column) {
|
||||
$field = isset($data[$column][$i]) ? $data[$column][$i] : '';
|
||||
|
||||
//enclose $field if necessary
|
||||
if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) ) {
|
||||
$output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
|
||||
}
|
||||
else {
|
||||
//if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) ) {
|
||||
// $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
|
||||
//}
|
||||
//else {
|
||||
$output[] = $field;
|
||||
}
|
||||
//}
|
||||
} //loop through columns
|
||||
$row = implode($delimiter, $output) . "\n";
|
||||
$csv .= $row;
|
||||
|
||||
$rows[] = $output;
|
||||
//$row = implode($delimiter, $output) . "\n";
|
||||
//$csv .= $row;
|
||||
}
|
||||
|
||||
//output the CSV to the browser
|
||||
drupal_add_http_header("Content-type", "application/octet-stream; charset=utf-8");
|
||||
drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
|
||||
print $csv;
|
||||
watchdog('booking_debug', "<pre>Variety session spreadsheet rows\n@info</pre>",
|
||||
array('@info' => print_r( $rows, true)));
|
||||
|
||||
// Create headers for Excel spreadsheet
|
||||
$filename = 'bookings-timeslot-' . $timeslot_id . '-variety-sessions-' . format_date(time(), 'custom', 'Y-m-d-His') . ".xlsx";
|
||||
header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
|
||||
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
|
||||
$sheetname = "Variety Session " . $timeslot_id;
|
||||
$writer = new XLSXWriter();
|
||||
$writer->setAuthor($event->booking_eventname);
|
||||
//Add the header row
|
||||
$writer->writeSheetHeader($sheetname, $column_headings, $header_style);
|
||||
|
||||
//Add the data
|
||||
foreach($rows as $row) {
|
||||
$writer->writeSheetRow($sheetname, $row, $row_style);
|
||||
}
|
||||
|
||||
$writer->writeToStdOut();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -622,7 +674,7 @@ function booking_variety_regn_edit_form($node, &$form_state, $nid)
|
||||
global $event;
|
||||
$form = array();
|
||||
$data = $node;
|
||||
$redirect_path = "admin/config/booking/variety/report";
|
||||
$redirect_path = "admin/booking/variety/report";
|
||||
|
||||
//verify that $variety_regn_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $nid)) {
|
||||
@@ -715,7 +767,7 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
$booking_variety_ids = array();
|
||||
$redirect_path = "admin/config/booking/variety/report";
|
||||
$redirect_path = "admin/booking/variety/report";
|
||||
|
||||
//get a list of timeslot IDs from matching form values
|
||||
$variety_timeslot_ids = preg_filter('/^select-variety-(\d+)/', '$1', array_keys( $values ));
|
||||
@@ -731,14 +783,14 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
}
|
||||
watchdog('booking_debug', "<pre>Variety session IDs from edit form:\n@info</pre>", array('@info' => print_r( $booking_variety_ids, true)));
|
||||
|
||||
// Get the previous variety session IDs and compare them
|
||||
// Get the previous variety session IDs so we can check for changes
|
||||
$person = db_query("SELECT * FROM {booking_person_view} WHERE nid = :nid",
|
||||
array(':nid' => $values['nid']))->fetchObject();
|
||||
$previous_variety_ids = drupal_json_decode($person->booking_variety_ids);
|
||||
|
||||
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||
if($form_state['values']['op'] == 'Delete Session Registration' && (!isset($form_state['storage']['confirm']))) {
|
||||
watchdog('booking_debug', "<pre>Variety session registration deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
//watchdog('booking_debug', "<pre>Variety session registration deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
$form_state['storage']['confirm'] = TRUE;
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
@@ -814,6 +866,7 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
}
|
||||
|
||||
//iterate over the old list comparing to the new list in case there are regn counts we need to decrease
|
||||
if (isset($previous_variety_ids)) {
|
||||
foreach ($previous_variety_ids as $previous_tid => $previous_sid) {
|
||||
if (! isset($booking_variety_ids[$previous_tid])) {
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid is no longer registered for a variety session so reducing count for @vid by 1', array(
|
||||
@@ -826,7 +879,25 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See if this person ever had a variety session registration
|
||||
$update_or_insert_check = db_query("SELECT * FROM {booking_variety_regn} " .
|
||||
"WHERE booking_person_nid = :nid",
|
||||
array(':nid' => $values['nid'],
|
||||
))->fetchObject();
|
||||
|
||||
if (! $update_or_insert_check) {
|
||||
// create new variety session registration information for this person
|
||||
$result = db_insert('booking_variety_regn')
|
||||
->fields(array(
|
||||
'booking_person_nid' => $values['nid'],
|
||||
'booking_variety_ids' => drupal_json_encode($booking_variety_ids),
|
||||
))
|
||||
->execute();
|
||||
watchdog('booking', "Created variety session registration for person ID !nid", array('!nid' => $values['nid']));
|
||||
}
|
||||
else {
|
||||
// update the session registration information for this person
|
||||
$result = db_update('booking_variety_regn')
|
||||
->fields(array(
|
||||
@@ -835,7 +906,9 @@ function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
->condition('booking_person_nid', $values['nid'])
|
||||
->execute();
|
||||
watchdog('booking', "Updated variety session registration for person ID !nid", array('!nid' => $values['nid']));
|
||||
}
|
||||
|
||||
// Finished, redirect to original table
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,9 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
$form = array();
|
||||
$data = $node;
|
||||
|
||||
$markup_input = variable_get('booking_variety_regn_page');
|
||||
$markup_html = token_replace($markup_input['value'], booking_define_tokens());
|
||||
|
||||
// Query the variety timeslot table
|
||||
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
@@ -22,9 +25,17 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
->orderBy('v.booking_variety_start');
|
||||
$result = $timeslot_query->execute();
|
||||
|
||||
$form['#prefix'] = '<div id="booking_variety_form_wrapper">';
|
||||
$form['#suffix'] = '</div>';
|
||||
|
||||
$form['paragraph'] = array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $markup_html,
|
||||
);
|
||||
|
||||
$form['identity'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Select Person',
|
||||
'#title' => 'Enter Your Details',
|
||||
);
|
||||
|
||||
$form['identity']['booking_nid'] = array(
|
||||
@@ -34,9 +45,25 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
'#size' => 60,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_nid) ? $data->booking_nid : '',
|
||||
//'#attributes' => array('inputmode' => 'numeric', 'pattern' =>'[0-9]*'),
|
||||
'#attributes' => array(' type' => 'number', ' pattern' =>'[0-9]*'),
|
||||
//'#ajax' => array(
|
||||
// 'event' => 'change',
|
||||
// 'wrapper' => 'booking_variety_form_wrapper',
|
||||
// 'callback' => 'booking_variety_session_form_callback',
|
||||
//),
|
||||
);
|
||||
|
||||
$form['identity']['booking_lastname'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Surname'),
|
||||
'#description' => t('Please enter your last name as it appeared when you registered.'),
|
||||
'#size' => 60,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_lastname) ? $data->booking_lastname : '',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_variety_session_fieldset_wrapper',
|
||||
'wrapper' => 'booking_variety_form_wrapper',
|
||||
'callback' => 'booking_variety_session_form_callback',
|
||||
),
|
||||
);
|
||||
@@ -44,8 +71,13 @@ function booking_variety_regn_form($node, &$form_state)
|
||||
$form['variety-sessions'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Select Variety Sessions',
|
||||
'#prefix' => '<div id="booking_variety_session_fieldset_wrapper">',
|
||||
'#suffix' => '</div>'
|
||||
//'#attributes' => array('class' => array('element-hidden')),
|
||||
//'#prefix' => '<div id="booking_variety_session_fieldset_wrapper">',
|
||||
//'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
$form['identity']['booking_feedback_wrapper'] = array(
|
||||
'#markup' => '<div id="booking_feedback_wrapper"></div>',
|
||||
);
|
||||
|
||||
//for each entry in the variety timeslot table, create a new form select item
|
||||
@@ -90,7 +122,7 @@ function _booking_get_variety_timeslot_options($timeslot_id) {
|
||||
foreach($session_query as $session) {
|
||||
$available_spots = $session->booking_variety_maxsize - $session->booking_variety_regncount;
|
||||
if ($available_spots > 0) {
|
||||
$session_options[$session->vid] = $session->booking_variety_descrip . " [" . $available_spots . " spots]";
|
||||
$session_options[$session->vid] = $session->booking_variety_descrip . " [" . $available_spots . " spots left]";
|
||||
}
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Variety Session Options:\n@info</pre>", array('@info' => print_r( $session_options, true)));
|
||||
@@ -103,8 +135,39 @@ function _booking_get_variety_timeslot_options($timeslot_id) {
|
||||
* Callback function to rebuild the variety session fieldset
|
||||
*/
|
||||
function booking_variety_session_form_callback($form, &$form_state) {
|
||||
global $event;
|
||||
$data = $form_state['input'];
|
||||
|
||||
//$form['form']['variety-sessions']['booking_feedback_wrapper']['#markup'] = '<div id="booking_feedback_wrapper">Test</div>';
|
||||
//return $form['form']['variety-sessions'];
|
||||
|
||||
if (isset($data['booking_nid']) && $data['booking_nid'] != '' && isset($data['booking_lastname']) && $data['booking_lastname'] != '') {
|
||||
// Perform lookup on person to make sure it matches someone attending the current event
|
||||
$db_and = db_and();
|
||||
$db_and->condition('p.booking_eventid', $event->eid, '=');
|
||||
$db_and->condition('p.booking_status', 1, '=');
|
||||
$db_and->condition('p.nid', $data['booking_nid'], '=');
|
||||
$db_and->condition('p.booking_lastname', $data['booking_lastname'], '=');
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition($db_and)
|
||||
->fields('p');
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
// Update feedback based on query result
|
||||
if (! $person) {
|
||||
$form['form']['identity']['booking_feedback_wrapper']['#markup'] = '<div id="booking_feedback_wrapper" style="font-size: 0.85em;">User not found.</div>';
|
||||
}
|
||||
else {
|
||||
$form['form']['identity']['booking_feedback_wrapper']['#markup'] = '<div id="booking_feedback_wrapper" style="font-size: 0.85em;">Verified user.</div>';
|
||||
//$form['form']['variety-sessions']['#attributes']['class'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild the form
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return $form['form']['variety-sessions'];
|
||||
return $form['form'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,6 +196,7 @@ function booking_variety_regn_form_validate($form, &$form_state) {
|
||||
$db_and->condition('p.booking_eventid', $event->eid, '=');
|
||||
$db_and->condition('p.booking_status', 1, '=');
|
||||
$db_and->condition('p.nid', $values['booking_nid'], '=');
|
||||
$db_and->condition('p.booking_lastname', $values['booking_lastname'], '=');
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition($db_and)
|
||||
@@ -141,7 +205,7 @@ function booking_variety_regn_form_validate($form, &$form_state) {
|
||||
->fetchObject();
|
||||
|
||||
if (! $person) {
|
||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number or your surname does not match your registration details.'));
|
||||
}
|
||||
|
||||
// --- Check that this person hasn't already registered for variety sessions
|
||||
@@ -195,7 +259,7 @@ function booking_variety_regn_form_validate($form, &$form_state) {
|
||||
function booking_variety_regn_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||
//watchdog('booking_debug', 'booking_variety_regn_form_submit: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||
$booking_variety_ids = array();
|
||||
|
||||
//get a list of timeslot IDs from matching form values
|
||||
|
968
libraries/xlsxwriter.class.php
Normal file
968
libraries/xlsxwriter.class.php
Normal file
@@ -0,0 +1,968 @@
|
||||
<?php
|
||||
/*
|
||||
* @license MIT License
|
||||
* */
|
||||
|
||||
class XLSXWriter
|
||||
{
|
||||
//http://www.ecma-international.org/publications/standards/Ecma-376.htm
|
||||
//http://officeopenxml.com/SSstyles.php
|
||||
//------------------------------------------------------------------
|
||||
//http://office.microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP010073849.aspx
|
||||
const EXCEL_2007_MAX_ROW=1048576;
|
||||
const EXCEL_2007_MAX_COL=16384;
|
||||
//------------------------------------------------------------------
|
||||
protected $title;
|
||||
protected $subject;
|
||||
protected $author;
|
||||
protected $company;
|
||||
protected $description;
|
||||
protected $keywords = array();
|
||||
|
||||
protected $current_sheet;
|
||||
protected $sheets = array();
|
||||
protected $temp_files = array();
|
||||
protected $cell_styles = array();
|
||||
protected $number_formats = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if(!ini_get('date.timezone'))
|
||||
{
|
||||
//using date functions can kick out warning if this isn't set
|
||||
date_default_timezone_set('UTC');
|
||||
}
|
||||
$this->addCellStyle($number_format='GENERAL', $style_string=null);
|
||||
$this->addCellStyle($number_format='GENERAL', $style_string=null);
|
||||
$this->addCellStyle($number_format='GENERAL', $style_string=null);
|
||||
$this->addCellStyle($number_format='GENERAL', $style_string=null);
|
||||
}
|
||||
|
||||
public function setTitle($title='') { $this->title=$title; }
|
||||
public function setSubject($subject='') { $this->subject=$subject; }
|
||||
public function setAuthor($author='') { $this->author=$author; }
|
||||
public function setCompany($company='') { $this->company=$company; }
|
||||
public function setKeywords($keywords='') { $this->keywords=$keywords; }
|
||||
public function setDescription($description='') { $this->description=$description; }
|
||||
public function setTempDir($tempdir='') { $this->tempdir=$tempdir; }
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (!empty($this->temp_files)) {
|
||||
foreach($this->temp_files as $temp_file) {
|
||||
@unlink($temp_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function tempFilename()
|
||||
{
|
||||
$tempdir = !empty($this->tempdir) ? $this->tempdir : sys_get_temp_dir();
|
||||
$filename = tempnam($tempdir, "xlsx_writer_");
|
||||
$this->temp_files[] = $filename;
|
||||
return $filename;
|
||||
}
|
||||
|
||||
public function writeToStdOut()
|
||||
{
|
||||
$temp_file = $this->tempFilename();
|
||||
self::writeToFile($temp_file);
|
||||
readfile($temp_file);
|
||||
}
|
||||
|
||||
public function writeToString()
|
||||
{
|
||||
$temp_file = $this->tempFilename();
|
||||
self::writeToFile($temp_file);
|
||||
$string = file_get_contents($temp_file);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function writeToFile($filename)
|
||||
{
|
||||
foreach($this->sheets as $sheet_name => $sheet) {
|
||||
self::finalizeSheet($sheet_name);//making sure all footers have been written
|
||||
}
|
||||
|
||||
if ( file_exists( $filename ) ) {
|
||||
if ( is_writable( $filename ) ) {
|
||||
@unlink( $filename ); //if the zip already exists, remove it
|
||||
} else {
|
||||
self::log( "Error in " . __CLASS__ . "::" . __FUNCTION__ . ", file is not writeable." );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$zip = new ZipArchive();
|
||||
if (empty($this->sheets)) { self::log("Error in ".__CLASS__."::".__FUNCTION__.", no worksheets defined."); return; }
|
||||
if (!$zip->open($filename, ZipArchive::CREATE)) { self::log("Error in ".__CLASS__."::".__FUNCTION__.", unable to create zip."); return; }
|
||||
|
||||
$zip->addEmptyDir("docProps/");
|
||||
$zip->addFromString("docProps/app.xml" , self::buildAppXML() );
|
||||
$zip->addFromString("docProps/core.xml", self::buildCoreXML());
|
||||
|
||||
$zip->addEmptyDir("_rels/");
|
||||
$zip->addFromString("_rels/.rels", self::buildRelationshipsXML());
|
||||
|
||||
$zip->addEmptyDir("xl/worksheets/");
|
||||
foreach($this->sheets as $sheet) {
|
||||
$zip->addFile($sheet->filename, "xl/worksheets/".$sheet->xmlname );
|
||||
}
|
||||
$zip->addFromString("xl/workbook.xml" , self::buildWorkbookXML() );
|
||||
$zip->addFile($this->writeStylesXML(), "xl/styles.xml" ); //$zip->addFromString("xl/styles.xml" , self::buildStylesXML() );
|
||||
$zip->addFromString("[Content_Types].xml" , self::buildContentTypesXML() );
|
||||
|
||||
$zip->addEmptyDir("xl/_rels/");
|
||||
$zip->addFromString("xl/_rels/workbook.xml.rels", self::buildWorkbookRelsXML() );
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
protected function initializeSheet($sheet_name, $col_widths=array(), $auto_filter=false, $freeze_rows=false, $freeze_columns=false )
|
||||
{
|
||||
//if already initialized
|
||||
if ($this->current_sheet==$sheet_name || isset($this->sheets[$sheet_name]))
|
||||
return;
|
||||
|
||||
$sheet_filename = $this->tempFilename();
|
||||
$sheet_xmlname = 'sheet' . (count($this->sheets) + 1).".xml";
|
||||
$this->sheets[$sheet_name] = (object)array(
|
||||
'filename' => $sheet_filename,
|
||||
'sheetname' => $sheet_name,
|
||||
'xmlname' => $sheet_xmlname,
|
||||
'row_count' => 0,
|
||||
'file_writer' => new XLSXWriter_BuffererWriter($sheet_filename),
|
||||
'columns' => array(),
|
||||
'merge_cells' => array(),
|
||||
'max_cell_tag_start' => 0,
|
||||
'max_cell_tag_end' => 0,
|
||||
'auto_filter' => $auto_filter,
|
||||
'freeze_rows' => $freeze_rows,
|
||||
'freeze_columns' => $freeze_columns,
|
||||
'finalized' => false,
|
||||
);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
$tabselected = count($this->sheets) == 1 ? 'true' : 'false';//only first sheet is selected
|
||||
$max_cell=XLSXWriter::xlsCell(self::EXCEL_2007_MAX_ROW, self::EXCEL_2007_MAX_COL);//XFE1048577
|
||||
$sheet->file_writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n");
|
||||
$sheet->file_writer->write('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">');
|
||||
$sheet->file_writer->write( '<sheetPr filterMode="false">');
|
||||
$sheet->file_writer->write( '<pageSetUpPr fitToPage="false"/>');
|
||||
$sheet->file_writer->write( '</sheetPr>');
|
||||
$sheet->max_cell_tag_start = $sheet->file_writer->ftell();
|
||||
$sheet->file_writer->write('<dimension ref="A1:' . $max_cell . '"/>');
|
||||
$sheet->max_cell_tag_end = $sheet->file_writer->ftell();
|
||||
$sheet->file_writer->write( '<sheetViews>');
|
||||
$sheet->file_writer->write( '<sheetView colorId="64" defaultGridColor="true" rightToLeft="false" showFormulas="false" showGridLines="true" showOutlineSymbols="true" showRowColHeaders="true" showZeros="true" tabSelected="' . $tabselected . '" topLeftCell="A1" view="normal" windowProtection="false" workbookViewId="0" zoomScale="100" zoomScaleNormal="100" zoomScalePageLayoutView="100">');
|
||||
if ($sheet->freeze_rows && $sheet->freeze_columns) {
|
||||
$sheet->file_writer->write( '<pane ySplit="'.$sheet->freeze_rows.'" xSplit="'.$sheet->freeze_columns.'" topLeftCell="'.self::xlsCell($sheet->freeze_rows, $sheet->freeze_columns).'" activePane="bottomRight" state="frozen"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell($sheet->freeze_rows, 0).'" activeCellId="0" pane="topRight" sqref="'.self::xlsCell($sheet->freeze_rows, 0).'"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell(0, $sheet->freeze_columns).'" activeCellId="0" pane="bottomLeft" sqref="'.self::xlsCell(0, $sheet->freeze_columns).'"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell($sheet->freeze_rows, $sheet->freeze_columns).'" activeCellId="0" pane="bottomRight" sqref="'.self::xlsCell($sheet->freeze_rows, $sheet->freeze_columns).'"/>');
|
||||
}
|
||||
elseif ($sheet->freeze_rows) {
|
||||
$sheet->file_writer->write( '<pane ySplit="'.$sheet->freeze_rows.'" topLeftCell="'.self::xlsCell($sheet->freeze_rows, 0).'" activePane="bottomLeft" state="frozen"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell($sheet->freeze_rows, 0).'" activeCellId="0" pane="bottomLeft" sqref="'.self::xlsCell($sheet->freeze_rows, 0).'"/>');
|
||||
}
|
||||
elseif ($sheet->freeze_columns) {
|
||||
$sheet->file_writer->write( '<pane xSplit="'.$sheet->freeze_columns.'" topLeftCell="'.self::xlsCell(0, $sheet->freeze_columns).'" activePane="topRight" state="frozen"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell(0, $sheet->freeze_columns).'" activeCellId="0" pane="topRight" sqref="'.self::xlsCell(0, $sheet->freeze_columns).'"/>');
|
||||
}
|
||||
else { // not frozen
|
||||
$sheet->file_writer->write( '<selection activeCell="A1" activeCellId="0" pane="topLeft" sqref="A1"/>');
|
||||
}
|
||||
$sheet->file_writer->write( '</sheetView>');
|
||||
$sheet->file_writer->write( '</sheetViews>');
|
||||
$sheet->file_writer->write( '<cols>');
|
||||
$i=0;
|
||||
if (!empty($col_widths)) {
|
||||
foreach($col_widths as $column_width) {
|
||||
$sheet->file_writer->write( '<col collapsed="false" hidden="false" max="'.($i+1).'" min="'.($i+1).'" style="0" customWidth="true" width="'.floatval($column_width).'"/>');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$sheet->file_writer->write( '<col collapsed="false" hidden="false" max="1024" min="'.($i+1).'" style="0" customWidth="false" width="11.5"/>');
|
||||
$sheet->file_writer->write( '</cols>');
|
||||
$sheet->file_writer->write( '<sheetData>');
|
||||
}
|
||||
|
||||
private function addCellStyle($number_format, $cell_style_string)
|
||||
{
|
||||
$number_format_idx = self::add_to_list_get_index($this->number_formats, $number_format);
|
||||
$lookup_string = $number_format_idx.";".$cell_style_string;
|
||||
$cell_style_idx = self::add_to_list_get_index($this->cell_styles, $lookup_string);
|
||||
return $cell_style_idx;
|
||||
}
|
||||
|
||||
private function initializeColumnTypes($header_types)
|
||||
{
|
||||
$column_types = array();
|
||||
foreach($header_types as $v)
|
||||
{
|
||||
$number_format = self::numberFormatStandardized($v);
|
||||
$number_format_type = self::determineNumberFormatType($number_format);
|
||||
$cell_style_idx = $this->addCellStyle($number_format, $style_string=null);
|
||||
$column_types[] = array('number_format' => $number_format,//contains excel format like 'YYYY-MM-DD HH:MM:SS'
|
||||
'number_format_type' => $number_format_type, //contains friendly format like 'datetime'
|
||||
'default_cell_style' => $cell_style_idx,
|
||||
);
|
||||
}
|
||||
return $column_types;
|
||||
}
|
||||
|
||||
public function writeSheetHeader($sheet_name, array $header_types, $col_options = null)
|
||||
{
|
||||
if (empty($sheet_name) || empty($header_types) || !empty($this->sheets[$sheet_name]))
|
||||
return;
|
||||
|
||||
$suppress_row = isset($col_options['suppress_row']) ? intval($col_options['suppress_row']) : false;
|
||||
if (is_bool($col_options))
|
||||
{
|
||||
self::log( "Warning! passing $suppress_row=false|true to writeSheetHeader() is deprecated, this will be removed in a future version." );
|
||||
$suppress_row = intval($col_options);
|
||||
}
|
||||
$style = &$col_options;
|
||||
|
||||
$col_widths = isset($col_options['widths']) ? (array)$col_options['widths'] : array();
|
||||
$auto_filter = isset($col_options['auto_filter']) ? intval($col_options['auto_filter']) : false;
|
||||
$freeze_rows = isset($col_options['freeze_rows']) ? intval($col_options['freeze_rows']) : false;
|
||||
$freeze_columns = isset($col_options['freeze_columns']) ? intval($col_options['freeze_columns']) : false;
|
||||
self::initializeSheet($sheet_name, $col_widths, $auto_filter, $freeze_rows, $freeze_columns);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
$sheet->columns = $this->initializeColumnTypes($header_types);
|
||||
if (!$suppress_row)
|
||||
{
|
||||
$header_row = array_keys($header_types);
|
||||
|
||||
$sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . (1) . '">');
|
||||
foreach ($header_row as $c => $v) {
|
||||
$cell_style_idx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle( 'GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style) );
|
||||
$this->writeCell($sheet->file_writer, 0, $c, $v, $number_format_type='n_string', $cell_style_idx);
|
||||
}
|
||||
$sheet->file_writer->write('</row>');
|
||||
$sheet->row_count++;
|
||||
}
|
||||
$this->current_sheet = $sheet_name;
|
||||
}
|
||||
|
||||
public function writeSheetRow($sheet_name, array $row, $row_options=null)
|
||||
{
|
||||
if (empty($sheet_name))
|
||||
return;
|
||||
|
||||
self::initializeSheet($sheet_name);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
if (count($sheet->columns) < count($row)) {
|
||||
$default_column_types = $this->initializeColumnTypes( array_fill($from=0, $until=count($row), 'GENERAL') );//will map to n_auto
|
||||
$sheet->columns = array_merge((array)$sheet->columns, $default_column_types);
|
||||
}
|
||||
|
||||
if (!empty($row_options))
|
||||
{
|
||||
$ht = isset($row_options['height']) ? floatval($row_options['height']) : 12.1;
|
||||
$customHt = isset($row_options['height']) ? true : false;
|
||||
$hidden = isset($row_options['hidden']) ? (bool)($row_options['hidden']) : false;
|
||||
$collapsed = isset($row_options['collapsed']) ? (bool)($row_options['collapsed']) : false;
|
||||
$sheet->file_writer->write('<row collapsed="'.($collapsed).'" customFormat="false" customHeight="'.($customHt).'" hidden="'.($hidden).'" ht="'.($ht).'" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">');
|
||||
}
|
||||
|
||||
$style = &$row_options;
|
||||
$c=0;
|
||||
foreach ($row as $v) {
|
||||
$number_format = $sheet->columns[$c]['number_format'];
|
||||
$number_format_type = $sheet->columns[$c]['number_format_type'];
|
||||
$cell_style_idx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle( $number_format, json_encode(isset($style[0]) ? $style[$c] : $style) );
|
||||
$this->writeCell($sheet->file_writer, $sheet->row_count, $c, $v, $number_format_type, $cell_style_idx);
|
||||
$c++;
|
||||
}
|
||||
$sheet->file_writer->write('</row>');
|
||||
$sheet->row_count++;
|
||||
$this->current_sheet = $sheet_name;
|
||||
}
|
||||
|
||||
public function countSheetRows($sheet_name = '')
|
||||
{
|
||||
$sheet_name = $sheet_name ?: $this->current_sheet;
|
||||
return array_key_exists($sheet_name, $this->sheets) ? $this->sheets[$sheet_name]->row_count : 0;
|
||||
}
|
||||
|
||||
protected function finalizeSheet($sheet_name)
|
||||
{
|
||||
if (empty($sheet_name) || $this->sheets[$sheet_name]->finalized)
|
||||
return;
|
||||
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
|
||||
$sheet->file_writer->write( '</sheetData>');
|
||||
|
||||
if (!empty($sheet->merge_cells)) {
|
||||
$sheet->file_writer->write( '<mergeCells>');
|
||||
foreach ($sheet->merge_cells as $range) {
|
||||
$sheet->file_writer->write( '<mergeCell ref="' . $range . '"/>');
|
||||
}
|
||||
$sheet->file_writer->write( '</mergeCells>');
|
||||
}
|
||||
|
||||
$max_cell = self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1);
|
||||
|
||||
if ($sheet->auto_filter) {
|
||||
$sheet->file_writer->write( '<autoFilter ref="A1:' . $max_cell . '"/>');
|
||||
}
|
||||
|
||||
$sheet->file_writer->write( '<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>');
|
||||
$sheet->file_writer->write( '<pageMargins left="0.5" right="0.5" top="1.0" bottom="1.0" header="0.5" footer="0.5"/>');
|
||||
$sheet->file_writer->write( '<pageSetup blackAndWhite="false" cellComments="none" copies="1" draft="false" firstPageNumber="1" fitToHeight="1" fitToWidth="1" horizontalDpi="300" orientation="portrait" pageOrder="downThenOver" paperSize="1" scale="100" useFirstPageNumber="true" usePrinterDefaults="false" verticalDpi="300"/>');
|
||||
$sheet->file_writer->write( '<headerFooter differentFirst="false" differentOddEven="false">');
|
||||
$sheet->file_writer->write( '<oddHeader>&C&"Times New Roman,Regular"&12&A</oddHeader>');
|
||||
$sheet->file_writer->write( '<oddFooter>&C&"Times New Roman,Regular"&12Page &P</oddFooter>');
|
||||
$sheet->file_writer->write( '</headerFooter>');
|
||||
$sheet->file_writer->write('</worksheet>');
|
||||
|
||||
$max_cell_tag = '<dimension ref="A1:' . $max_cell . '"/>';
|
||||
$padding_length = $sheet->max_cell_tag_end - $sheet->max_cell_tag_start - strlen($max_cell_tag);
|
||||
$sheet->file_writer->fseek($sheet->max_cell_tag_start);
|
||||
$sheet->file_writer->write($max_cell_tag.str_repeat(" ", $padding_length));
|
||||
$sheet->file_writer->close();
|
||||
$sheet->finalized=true;
|
||||
}
|
||||
|
||||
public function markMergedCell($sheet_name, $start_cell_row, $start_cell_column, $end_cell_row, $end_cell_column)
|
||||
{
|
||||
if (empty($sheet_name) || $this->sheets[$sheet_name]->finalized)
|
||||
return;
|
||||
|
||||
self::initializeSheet($sheet_name);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
|
||||
$startCell = self::xlsCell($start_cell_row, $start_cell_column);
|
||||
$endCell = self::xlsCell($end_cell_row, $end_cell_column);
|
||||
$sheet->merge_cells[] = $startCell . ":" . $endCell;
|
||||
}
|
||||
|
||||
public function writeSheet(array $data, $sheet_name='', array $header_types=array())
|
||||
{
|
||||
$sheet_name = empty($sheet_name) ? 'Sheet1' : $sheet_name;
|
||||
$data = empty($data) ? array(array('')) : $data;
|
||||
if (!empty($header_types))
|
||||
{
|
||||
$this->writeSheetHeader($sheet_name, $header_types);
|
||||
}
|
||||
foreach($data as $i=>$row)
|
||||
{
|
||||
$this->writeSheetRow($sheet_name, $row);
|
||||
}
|
||||
$this->finalizeSheet($sheet_name);
|
||||
}
|
||||
|
||||
protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $column_number, $value, $num_format_type, $cell_style_idx)
|
||||
{
|
||||
$cell_name = self::xlsCell($row_number, $column_number);
|
||||
|
||||
if (!is_scalar($value) || $value==='') { //objects, array, empty
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'"/>');
|
||||
} elseif (is_string($value) && $value{0}=='='){
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="s"><f>'.self::xmlspecialchars($value).'</f></c>');
|
||||
} elseif ($num_format_type=='n_date') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.intval(self::convert_date_time($value)).'</v></c>');
|
||||
} elseif ($num_format_type=='n_datetime') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::convert_date_time($value).'</v></c>');
|
||||
} elseif ($num_format_type=='n_numeric') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>');//int,float,currency
|
||||
} elseif ($num_format_type=='n_string') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>');
|
||||
} elseif ($num_format_type=='n_auto' || 1) { //auto-detect unknown column types
|
||||
if (!is_string($value) || $value=='0' || ($value[0]!='0' && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value)){
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>');//int,float,currency
|
||||
} else { //implied: ($cell_format=='string')
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function styleFontIndexes()
|
||||
{
|
||||
static $border_allowed = array('left','right','top','bottom');
|
||||
static $border_style_allowed = array('thin','medium','thick','dashDot','dashDotDot','dashed','dotted','double','hair','mediumDashDot','mediumDashDotDot','mediumDashed','slantDashDot');
|
||||
static $horizontal_allowed = array('general','left','right','justify','center');
|
||||
static $vertical_allowed = array('bottom','center','distributed','top');
|
||||
$default_font = array('size'=>'10','name'=>'Arial','family'=>'2');
|
||||
$fills = array('','');//2 placeholders for static xml later
|
||||
$fonts = array('','','','');//4 placeholders for static xml later
|
||||
$borders = array('');//1 placeholder for static xml later
|
||||
$style_indexes = array();
|
||||
foreach($this->cell_styles as $i=>$cell_style_string)
|
||||
{
|
||||
$semi_colon_pos = strpos($cell_style_string,";");
|
||||
$number_format_idx = substr($cell_style_string, 0, $semi_colon_pos);
|
||||
$style_json_string = substr($cell_style_string, $semi_colon_pos+1);
|
||||
$style = @json_decode($style_json_string, $as_assoc=true);
|
||||
|
||||
$style_indexes[$i] = array('num_fmt_idx'=>$number_format_idx);//initialize entry
|
||||
if (isset($style['border']) && is_string($style['border']))//border is a comma delimited str
|
||||
{
|
||||
$border_value['side'] = array_intersect(explode(",", $style['border']), $border_allowed);
|
||||
if (isset($style['border-style']) && in_array($style['border-style'],$border_style_allowed))
|
||||
{
|
||||
$border_value['style'] = $style['border-style'];
|
||||
}
|
||||
if (isset($style['border-color']) && is_string($style['border-color']) && $style['border-color'][0]=='#')
|
||||
{
|
||||
$v = substr($style['border-color'],1,6);
|
||||
$v = strlen($v)==3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v;// expand cf0 => ccff00
|
||||
$border_value['color'] = "FF".strtoupper($v);
|
||||
}
|
||||
$style_indexes[$i]['border_idx'] = self::add_to_list_get_index($borders, json_encode($border_value));
|
||||
}
|
||||
if (isset($style['fill']) && is_string($style['fill']) && $style['fill'][0]=='#')
|
||||
{
|
||||
$v = substr($style['fill'],1,6);
|
||||
$v = strlen($v)==3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v;// expand cf0 => ccff00
|
||||
$style_indexes[$i]['fill_idx'] = self::add_to_list_get_index($fills, "FF".strtoupper($v) );
|
||||
}
|
||||
if (isset($style['halign']) && in_array($style['halign'],$horizontal_allowed))
|
||||
{
|
||||
$style_indexes[$i]['alignment'] = true;
|
||||
$style_indexes[$i]['halign'] = $style['halign'];
|
||||
}
|
||||
if (isset($style['valign']) && in_array($style['valign'],$vertical_allowed))
|
||||
{
|
||||
$style_indexes[$i]['alignment'] = true;
|
||||
$style_indexes[$i]['valign'] = $style['valign'];
|
||||
}
|
||||
if (isset($style['wrap_text']))
|
||||
{
|
||||
$style_indexes[$i]['alignment'] = true;
|
||||
$style_indexes[$i]['wrap_text'] = (bool)$style['wrap_text'];
|
||||
}
|
||||
|
||||
$font = $default_font;
|
||||
if (isset($style['font-size']))
|
||||
{
|
||||
$font['size'] = floatval($style['font-size']);//floatval to allow "10.5" etc
|
||||
}
|
||||
if (isset($style['font']) && is_string($style['font']))
|
||||
{
|
||||
if ($style['font']=='Comic Sans MS') { $font['family']=4; }
|
||||
if ($style['font']=='Times New Roman') { $font['family']=1; }
|
||||
if ($style['font']=='Courier New') { $font['family']=3; }
|
||||
$font['name'] = strval($style['font']);
|
||||
}
|
||||
if (isset($style['font-style']) && is_string($style['font-style']))
|
||||
{
|
||||
if (strpos($style['font-style'], 'bold')!==false) { $font['bold'] = true; }
|
||||
if (strpos($style['font-style'], 'italic')!==false) { $font['italic'] = true; }
|
||||
if (strpos($style['font-style'], 'strike')!==false) { $font['strike'] = true; }
|
||||
if (strpos($style['font-style'], 'underline')!==false) { $font['underline'] = true; }
|
||||
}
|
||||
if (isset($style['color']) && is_string($style['color']) && $style['color'][0]=='#' )
|
||||
{
|
||||
$v = substr($style['color'],1,6);
|
||||
$v = strlen($v)==3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v;// expand cf0 => ccff00
|
||||
$font['color'] = "FF".strtoupper($v);
|
||||
}
|
||||
if ($font!=$default_font)
|
||||
{
|
||||
$style_indexes[$i]['font_idx'] = self::add_to_list_get_index($fonts, json_encode($font) );
|
||||
}
|
||||
}
|
||||
return array('fills'=>$fills,'fonts'=>$fonts,'borders'=>$borders,'styles'=>$style_indexes );
|
||||
}
|
||||
|
||||
protected function writeStylesXML()
|
||||
{
|
||||
$r = self::styleFontIndexes();
|
||||
$fills = $r['fills'];
|
||||
$fonts = $r['fonts'];
|
||||
$borders = $r['borders'];
|
||||
$style_indexes = $r['styles'];
|
||||
|
||||
$temporary_filename = $this->tempFilename();
|
||||
$file = new XLSXWriter_BuffererWriter($temporary_filename);
|
||||
$file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
|
||||
$file->write('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">');
|
||||
$file->write('<numFmts count="'.count($this->number_formats).'">');
|
||||
foreach($this->number_formats as $i=>$v) {
|
||||
$file->write('<numFmt numFmtId="'.(164+$i).'" formatCode="'.self::xmlspecialchars($v).'" />');
|
||||
}
|
||||
//$file->write( '<numFmt formatCode="GENERAL" numFmtId="164"/>');
|
||||
//$file->write( '<numFmt formatCode="[$$-1009]#,##0.00;[RED]\-[$$-1009]#,##0.00" numFmtId="165"/>');
|
||||
//$file->write( '<numFmt formatCode="YYYY-MM-DD\ HH:MM:SS" numFmtId="166"/>');
|
||||
//$file->write( '<numFmt formatCode="YYYY-MM-DD" numFmtId="167"/>');
|
||||
$file->write('</numFmts>');
|
||||
|
||||
$file->write('<fonts count="'.(count($fonts)).'">');
|
||||
$file->write( '<font><name val="Arial"/><charset val="1"/><family val="2"/><sz val="10"/></font>');
|
||||
$file->write( '<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
|
||||
$file->write( '<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
|
||||
$file->write( '<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
|
||||
|
||||
foreach($fonts as $font) {
|
||||
if (!empty($font)) { //fonts have 4 empty placeholders in array to offset the 4 static xml entries above
|
||||
$f = json_decode($font,true);
|
||||
$file->write('<font>');
|
||||
$file->write( '<name val="'.htmlspecialchars($f['name']).'"/><charset val="1"/><family val="'.intval($f['family']).'"/>');
|
||||
$file->write( '<sz val="'.intval($f['size']).'"/>');
|
||||
if (!empty($f['color'])) { $file->write('<color rgb="'.strval($f['color']).'"/>'); }
|
||||
if (!empty($f['bold'])) { $file->write('<b val="true"/>'); }
|
||||
if (!empty($f['italic'])) { $file->write('<i val="true"/>'); }
|
||||
if (!empty($f['underline'])) { $file->write('<u val="single"/>'); }
|
||||
if (!empty($f['strike'])) { $file->write('<strike val="true"/>'); }
|
||||
$file->write('</font>');
|
||||
}
|
||||
}
|
||||
$file->write('</fonts>');
|
||||
|
||||
$file->write('<fills count="'.(count($fills)).'">');
|
||||
$file->write( '<fill><patternFill patternType="none"/></fill>');
|
||||
$file->write( '<fill><patternFill patternType="gray125"/></fill>');
|
||||
foreach($fills as $fill) {
|
||||
if (!empty($fill)) { //fills have 2 empty placeholders in array to offset the 2 static xml entries above
|
||||
$file->write('<fill><patternFill patternType="solid"><fgColor rgb="'.strval($fill).'"/><bgColor indexed="64"/></patternFill></fill>');
|
||||
}
|
||||
}
|
||||
$file->write('</fills>');
|
||||
|
||||
$file->write('<borders count="'.(count($borders)).'">');
|
||||
$file->write( '<border diagonalDown="false" diagonalUp="false"><left/><right/><top/><bottom/><diagonal/></border>');
|
||||
foreach($borders as $border) {
|
||||
if (!empty($border)) { //fonts have an empty placeholder in the array to offset the static xml entry above
|
||||
$pieces = json_decode($border,true);
|
||||
$border_style = !empty($pieces['style']) ? $pieces['style'] : 'hair';
|
||||
$border_color = !empty($pieces['color']) ? '<color rgb="'.strval($pieces['color']).'"/>' : '';
|
||||
$file->write('<border diagonalDown="false" diagonalUp="false">');
|
||||
foreach (array('left', 'right', 'top', 'bottom') as $side)
|
||||
{
|
||||
$show_side = in_array($side,$pieces['side']) ? true : false;
|
||||
$file->write($show_side ? "<$side style=\"$border_style\">$border_color</$side>" : "<$side/>");
|
||||
}
|
||||
$file->write( '<diagonal/>');
|
||||
$file->write('</border>');
|
||||
}
|
||||
}
|
||||
$file->write('</borders>');
|
||||
|
||||
$file->write('<cellStyleXfs count="20">');
|
||||
$file->write( '<xf applyAlignment="true" applyBorder="true" applyFont="true" applyProtection="true" borderId="0" fillId="0" fontId="0" numFmtId="164">');
|
||||
$file->write( '<alignment horizontal="general" indent="0" shrinkToFit="false" textRotation="0" vertical="bottom" wrapText="false"/>');
|
||||
$file->write( '<protection hidden="false" locked="true"/>');
|
||||
$file->write( '</xf>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="2" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="2" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="43"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="41"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="44"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="42"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="9"/>');
|
||||
$file->write('</cellStyleXfs>');
|
||||
|
||||
$file->write('<cellXfs count="'.(count($style_indexes)).'">');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="164" xfId="0"/>');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="165" xfId="0"/>');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="166" xfId="0"/>');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="167" xfId="0"/>');
|
||||
foreach($style_indexes as $v)
|
||||
{
|
||||
$applyAlignment = isset($v['alignment']) ? 'true' : 'false';
|
||||
$wrapText = !empty($v['wrap_text']) ? 'true' : 'false';
|
||||
$horizAlignment = isset($v['halign']) ? $v['halign'] : 'general';
|
||||
$vertAlignment = isset($v['valign']) ? $v['valign'] : 'bottom';
|
||||
$applyBorder = isset($v['border_idx']) ? 'true' : 'false';
|
||||
$applyFont = 'true';
|
||||
$borderIdx = isset($v['border_idx']) ? intval($v['border_idx']) : 0;
|
||||
$fillIdx = isset($v['fill_idx']) ? intval($v['fill_idx']) : 0;
|
||||
$fontIdx = isset($v['font_idx']) ? intval($v['font_idx']) : 0;
|
||||
//$file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164+$v['num_fmt_idx']).'" xfId="0"/>');
|
||||
$file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164+$v['num_fmt_idx']).'" xfId="0">');
|
||||
$file->write(' <alignment horizontal="'.$horizAlignment.'" vertical="'.$vertAlignment.'" textRotation="0" wrapText="'.$wrapText.'" indent="0" shrinkToFit="false"/>');
|
||||
$file->write(' <protection locked="true" hidden="false"/>');
|
||||
$file->write('</xf>');
|
||||
}
|
||||
$file->write('</cellXfs>');
|
||||
$file->write( '<cellStyles count="6">');
|
||||
$file->write( '<cellStyle builtinId="0" customBuiltin="false" name="Normal" xfId="0"/>');
|
||||
$file->write( '<cellStyle builtinId="3" customBuiltin="false" name="Comma" xfId="15"/>');
|
||||
$file->write( '<cellStyle builtinId="6" customBuiltin="false" name="Comma [0]" xfId="16"/>');
|
||||
$file->write( '<cellStyle builtinId="4" customBuiltin="false" name="Currency" xfId="17"/>');
|
||||
$file->write( '<cellStyle builtinId="7" customBuiltin="false" name="Currency [0]" xfId="18"/>');
|
||||
$file->write( '<cellStyle builtinId="5" customBuiltin="false" name="Percent" xfId="19"/>');
|
||||
$file->write( '</cellStyles>');
|
||||
$file->write('</styleSheet>');
|
||||
$file->close();
|
||||
return $temporary_filename;
|
||||
}
|
||||
|
||||
protected function buildAppXML()
|
||||
{
|
||||
$app_xml="";
|
||||
$app_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
|
||||
$app_xml.='<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">';
|
||||
$app_xml.='<TotalTime>0</TotalTime>';
|
||||
$app_xml.='<Company>'.self::xmlspecialchars($this->company).'</Company>';
|
||||
$app_xml.='</Properties>';
|
||||
return $app_xml;
|
||||
}
|
||||
|
||||
protected function buildCoreXML()
|
||||
{
|
||||
$core_xml="";
|
||||
$core_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
|
||||
$core_xml.='<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
|
||||
$core_xml.='<dcterms:created xsi:type="dcterms:W3CDTF">'.date("Y-m-d\TH:i:s.00\Z").'</dcterms:created>';//$date_time = '2014-10-25T15:54:37.00Z';
|
||||
$core_xml.='<dc:title>'.self::xmlspecialchars($this->title).'</dc:title>';
|
||||
$core_xml.='<dc:subject>'.self::xmlspecialchars($this->subject).'</dc:subject>';
|
||||
$core_xml.='<dc:creator>'.self::xmlspecialchars($this->author).'</dc:creator>';
|
||||
if (!empty($this->keywords)) {
|
||||
$core_xml.='<cp:keywords>'.self::xmlspecialchars(implode (", ", (array)$this->keywords)).'</cp:keywords>';
|
||||
}
|
||||
$core_xml.='<dc:description>'.self::xmlspecialchars($this->description).'</dc:description>';
|
||||
$core_xml.='<cp:revision>0</cp:revision>';
|
||||
$core_xml.='</cp:coreProperties>';
|
||||
return $core_xml;
|
||||
}
|
||||
|
||||
protected function buildRelationshipsXML()
|
||||
{
|
||||
$rels_xml="";
|
||||
$rels_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$rels_xml.='<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';
|
||||
$rels_xml.='<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>';
|
||||
$rels_xml.='<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>';
|
||||
$rels_xml.='<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>';
|
||||
$rels_xml.="\n";
|
||||
$rels_xml.='</Relationships>';
|
||||
return $rels_xml;
|
||||
}
|
||||
|
||||
protected function buildWorkbookXML()
|
||||
{
|
||||
$i=0;
|
||||
$workbook_xml="";
|
||||
$workbook_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
|
||||
$workbook_xml.='<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">';
|
||||
$workbook_xml.='<fileVersion appName="Calc"/><workbookPr backupFile="false" showObjects="all" date1904="false"/><workbookProtection/>';
|
||||
$workbook_xml.='<bookViews><workbookView activeTab="0" firstSheet="0" showHorizontalScroll="true" showSheetTabs="true" showVerticalScroll="true" tabRatio="212" windowHeight="8192" windowWidth="16384" xWindow="0" yWindow="0"/></bookViews>';
|
||||
$workbook_xml.='<sheets>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
$sheetname = self::sanitize_sheetname($sheet->sheetname);
|
||||
$workbook_xml.='<sheet name="'.self::xmlspecialchars($sheetname).'" sheetId="'.($i+1).'" state="visible" r:id="rId'.($i+2).'"/>';
|
||||
$i++;
|
||||
}
|
||||
$workbook_xml.='</sheets>';
|
||||
$workbook_xml.='<definedNames>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
if ($sheet->auto_filter) {
|
||||
$sheetname = self::sanitize_sheetname($sheet->sheetname);
|
||||
$workbook_xml.='<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\''.self::xmlspecialchars($sheetname).'\'!$A$1:' . self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1, true) . '</definedName>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$workbook_xml.='</definedNames>';
|
||||
$workbook_xml.='<calcPr iterateCount="100" refMode="A1" iterate="false" iterateDelta="0.001"/></workbook>';
|
||||
return $workbook_xml;
|
||||
}
|
||||
|
||||
protected function buildWorkbookRelsXML()
|
||||
{
|
||||
$i=0;
|
||||
$wkbkrels_xml="";
|
||||
$wkbkrels_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$wkbkrels_xml.='<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';
|
||||
$wkbkrels_xml.='<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
$wkbkrels_xml.='<Relationship Id="rId'.($i+2).'" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/'.($sheet->xmlname).'"/>';
|
||||
$i++;
|
||||
}
|
||||
$wkbkrels_xml.="\n";
|
||||
$wkbkrels_xml.='</Relationships>';
|
||||
return $wkbkrels_xml;
|
||||
}
|
||||
|
||||
protected function buildContentTypesXML()
|
||||
{
|
||||
$content_types_xml="";
|
||||
$content_types_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$content_types_xml.='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
||||
$content_types_xml.='<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/xl/_rels/workbook.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
$content_types_xml.='<Override PartName="/xl/worksheets/'.($sheet->xmlname).'" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>';
|
||||
}
|
||||
$content_types_xml.='<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>';
|
||||
$content_types_xml.="\n";
|
||||
$content_types_xml.='</Types>';
|
||||
return $content_types_xml;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/*
|
||||
* @param $row_number int, zero based
|
||||
* @param $column_number int, zero based
|
||||
* @param $absolute bool
|
||||
* @return Cell label/coordinates, ex: A1, C3, AA42 (or if $absolute==true: $A$1, $C$3, $AA$42)
|
||||
* */
|
||||
public static function xlsCell($row_number, $column_number, $absolute=false)
|
||||
{
|
||||
$n = $column_number;
|
||||
for($r = ""; $n >= 0; $n = intval($n / 26) - 1) {
|
||||
$r = chr($n%26 + 0x41) . $r;
|
||||
}
|
||||
if ($absolute) {
|
||||
return '$' . $r . '$' . ($row_number+1);
|
||||
}
|
||||
return $r . ($row_number+1);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function log($string)
|
||||
{
|
||||
file_put_contents("php://stderr", date("Y-m-d H:i:s:").rtrim(is_array($string) ? json_encode($string) : $string)."\n");
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function sanitize_filename($filename) //http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx
|
||||
{
|
||||
$nonprinting = array_map('chr', range(0,31));
|
||||
$invalid_chars = array('<', '>', '?', '"', ':', '|', '\\', '/', '*', '&');
|
||||
$all_invalids = array_merge($nonprinting,$invalid_chars);
|
||||
return str_replace($all_invalids, "", $filename);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function sanitize_sheetname($sheetname)
|
||||
{
|
||||
static $badchars = '\\/?*:[]';
|
||||
static $goodchars = ' ';
|
||||
$sheetname = strtr($sheetname, $badchars, $goodchars);
|
||||
$sheetname = substr($sheetname, 0, 31);
|
||||
$sheetname = trim(trim(trim($sheetname),"'"));//trim before and after trimming single quotes
|
||||
return !empty($sheetname) ? $sheetname : 'Sheet'.((rand()%900)+100);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function xmlspecialchars($val)
|
||||
{
|
||||
//note, badchars does not include \t\n\r (\x09\x0a\x0d)
|
||||
static $badchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f";
|
||||
static $goodchars = " ";
|
||||
return strtr(htmlspecialchars($val, ENT_QUOTES | ENT_XML1), $badchars, $goodchars);//strtr appears to be faster than str_replace
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function array_first_key(array $arr)
|
||||
{
|
||||
reset($arr);
|
||||
$first_key = key($arr);
|
||||
return $first_key;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
private static function determineNumberFormatType($num_format)
|
||||
{
|
||||
$num_format = preg_replace("/\[(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow)\]/i", "", $num_format);
|
||||
if ($num_format=='GENERAL') return 'n_auto';
|
||||
if ($num_format=='@') return 'n_string';
|
||||
if ($num_format=='0') return 'n_numeric';
|
||||
if (preg_match("/[H]{1,2}:[M]{1,2}/i", $num_format)) return 'n_datetime';
|
||||
if (preg_match("/[M]{1,2}:[S]{1,2}/i", $num_format)) return 'n_datetime';
|
||||
if (preg_match("/[Y]{2,4}/i", $num_format)) return 'n_date';
|
||||
if (preg_match("/[D]{1,2}/i", $num_format)) return 'n_date';
|
||||
if (preg_match("/[M]{1,2}/i", $num_format)) return 'n_date';
|
||||
if (preg_match("/$/", $num_format)) return 'n_numeric';
|
||||
if (preg_match("/%/", $num_format)) return 'n_numeric';
|
||||
if (preg_match("/0/", $num_format)) return 'n_numeric';
|
||||
return 'n_auto';
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
private static function numberFormatStandardized($num_format)
|
||||
{
|
||||
if ($num_format=='money') { $num_format='dollar'; }
|
||||
if ($num_format=='number') { $num_format='integer'; }
|
||||
|
||||
if ($num_format=='string') $num_format='@';
|
||||
else if ($num_format=='integer') $num_format='0';
|
||||
else if ($num_format=='date') $num_format='YYYY-MM-DD';
|
||||
else if ($num_format=='datetime') $num_format='YYYY-MM-DD HH:MM:SS';
|
||||
else if ($num_format=='price') $num_format='#,##0.00';
|
||||
else if ($num_format=='dollar') $num_format='[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00';
|
||||
else if ($num_format=='euro') $num_format='#,##0.00 [$€-407];[RED]-#,##0.00 [$€-407]';
|
||||
$ignore_until='';
|
||||
$escaped = '';
|
||||
for($i=0,$ix=strlen($num_format); $i<$ix; $i++)
|
||||
{
|
||||
$c = $num_format[$i];
|
||||
if ($ignore_until=='' && $c=='[')
|
||||
$ignore_until=']';
|
||||
else if ($ignore_until=='' && $c=='"')
|
||||
$ignore_until='"';
|
||||
else if ($ignore_until==$c)
|
||||
$ignore_until='';
|
||||
if ($ignore_until=='' && ($c==' ' || $c=='-' || $c=='(' || $c==')') && ($i==0 || $num_format[$i-1]!='_'))
|
||||
$escaped.= "\\".$c;
|
||||
else
|
||||
$escaped.= $c;
|
||||
}
|
||||
return $escaped;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function add_to_list_get_index(&$haystack, $needle)
|
||||
{
|
||||
$existing_idx = array_search($needle, $haystack, $strict=true);
|
||||
if ($existing_idx===false)
|
||||
{
|
||||
$existing_idx = count($haystack);
|
||||
$haystack[] = $needle;
|
||||
}
|
||||
return $existing_idx;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function convert_date_time($date_input) //thanks to Excel::Writer::XLSX::Worksheet.pm (perl)
|
||||
{
|
||||
$days = 0; # Number of days since epoch
|
||||
$seconds = 0; # Time expressed as fraction of 24h hours in seconds
|
||||
$year=$month=$day=0;
|
||||
$hour=$min =$sec=0;
|
||||
|
||||
$date_time = $date_input;
|
||||
if (preg_match("/(\d{4})\-(\d{2})\-(\d{2})/", $date_time, $matches))
|
||||
{
|
||||
list($junk,$year,$month,$day) = $matches;
|
||||
}
|
||||
if (preg_match("/(\d+):(\d{2}):(\d{2})/", $date_time, $matches))
|
||||
{
|
||||
list($junk,$hour,$min,$sec) = $matches;
|
||||
$seconds = ( $hour * 60 * 60 + $min * 60 + $sec ) / ( 24 * 60 * 60 );
|
||||
}
|
||||
|
||||
//using 1900 as epoch, not 1904, ignoring 1904 special case
|
||||
|
||||
# Special cases for Excel.
|
||||
if ("$year-$month-$day"=='1899-12-31') return $seconds ; # Excel 1900 epoch
|
||||
if ("$year-$month-$day"=='1900-01-00') return $seconds ; # Excel 1900 epoch
|
||||
if ("$year-$month-$day"=='1900-02-29') return 60 + $seconds ; # Excel false leapday
|
||||
|
||||
# We calculate the date by calculating the number of days since the epoch
|
||||
# and adjust for the number of leap days. We calculate the number of leap
|
||||
# days by normalising the year in relation to the epoch. Thus the year 2000
|
||||
# becomes 100 for 4 and 100 year leapdays and 400 for 400 year leapdays.
|
||||
$epoch = 1900;
|
||||
$offset = 0;
|
||||
$norm = 300;
|
||||
$range = $year - $epoch;
|
||||
|
||||
# Set month days and check for leap year.
|
||||
$leap = (($year % 400 == 0) || (($year % 4 == 0) && ($year % 100)) ) ? 1 : 0;
|
||||
$mdays = array( 31, ($leap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
|
||||
|
||||
# Some boundary checks
|
||||
if($year < $epoch || $year > 9999) return 0;
|
||||
if($month < 1 || $month > 12) return 0;
|
||||
if($day < 1 || $day > $mdays[ $month - 1 ]) return 0;
|
||||
|
||||
# Accumulate the number of days since the epoch.
|
||||
$days = $day; # Add days for current month
|
||||
$days += array_sum( array_slice($mdays, 0, $month-1 ) ); # Add days for past months
|
||||
$days += $range * 365; # Add days for past years
|
||||
$days += intval( ( $range ) / 4 ); # Add leapdays
|
||||
$days -= intval( ( $range + $offset ) / 100 ); # Subtract 100 year leapdays
|
||||
$days += intval( ( $range + $offset + $norm ) / 400 ); # Add 400 year leapdays
|
||||
$days -= $leap; # Already counted above
|
||||
|
||||
# Adjust for Excel erroneously treating 1900 as a leap year.
|
||||
if ($days > 59) { $days++;}
|
||||
|
||||
return $days + $seconds;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
}
|
||||
|
||||
class XLSXWriter_BuffererWriter
|
||||
{
|
||||
protected $fd=null;
|
||||
protected $buffer='';
|
||||
protected $check_utf8=false;
|
||||
|
||||
public function __construct($filename, $fd_fopen_flags='w', $check_utf8=false)
|
||||
{
|
||||
$this->check_utf8 = $check_utf8;
|
||||
$this->fd = fopen($filename, $fd_fopen_flags);
|
||||
if ($this->fd===false) {
|
||||
XLSXWriter::log("Unable to open $filename for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
public function write($string)
|
||||
{
|
||||
$this->buffer.=$string;
|
||||
if (isset($this->buffer[8191])) {
|
||||
$this->purge();
|
||||
}
|
||||
}
|
||||
|
||||
protected function purge()
|
||||
{
|
||||
if ($this->fd) {
|
||||
if ($this->check_utf8 && !self::isValidUTF8($this->buffer)) {
|
||||
XLSXWriter::log("Error, invalid UTF8 encoding detected.");
|
||||
$this->check_utf8 = false;
|
||||
}
|
||||
fwrite($this->fd, $this->buffer);
|
||||
$this->buffer='';
|
||||
}
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
$this->purge();
|
||||
if ($this->fd) {
|
||||
fclose($this->fd);
|
||||
$this->fd=null;
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
}
|
||||
|
||||
public function ftell()
|
||||
{
|
||||
if ($this->fd) {
|
||||
$this->purge();
|
||||
return ftell($this->fd);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function fseek($pos)
|
||||
{
|
||||
if ($this->fd) {
|
||||
$this->purge();
|
||||
return fseek($this->fd, $pos);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected static function isValidUTF8($string)
|
||||
{
|
||||
if (function_exists('mb_check_encoding'))
|
||||
{
|
||||
return mb_check_encoding($string, 'UTF-8') ? true : false;
|
||||
}
|
||||
return preg_match("//u", $string) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// vim: set filetype=php expandtab tabstop=4 shiftwidth=4 autoindent smartindent:
|
@@ -233,9 +233,9 @@ max-width: 100% !important; } }
|
||||
<tr>
|
||||
<td style="padding-right: 0px; padding-left: 0px; padding-top:0px; padding-bottom:0px;" align="center">
|
||||
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="<?php print $linkitem['link'] ?>" style="height:46px; v-text-anchor:middle; width:185px;" arcsize="9%" strokecolor="transparent" fillcolor="transparent"><w:anchorlock/>
|
||||
<center style="color:<?php print $colors['booking_mailtemplate_text_color'] ?>; font-family:Verdana, Geneva, sans-serif; font-size:18px;">
|
||||
<center style="color:<?php print $colors['booking_mailtemplate_header_text_color'] ?>; font-family:Verdana, Geneva, sans-serif; font-size:18px;">
|
||||
<![endif]-->
|
||||
<a href="<?php print $linkitem['link'] ?>" target="_blank" style="display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: <?php print $colors['booking_mailtemplate_text_color'] ?>;background-color: transparent;border-radius: 4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;max-width: 165px;width: auto;border-top: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-left: 0px solid transparent;padding-top: 5px;padding-right: 20px;padding-bottom: 5px;padding-left: 20px;font-family: Verdana, Geneva, sans-serif;mso-border-alt: none">
|
||||
<a href="<?php print $linkitem['link'] ?>" target="_blank" style="display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: <?php print $colors['booking_mailtemplate_header_text_color'] ?>;background-color: transparent;border-radius: 4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;max-width: 165px;width: auto;border-top: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-left: 0px solid transparent;padding-top: 5px;padding-right: 20px;padding-bottom: 5px;padding-left: 20px;font-family: Verdana, Geneva, sans-serif;mso-border-alt: none">
|
||||
<span style="font-size: 18px; line-height: 36px;" data-mce-style="font-size: 18px; line-height: 36px;"><strong><?php print $linkitem['text'] ?></strong></span>
|
||||
</a>
|
||||
<!--[if mso]></center></v:roundrect></td></tr></table><![endif]-->
|
||||
@@ -290,9 +290,7 @@ max-width: 100% !important; } }
|
||||
</div>
|
||||
<!--[if mso]></td></tr></table><![endif]-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Social Media section -->
|
||||
<div align="center" style="padding-right: 10px; padding-left: 10px; padding-bottom: 10px;">
|
||||
<div style="line-height:10px;font-size:1px"> </div>
|
||||
<div style="display: table; max-width:171px;">
|
||||
@@ -302,7 +300,7 @@ max-width: 100% !important; } }
|
||||
<tr>
|
||||
<![endif]-->
|
||||
<?php foreach ($social_links as $linkitem) : ?>
|
||||
<?php if (isset($linkitem['text'])) : ?>
|
||||
<?php if (isset($linkitem['text']) && (! empty($linkitem['text']))) : ?>
|
||||
<!--[if (mso)|(IE)]><td width="32" style="width:32px; padding-right: 15px;" valign="top"><![endif]-->
|
||||
<table align="left" border="0" cellspacing="0" cellpadding="0" width="32" height="32" style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;Margin-right: 15px">
|
||||
<tbody><tr style="vertical-align: top"><td align="left" valign="middle" style="word-break: break-word;border-collapse: collapse !important;vertical-align: top">
|
||||
@@ -318,16 +316,13 @@ max-width: 100% !important; } }
|
||||
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div style="padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px;">
|
||||
<!--[if (mso)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 10px;padding-left: 10px; padding-top: 10px; padding-bottom: 10px;"><table width="100%" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
|
||||
<div align="center"><div style="border-top: 1px solid #BBBBBB; width:100%; line-height:1px; height:1px; font-size:1px;"> </div></div>
|
||||
<div align="center">
|
||||
<div style="border-top: 1px solid #BBBBBB; width:100%; line-height:1px; height:1px; font-size:1px;"> </div>
|
||||
</div>
|
||||
<!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
|
||||
|
||||
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
@@ -337,6 +332,4 @@ max-width: 100% !important; } }
|
||||
</div> <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
|
||||
</div>
|
||||
<!--[if (mso)|(IE)]></div><![endif]-->
|
||||
|
||||
|
||||
</body></html>
|
Reference in New Issue
Block a user