Compare commits
673 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 | ||
|
f3eeedaea1 | ||
|
780221c475 | ||
|
bf07ed21a3 | ||
|
7dea27104b | ||
|
19d6b1d432 | ||
|
3601e7492b | ||
|
7c25b701e3 | ||
|
8ef3b83adf | ||
|
7d9db5af8f | ||
|
8198b48462 | ||
|
1d78d73a9d | ||
|
8e9b0f9709 | ||
|
5fd8d5ce0e | ||
|
caad0538fe | ||
|
3ad86cfead | ||
|
82c9f23b78 | ||
|
78473752e4 | ||
|
5cb02b49b7 | ||
|
4a902166f7 | ||
|
35eac186b8 | ||
|
01048189a9 | ||
|
1cedef106c | ||
|
aa288a4d4f | ||
|
7770fbfe2b | ||
|
967176b7b4 | ||
|
49a2a68072 | ||
|
81a2a27895 | ||
|
d56d6bbc92 | ||
|
4fe8c86245 | ||
|
ecf0342310 | ||
|
261f0201be | ||
|
a56400b6e4 | ||
|
bc365a005c | ||
|
43d69907e0 | ||
|
3c6687892f | ||
|
83c2c498db | ||
|
5e2f47133f | ||
|
e6f46f554d | ||
|
be12693e1c | ||
|
10f0087a0b | ||
|
654968dc57 | ||
|
be7b7db7d8 | ||
|
48a6db74ed | ||
|
624d49d66c | ||
|
16f3a82c81 | ||
|
7cd93a09f1 | ||
|
63a17dcefc | ||
|
9ac93d701c | ||
|
b82360598f | ||
|
b32b719a29 | ||
|
04bfd9d876 | ||
|
b283cadcf9 | ||
|
01ffc3424e | ||
|
e17b190d2f | ||
|
46001d1700 | ||
|
6a056c80eb | ||
|
9a4b327250 | ||
|
b376faca6f | ||
|
d18b56e19e | ||
|
1d913c156e | ||
|
a90960619d | ||
|
2ca29c0d46 | ||
|
6c908d29f2 | ||
|
59d04fea5d | ||
|
7f8c3386b6 | ||
|
ade7c5d584 | ||
|
4d0d5b2979 | ||
|
2521a6fd96 | ||
|
59cbcb9c52 | ||
|
fe632ee847 | ||
|
6ef447921b | ||
|
3cfca677ea | ||
|
cd1493ef4a | ||
|
558b72e663 | ||
|
732b6c63be | ||
|
8bcf1d51b1 | ||
|
8b133cf160 | ||
|
145e914f5e | ||
|
b0a7b7007a | ||
|
7f4f8455ee | ||
|
76c82fae85 | ||
|
427f1dd2e7 | ||
|
346414ba3b | ||
|
67d449ca4e | ||
|
295333c230 | ||
|
6c3ce18d2d | ||
|
7a3a43a837 | ||
|
c9705ce122 | ||
|
a507c3f219 | ||
|
a12351c15e | ||
|
ba9b7d86ee | ||
|
d6f4b8e6be | ||
|
a5efdeadf0 | ||
|
a5f49c7301 | ||
|
a61dd8cdc4 | ||
|
b5614a80e4 | ||
|
187f056197 | ||
|
c4cd0e63cb | ||
|
d7108419c1 | ||
|
9917b5990b | ||
|
27c4920165 | ||
|
11dd6a2edf | ||
|
f65c99a80e | ||
|
ef66bf4842 | ||
|
f1fa34d6bc | ||
|
88d5ee6cbf | ||
|
5cf0962d1f | ||
|
11122b9696 | ||
|
2be119ca1c | ||
|
44fcfef61f | ||
|
ccc5a8d772 | ||
|
b804eec1df | ||
|
22d6e0a03d | ||
|
5beb81a47f | ||
|
0874913fb8 | ||
|
3b0d8c5628 | ||
|
f244562358 | ||
|
3c8ed7f1e3 | ||
|
c440c769d2 | ||
|
2ab0fbe0d8 | ||
|
7e84ad2b0d | ||
|
4e2f7f74f8 | ||
|
f8a9f76e20 | ||
|
29e71e658d | ||
|
82c6db47ed | ||
|
2075dbfc92 | ||
|
2c59c26cbd | ||
|
c1957a6c83 | ||
|
340cfa503d | ||
|
7ceacf9f6d | ||
|
0d6334e5b4 | ||
|
4364104454 | ||
|
fc05fb9e4e | ||
|
e7a0999da8 | ||
|
50c464265d | ||
|
43a174db79 | ||
|
d3dd2384f0 | ||
|
c5f9be5f7c | ||
|
09235cb589 | ||
|
a8ec4e31b3 | ||
|
54e74b412e | ||
|
9e5fdc450f | ||
|
288efddf8e | ||
|
404021335c | ||
|
1ad5da11d3 | ||
|
2a5fce9dc4 | ||
|
e083fdaaca | ||
|
0c9754e41b | ||
|
796b910a85 | ||
|
c45dfa21b9 | ||
|
0e427a8416 | ||
|
dc7353e1e2 | ||
|
5d3a7ffbf1 | ||
|
c29d8a7a21 | ||
|
b25a858054 | ||
|
a1b392a675 | ||
|
c70b05922d | ||
|
584376bf25 | ||
|
fb7084012c | ||
|
c422dcedd8 | ||
|
6e8adebeb5 | ||
|
87b53bbc24 | ||
|
cfa5b01db8 | ||
|
0f2e415baf | ||
|
46180afaeb | ||
|
3a25d690f4 | ||
|
db64bff16e | ||
|
132570540f | ||
|
d79ff5289a | ||
|
18233ba6ee | ||
|
51bf95dfeb | ||
|
9ac1c170a0 | ||
|
2b47366511 | ||
|
7849265288 | ||
|
fa383cb515 | ||
|
fdf1534542 | ||
|
7a5cc19de9 | ||
|
37317e0ea7 | ||
|
acdae37921 | ||
|
e470b7a9b1 | ||
|
5865803250 | ||
|
011a4fac70 | ||
|
2f91fef245 | ||
|
6a7260eec8 | ||
|
4bc7c8745c | ||
|
c0f076b889 | ||
|
0395b406a5 | ||
|
6ff5ae7790 | ||
|
85249b475f | ||
|
0f260a1675 | ||
9a720ce93e | |||
8e6164a45c | |||
a9796b3f47 | |||
036d911272 | |||
a8ff994a9d | |||
332dcabd52 | |||
d1f82c4ecb | |||
981303635d | |||
141d78c64d | |||
aaa13c6988 | |||
5afd8f6f05 | |||
0bb9d0bbf7 | |||
e8531a8baf | |||
8187deacdb | |||
e0eb865706 | |||
266449d21c | |||
af138df744 | |||
8f1319c79a | |||
19978d51f5 | |||
009e9732b2 | |||
76ac3fbead | |||
e1cb00858f | |||
aa9adc3320 | |||
254c09ded7 | |||
d01be3b8a1 | |||
557b99966d | |||
9910b523c6 | |||
f200fbc9b2 | |||
308c8be4a4 | |||
9ad6291d0c | |||
6e57f78d26 | |||
ca634916c0 | |||
414c2ef8ae | |||
784bf46378 | |||
a7d24fb16c | |||
461c6b1053 | |||
3155c277ef | |||
895b3b80e6 | |||
c3f0f191f3 | |||
b6460fa681 | |||
5fbdfd1cd4 | |||
f3cd3f0745 | |||
4135790c64 | |||
2b20549707 | |||
83800b155e | |||
c27f2c1005 | |||
5e616019dd | |||
f741694491 | |||
088648812e | |||
0763037aec | |||
258febf238 | |||
78ebc3ac27 | |||
54ad2404be | |||
aff52e4349 | |||
14fb815c97 | |||
1f3040ebe5 | |||
c522f94dfa | |||
5c2715f28a | |||
31c02c153d | |||
e2d8a9d89b | |||
e90b2ebb62 | |||
e3fee20b7d | |||
79b2b0e505 | |||
d568cf2043 | |||
57bf81dfa4 | |||
a707ab2fd0 | |||
d023e67da5 | |||
31b98fb623 | |||
23ff234bae | |||
9f9c437037 | |||
1fb55cc4d5 | |||
557c5a8a3d | |||
73d6dabecf | |||
686f3c5eef | |||
8ba365ed97 | |||
3f42c97ef2 | |||
388e52462d | |||
d6e76f6e81 | |||
1037efed19 | |||
6730787ea1 | |||
99fa4d4584 | |||
3a150be2f3 | |||
12fdc944ab | |||
8e3b8e75c6 | |||
cf8736d43b | |||
8999130762 | |||
890cb7159d | |||
ee4a13bdd5 | |||
b2292c0eca | |||
0b8b257364 | |||
512f863058 | |||
d9107c0d48 | |||
c48f31613d | |||
8bb01c00ee | |||
e324071ad9 | |||
9294e17e3f | |||
43d9ab4e4c | |||
84a44b9845 | |||
3d1a323a3b | |||
574fd3ecb7 | |||
7f3a8f94f8 | |||
45d473a646 | |||
8444477ab2 | |||
899fd83499 | |||
dc2f10fee3 | |||
71c0cbb26b | |||
409e00fc84 | |||
527b961f7c | |||
4ad18bf7fd | |||
627b1767e8 | |||
0fd7f95baf | |||
2c20f04a1d | |||
0b3a2f2273 | |||
5701fee75f | |||
eb78639b06 | |||
b85f17b362 | |||
7df9904aaf | |||
13f5125ccc | |||
49ee2846a2 | |||
238c8a8ed7 | |||
6459d7d243 | |||
3fcbe0f9b6 | |||
7e908389dd | |||
ac8ed27d63 | |||
acfbd806ef | |||
1111b91b73 | |||
2b01006b0a | |||
ff036eab50 | |||
f786e02efa | |||
c18752c56a | |||
1f31169ca6 | |||
d75b946bdb | |||
4cf96a2a68 | |||
bb9942fd3b | |||
22c07cc832 | |||
b14edc70a2 | |||
b109cb792f | |||
381d61b85d | |||
241f1e02e2 | |||
5f9465dd59 | |||
16e34ebfd1 | |||
a0f5f259fd | |||
f4116040c1 | |||
cd83d885d8 | |||
fab55d7aef | |||
99a54e7f76 | |||
9d5ebccb0e | |||
b5d9b5ea7f | |||
e90d02f46e | |||
0c975086e5 | |||
3d68e2a8ce | |||
b0cc61de6c | |||
d1dc168197 | |||
f7345875f8 | |||
7cfe389e62 | |||
5a8ddd4a5e | |||
d6f6b78f24 | |||
977ba0769b | |||
d613b5b736 | |||
83d3b57d1d | |||
c2f8d71664 | |||
2d37380939 | |||
2f1050cf7f | |||
a1dd635148 | |||
c94c90dd94 | |||
39f174401a | |||
298ca2d48a | |||
4c9cc6f519 | |||
73185c28f3 | |||
db45ff0ddb | |||
9c198c27d6 | |||
fd9289a57d | |||
4768fe7ba1 | |||
d0f8d44516 | |||
554a73623e | |||
2559d03a8a | |||
5c0bbbc805 | |||
a28775e5b8 | |||
677afbd060 | |||
cad04505f3 | |||
a84626e96a | |||
25f0a2af03 | |||
8fcb858f2e | |||
a7ef7e36cd | |||
0f2511205d | |||
51d89c19c6 | |||
c45c5739a9 | |||
526060696e | |||
9cc9140a73 | |||
e8e73cfe75 | |||
9fd05f98da | |||
e589f6b0a5 | |||
39dd2e43b8 | |||
44931adb82 | |||
0fe7189f10 | |||
d4ac574142 | |||
7e99092df7 | |||
b1b900dfb3 | |||
b2f1372950 | |||
3d588081ee | |||
ce2914cf03 | |||
c02e933cb8 | |||
ec7a9ea0d8 | |||
d88df40702 | |||
b530dba1ad | |||
f951c6bc9b | |||
e332a35fa0 | |||
3af311609c | |||
|
6004c3250c | ||
|
f02b4bf53b | ||
|
e89f48b17d | ||
|
f79f812e4e | ||
d906c2e220 | |||
|
af648cce84 | ||
|
a24a60fb77 | ||
|
3cbb0334c3 | ||
|
9e26b69edf | ||
|
cc7d8680f3 | ||
|
ef938eb58f | ||
|
b0fca9b101 | ||
|
51bdc6da2f | ||
|
35731c3835 | ||
|
cd37a85ad6 | ||
|
cb97f64ecd | ||
|
581b7d7537 | ||
|
f6ee9d11a7 | ||
|
dd70dfd5a3 | ||
|
f4456a86f0 | ||
|
9f50f2f2c3 | ||
|
28a520aea6 | ||
|
385ba3c83b | ||
|
69bae12146 | ||
|
2cbfda6cf7 | ||
|
07078de79b | ||
|
dd9e4ac822 | ||
|
87247d87f4 | ||
|
04396cda56 | ||
|
1878fc72e1 | ||
|
297a0acf28 | ||
|
a7d33c6239 | ||
|
b102d4c496 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
.DS_Store
|
||||
images/Thumbs.db
|
||||
|
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.
|
||||
|
48
booking.MailSystemInterface.inc
Normal file
48
booking.MailSystemInterface.inc
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// @deprecated
|
||||
// Use MimeMail module instead of this class
|
||||
// Since this class doesn't handle attaching files
|
||||
|
||||
/**
|
||||
* Implements MailSystemInterface
|
||||
* Taken from http://www.ardoubleyou.com/blog/how-programmatically-send-e-mail-using-html-and-text-content-type-drupal-7
|
||||
*/
|
||||
class BookingMailSystem implements MailSystemInterface {
|
||||
/**
|
||||
* Concatenate and wrap the e-mail body for plain-text mails
|
||||
* @param $message
|
||||
* A message array, as described in hook_mail_alter().
|
||||
*
|
||||
* @return
|
||||
* The formatted $message
|
||||
*/
|
||||
public function format(array $message) {
|
||||
$message['body'] = implode("\n\n", $message['body']);
|
||||
//watchdog('booking_debug', "<pre>BookingMailSystem format:\n@info</pre>", array('@info' => print_r( $message, true)));
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an e-mail message, using Drupal variables and default settings.
|
||||
* @see drupal_mail*()
|
||||
* @param $message
|
||||
* A message array, as described in hook_mail_alter()
|
||||
* @return
|
||||
* TRUE if the mail was successfully accepted, otherwise FALSE
|
||||
*/
|
||||
public function mail(array $message) {
|
||||
$mimeheaders = array();
|
||||
foreach($message['headers'] as $name => $value) {
|
||||
$mimeheaders[] = $name . ': ' . mime_header_encode($value);
|
||||
}
|
||||
$line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
|
||||
$mail = mail(
|
||||
$message['to'],
|
||||
mime_header_encode($message['subject']),
|
||||
preg_replace('@\r?\n@', $line_endings, $message['body']),
|
||||
join("\n", $mimeheaders)
|
||||
);
|
||||
//watchdog('booking_debug', "<pre>BookingMailSystem mail:\n@info</pre>", array('@info' => print_r( $mail, true)));
|
||||
return $mail;
|
||||
}
|
||||
}
|
@@ -9,7 +9,7 @@ function booking_admin() {
|
||||
|
||||
//regenerate all our menu hooks when loading this form
|
||||
menu_rebuild();
|
||||
|
||||
|
||||
//create the mysql view booking_person_view if necessary
|
||||
try {
|
||||
$sqlview_check = db_query("SELECT * FROM {booking_person_view}")->fetchAssoc();
|
||||
@@ -23,8 +23,9 @@ function booking_admin() {
|
||||
//form commences here
|
||||
$form['email'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Email Addresses'
|
||||
);
|
||||
'#title' => 'Email Addresses',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['email']['booking_from_email'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -53,7 +54,7 @@ function booking_admin() {
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
'#default_value' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from'))),
|
||||
);
|
||||
|
||||
$form['email']['booking_logistics_email'] = array(
|
||||
@@ -63,8 +64,18 @@ function booking_admin() {
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
'#default_value' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from'))),
|
||||
);
|
||||
$form['email']['booking_enable_html_mail'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable html emails?'),
|
||||
'#description' => t('Turn this feature on for html based emails, otherwise plaintext emails will be used. HTML based emails will require a custom template file to be defined.<br /><strong>WARNING: This will reset all existing mail definitions.</strong> Take care before changing this value.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_html_mail', 0),
|
||||
);
|
||||
$form['email']['booking_custom_email_count'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Number of custom email definitions'),
|
||||
@@ -73,10 +84,20 @@ 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',
|
||||
'#title' => 'Attendee restrictions'
|
||||
'#title' => 'Attendee restrictions',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['attendee']['booking_max_dob'] = array(
|
||||
@@ -124,8 +145,9 @@ function booking_admin() {
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Paypal Settings',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
//'#collapsed' => TRUE,
|
||||
);
|
||||
/*
|
||||
$form['paypal']['booking_use_paypal'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Use Paypal? (DEPRECATED)'),
|
||||
@@ -136,6 +158,7 @@ function booking_admin() {
|
||||
),
|
||||
'#default_value' => variable_get('booking_use_paypal', 0)
|
||||
);
|
||||
*/
|
||||
$form['paypal']['booking_paypal_account'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify Paypal Account Address'),
|
||||
@@ -182,9 +205,10 @@ function booking_admin() {
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Stripe Settings',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
//'#collapsed' => TRUE,
|
||||
);
|
||||
$explanation_text = t('<p>Register an account at stripe.com and visit <a href="https://dashboard.stripe.com/account/apikeys">the API keys page</a>, then copy your API keys here.</p>');
|
||||
$explanation_text = t('<p>Verify your country supports stripe at <a href="https://stripe.com/global">the stripe website</a>.</p>' .
|
||||
'<p>Register an account at stripe.com and visit <a href="https://dashboard.stripe.com/account/apikeys">the API keys page</a>, then copy your API keys here.</p>');
|
||||
$form['stripe']['explanation-text'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => $explanation_text,
|
||||
@@ -242,13 +266,20 @@ function booking_admin() {
|
||||
'#default_value' => variable_get('booking_stripe_transaction_fee_percentage_intl', '2.9'),
|
||||
'#field_prefix' => '%',
|
||||
'#size' => 5,
|
||||
'#description' => 'Percentage of transaction charged as stripe fee for transactions that include currency conversion, currently 2.9% in Australia',
|
||||
'#description' => 'Percentage of transaction charged as stripe fee for transactions that include currency conversion, currently 2.9% in Australia. This fee also applies to American Express cards.',
|
||||
);
|
||||
$form['stripe']['booking_stripe_logo'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Logo URL for Stripe Checkout Form'),
|
||||
'#description' => 'Enter the full URL to a logo file that will be used on the stripe checkout form.<br />The recommended minimum size is 128x128px. The supported image types are: .gif, .jpeg, and .png.',
|
||||
'#default_value' => variable_get('booking_stripe_logo', 'https://stripe.com/img/documentation/checkout/marketplace.png'),
|
||||
);
|
||||
|
||||
//feature settings
|
||||
$form['features'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Enable/Disable Features'
|
||||
'#title' => 'Enable/Disable Features',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
$form['features']['booking_payment_processor'] = array (
|
||||
'#type' => 'radios',
|
||||
@@ -323,6 +354,16 @@ function booking_admin() {
|
||||
'#options' => array(0 => t('No'), t('Yes')),
|
||||
'#default_value' => variable_get('booking_studygroup_csv_ages', 0),
|
||||
);
|
||||
$form['features']['booking_enable_emoji_removal'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Remove emoji from user input?'),
|
||||
'#description' => t('Select whether to strip emoji from user input before saving to database. Useful if mysql does not support utf8mb4.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_emoji_removal', 1)
|
||||
);
|
||||
$form['misc'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Configuration Options'
|
||||
@@ -382,7 +423,8 @@ function booking_admin() {
|
||||
|
||||
$form['regn_options'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Registration Form Configuration'
|
||||
'#title' => 'Registration Form Configuration',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['regn_options']['booking_default_country'] = array(
|
||||
@@ -445,17 +487,6 @@ function booking_admin() {
|
||||
)
|
||||
);
|
||||
|
||||
$form['regn_options']['booking_dependant_children_text'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Ask whether a couple has dependant children attending?'),
|
||||
'#description' => t('Select whether to ask about dependant children of married couples in the registration form'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_ask_dependant_children', 0)
|
||||
);
|
||||
|
||||
$form['regn_options']['booking_enable_medicare'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable Medicare requirement?'),
|
||||
@@ -494,10 +525,10 @@ function booking_admin() {
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_tshirts', 0)
|
||||
);
|
||||
|
||||
/*
|
||||
$form['regn_options']['booking_enable_passport'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable passport information?'),
|
||||
'#title' => t('Enable passport information? (DEPRECATED)'),
|
||||
'#description' => t('Select whether to include passport details in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
@@ -505,6 +536,7 @@ function booking_admin() {
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_passport', 0)
|
||||
);
|
||||
*/
|
||||
$form['regn_options']['booking_enable_helpareas'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable help area questions?'),
|
||||
@@ -604,10 +636,90 @@ function booking_admin() {
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$form['regn_options']['booking_enable_earlyaccess_codes'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Allow early access to registration form with unique code?'),
|
||||
'#description' => t('Select whether to enable the feature that will allow early registrations with a unique code. Turning on this feature will allow registrations immediately, regardless of event registration start date.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_earlyaccess_codes', 0)
|
||||
);
|
||||
$form['regn_options']['booking_earlyaccess_codes_count'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Number of early access codes'),
|
||||
'#description' => t("Set to the number of early access codes to generate. You will need to visit the !configuration to actually generate these codes.",
|
||||
array('!configuration' => l('Configuration Page', 'admin/config/booking/earlyaccess'))),
|
||||
'#size' => 3,
|
||||
'#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'
|
||||
'#title' => 'Data Management Options',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
$form['management']['booking_csv_exclude_fields'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -628,22 +740,53 @@ function booking_admin() {
|
||||
|
||||
$booking_view_fields = _booking_get_person_fields();
|
||||
$form['management']['booking_export_include_fields_dynamic'] = array(
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#title' => t('Not In Use - Select database fields'),
|
||||
'#description' => t('Select database fields to export to CSV. Ensure you hold down control/command when selecting multiple options.'),
|
||||
'#options' => $booking_view_fields,
|
||||
'#default_value' => variable_get('booking_export_include_fields_dynamic', ''),
|
||||
);
|
||||
$form['management']['booking_import_include_fields_dynamic'] = array(
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#title' => t('Not In Use - Select database fields'),
|
||||
'#description' => t('Select database fields to import from an uploaded CSV file. Ensure you hold down control/command when selecting multiple options.'),
|
||||
'#options' => $booking_view_fields,
|
||||
'#default_value' => variable_get('booking_import_include_fields_dynamic', ''),
|
||||
);
|
||||
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#title' => t('Not In Use - Select database fields'),
|
||||
'#description' => t('Select database fields to export to CSV. Ensure you hold down control/command when selecting multiple options.'),
|
||||
'#options' => $booking_view_fields,
|
||||
'#default_value' => variable_get('booking_export_include_fields_dynamic', ''),
|
||||
);
|
||||
$form['management']['booking_import_include_fields_dynamic'] = array(
|
||||
'#type' => 'select',
|
||||
'#multiple' => TRUE,
|
||||
'#title' => t('Not In Use - Select database fields'),
|
||||
'#description' => t('Select database fields to import from an uploaded CSV file. Ensure you hold down control/command when selecting multiple options.'),
|
||||
'#options' => $booking_view_fields,
|
||||
'#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);
|
||||
|
@@ -1,19 +1,20 @@
|
||||
<?php
|
||||
// $Id: booking.confirm.inc,v 0.1 2011/07/12
|
||||
|
||||
/**
|
||||
* Confirmation page for event registration
|
||||
* Balance payment page for event registration
|
||||
*/
|
||||
function booking_balance_page() {
|
||||
global $event;
|
||||
$payment_processor_type = variable_get('booking_payment_processor', 0);
|
||||
$output = "";
|
||||
$waiting_list = False;
|
||||
$already_paid = false;
|
||||
$waiting_list = FALSE;
|
||||
$already_paid = FALSE;
|
||||
$paypal_form = "";
|
||||
|
||||
//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 "";
|
||||
@@ -21,16 +22,25 @@ function booking_balance_page() {
|
||||
|
||||
//TODO: if the person says they're married, query to see if they're listed partner has already registered and paid
|
||||
//if they have, then let the new registration person know their partner has already paid, and send them the confirmation email
|
||||
|
||||
|
||||
//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)
|
||||
{
|
||||
if ($person) {
|
||||
//load all the fields
|
||||
$node = node_load($person->nid);
|
||||
//calculate the invoice ID
|
||||
@@ -38,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 "";
|
||||
@@ -45,32 +58,32 @@ function booking_balance_page() {
|
||||
|
||||
//populate tokens and paypal form
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
// @todo - use admin variable booking_payment_processor to determine which of these to calculate
|
||||
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
||||
$tokens['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
||||
|
||||
//Calculate the amount outstanding
|
||||
//watchdog('booking', 'Booking Balance form calculating amount owing');
|
||||
//$amount_owing = _booking_amount_owing($person->nid);
|
||||
|
||||
//if paypal is enabled
|
||||
if ($payment_processor_type == 0) {
|
||||
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Balance");
|
||||
}
|
||||
//if stripe is enabled
|
||||
elseif ($payment_processor_type == 1) {
|
||||
$tokens['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['payment-required'], "Pay Balance");
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Balance page tokens:\n@info</pre>", array('@info' => print_r( $tokens, true)));
|
||||
|
||||
//If the amount outstanding is zero, then display information to that effect.
|
||||
if ($tokens['paypal-total-amount'] == 0)
|
||||
{
|
||||
if ($tokens['payment-required'] == 0) {
|
||||
$output = token_replace(variable_get('booking_regn_balance_page_paid'), $tokens);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$output = token_replace(variable_get('booking_regn_balance_page'), $tokens);
|
||||
//optional additional text for married people
|
||||
if ($node->booking_married == 'Y')
|
||||
if ($node->booking_married == 'Y') {
|
||||
$output .= token_replace(variable_get('booking_regn_balance_married_text'), $tokens);
|
||||
}
|
||||
}
|
||||
|
||||
//put all the bits together
|
||||
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
|
||||
//$return_array[] = array('form' => $paypal_form);
|
||||
|
||||
//return the form
|
||||
//return the page
|
||||
return $return_array;
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ function booking_confirm_page() {
|
||||
$already_paid = false;
|
||||
$paypal_form = "";
|
||||
$uuid = arg(1);
|
||||
$payment_processor_type = variable_get('booking_payment_processor', 0);
|
||||
|
||||
//verify that arg(1) is a uuid
|
||||
if (! preg_match('/^[0-9A-Fa-f\-]+$/', $uuid)) {
|
||||
@@ -31,7 +32,9 @@ function booking_confirm_page() {
|
||||
|
||||
if ($person) {
|
||||
//load all the fields
|
||||
$node = node_load($person->nid);
|
||||
$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);
|
||||
@@ -44,13 +47,20 @@ function booking_confirm_page() {
|
||||
|
||||
//populate tokens
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
//add in the paypal forms as tokens
|
||||
$tokens['paypal-deposit-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-deposit-amount'], "Pay Deposit");
|
||||
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Full Amount");
|
||||
|
||||
//watchdog('booking', 'Paypal form "@info"', array ('@info' => var_export($tokens['paypal-total-form'], TRUE)));
|
||||
|
||||
|
||||
//if paypal is enabled then add tokens for it
|
||||
if ($payment_processor_type == 0) {
|
||||
$tokens['paypal-deposit-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-deposit-amount'], "Pay Deposit");
|
||||
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Full Amount");
|
||||
//watchdog('booking', 'Paypal form "@info"', array ('@info' => var_export($tokens['paypal-total-form'], TRUE)));
|
||||
}
|
||||
//if stripe is enabled
|
||||
elseif ($payment_processor_type == 1) {
|
||||
//@todo confirm that the deposit amount is correct for a stripe deposit
|
||||
$tokens['stripe-deposit-form'] = _booking_stripe_form($node, $invoiceid, $tokens['stripe-deposit-amount'], "Pay Deposit");
|
||||
$tokens['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['payment-required'], "Pay Balance");
|
||||
}
|
||||
|
||||
//check if this registration will be on the waiting list
|
||||
if (_booking_check_bookings_full() == True || $node->booking_status == 2) {
|
||||
$waiting_list = TRUE;
|
||||
|
@@ -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
|
||||
@@ -186,13 +227,13 @@ function _booking_readinggroup_colour_lookup($input = NULL)
|
||||
$group[] = t('Beige');
|
||||
$group[] = t('Maroon');
|
||||
$group[] = t('Pink');
|
||||
$group[] = t('Black');
|
||||
$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');
|
||||
|
232
booking.earlyaccess_admin.inc
Normal file
232
booking.earlyaccess_admin.inc
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin pages for managing early access codes
|
||||
*/
|
||||
|
||||
// @todo - list all early access codes for the current event, whether they're available, and who used them if not
|
||||
|
||||
|
||||
/**
|
||||
* Function to summarise information about early access codes
|
||||
*/
|
||||
function booking_earlyaccess_admin() {
|
||||
global $event;
|
||||
$output = "";
|
||||
$rows = array();
|
||||
$attributes = array('style' => 'max-width:60%', 'id' => 'sort-table');
|
||||
$prefix = t("<h2>Early Access Codes</h2>");
|
||||
|
||||
$header = array(
|
||||
'booking_earlyaccess_code' => array('data' => t('Code'), 'field' => 'c.booking_earlyaccess_code', 'sort' => 'asc'),
|
||||
'booking_earlyaccess_code_avail' => array('data' => t('Available?'), 'field' => 'c.booking_earlyaccess_code_avail'),
|
||||
'booking_firstname' => array('data' => t('First Name'), 'field' => 'p.booking_firstname'),
|
||||
'booking_lastname' => array('data' => t('Last Name'), 'field' => 'p.booking_lastname'),
|
||||
);
|
||||
|
||||
//get a list of all the early access codes for this event
|
||||
$codelist_query = db_select('booking_earlyaccess_codes', 'c');
|
||||
$codelist_query->leftJoin('booking_person', 'p', 'c.cid = p.booking_earlyaccess_code_id');
|
||||
$codelist_query->condition('c.booking_eventid', $event->eid, '=')
|
||||
->fields('c')
|
||||
->fields('p')
|
||||
->orderBy('cid');
|
||||
$result = $codelist_query->execute();
|
||||
|
||||
//add results to array
|
||||
foreach($result as $data) {
|
||||
$rows[] = array(
|
||||
'data' => array(
|
||||
$data->booking_earlyaccess_code,
|
||||
$data->booking_earlyaccess_code_avail == 'Y' ? 'Yes' : 'No',
|
||||
$data->booking_firstname,
|
||||
$data->booking_lastname,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//theme output
|
||||
$output = array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'table' => array (
|
||||
'#theme' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#attributes' => $attributes,
|
||||
//'#sticky' => FALSE,
|
||||
)
|
||||
);
|
||||
|
||||
//return markup array
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate early access codes for the current event
|
||||
*/
|
||||
function booking_earlyaccess_generate_codes() {
|
||||
global $event;
|
||||
$num_codes_to_add = 0;
|
||||
$num_codes_available = 0;
|
||||
$code_length = 7;
|
||||
|
||||
//determine number of currently available access codes for this event
|
||||
$codecount_query = db_query("SELECT count(*) as num_codes FROM {booking_earlyaccess_codes} where booking_eventid = :eventid and booking_earlyaccess_code_avail = 'Y'",
|
||||
array(':eventid' => $event->eid))
|
||||
->fetchObject();
|
||||
$num_codes_available = $codecount_query->num_codes;
|
||||
//get the number of codes we need to have available from variable_get('booking_earlyaccess_codes_count')
|
||||
$num_codes_to_add = variable_get('booking_earlyaccess_codes_count', 0) - $num_codes_available;
|
||||
//add required number of codes to database table
|
||||
watchdog('booking_debug', "Creating $num_codes_to_add early access codes.");
|
||||
|
||||
//use the multi-insert query type at https://drupal.org/node/310079
|
||||
$insert_query = db_insert('booking_earlyaccess_codes')
|
||||
->fields(array(
|
||||
'booking_eventid',
|
||||
'booking_earlyaccess_code',
|
||||
'booking_earlyaccess_code_avail',
|
||||
));
|
||||
|
||||
for ($i = 0; $i < $num_codes_to_add; $i++) {
|
||||
$insert_query->values(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_earlyaccess_code' => booking_getToken($code_length),
|
||||
'booking_earlyaccess_code_avail' => 'Y',
|
||||
));
|
||||
}
|
||||
$insert_query->execute();
|
||||
return t("Created $num_codes_to_add early access codes.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate csv of early access codes for the current event
|
||||
*/
|
||||
function booking_earlyaccess_csv_report() {
|
||||
global $event;
|
||||
$data = array();
|
||||
$header_array = array();
|
||||
//set options for the CSV file
|
||||
$name = 'bookings-earlyaccesscodes-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||
$filename = file_directory_temp() . '/' . $name;
|
||||
$csv = '';
|
||||
$delimiter = ',';
|
||||
$enclosure = '"';
|
||||
$encloseAll = true;
|
||||
$nullToMysqlNull = true;
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
|
||||
//get a list of all the early access codes for this event
|
||||
$codelist_query = db_select('booking_earlyaccess_codes', 'c');
|
||||
$codelist_query->condition('c.booking_eventid', $event->eid, '=')
|
||||
->fields('c', array('booking_earlyaccess_code', 'booking_earlyaccess_code_avail'))
|
||||
->orderBy('cid');
|
||||
$result = $codelist_query->execute();
|
||||
|
||||
foreach ($result as $record) {
|
||||
foreach ($record as $key => $value) {
|
||||
$header_array[] = $key;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//calculate the header row for CSV
|
||||
$header = implode($delimiter, $header_array);
|
||||
$csv .= $header . "\n";
|
||||
|
||||
//add the records
|
||||
reset($result);
|
||||
foreach ($result as $record) {
|
||||
$output = array();
|
||||
//each keypair in the record
|
||||
foreach ($record as $key => $value) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
$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;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to calculate unique code
|
||||
* @see https://stackoverflow.com/questions/1846202/php-how-to-generate-a-random-unique-alphanumeric-string
|
||||
* Requires PHP7
|
||||
*/
|
||||
function booking_getToken($length) {
|
||||
$token = "";
|
||||
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
//$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
|
||||
$codeAlphabet.= "0123456789";
|
||||
$max = strlen($codeAlphabet); // edited
|
||||
|
||||
if (!function_exists('random_int')) {
|
||||
function random_int($min, $max) {
|
||||
if (!function_exists('mcrypt_create_iv')) {
|
||||
trigger_error(
|
||||
'mcrypt must be loaded for random_int to work',
|
||||
E_USER_WARNING
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_int($min) || !is_int($max)) {
|
||||
trigger_error('$min and $max must be integer values', E_USER_NOTICE);
|
||||
$min = (int)$min;
|
||||
$max = (int)$max;
|
||||
}
|
||||
|
||||
if ($min > $max) {
|
||||
trigger_error('$max can\'t be lesser than $min', E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
|
||||
$range = $counter = $max - $min;
|
||||
$bits = 1;
|
||||
|
||||
while ($counter >>= 1) {
|
||||
++$bits;
|
||||
}
|
||||
|
||||
$bytes = (int)max(ceil($bits/8), 1);
|
||||
$bitmask = pow(2, $bits) - 1;
|
||||
|
||||
if ($bitmask >= PHP_INT_MAX) {
|
||||
$bitmask = PHP_INT_MAX;
|
||||
}
|
||||
|
||||
do {
|
||||
$result = hexdec(
|
||||
bin2hex(
|
||||
mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
|
||||
)
|
||||
) & $bitmask;
|
||||
} while ($result > $range);
|
||||
|
||||
return $result + $min;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0; $i < $length; $i++) {
|
||||
$token .= $codeAlphabet[random_int(0, $max-1)];
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
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.");
|
||||
}
|
@@ -1,12 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper function to put together all the information for theming a HTML based email, if enabled
|
||||
*
|
||||
* @param
|
||||
* @return themed message text
|
||||
*/
|
||||
function _booking_generate_html_body($subject, $body, $tokens) {
|
||||
global $event;
|
||||
$output_text = "";
|
||||
|
||||
//Check if we should apply a HTML theme to the email text or just send a normal email
|
||||
if (variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
//get the footer text
|
||||
$message_footer = variable_get('booking_html_mail_footer');
|
||||
$message_footer = isset($message_footer['format']) ? $message_footer['value'] : $message_footer;
|
||||
$message_footer = token_replace($message_footer, $tokens);
|
||||
|
||||
$colors = json_decode(variable_get('booking_mailtemplate_colors'), TRUE);
|
||||
$header_links = json_decode(variable_get('booking_mailtemplate_header_links'), TRUE);
|
||||
$social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE);
|
||||
|
||||
$output_text = theme('booking_htmlmail_registration_mail',
|
||||
array(
|
||||
'module' => 'booking',
|
||||
'key' => 'registration_mail',
|
||||
'body' => $body,
|
||||
'subject' => $subject,
|
||||
'footer' => $message_footer,
|
||||
'colors' => $colors,
|
||||
'header_links' => $header_links,
|
||||
'social_links' => $social_links,
|
||||
));
|
||||
}
|
||||
else {
|
||||
$output_text = $body;
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', "<pre>HTML body themed\n@info</pre>", array('@info' => print_r($output_text, true)));
|
||||
return $output_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to send email to registrant after completing registration process
|
||||
*
|
||||
* @param $nid - the node id relating to the registration node
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
||||
function _booking_registration_email($nid, $balance_payment, $manual = false) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
@@ -17,8 +58,10 @@
|
||||
|
||||
//load the node matching this id
|
||||
$node = node_load($nid);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
watchdog('booking', 'Sending registration email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
watchdog('booking', 'Sending registration email to !first !last',
|
||||
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
|
||||
//waiting list has already been calculated, stored in node
|
||||
$waiting_list = $node->booking_status == 2 ? TRUE : FALSE;
|
||||
@@ -28,34 +71,36 @@
|
||||
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
|
||||
//send the registering person an email
|
||||
//calculate fields for email to be sent
|
||||
$to = $node->booking_email;
|
||||
$body = _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual);
|
||||
if ($balance_payment == TRUE)
|
||||
$subject = t('!event Payment Complete', array('!event' => $event->booking_eventname));
|
||||
else
|
||||
$subject = t('!event Registration', array('!event' => $event->booking_eventname));
|
||||
|
||||
if ($balance_payment == TRUE) {
|
||||
$subject = t('!event Payment Complete', array('!event' => $event->booking_eventname));
|
||||
}
|
||||
else {
|
||||
$subject = t('!event Registration', array('!event' => $event->booking_eventname));
|
||||
}
|
||||
$params['subject'] = $subject;
|
||||
$params['body'] = $body;
|
||||
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
|
||||
$raw_body = _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual);
|
||||
$themed_body = _booking_generate_html_body($subject, $raw_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//send the email to the person
|
||||
drupal_mail('booking', 'registration_mail', $to, $language, $params, $from);
|
||||
//drupal_mail('booking', 'registration_mail', 'it@coadcorp.com', $language, $params, $from);
|
||||
|
||||
//send a notification email if we didn't automatically send one earlier
|
||||
if (variable_get('booking_auto_confirm_email', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_auto_confirm_email', 0) == 1) {
|
||||
_booking_regn_notifyonly_email($node, $balance_payment);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to send notification email only, nothing to the end user
|
||||
@@ -63,14 +108,14 @@
|
||||
* @param $node - variable representing the booking node
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_regn_notifyonly_email($node, $balance_payment)
|
||||
{
|
||||
function _booking_regn_notifyonly_email($node, $balance_payment) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
watchdog('booking', 'Sending notification email about !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
watchdog('booking', 'Sending notification email about !first !last',
|
||||
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
|
||||
//calculate the from email address
|
||||
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
||||
@@ -80,19 +125,28 @@
|
||||
//just put the registration info in this email to notify the appropriate people
|
||||
$to = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
|
||||
if ($balance_payment == TRUE)
|
||||
$params['subject'] = t('Registration Fully Paid: !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
else
|
||||
$params['subject'] = t('New Registration: !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
|
||||
//$params['body'] = _booking_details_email_summary($node);
|
||||
$params['body'] = token_replace(variable_get('booking_email_notification_text'), $tokens);
|
||||
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if ($balance_payment == TRUE) {
|
||||
$subject = t('Registration Fully Paid: !first !last',
|
||||
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
}
|
||||
else {
|
||||
$subject = t('New Registration: !first !last',
|
||||
array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
}
|
||||
$params['subject'] = $subject;
|
||||
|
||||
$message_body = variable_get('booking_email_notification_text');
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
drupal_mail('booking', 'registration_mail_notify', $to, $language, $params, $from);
|
||||
@@ -106,27 +160,30 @@
|
||||
* @param $waiting_list - whether this registration is on on the waiting list
|
||||
* @return array containing email text
|
||||
*/
|
||||
function _booking_registration_email_generate($node, $waiting_list, $balance_payment, $manual) {
|
||||
|
||||
function _booking_registration_email_generate($node, $tokens, $waiting_list, $balance_payment, $manual) {
|
||||
global $event;
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
//$tokens = booking_define_personspecific_tokens($node);
|
||||
$body = "";
|
||||
|
||||
if ($balance_payment == True)
|
||||
{
|
||||
$contact_message = token_replace(variable_get('booking_email_regn_complete_text'), $tokens);
|
||||
if ($balance_payment == True) {
|
||||
$body = variable_get('booking_email_regn_complete_text');
|
||||
//$contact_message = token_replace(variable_get('booking_email_regn_complete_text'), $tokens);
|
||||
}
|
||||
elseif ($waiting_list == False)
|
||||
{
|
||||
$contact_message = token_replace(variable_get('booking_email_bookedin_text'), $tokens);
|
||||
elseif ($waiting_list == False) {
|
||||
$body = variable_get('booking_email_bookedin_text');
|
||||
//$contact_message = token_replace(variable_get('booking_email_bookedin_text'), $tokens);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//booking is on the waiting list
|
||||
$contact_message = token_replace(variable_get('booking_email_waitinglist_text'), $tokens);
|
||||
$body = variable_get('booking_email_waitinglist_text');
|
||||
//$contact_message = token_replace(variable_get('booking_email_waitinglist_text'), $tokens);
|
||||
}
|
||||
|
||||
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$body = isset($body['format']) ? $body['value'] : $body;
|
||||
//watchdog('booking_debug', "<pre>Email generation:\n@info</pre>", array('@info' => print_r( $body, true)));
|
||||
//$contact_message .= "\n\n" . t("!details", array('!details' => _booking_details_email_summary($node)));
|
||||
return $contact_message;
|
||||
return token_replace($body, $tokens);
|
||||
|
||||
}
|
||||
|
||||
@@ -136,19 +193,21 @@
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_balance_payment_email($nid)
|
||||
{
|
||||
function _booking_balance_payment_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
$language = user_preferred_language($user);
|
||||
$message_body = "";
|
||||
|
||||
//load the node matching this id
|
||||
$node = node_load($nid);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
if ($tokens['payment-required'] <= 0)
|
||||
{
|
||||
watchdog('booking', "Not sending amount owing email, since this person doesn't owe any money: @info", array('@info' => var_export($node, TRUE)));
|
||||
if ($tokens['payment-required'] <= 0) {
|
||||
drupal_set_message(t("Ignore below status - didn't send unnecessary balance outstanding email to: !person",
|
||||
array('!person' => $node->booking_firstname . ' ' . $node->booking_lastname)));
|
||||
watchdog('booking', "Not sending amount owing email, since this person doesn't owe any money: @info",
|
||||
array('@info' => var_export($node, TRUE)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,31 +217,33 @@ function _booking_balance_payment_email($nid)
|
||||
));
|
||||
|
||||
//calculate the remaining parameters
|
||||
$to = $node->booking_email;
|
||||
//$subject = t('!event Payment Required', array('!event' => $event->booking_eventname));
|
||||
//$params['subject'] = $subject;
|
||||
$params['subject'] = token_replace(variable_get('booking_email_paymentoutstanding_subject',
|
||||
$to = $node->booking_email;
|
||||
$subject = token_replace(variable_get('booking_email_paymentoutstanding_subject',
|
||||
t('!event Payment Required', array('!event' => $event->booking_eventname))), $tokens);
|
||||
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//retrieve the body of the email for a married couple only if we're combining pricing for couples
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $node->booking_partner_id > 0)
|
||||
{
|
||||
watchdog('booking', "Sending the married-couple specific outstanding balance email for this person: @info", array('@info' => var_export($node, TRUE)));
|
||||
$params['body'] = token_replace(variable_get('booking_email_paymentoutstanding_married_text'), $tokens);
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $node->booking_partner_id > 0) {
|
||||
watchdog('booking', "Sending the married-couple specific outstanding balance email for this person: @info",
|
||||
array('@info' => var_export($node, TRUE)));
|
||||
$message_body = variable_get('booking_email_paymentoutstanding_married_text');
|
||||
}
|
||||
//otherwise retrieve the body of the email for individuals
|
||||
else
|
||||
{
|
||||
$params['body'] = token_replace(variable_get('booking_email_paymentoutstanding_text'), $tokens);
|
||||
else {
|
||||
$message_body = variable_get('booking_email_paymentoutstanding_text');
|
||||
}
|
||||
|
||||
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['subject'] = $subject;
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -192,8 +253,7 @@ function _booking_balance_payment_email($nid)
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_partialbalance_payment_email($nid)
|
||||
{
|
||||
function _booking_partialbalance_payment_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
@@ -202,8 +262,7 @@ function _booking_partialbalance_payment_email($nid)
|
||||
$node = node_load($nid);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
if ($tokens['payment-required'] <= 0)
|
||||
{
|
||||
if ($tokens['payment-required'] <= 0) {
|
||||
watchdog('booking', "Not sending amount owing email, since this person doesn't owe any money: @info", array('@info' => var_export($node, TRUE)));
|
||||
return;
|
||||
}
|
||||
@@ -217,19 +276,23 @@ function _booking_partialbalance_payment_email($nid)
|
||||
$to = $node->booking_email;
|
||||
$subject = t('!event Partial Payment Received', array('!event' => $event->booking_eventname));
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//TODO: Married couple version of this
|
||||
$params['body'] = token_replace(variable_get('booking_email_partialpayment_received_text'), $tokens);
|
||||
|
||||
|
||||
$message_body = variable_get('booking_email_partialpayment_received_text');
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
|
||||
//$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
drupal_mail('booking', 'registration_mail_bal_outstanding', $to, $language, $params, $from);
|
||||
}
|
||||
|
||||
|
||||
@@ -240,11 +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;
|
||||
@@ -256,7 +319,8 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact')
|
||||
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
} elseif ($sender == 'logistics') {
|
||||
}
|
||||
elseif ($sender == 'logistics') {
|
||||
watchdog('booking_debug', "<pre>Custom logistics email\n@subject\n@body</pre>",
|
||||
array('@subject' => $email_subject_variable, '@body' => $email_body_variable));
|
||||
//calculate the from email address for a logistics email
|
||||
@@ -273,16 +337,30 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact')
|
||||
$to = $node->booking_email;
|
||||
$subject = token_replace(variable_get($email_subject_variable, t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get($email_body_variable), $tokens);
|
||||
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//get the matching message text and replace any tokens needed
|
||||
$message_body = variable_get($email_body_variable);
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$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);
|
||||
}
|
||||
@@ -292,15 +370,13 @@ function _booking_custom_email($nid, $email_type, $sender = 'contact')
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_promoted_from_waitinglist_email($nid)
|
||||
{
|
||||
function _booking_promoted_from_waitinglist_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending promoted-from-waitinglist email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
@@ -318,16 +394,28 @@ function _booking_promoted_from_waitinglist_email($nid)
|
||||
$to = $node->booking_email;
|
||||
$subject = t('!event Position Available', array('!event' => $event->booking_eventname));
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_waitinglistpromotion'), $tokens);
|
||||
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
if ($tokens['payment-required'] == 0) {
|
||||
watchdog('booking_debug', 'This person has fully paid so sending promoted-from-waitinglist-fullypaid email.');
|
||||
$message_body = variable_get('booking_email_waitinglistpromotion_fullypaid');
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', 'This person has an outstanding balance of ' . $tokens['payment-required']);
|
||||
$message_body = variable_get('booking_email_waitinglistpromotion');
|
||||
}
|
||||
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -337,15 +425,13 @@ function _booking_promoted_from_waitinglist_email($nid)
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_demoted_to_notcoming_email($nid)
|
||||
{
|
||||
function _booking_demoted_to_notcoming_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending not-coming email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
@@ -364,16 +450,21 @@ function _booking_demoted_to_notcoming_email($nid)
|
||||
$subject = token_replace(variable_get('booking_email_notcoming_demotion_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
//$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname));
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_notcoming_demotion'), $tokens);
|
||||
|
||||
$message_body = variable_get('booking_email_notcoming_demotion');
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -383,15 +474,13 @@ function _booking_demoted_to_notcoming_email($nid)
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_missedpayment_email($nid)
|
||||
{
|
||||
function _booking_missedpayment_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending missed-payment email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
@@ -410,15 +499,21 @@ function _booking_missedpayment_email($nid)
|
||||
$subject = token_replace(variable_get('booking_email_missedpayment_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
//$subject = t('!event withdrawal confirmation', array('!event' => $event->booking_eventname));
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_missedpayment'), $tokens);
|
||||
|
||||
$message_body = variable_get('booking_email_missedpayment');
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -428,15 +523,13 @@ function _booking_missedpayment_email($nid)
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_travelform_initial_request_email($nid)
|
||||
{
|
||||
function _booking_travelform_initial_request_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending travelform initial request email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
@@ -455,16 +548,21 @@ function _booking_travelform_initial_request_email($nid)
|
||||
$subject = token_replace(variable_get('booking_email_travel_initial_email_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_travel_initial_email_text'), $tokens);
|
||||
|
||||
$message_body = variable_get('booking_email_travel_initial_email_text');
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -475,15 +573,13 @@ function _booking_travelform_initial_request_email($nid)
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_travelform_reminder_request_email($nid)
|
||||
{
|
||||
function _booking_travelform_reminder_request_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending travelform reminder request email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
@@ -502,16 +598,21 @@ function _booking_travelform_reminder_request_email($nid)
|
||||
$subject = token_replace(variable_get('booking_email_travel_reminder_email_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_travel_reminder_email_text'), $tokens);
|
||||
|
||||
$message_body = variable_get('booking_email_travel_reminder_email_text');
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
@@ -522,15 +623,13 @@ function _booking_travelform_reminder_request_email($nid)
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_travelform_confirmation_email($nid)
|
||||
{
|
||||
function _booking_travelform_confirmation_email($nid) {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//return without doing anything if we shouldn't send workflow emails
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0)
|
||||
{
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending travelform confirmation email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
@@ -552,16 +651,21 @@ function _booking_travelform_confirmation_email($nid)
|
||||
//$subject = t('!event Travel Details Received', array('!event' => $event->booking_eventname));
|
||||
|
||||
$params['subject'] = $subject;
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1)
|
||||
{
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com, " . variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
} else {
|
||||
$params['headers']['Bcc'] = "it@coadcorp.com";
|
||||
if (variable_get('booking_bcc_notify_email_workflow', 0) == 1) {
|
||||
$params['headers']['Bcc'] = variable_get('booking_notify_email', variable_get('site_mail', ini_get('sendmail_from')));
|
||||
}
|
||||
|
||||
else {
|
||||
$params['headers']['Bcc'] = BOOKING_EMAIL_DEV_NOTIFY;
|
||||
}
|
||||
|
||||
//retrieve the body of the email
|
||||
$params['body'] = token_replace(variable_get('booking_email_travel_complete_text'), $tokens);
|
||||
|
||||
$message_body = variable_get('booking_email_travel_complete_text');
|
||||
//Use the value of the field if it is an array from a HTML textarea
|
||||
$message_body = isset($message_body['format']) ? $message_body['value'] : $message_body;
|
||||
$message_body = token_replace($message_body, $tokens);
|
||||
$themed_body = _booking_generate_html_body($subject, $message_body, $tokens);
|
||||
$params['body'] = $themed_body;
|
||||
|
||||
//send the email
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
|
||||
function booking_emails_admin() {
|
||||
/**
|
||||
* Function to allow admin user to define contents of workflow emails that can be sent by Bookings module
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_emails_workflow_admin() {
|
||||
global $event;
|
||||
$form = array();
|
||||
//some initial workflow email definitions
|
||||
@@ -45,8 +51,22 @@ function booking_emails_admin() {
|
||||
"and you will not receive the confirmation email until that has occurred.\n" .
|
||||
"Please don't hesitate to contact us if you have any queries by replying to this email. We look forward to seeing you, God Willing, at [booking:eventname]\n" .
|
||||
"Love in Jesus,\n[booking:eventname] Registrations Team.";
|
||||
$booking_email_waitinglistpromotion_fullypaid = "Dear [booking:fname],\n" .
|
||||
"We have some great news for you. A place at [booking:eventname] for you has just become available. " .
|
||||
"Our records indicate that you have already fully paid, so there is nothing further needed to secure your spot.\n" .
|
||||
"Please don't hesitate to contact us if you have any queries by replying to this email. We look forward to seeing you, God Willing, at [booking:eventname]\n" .
|
||||
"Love in Jesus,\n[booking:eventname] Registrations Team.";
|
||||
$booking_email_notcoming_demotion = "";
|
||||
$booking_email_paymentoutstanding_married_text = "";
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form_type = 'text_format';
|
||||
$form_format = 'full_html';
|
||||
}
|
||||
else {
|
||||
$form_type = 'textarea';
|
||||
$form_format = NULL;
|
||||
}
|
||||
|
||||
//include the token definitions
|
||||
$form['tokens'] = array(
|
||||
@@ -59,44 +79,55 @@ function booking_emails_admin() {
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Built-In Workflow Email Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
//if HTML mail is enabled, allow user to specify footer
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form['emails']['booking_html_mail_footer'] = array(
|
||||
'#title' => t('Footer text for HTML email'),
|
||||
'#description' => t('Enter HTML to go in the footer of the email template (above the social media icons).<br /><strong>NOTE:</strong> No token subsitutions will be made here.'),
|
||||
'#default_value' => isset(variable_get('booking_html_mail_footer')['value']) ? variable_get('booking_html_mail_footer')['value'] : variable_get('booking_html_mail_footer', '<p> </p>'),
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
}
|
||||
$form['emails']['booking_email_notification_text'] = array(
|
||||
'#title' => t('Notification Email'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#description' => t('Email to send to the notification email address (defined in general configuration) when a person has registered'),
|
||||
'#default_value' => variable_get('booking_email_notification_text', '[booking:regn-summary]'),
|
||||
'#default_value' => isset(variable_get('booking_email_notification_text')['value']) ? variable_get('booking_email_notification_text')['value'] : variable_get('booking_email_notification_text', '[booking:regn-summary]'),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_bookedin_text'] = array(
|
||||
'#title' => t('Registration Successful Email'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#description' => t('Text to use in an email indicating the person has booked in, paid their deposit and is not on the waiting list'),
|
||||
'#default_value' => variable_get('booking_email_bookedin_text', $default_email_text),
|
||||
'#default_value' => isset(variable_get('booking_email_bookedin_text')['value']) ? variable_get('booking_email_bookedin_text')['value'] : variable_get('booking_email_bookedin_text', $default_email_text),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_regn_complete_text'] = array(
|
||||
'#title' => t('Payment Complete Email'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#description' => t('Email text to indicate a person has booked in, fully paid and is not on the waiting list. ' .
|
||||
'This will be sent either at initial registration if the full amount is paid, or when the balance is paid.'),
|
||||
'#default_value' => variable_get('booking_email_regn_complete_text', $booking_email_regn_complete_text),
|
||||
'#default_value' => isset(variable_get('booking_email_regn_complete_text')['value']) ? variable_get('booking_email_regn_complete_text')['value'] : variable_get('booking_email_regn_complete_text', $booking_email_regn_complete_text),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_waitinglist_text'] = array(
|
||||
'#title' => t('Registration on Waiting List Email'),
|
||||
'#description' => t('Email text to indicate a person has registered but is on the waiting list. ' .
|
||||
'This will be sent instead of the Registration Successful or Registration Complete emails if the person is on the waiting list.'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#default_value' => variable_get('booking_email_waitinglist_text', $booking_email_waitinglist_text),
|
||||
'#default_value' => isset(variable_get('booking_email_waitinglist_text')['value']) ? variable_get('booking_email_waitinglist_text')['value'] : variable_get('booking_email_waitinglist_text', $booking_email_waitinglist_text),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_partialpayment_received_text'] = array(
|
||||
'#title' => t('Email text to send a person thanking them for their partial payment'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_email_partialpayment_received_text', ''),
|
||||
'#default_value' => isset(variable_get('booking_email_partialpayment_received_text')['value']) ? variable_get('booking_email_partialpayment_received_text')['value'] : variable_get('booking_email_partialpayment_received_text', ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_paymentoutstanding_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -108,25 +139,35 @@ function booking_emails_admin() {
|
||||
);
|
||||
$form['emails']['booking_email_paymentoutstanding_text'] = array(
|
||||
'#description' => t('Email text to send a person reminding them of how much they owe'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#title' => t('Balance Outstanding Email Text'),
|
||||
'#default_value' => variable_get('booking_email_paymentoutstanding_text', $booking_email_paymentoutstanding_text),
|
||||
'#default_value' => isset(variable_get('booking_email_paymentoutstanding_text')['value']) ? variable_get('booking_email_paymentoutstanding_text')['value'] : variable_get('booking_email_paymentoutstanding_text', $booking_email_paymentoutstanding_text),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
|
||||
$form['emails']['booking_email_paymentoutstanding_married_text'] = array(
|
||||
'#title' => t('Email text to send a married couple reminding them of how much they both owe (only applies when combined pricing enabled)'),
|
||||
'#type' => 'textarea',
|
||||
//'#format' => 'full_html',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_email_paymentoutstanding_married_text', $booking_email_paymentoutstanding_married_text),
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_email_paymentoutstanding_married_text')['value']) ? variable_get('booking_email_paymentoutstanding_married_text')['value'] : variable_get('booking_email_paymentoutstanding_married_text', $booking_email_paymentoutstanding_married_text),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_waitinglistpromotion'] = array(
|
||||
'#title' => t('Email text to send a person on the waiting list when a spot opens up for them'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_email_waitinglistpromotion', $booking_email_waitinglistpromotion),
|
||||
'#title' => t('Email text to send a person on the waiting list when a spot opens up for them but they have an outstanding balance.'),
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_email_waitinglistpromotion')['value']) ? variable_get('booking_email_waitinglistpromotion')['value'] : variable_get('booking_email_waitinglistpromotion', $booking_email_waitinglistpromotion),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_waitinglistpromotion_fullypaid'] = array(
|
||||
'#title' => t('Email text to send a person on the waiting list when a spot opens up for them and they have already fully paid.'),
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_email_waitinglistpromotion_fullypaid')['value']) ?
|
||||
variable_get('booking_email_waitinglistpromotion_fullypaid')['value'] :
|
||||
variable_get('booking_email_waitinglistpromotion_fullypaid', $booking_email_waitinglistpromotion_fullypaid),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_notcoming_demotion_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Withdrawal Processed Email'),
|
||||
@@ -137,9 +178,10 @@ function booking_emails_admin() {
|
||||
);
|
||||
$form['emails']['booking_email_notcoming_demotion'] = array(
|
||||
'#title' => t('Email text to send a person who withdraws their registration'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_email_notcoming_demotion', $booking_email_notcoming_demotion),
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_email_notcoming_demotion')['value']) ? variable_get('booking_email_notcoming_demotion')['value'] : variable_get('booking_email_notcoming_demotion', $booking_email_notcoming_demotion),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_missedpayment_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -151,9 +193,10 @@ function booking_emails_admin() {
|
||||
);
|
||||
$form['emails']['booking_email_missedpayment'] = array(
|
||||
'#title' => t('Missed Payment Email Text'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t('Email text to send a person who missed the payment deadline'),
|
||||
'#default_value' => variable_get('booking_email_missedpayment', ''),
|
||||
'#default_value' => isset(variable_get('booking_email_missedpayment')['value']) ? variable_get('booking_email_missedpayment')['value'] : variable_get('booking_email_missedpayment', ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_travel_initial_email_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -166,8 +209,9 @@ function booking_emails_admin() {
|
||||
$form['emails']['booking_email_travel_initial_email_text'] = array(
|
||||
'#title' => t('Initial Travel Form Required Text'),
|
||||
'#description' => t('Text for first email requesting attendee to complete the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))),
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => variable_get('booking_email_travel_initial_email_text', ''),
|
||||
'#default_value' => isset(variable_get('booking_email_travel_initial_email_text')['value']) ? variable_get('booking_email_travel_initial_email_text')['value'] : variable_get('booking_email_travel_initial_email_text', ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_travel_reminder_email_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -180,8 +224,9 @@ function booking_emails_admin() {
|
||||
$form['emails']['booking_email_travel_reminder_email_text'] = array(
|
||||
'#title' => t('Reminder Travel Form Required Text'),
|
||||
'#description' => t('Text for reminder email requesting attendee to complete the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))),
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => variable_get('booking_email_travel_reminder_email_text', ''),
|
||||
'#default_value' => isset(variable_get('booking_email_travel_reminder_email_text')['value']) ? variable_get('booking_email_travel_reminder_email_text')['value'] : variable_get('booking_email_travel_reminder_email_text', ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
$form['emails']['booking_email_travel_complete_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
@@ -194,8 +239,215 @@ function booking_emails_admin() {
|
||||
$form['emails']['booking_email_travel_complete_text'] = array(
|
||||
'#title' => t('Travel Form Complete Text'),
|
||||
'#description' => t('Email text to indicate a person has completed the travel form. This email will be sent from the !email email address', array('!email' => variable_get('booking_logistics_email'))),
|
||||
'#type' => 'textarea',
|
||||
'#default_value' => variable_get('booking_email_travel_complete_text', ''),
|
||||
'#default_value' => isset(variable_get('booking_email_travel_complete_text')['value']) ? variable_get('booking_email_travel_complete_text')['value'] : variable_get('booking_email_travel_complete_text', ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
|
||||
//let the builtin hook do all the hard work
|
||||
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
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_emails_custom_admin() {
|
||||
global $event;
|
||||
$form = array();
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form_type = 'text_format';
|
||||
$form_format = 'full_html';
|
||||
}
|
||||
else {
|
||||
$form_type = 'textarea';
|
||||
$form_format = NULL;
|
||||
}
|
||||
|
||||
//include the token definitions
|
||||
$form['tokens'] = array(
|
||||
'#theme' => 'token_tree',
|
||||
'#token_types' => array('booking'),
|
||||
);
|
||||
|
||||
/*Text for emails*/
|
||||
@@ -203,7 +455,7 @@ function booking_emails_admin() {
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Custom Email Text Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
@@ -219,18 +471,47 @@ function booking_emails_admin() {
|
||||
);
|
||||
$form['custom-emails'][$body_fieldname] = array(
|
||||
'#title' => t('Email text for custom email ' . $i),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get($body_fieldname, ''),
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get($body_fieldname)['value']) ? variable_get($body_fieldname)['value'] : variable_get($body_fieldname, ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
}
|
||||
}
|
||||
//let the builtin hook do all the hard work
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to allow admin user to define custom logistics emails that can be sent by Bookings module, from the logistics email address
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_emails_customlogistics_admin() {
|
||||
global $event;
|
||||
$form = array();
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form_type = 'text_format';
|
||||
$form_format = 'full_html';
|
||||
}
|
||||
else {
|
||||
$form_type = 'textarea';
|
||||
$form_format = NULL;
|
||||
}
|
||||
|
||||
//include the token definitions
|
||||
$form['tokens'] = array(
|
||||
'#theme' => 'token_tree',
|
||||
'#token_types' => array('booking'),
|
||||
);
|
||||
|
||||
/*Text for logistics emails*/
|
||||
$form['custom-logistics-emails'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Custom Logistics Email Text Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
@@ -247,452 +528,12 @@ function booking_emails_admin() {
|
||||
);
|
||||
$form['custom-logistics-emails'][$body_fieldname] = array(
|
||||
'#title' => t('Email text for Logistics Custom Email ' . $i),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get($body_fieldname, ''),
|
||||
'#default_value' => isset(variable_get($body_fieldname)['value']) ? variable_get($body_fieldname)['value'] : variable_get($body_fieldname, ''),
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
//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['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['bookedin'] = 'People who are booked-in';
|
||||
$preselection_options['waitinglist'] = 'People on waiting list';
|
||||
$preselection_options['unpaid'] = 'People booked-in with outstanding balance';
|
||||
$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'),
|
||||
'travel_form' => array('data' => t('Travel Submitted?'), 'field' => 'tid'),
|
||||
);
|
||||
|
||||
//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'),
|
||||
);
|
||||
|
||||
//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;
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3><pre>";
|
||||
$markup_post = "</pre><br /><br /></div>";
|
||||
$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');
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1) {
|
||||
$text .= "\n</pre><h3>If married</h3>\n<pre>" . variable_get('booking_email_paymentoutstanding_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;
|
||||
}
|
||||
//handle custom email types
|
||||
if (strpos($emailtype, 'custom') !== false) {
|
||||
$text = variable_get('booking_email_' . $form_state['values']['email-type']);
|
||||
}
|
||||
|
||||
//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 'bookedin':
|
||||
if ($person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'waitinglist':
|
||||
if ($person->booking_status == 2) {
|
||||
$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 (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.");
|
||||
return system_settings_form($form, FALSE);
|
||||
}
|
||||
|
@@ -8,15 +8,15 @@
|
||||
function booking_event_admin()
|
||||
{
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
$form = array();
|
||||
$options = array();
|
||||
$prefix = t("<p>!link</p>",
|
||||
array ('!link' => l('Add New Event', 'admin/config/booking/events/create')));
|
||||
|
||||
$header = array (
|
||||
'booking_eventid' => t('Event ID'),
|
||||
'booking_eventname' => t('Event Name'),
|
||||
'booking_event_active' => t('Event currently active'),
|
||||
'booking_eventname' => t('Event Name'),
|
||||
'booking_event_active' => t('Event currently active'),
|
||||
'booking_event_start' => t('Event Start Date'),
|
||||
'booking_event_end' => t('Event End Date'),
|
||||
'booking_register_open' => t('Registrations open'),
|
||||
@@ -32,8 +32,8 @@ function booking_event_admin()
|
||||
$options[$data->eid] = array
|
||||
(
|
||||
'booking_eventid' => $data->eid,
|
||||
'booking_eventname' => $data->booking_eventname,
|
||||
'booking_event_active' => $data->booking_event_active == 1 ? 'Yes' : 'No',
|
||||
'booking_eventname' => $data->booking_eventname,
|
||||
'booking_event_active' => $data->booking_event_active == 1 ? 'Yes' : 'No',
|
||||
'booking_event_start' => date("Y-m-d H:i", $data->booking_event_start),
|
||||
'booking_event_end' => date("Y-m-d H:i", $data->booking_event_end),
|
||||
'booking_register_open' => date("Y-m-d H:i", $data->booking_register_open),
|
||||
@@ -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 (
|
||||
@@ -95,16 +103,18 @@ function booking_event_admin_submit($form, &$form_state) {
|
||||
|
||||
//update menus
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
menu_router_build(TRUE);
|
||||
menu_cache_clear_all();
|
||||
menu_router_build(TRUE);
|
||||
menu_cache_clear_all();
|
||||
menu_rebuild();
|
||||
|
||||
// update SQL view
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
|
||||
function booking_event_form($node, &$form_state, $create, $editid = 0)
|
||||
{
|
||||
$form = array ();
|
||||
$form = array();
|
||||
$prefix = "<p>Add a new event to the bookings module.</p>";
|
||||
|
||||
if ($create == true)
|
||||
@@ -150,7 +160,7 @@ function booking_event_form($node, &$form_state, $create, $editid = 0)
|
||||
'#default_value' => empty($data->booking_event_start) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_event_start),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
'#date_year_range' => '-1:+5'
|
||||
);
|
||||
$form['booking_event_end'] = array(
|
||||
'#type' => 'date_select',
|
||||
@@ -158,7 +168,7 @@ function booking_event_form($node, &$form_state, $create, $editid = 0)
|
||||
'#default_value' => empty($data->booking_event_end) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_event_end),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
'#date_year_range' => '-1:+5'
|
||||
);
|
||||
$form['booking_register_open'] = array(
|
||||
'#type' => 'date_select',
|
||||
@@ -166,7 +176,7 @@ function booking_event_form($node, &$form_state, $create, $editid = 0)
|
||||
'#default_value' => empty($data->booking_register_open) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_register_open),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
'#date_year_range' => '-1:+5'
|
||||
);
|
||||
$form['booking_earlybird_close'] = array(
|
||||
'#type' => 'date_select',
|
||||
@@ -174,7 +184,7 @@ function booking_event_form($node, &$form_state, $create, $editid = 0)
|
||||
'#default_value' => empty($data->booking_earlybird_close) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_earlybird_close),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
'#date_year_range' => '-1:+5'
|
||||
);
|
||||
$form['booking_register_close'] = array(
|
||||
'#type' => 'date_select',
|
||||
@@ -182,7 +192,7 @@ function booking_event_form($node, &$form_state, $create, $editid = 0)
|
||||
'#default_value' => empty($data->booking_register_close) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_register_close),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
'#date_year_range' => '-1:+5'
|
||||
);
|
||||
|
||||
|
||||
@@ -293,6 +303,9 @@ function booking_event_form_submit($form, &$form_state) {
|
||||
->condition('eid', $values['booking_eid'])
|
||||
->execute();
|
||||
}
|
||||
|
||||
// update SQL view
|
||||
_booking_node_create_mysqlview();
|
||||
|
||||
$form_state['redirect'] = array('admin/config/booking/events');
|
||||
}
|
@@ -1,5 +1,76 @@
|
||||
<?php
|
||||
// $Id: booking.helper.inc,v 0.1 2011/07/12
|
||||
|
||||
/**
|
||||
* Helper function to strip emoji characters from input text
|
||||
* from https://stackoverflow.com/a/41831874/7638834
|
||||
*/
|
||||
function _booking_remove_emoji($text) {
|
||||
$clean_text = "";
|
||||
|
||||
//don't try to strip emojis if that feature is disabled
|
||||
if (variable_get('booking_enable_emoji_removal', 1) == 0) {
|
||||
return $text;
|
||||
}
|
||||
else {
|
||||
return preg_replace(
|
||||
'/[\x{1F600}-\x{1F64F}]|' .
|
||||
'[\x{1F300}-\x{1F5FF}]|' .
|
||||
'[\x{1F680}-\x{1F6FF}]|' .
|
||||
'[\x{2600}-\x{26FF}]|' .
|
||||
'[\x{2700}-\x{27BF}]|' .
|
||||
'[\x{1F1E6}-\x{1F1FF}]|' .
|
||||
'[\x{1F910}-\x{1F95E}]|' .
|
||||
'[\x{1F980}-\x{1F991}]|' .
|
||||
'[\x{1F9C0}]|' .
|
||||
'[\x{1F9F9}]/u', '', $text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to convert text of any case to Title Case, specifically for names
|
||||
* Taken from http://php.net/manual/en/function.ucwords.php
|
||||
*/
|
||||
function _booking_ucname($string) {
|
||||
$all_uppercase = '';
|
||||
$all_lowercase = 'De La|De Las|Der|Van De|Van Der|Vit De|Von|Or|And';
|
||||
$prefixes = 'Mc';
|
||||
$suffixes = "'S";
|
||||
|
||||
// captialize all first letters
|
||||
$string = preg_replace_callback("/\b(\w)/", function ($m) { return strtoupper($m[1]); }, strtolower(trim($string)));
|
||||
|
||||
if ($all_uppercase) {
|
||||
// capitalize acronymns and initialisms e.g. PHP
|
||||
$string = preg_replace_callback("/\b($all_uppercase)\b/", function ($m) { return strtoupper($m[1]); }, $string);
|
||||
}
|
||||
if ($all_lowercase) {
|
||||
// decapitalize short words e.g. and
|
||||
// all occurences will be changed to lowercase
|
||||
$string = preg_replace_callback("/\b($all_lowercase)\b/", function ($m) { return strtolower($m[1]); }, $string);
|
||||
}
|
||||
|
||||
if ($prefixes) {
|
||||
// capitalize letter after certain name prefixes e.g 'Mc'
|
||||
$string = preg_replace_callback("/\b($prefixes)(\w)/", function ($m) {
|
||||
//watchdog('booking_debug', "<pre>Prefixes match: \n@info</pre>", array('@info' => print_r( $m, true)));
|
||||
return $m[1] . strtoupper($m[2]);
|
||||
}, $string);
|
||||
}
|
||||
if ($suffixes) {
|
||||
// decapitalize certain word suffixes e.g. 's
|
||||
$string = preg_replace_callback("/(\w)($suffixes)\b/", function ($m) { return $m[1] . strtolower($m[2]); }, $string);
|
||||
}
|
||||
|
||||
/*
|
||||
$string = ucwords(strtolower($string));
|
||||
foreach (array('-', '\'') as $delimiter) {
|
||||
if (strpos($string, $delimiter) !== false) {
|
||||
$string = implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to perform some validity checking of email addresses
|
||||
@@ -35,30 +106,29 @@ function _valid_email_address($email) {
|
||||
*/
|
||||
function _valid_medicare_number($input) {
|
||||
//strip any whitespace
|
||||
$medicare = preg_replace( '/\s+/', '', $input );
|
||||
if (is_numeric($medicare) && strlen($medicare) >= 9 && $medicare > 0)
|
||||
{
|
||||
$check_digit = $medicare[0] + (3 * $medicare[1]) + (7 * $medicare[2]) + (9 * $medicare[3])
|
||||
+ $medicare[4] + (3 * $medicare[5]) + (7 * $medicare[6]) + (9 * $medicare[7]);
|
||||
$medicare = preg_replace( '/\s+/', '', $input );
|
||||
|
||||
if (($check_digit % 10) == $medicare[8])
|
||||
{
|
||||
watchdog('booking', 'Medicare number (!mca) validates since check digit !check matches remainder from !remainder',
|
||||
array('!mca' => $input, '!check' => $medicare[8], '!remainder' => $check_digit));
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
watchdog('booking', 'Medicare number (!mca) does not validate since check digit !check does not match remainder from !remainder',
|
||||
array('!mca' => $input, '!check' => $medicare[8], '!remainder' => $check_digit));
|
||||
return FALSE;
|
||||
}
|
||||
//for testing, use the fake medicare number 111111110
|
||||
|
||||
if (is_numeric($medicare) && strlen($medicare) >= 9 && $medicare > 0) {
|
||||
$check_digit = $medicare[0] + (3 * $medicare[1]) + (7 * $medicare[2]) + (9 * $medicare[3])
|
||||
+ $medicare[4] + (3 * $medicare[5]) + (7 * $medicare[6]) + (9 * $medicare[7]);
|
||||
|
||||
if (($check_digit % 10) == $medicare[8]) {
|
||||
watchdog('booking', 'Medicare number (!mca) validates since check digit !check matches remainder from !remainder',
|
||||
array('!mca' => $input, '!check' => $medicare[8], '!remainder' => $check_digit));
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
watchdog('booking', 'Medicare number (!mca) does not validate since check digit !check does not match remainder from !remainder',
|
||||
array('!mca' => $input, '!check' => $medicare[8], '!remainder' => $check_digit));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
watchdog('booking', 'Medicare number (!mca) does not validate since it is either non-numeric or too short',
|
||||
array('!mca' => $input));
|
||||
return FALSE;
|
||||
else {
|
||||
watchdog('booking', 'Medicare number (!mca) does not validate since it is either non-numeric or too short',
|
||||
array('!mca' => $input));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -118,14 +188,14 @@ function _booking_check_bookings_full()
|
||||
//check the number of people registered against the defined max
|
||||
if ($waitinglist_query->num_ppl >= variable_get('booking_regn_limit', 350))
|
||||
{
|
||||
//watchdog('booking', 'There are !num people booked in, which is greater than or equal to the limit of !limit.',
|
||||
// array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) ));
|
||||
watchdog('booking', 'There are !num people booked in, which is greater than or equal to the limit of !limit.',
|
||||
array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) ));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//watchdog('booking', 'There are !num people booked in, which is less than the limit of !limit.',
|
||||
// array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) ));
|
||||
watchdog('booking', 'There are !num people booked in, which is less than the limit of !limit.',
|
||||
array('!num' => $waitinglist_query->num_ppl, '!limit' => variable_get('booking_regn_limit', 350) ));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -166,6 +236,51 @@ function _booking_get_waitinglist_top()
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to retrieve all the people on the waiting list
|
||||
*/
|
||||
function _booking_get_waitinglist()
|
||||
{
|
||||
global $event;
|
||||
|
||||
// This query doesn't work once someone on the waiting list has paid a deposit then a balance payment
|
||||
// Since there are multiple results in the booking_payment table
|
||||
// And only the most recent is returned
|
||||
/*
|
||||
//get a list of everyone on the waiting list
|
||||
$db_or = db_or();
|
||||
$db_or->condition('p.booking_status', 2, '=');
|
||||
$db_or->condition('p.booking_status', 4, '=');
|
||||
|
||||
$db_and = db_and();
|
||||
$db_and->condition('p.booking_eventid', $event->eid, '=');
|
||||
$db_and->condition($db_or);
|
||||
|
||||
$query = db_select('booking_person', 'p')->distinct();
|
||||
$query->join('booking_payment', 'y', 'p.nid = y.booking_person_nid');
|
||||
$query->condition($db_and)
|
||||
->fields('p', array('nid', 'booking_firstname', 'booking_lastname', 'booking_state', 'booking_readinggroup', 'booking_country', 'booking_status'))
|
||||
->fields('y', array('booking_payment_date'))
|
||||
->orderBy('p.booking_status')->orderBy('y.booking_payment_date');
|
||||
$definition_result = $query->execute();
|
||||
|
||||
watchdog('booking_debug', "<pre>_booking_get_waitinglist\n@info</pre>", array('@info' => print_r($definition_result->queryString, true)));
|
||||
return $definition_result;
|
||||
*/
|
||||
|
||||
// Taken from the Waiting List page, not very optimised
|
||||
$result = db_query('SELECT DISTINCT nid, booking_firstname, booking_lastname, booking_state, booking_readinggroup, booking_country, booking_status
|
||||
FROM (
|
||||
SELECT p.nid, p.booking_firstname, p.booking_lastname, p.booking_state, p.booking_country, p.booking_readinggroup, pay.booking_payment_date, p.booking_status
|
||||
FROM {booking_person} p, {booking_payment} pay
|
||||
WHERE p.booking_eventid = :eid and p.nid = pay.booking_person_nid and ( p.booking_status = 2 or p.booking_status = 4)
|
||||
) AS booking
|
||||
ORDER BY booking_status, booking_payment_date',
|
||||
array(':eid' => $event->eid));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to update the status of a registration
|
||||
*/
|
||||
@@ -633,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;
|
||||
}
|
||||
@@ -801,6 +916,22 @@ function _booking_is_earlybird() {
|
||||
}
|
||||
}
|
||||
|
||||
//figure out if we're in the right time period for discounted registration rates
|
||||
function _booking_is_earlyaccess() {
|
||||
global $event;
|
||||
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) {
|
||||
$booking_times = db_query("SELECT booking_register_open, booking_register_close FROM {booking_event} where eid = :eid",
|
||||
array(':eid' => $event->eid))->fetchObject();
|
||||
|
||||
//if we're now before the time that registrations open, then this registration must be from the early access time period
|
||||
return ($booking_times->booking_register_open > time());
|
||||
}
|
||||
|
||||
//if the feature isn't enabled then just return false
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function _booking_datepaid_ts($nid) {
|
||||
$query = db_query("SELECT * FROM {booking_payment} where booking_person_nid = :nid", array(':nid' => $nid))
|
||||
->fetchObject();
|
||||
@@ -813,60 +944,10 @@ function _booking_datepaid_ts($nid) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate paypal fees
|
||||
*/
|
||||
function _booking_add_paypal_fees($amount, $country)
|
||||
{
|
||||
//add the 30 cent fixed cost
|
||||
$result = '0.00';
|
||||
$result = (float) ($amount + (float) variable_get('booking_paypal_transaction_fee_fixedcost', '0.3'));
|
||||
|
||||
//and the 2.6 percent transaction fee for australian transaction with no currency conversion
|
||||
if ($country == variable_get('booking_default_country', 'Australia')) {
|
||||
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage', '2.6');
|
||||
} else {
|
||||
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage_intl', '3.6');
|
||||
//watchdog('booking', "Calculating paypal fees for a currency conversion transaction which adds $percentage percent.");
|
||||
}
|
||||
|
||||
//apply the percentage
|
||||
$percentage = (float) $percentage / 100;
|
||||
//watchdog('booking', "Paypal percentage transaction fee works out to $percentage.");
|
||||
$result = $result / (1 - $percentage);
|
||||
|
||||
//return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate stripe transaction fees
|
||||
*/
|
||||
function _booking_add_stripe_fees($amount, $country) {
|
||||
//add the 30 cent fixed cost
|
||||
$result = '0.00';
|
||||
$result = (float) ($amount + (float) variable_get('booking_stripe_transaction_fee_fixedcost', '0.3'));
|
||||
|
||||
//and the 2.6 percent transaction fee for australian transaction with no currency conversion
|
||||
if ($country == variable_get('booking_default_country', 'Australia')) {
|
||||
$percentage = (float) variable_get('booking_stripe_transaction_fee_percentage', '1.75');
|
||||
} else {
|
||||
$percentage = (float) variable_get('booking_stripe_transaction_fee_percentage_intl', '2.9');
|
||||
}
|
||||
|
||||
//apply the percentage
|
||||
$percentage = (float) $percentage / 100;
|
||||
$result = $result / (1 - $percentage);
|
||||
|
||||
//return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to return the amount for a booking deposit, if there is one
|
||||
*/
|
||||
function _booking_deposit_amount($person, $include_fees = TRUE)
|
||||
{
|
||||
function _booking_deposit_amount($person, $include_fees = TRUE) {
|
||||
global $event;
|
||||
|
||||
$deposit = db_query("SELECT price.booking_price, price.booking_price_descrip " .
|
||||
@@ -878,9 +959,11 @@ function _booking_deposit_amount($person, $include_fees = TRUE)
|
||||
//if we're using paypal or stripe, add the transaction fee
|
||||
$payment_processor_type = variable_get('booking_payment_processor', 0);
|
||||
if ($include_fees == TRUE) {
|
||||
//paypal is enabled
|
||||
if ($payment_processor_type == 0) {
|
||||
$amount_owing = _booking_add_paypal_fees($deposit->booking_price, $person->booking_country);
|
||||
}
|
||||
}
|
||||
//stripe is enabled
|
||||
elseif ($payment_processor_type == 1) {
|
||||
$amount_owing = _booking_add_stripe_fees($deposit->booking_price, $person->booking_country);
|
||||
}
|
||||
@@ -1014,7 +1097,7 @@ function _booking_total_due($person)
|
||||
$total_due = $person->booking_total_pay_reqd;
|
||||
}
|
||||
//the early bird rate will be defined by default for the registration
|
||||
elseif (_booking_is_earlybird() == TRUE)
|
||||
elseif (_booking_is_earlybird() == TRUE || _booking_is_earlyaccess() == TRUE)
|
||||
{
|
||||
$total_due = $person->booking_total_pay_reqd;
|
||||
}
|
||||
@@ -1045,10 +1128,11 @@ function _booking_total_due($person)
|
||||
*
|
||||
* @param $person - the object relating to the registration node
|
||||
* @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value
|
||||
* @param $include_fees - boolean to indicate whether we want the net amount or the amount owing including paypal fees
|
||||
* @param $include_fees - boolean to indicate whether we want the net amount or the amount owing including paypal or stripe fees
|
||||
* @param $include_fees - boolean to indicate whether we want the fees for an international transaction
|
||||
* @return amount owing as a decimal value
|
||||
*/
|
||||
function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE) {
|
||||
function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE, $international_fees = FALSE) {
|
||||
global $event;
|
||||
//quick sanity check
|
||||
if (! $person->nid) {
|
||||
@@ -1077,7 +1161,12 @@ function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE)
|
||||
$amount_owing = _booking_add_paypal_fees($total_due - $amount_paid, $person->booking_country);
|
||||
}
|
||||
elseif ($payment_processor_type == 1) {
|
||||
$amount_owing = _booking_add_stripe_fees($total_due - $amount_paid, $person->booking_country);
|
||||
if ($international_fees == FALSE) {
|
||||
$amount_owing = _booking_add_stripe_fees($total_due - $amount_paid, $person->booking_country);
|
||||
}
|
||||
else {
|
||||
$amount_owing = _booking_add_stripe_fees($total_due - $amount_paid, 'FakeCountry');
|
||||
}
|
||||
}
|
||||
}
|
||||
//otherwise we're using manual payment processing so don't add any fees
|
||||
@@ -1342,6 +1431,18 @@ function _booking_details_email_summary($node) {
|
||||
$rows[] = t('Name: !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
$rows[] = t('Gender: !gender', array('!gender' => $node->booking_gender == 'M' ? 'Male' : 'Female'));
|
||||
$rows[] = t('Date of birth: !dob', array('!dob' => _booking_convert_ts($node->booking_dob)->format('d/m/Y')));
|
||||
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) {
|
||||
//look up the actual code since the booking_person node available at this time only has the primary key for that table
|
||||
$earlyaccess_query = db_query("SELECT booking_earlyaccess_code FROM {booking_earlyaccess_codes} where cid = :code",
|
||||
array(':code' => $node->booking_earlyaccess_code_id))
|
||||
->fetchObject();
|
||||
//only add the row if there was a result returned
|
||||
if ($earlyaccess_query) {
|
||||
$rows[] = t('Early Access Code: !code', array('!code' => $earlyaccess_query->booking_earlyaccess_code));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (variable_get('booking_enable_passport', 1) == 1) {
|
||||
$rows[] = t('Passport Number: !value', array('!value' => $node->booking_passport_num));
|
||||
@@ -1365,20 +1466,28 @@ function _booking_details_email_summary($node) {
|
||||
$rows[] = t("If married, attending partner's name: !name", array('!name' => $node->booking_partner_name));
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_tshirts', 1) == 1) {
|
||||
$rows[] = t('!text: !size', array('!text' => variable_get('booking_tshirts_text_definition', 'T-Shirt size'),
|
||||
'!size' => $node->booking_shirt_size));
|
||||
if (variable_get('booking_enable_songchoice', 0) == 1) {
|
||||
$rows[] = t('Song Choice: !song', array('!song' => $node->booking_song_choice));
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_freestyle', 0) == 1) {
|
||||
$rows[] = t('Freestyle: !text', array('!text' => $node->booking_freestyle_text));
|
||||
}
|
||||
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));
|
||||
$rows[] = t('Emergency Contact Alternate Phone: !phone', array('!phone' => $node->booking_guardian_phone_alt));
|
||||
|
||||
$rows[] = t('Emergency Contact Alternate Phone: !phone', array('!phone' => $node->booking_guardian_phone_alt));
|
||||
//really don't need medicare number being emailed around
|
||||
/*
|
||||
if (variable_get('booking_enable_medicare', 1) == 1) {
|
||||
$rows[] = t('Medicare Number: !medicare', array('!medicare' => $node->booking_medicare));
|
||||
}
|
||||
|
||||
*/
|
||||
if (variable_get('booking_enable_roommate', 0) == 1) {
|
||||
$rows[] = t('Preferred room-mates: !room', array('!room' => $node->booking_room_mate1 . ' ' . $node->booking_room_mate2));
|
||||
}
|
||||
@@ -1425,9 +1534,16 @@ function _booking_details_email_summary($node) {
|
||||
$rows[] = t('Net Amount Due: !payment', array('!payment' => $node->booking_total_pay_reqd));
|
||||
$rows[] = t('Payment Type: !payment', array('!payment' => $payment_description_query->booking_price_descrip));
|
||||
|
||||
foreach ($rows as $key => $value)
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
return implode("\n<br />", $rows);
|
||||
}
|
||||
else {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1437,26 +1553,22 @@ function _booking_travelform_email_summary($node) {
|
||||
global $event;
|
||||
$rows = array();
|
||||
|
||||
if (! empty($node->tid))
|
||||
{
|
||||
if (! empty($node->tid)) {
|
||||
//look up the actual name if a boyfriend/girlfriend is defined
|
||||
if ($node->booking_bf_gf_nid != 0)
|
||||
{
|
||||
if ($node->booking_bf_gf_nid != 0) {
|
||||
$query = db_query("Select booking_firstname, booking_lastname from {booking_person} where nid = :nid",
|
||||
array(':nid' => $node->booking_bf_gf_nid))
|
||||
->fetchObject();
|
||||
$bf_gf = $query->booking_firstname . " " . $query->booking_lastname;
|
||||
}
|
||||
else
|
||||
else {
|
||||
$bf_gf = "N/A";
|
||||
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
$rows[] = t('Name: !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
$rows[] = t('Transport Type: !transport', array('!transport' => $node->booking_transport_type));
|
||||
|
||||
if ($node->booking_transport_type == 'Flying')
|
||||
{
|
||||
if ($node->booking_transport_type == 'Flying') {
|
||||
$rows[] = t('Catching the train to Study Week: !value',
|
||||
array('!value' => $node->booking_transport_from_morriset_reqd == 1 ? 'Yes' : 'No'));
|
||||
$rows[] = t('Inbound Flight Number: ' . $node->booking_flightnum_inbound);
|
||||
@@ -1464,24 +1576,97 @@ function _booking_travelform_email_summary($node) {
|
||||
$rows[] = t('Outbound Flight Number: ' . $node->booking_flightnum_outbound);
|
||||
$rows[] = t('Flight Departure: !date', array('!date' => format_date($node->booking_flight_datetime_outbound, 'custom', 'd/m/Y H:i')));
|
||||
}
|
||||
|
||||
$rows[] = t('Accommodation before Study Week Required: !value', array('!value' => $node->booking_accom_before_reqd == 1 ? 'Yes' : 'No'));
|
||||
$rows[] = t('Accommodation after Study Week Required: !value', array('!value' => $node->booking_accom_after_reqd == 1 ? 'Yes' : 'No'));
|
||||
|
||||
//fields from booking_person
|
||||
if (variable_get('booking_enable_dietary', 0) == 1)
|
||||
if (variable_get('booking_enable_dietary', 0) == 1) {
|
||||
$rows[] = t('Special Dietary Requirements: ' . $node->booking_dietary);
|
||||
|
||||
if (variable_get('booking_enable_roommate', 0) == 1)
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_roommate', 0) == 1) {
|
||||
$rows[] = t('Special Medical Conditions: ' . $node->booking_medical_conditions);
|
||||
|
||||
}
|
||||
|
||||
$rows[] = t('Boyfriend/Girlfriend: ' . $bf_gf);
|
||||
$rows[] = t('Requested room mate(s): ' . $node->booking_room_mate1);
|
||||
|
||||
foreach ($rows as $key => $value)
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
}
|
||||
}
|
||||
} //end empty travel node check
|
||||
//watchdog('booking_debug', "<pre>Travel form summary\n@info</pre>", array('@info' => print_r( $rows, true)));
|
||||
return implode("\n", $rows);
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
return implode("\n<br />", $rows);
|
||||
}
|
||||
else {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1492,32 +1677,57 @@ function _booking_studygroup_email_summary($node) {
|
||||
$rows = array();
|
||||
|
||||
//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",
|
||||
array(':eid' => $event->eid));
|
||||
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||
if (variable_get('booking_enable_studygroups', 0) == 0) {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
|
||||
//for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||
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));
|
||||
}
|
||||
}
|
||||
//look up the titles of the study groups
|
||||
$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');
|
||||
|
||||
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));
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value)
|
||||
$rows[$key] = wordwrap($value);
|
||||
|
||||
return implode("\n", $rows);
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1526,12 +1736,13 @@ 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');
|
||||
|
||||
@@ -1550,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";
|
||||
@@ -1570,7 +1781,7 @@ function _booking_leader_helper_email_summary($node) {
|
||||
" AND booking_studygroup_id = :group AND booking_studygroup_role = :role AND booking_session_id = :session",
|
||||
array(':eid' => $event->eid, ':group' => $studygroup->sid, ':role' => $otherrole_id, ':session' => $node->$sessionid,
|
||||
));
|
||||
$otherperson = $otherperson_query->fetchAll();
|
||||
$otherperson = $otherperson_query->fetchAll();
|
||||
|
||||
//watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>",
|
||||
// array('!group' => $studygroup->sid, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true)));
|
||||
@@ -1581,11 +1792,27 @@ function _booking_leader_helper_email_summary($node) {
|
||||
$otherperson_email = $other->booking_email;
|
||||
$otherperson_phone = $other->booking_mobile;
|
||||
}
|
||||
|
||||
$rows[] = t('!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.',
|
||||
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,
|
||||
);
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1594,7 +1821,19 @@ function _booking_leader_helper_email_summary($node) {
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
}
|
||||
return implode("\n", $rows);
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1619,10 +1858,16 @@ function _booking_room_email_summary($node) {
|
||||
$rows[] = t("\tNo room currently allocated.");
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value)
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
}
|
||||
|
||||
return implode("\n", $rows);
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
return implode("\n<br />", $rows);
|
||||
}
|
||||
else {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,22 +1,19 @@
|
||||
<?php
|
||||
// $Id: booking.import_data.inc,v 0.1
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide functionality to upload csv for bulk update of payment data
|
||||
*/
|
||||
|
||||
|
||||
function booking_import_data_admin()
|
||||
function booking_import_data_admin($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
$form = array();
|
||||
|
||||
$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',
|
||||
@@ -24,6 +21,24 @@ function booking_import_data_admin()
|
||||
'#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'),
|
||||
@@ -61,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;
|
||||
@@ -71,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'];
|
||||
@@ -94,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++;
|
||||
@@ -107,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++;
|
||||
@@ -120,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
|
||||
$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();
|
||||
*/
|
||||
|
||||
//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[$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
|
284
booking.install
284
booking.install
@@ -93,7 +93,7 @@ function booking_update_7201() {
|
||||
* Add table for variety sessions
|
||||
*/
|
||||
function booking_update_7202() {
|
||||
$booking_variety_options = array(
|
||||
$booking_variety_sessions = array(
|
||||
'fields' => array(
|
||||
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
@@ -105,7 +105,7 @@ function booking_update_7202() {
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
);
|
||||
$booking_variety_times = array(
|
||||
$booking_variety_timeslots = array(
|
||||
'fields' => array(
|
||||
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
@@ -127,8 +127,8 @@ function booking_update_7202() {
|
||||
);
|
||||
|
||||
|
||||
db_create_table('booking_variety_options', $booking_variety_options);
|
||||
db_create_table('booking_variety_times', $booking_variety_times);
|
||||
db_create_table('booking_variety_sessions', $booking_variety_sessions);
|
||||
db_create_table('booking_variety_timeslots', $booking_variety_timeslots);
|
||||
db_create_table('booking_variety_regn', $booking_variety_regn);
|
||||
|
||||
//TODO: create tables for variety session timeslots and variety session registrations (map user to variety session id)
|
||||
@@ -615,6 +615,223 @@ function booking_update_7240() {
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change stripe token field to store stripe charge response as JSON
|
||||
*/
|
||||
function booking_update_7241() {
|
||||
$spec = array('type' => 'text', 'not null' => FALSE);
|
||||
db_change_field('booking_payment', 'booking_stripe_token', 'booking_stripe_response', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add support for early registration code
|
||||
*/
|
||||
function booking_update_7242() {
|
||||
//add field to booking_person table
|
||||
$spec = array('type' => 'int', 'length' => '11', 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_earlyaccess_code_id', $spec);
|
||||
|
||||
//create new table to store the valid codes
|
||||
$booking_earlyaccess_codes = array(
|
||||
'fields' => array(
|
||||
'cid' => 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_earlyaccess_code' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_avail' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
|
||||
),
|
||||
'primary key' => array('cid'),
|
||||
);
|
||||
|
||||
db_create_table('booking_earlyaccess_codes', $booking_earlyaccess_codes);
|
||||
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add support for html emails
|
||||
*/
|
||||
function booking_update_7243() {
|
||||
$current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
|
||||
$addition = array('booking' => 'BookingMailSystem');
|
||||
variable_set('mail_system', array_merge($current, $addition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename booking_regn_earlyaccess_codes table to booking_earlyaccess_codes
|
||||
*/
|
||||
function booking_update_7244() {
|
||||
db_drop_table('booking_regn_earlyaccess_codes');
|
||||
|
||||
//create new table to store the valid codes
|
||||
$booking_earlyaccess_codes = array(
|
||||
'fields' => array(
|
||||
'cid' => 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_earlyaccess_code' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_avail' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
|
||||
),
|
||||
'primary key' => array('cid'),
|
||||
);
|
||||
|
||||
//db_create_table('booking_earlyaccess_codes', $booking_earlyaccess_codes);
|
||||
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename booking_earlyaccess_code back to booking_earlyaccess_code_id in booking_person table
|
||||
*/
|
||||
/*
|
||||
function booking_update_7245() {
|
||||
$spec = array('type' => 'int', 'length' => '11', 'not null' => FALSE);
|
||||
db_change_field('booking_person', 'booking_earlyaccess_code', 'booking_earlyaccess_code_id', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Add node id to booking_earlyaccess_codes table
|
||||
*/
|
||||
/*
|
||||
function booking_update_7246() {
|
||||
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10');
|
||||
db_add_field('booking_earlyaccess_codes', 'booking_earlyaccess_code_nid', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add field for attendee's music choice
|
||||
*/
|
||||
function booking_update_7247() {
|
||||
$spec = array('type' => 'varchar', 'length' => '500', 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_song_choice', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase maximum length of booking_medical_conditions field to 5000 characters
|
||||
*/
|
||||
function booking_update_7248() {
|
||||
$spec = array('type' => 'varchar', 'length' => '5000', 'not null' => FALSE);
|
||||
db_change_field('booking_person', 'booking_medical_conditions', 'booking_medical_conditions', $spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add field for attendee's freestyle text entry
|
||||
*/
|
||||
function booking_update_7249() {
|
||||
$spec = array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_freestyle_text', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - Create table to store configuration for HTML email templates
|
||||
*/
|
||||
/*
|
||||
function booking_update_7250() {
|
||||
$booking_mailtemplate_fields = array(
|
||||
'fields' => array(
|
||||
'mid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_mailtemplate_media_type' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_mailtemplate_link_title' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_mailtemplate_icon_url' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
|
||||
'booking_mailtemplate_link_url' => array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE),
|
||||
'booking_mailtemplate_link_active' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
),
|
||||
'primary key' => array('mid'),
|
||||
);
|
||||
|
||||
db_create_table('booking_mailtemplate_fields', $booking_mailtemplate_fields);
|
||||
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add custom cache table
|
||||
*/
|
||||
function booking_update_7252() {
|
||||
if (!db_table_exists('cache_booking')) {
|
||||
$schema = drupal_get_schema_unprocessed('system', 'cache');
|
||||
$schema['description'] = 'Cache table used by booking module.';
|
||||
db_create_table('cache_booking', $schema);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add field to store waiting list position
|
||||
*/
|
||||
function booking_update_7253() {
|
||||
$spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_waitlist_pos', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change booking_variety_regn field type and rename some tables
|
||||
*/
|
||||
function booking_update_7254() {
|
||||
$spec = array('type' => 'varchar', 'length' => '1000', 'not null' => FALSE);
|
||||
db_change_field('booking_variety_regn', 'booking_variety_id', 'booking_variety_ids', $spec);
|
||||
db_rename_table('booking_variety_times', 'booking_variety_timeslots');
|
||||
db_rename_table('booking_variety_options', 'booking_variety_sessions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix incorrect field name in booking_variety_regn table
|
||||
*/
|
||||
function booking_update_7255() {
|
||||
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10');
|
||||
db_change_field('booking_variety_regn', 'booking_node_id', 'booking_person_nid', $spec);
|
||||
_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().
|
||||
*/
|
||||
@@ -654,26 +871,56 @@ function booking_uninstall() {
|
||||
//drupal_uninstall_schema('booking');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_enable()
|
||||
* Based on https://drupal.stackexchange.com/questions/23821/email-a-whole-node-including-template-contents
|
||||
*/
|
||||
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');
|
||||
// Use MimeMail module instead of our own version
|
||||
$addition = array('booking' => 'MimeMailSystem');
|
||||
|
||||
variable_set('mail_system', array_merge($current, $addition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_disable()
|
||||
*/
|
||||
function booking_disable() {
|
||||
drupal_set_message($message = t('The Booking System module was successfully disabled.'), $type = 'status');
|
||||
$mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
|
||||
unset($mail_system['booking']);
|
||||
variable_set('mail_system', $mail_system);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_schema().
|
||||
*/
|
||||
function booking_schema() {
|
||||
|
||||
//configure our own cache table
|
||||
$schema['cache_booking'] = drupal_get_schema_unprocessed('system', 'cache');
|
||||
|
||||
$schema['booking_person'] = array(
|
||||
'fields' => array(
|
||||
//identifiers
|
||||
'nid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE),
|
||||
'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_id' => array('type' => 'int', 'length' => '11', 'not null' => FALSE),
|
||||
'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
|
||||
'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE),
|
||||
'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE),
|
||||
'booking_gender' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE),
|
||||
'booking_dob' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'),
|
||||
'booking_status' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
'booking_waitlist_pos' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE),
|
||||
'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),
|
||||
@@ -748,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(
|
||||
@@ -855,7 +1105,7 @@ function booking_schema() {
|
||||
'primary key' => array('payid'),
|
||||
);
|
||||
|
||||
$schema['booking_variety_options'] = array(
|
||||
$schema['booking_variety_sessions'] = array(
|
||||
'fields' => array(
|
||||
'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
@@ -868,7 +1118,7 @@ function booking_schema() {
|
||||
'primary key' => array('vid'),
|
||||
);
|
||||
|
||||
$schema['booking_variety_times'] = array(
|
||||
$schema['booking_variety_timeslots'] = array(
|
||||
'fields' => array(
|
||||
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
@@ -883,8 +1133,8 @@ function booking_schema() {
|
||||
$schema['booking_variety_regn'] = array(
|
||||
'fields' => array(
|
||||
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_variety_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_variety_ids' => array('type' => 'varchar', 'length' => '1000', 'not null' => TRUE),
|
||||
'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
),
|
||||
'primary key' => array('rid'),
|
||||
);
|
||||
@@ -907,13 +1157,15 @@ function booking_schema() {
|
||||
),
|
||||
'primary key' => array('tid'),
|
||||
);
|
||||
|
||||
|
||||
//This lists all the study groups
|
||||
$schema['booking_studygroup_list'] = array(
|
||||
'fields' => array(
|
||||
'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),
|
||||
),
|
||||
@@ -978,5 +1230,17 @@ function booking_schema() {
|
||||
'primary key' => array('mid'),
|
||||
);
|
||||
|
||||
//This lists all the early registration access codes
|
||||
$schema['booking_earlyaccess_codes'] = array(
|
||||
'fields' => array(
|
||||
'cid' => 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_earlyaccess_code' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_avail' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_earlyaccess_code_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
|
||||
),
|
||||
'primary key' => array('cid'),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
241
booking.mailtemplate_admin.inc
Normal file
241
booking.mailtemplate_admin.inc
Normal file
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Function to allow admin user to define parameters for HTML emails that can be sent by Bookings module
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_mailtemplate_form($node, &$form_state) {
|
||||
global $event;
|
||||
$form = array();
|
||||
$header_link_max_count = 3;
|
||||
$social_media_link_max_count = 3;
|
||||
|
||||
$prefix = "<h2>Configure HTML email template</h2>";
|
||||
|
||||
// load any existing values from the drupal variable table
|
||||
$colors = json_decode(variable_get('booking_mailtemplate_colors'), TRUE);
|
||||
$header_links = json_decode(variable_get('booking_mailtemplate_header_links'), TRUE);
|
||||
$social_links = json_decode(variable_get('booking_mailtemplate_social_links'), TRUE);
|
||||
|
||||
//watchdog('booking_debug', "<pre>Mail template navigation links loaded\n@info</pre>", array('@info' => print_r($header_links, true)));
|
||||
//watchdog('booking_debug', "<pre>Mail template social links loaded\n@info</pre>", array('@info' => print_r($social_links, true)));
|
||||
|
||||
$form['booking_mailtemplate_header_image_url'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL of header image'),
|
||||
'#description' => t('Specify full URL to image used in header'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 500,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_header_image_url']) ? $GLOBALS['base_url'] . '/sites/all/modules/booking/images/logo.png' : $colors['booking_mailtemplate_header_image_url'],
|
||||
);
|
||||
$form['booking_mailtemplate_header_link_url'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Destination URL for header'),
|
||||
'#description' => t('Specify full URL to direct user if they click on header image'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 500,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_header_link_url']) ? $GLOBALS['base_url'] : $colors['booking_mailtemplate_header_link_url'],
|
||||
);
|
||||
|
||||
$form['colors'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Define Colours',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_background_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Background Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_content_background_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Content area Background Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_content_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_content_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_header_background_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Header area Background Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_header_background_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_header_background_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_navigation_background_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Navigation links area Background Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#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'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_text_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_text_color'],
|
||||
);
|
||||
$form['colors']['booking_mailtemplate_subjectheading_text_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject Heading Text Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_subjectheading_text_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_subjectheading_text_color'],
|
||||
);
|
||||
/*
|
||||
$form['colors']['booking_mailtemplate_link_color'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Link Colour'),
|
||||
'#description' => t('Specify CSS compatible value'),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 50,
|
||||
'#default_value' => empty($colors['booking_mailtemplate_link_color']) ? '#FFFFFF' : $colors['booking_mailtemplate_link_color'],
|
||||
);
|
||||
*/
|
||||
|
||||
$form['header-links'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Navigation Header Links',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
//add form elements for header links
|
||||
for ($i = 1; $i <= $header_link_max_count; $i++) {
|
||||
$header_link_text = 'booking_mailtemplate_headerlink_text' . $i;
|
||||
$header_link_url = 'booking_mailtemplate_headerlink_url' . $i;
|
||||
$form['header-links'][$header_link_text] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Display text for navigation header link ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => empty($header_links[$i]['text']) ? 'Link Title' : $header_links[$i]['text'],
|
||||
);
|
||||
$form['header-links'][$header_link_url] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL for navigation header link ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 500,
|
||||
'#default_value' => empty($header_links[$i]['link']) ? $GLOBALS['base_url'] : $header_links[$i]['link'],
|
||||
);
|
||||
}
|
||||
|
||||
$form['social-links'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Social Media Links',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
//add form elements for social media links
|
||||
for ($i = 1; $i <= $social_media_link_max_count; $i++) {
|
||||
$social_link_text = 'booking_mailtemplate_sociallink_text' . $i;
|
||||
$social_image_url = 'booking_mailtemplate_socialimage_url' . $i;
|
||||
$social_link_url = 'booking_mailtemplate_sociallink_url' . $i;
|
||||
$form['social-links'][$social_link_text] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Hover text for social link ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => empty($social_links[$i]['text']) ? '' : $social_links[$i]['text'],
|
||||
);
|
||||
$form['social-links'][$social_image_url] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL to social image ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 500,
|
||||
'#default_value' => empty($social_links[$i]['imageurl']) ? $GLOBALS['base_url'] : $social_links[$i]['imageurl'],
|
||||
);
|
||||
$form['social-links'][$social_link_url] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('URL for social link ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 500,
|
||||
'#default_value' => empty($social_links[$i]['linkurl']) ? $GLOBALS['base_url'] : $social_links[$i]['linkurl'],
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
function booking_mailtemplate_form_submit($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
$color_data = array();
|
||||
$header_data = array();
|
||||
$social_data = array();
|
||||
|
||||
$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_header_text_color', 'booking_mailtemplate_text_color',
|
||||
'booking_mailtemplate_header_image_url', 'booking_mailtemplate_header_link_url',
|
||||
);
|
||||
//'booking_mailtemplate_link_color',
|
||||
|
||||
//set all the values that are just using the builtin drupal variable definitions
|
||||
foreach ($values as $key => $value) {
|
||||
if (in_array($key, $colors_variable_list, FALSE)) {
|
||||
//variable_set($key, $value);
|
||||
$color_data[$key] = $value;
|
||||
}
|
||||
// update navigation header links
|
||||
elseif (strpos($key, "booking_mailtemplate_headerlink") === 0) {
|
||||
//get the ID for this header navigation link
|
||||
preg_match("/.*(\d+)$/", $key, $matches);
|
||||
$id = $matches[1];
|
||||
$header_data[$id] = array(
|
||||
'text' => $values['booking_mailtemplate_headerlink_text' . $id],
|
||||
'link' => $values['booking_mailtemplate_headerlink_url' . $id],
|
||||
);
|
||||
}
|
||||
// update social media links
|
||||
elseif (strpos($key, "booking_mailtemplate_social") === 0) {
|
||||
//get the ID for this header navigation link
|
||||
preg_match("/.*(\d+)$/", $key, $matches);
|
||||
$id = $matches[1];
|
||||
$social_data[$id] = array(
|
||||
'text' => $values['booking_mailtemplate_sociallink_text' . $id],
|
||||
'imageurl' => $values['booking_mailtemplate_socialimage_url' . $id],
|
||||
'linkurl' => $values['booking_mailtemplate_sociallink_url' . $id],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', "<pre>Mail template navigation links\n@info</pre>", array('@info' => print_r($header_data, true)));
|
||||
|
||||
// store the data into the standard drupal variable table
|
||||
variable_set('booking_mailtemplate_colors', json_encode($color_data));
|
||||
variable_set('booking_mailtemplate_header_links', json_encode($header_data));
|
||||
variable_set('booking_mailtemplate_social_links', json_encode($social_data));
|
||||
}
|
@@ -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) {
|
||||
$total_paid = $person->booking_amount_paid + $price;
|
||||
$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' => '',
|
||||
|
43
booking.misc.inc
Normal file
43
booking.misc.inc
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Provide a home for miscellaneous functions that don't really belong anywhere else
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function for generating the "lucky number" to be used on the lanyard
|
||||
*/
|
||||
function booking_generate_luckynumbers() {
|
||||
global $event;
|
||||
|
||||
$i = 0;
|
||||
|
||||
//query for the mappings relating to $readinggroup_studygroup_id
|
||||
$attendee_query = db_query("SELECT * FROM {booking_person} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$attendees = $attendee_query->fetchAll();
|
||||
|
||||
//assuming there's less than 900 people, generate numbers within that range and shuffle the order
|
||||
$numbers = range(100,750);
|
||||
shuffle($numbers);
|
||||
|
||||
foreach ($attendees as $attendee)
|
||||
{
|
||||
$luckynum = $numbers[$i++];
|
||||
|
||||
drupal_set_message(t('Updating user !id to have lucky number !num.',
|
||||
array('!id' => $attendee->nid, '!num' => $luckynum)));
|
||||
|
||||
//run an update query
|
||||
db_update('booking_person')
|
||||
->fields(array (
|
||||
'booking_luckynum' => $luckynum,
|
||||
))
|
||||
->condition('nid', $attendee->nid)
|
||||
->execute();
|
||||
|
||||
}
|
||||
drupal_set_message(t('Finished.'));
|
||||
|
||||
return t("<h3>Generate Lucky Numbers</h3>");
|
||||
}
|
1788
booking.module
1788
booking.module
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Helper function to calculate paypal fees
|
||||
*/
|
||||
function _booking_add_paypal_fees($amount, $country)
|
||||
{
|
||||
//add the 30 cent fixed cost
|
||||
$result = '0.00';
|
||||
$result = (float) ($amount + (float) variable_get('booking_paypal_transaction_fee_fixedcost', '0.3'));
|
||||
|
||||
//and the 2.6 percent transaction fee for australian transaction with no currency conversion
|
||||
if ($country == variable_get('booking_default_country', 'Australia')) {
|
||||
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage', '2.6');
|
||||
} else {
|
||||
$percentage = (float) variable_get('booking_paypal_transaction_fee_percentage_intl', '3.6');
|
||||
//watchdog('booking', "Calculating paypal fees for a currency conversion transaction which adds $percentage percent.");
|
||||
}
|
||||
|
||||
//apply the percentage
|
||||
$percentage = (float) $percentage / 100;
|
||||
//watchdog('booking', "Paypal percentage transaction fee works out to $percentage.");
|
||||
$result = $result / (1 - $percentage);
|
||||
|
||||
//return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate string to post to paypal to verify a successful IPN
|
||||
*/
|
||||
function _booking_paypal_post($data = array()) {
|
||||
$post = '';
|
||||
foreach ($data as $key => $value) {
|
||||
@@ -10,7 +39,10 @@ function _booking_paypal_post($data = array()) {
|
||||
return $post;
|
||||
}
|
||||
|
||||
//see https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php for more details
|
||||
/**
|
||||
* Helper function to verify a successful IPN from Paypal
|
||||
* @see https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php
|
||||
*/
|
||||
function _booking_paypal_ipn_verify($vars = array()) {
|
||||
|
||||
if (variable_get('booking_paypal_sandbox', 0)) {
|
||||
|
@@ -8,13 +8,14 @@
|
||||
function booking_price_admin()
|
||||
{
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
$form = array();
|
||||
$options = array();
|
||||
$prefix = t("<p>!link</p>",
|
||||
array ('!link' => l('Add New Price Entry', 'admin/config/booking/prices/create')));
|
||||
|
||||
$header = array (
|
||||
'booking_price_active' => t('Active'),
|
||||
'booking_eventname' => t('Event Name'),
|
||||
'booking_eventid' => t('Event ID'),
|
||||
'booking_price_descrip' => t('Description'),
|
||||
'booking_price' => t('Early-Bird Price'),
|
||||
@@ -25,14 +26,17 @@ function booking_price_admin()
|
||||
'booking_edit' => t('Edit Price'),
|
||||
);
|
||||
|
||||
$result = db_query("SELECT pid, booking_eventid, booking_price, booking_late_price, booking_late_buttonid, booking_price_descrip, booking_buttonid, booking_price_active, " .
|
||||
"booking_depositonly from {booking_price}");
|
||||
$result = db_query("SELECT pid, p.booking_eventid, booking_price, booking_late_price, booking_late_buttonid, booking_price_descrip, " .
|
||||
"booking_buttonid, booking_price_active, booking_depositonly, e.booking_eventname " .
|
||||
"from {booking_price} p " .
|
||||
"inner join {booking_event} e on e.eid = p.booking_eventid");
|
||||
|
||||
foreach($result as $data)
|
||||
{
|
||||
$options[$data->pid] = array
|
||||
(
|
||||
'booking_price_active' => $data->booking_price_active == 1 ? 'Yes' : 'No',
|
||||
'booking_price_active' => $data->booking_price_active == 1 ? 'Yes' : 'No',
|
||||
'booking_eventname' => $data->booking_eventname,
|
||||
'booking_eventid' => $data->booking_eventid,
|
||||
'booking_price_descrip' => $data->booking_price_descrip,
|
||||
'booking_price' => $data->booking_price,
|
||||
@@ -61,7 +65,13 @@ function booking_price_admin()
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Set Inactive'),
|
||||
);
|
||||
);
|
||||
|
||||
$form['submit_current'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Change to current event'),
|
||||
);
|
||||
|
||||
//watchdog('booking', 'Setting button form: @info', array ('@info' => var_export($form, TRUE)));
|
||||
|
||||
@@ -85,27 +95,40 @@ function booking_price_admin_submit($form, &$form_state) {
|
||||
|
||||
foreach($checkboxes as $key => $value) {
|
||||
//only set the entries that are ticked
|
||||
if ($value != 0)
|
||||
{
|
||||
if ($form_state['values']['op'] == 'Set Active')
|
||||
$setting = 1;
|
||||
else
|
||||
$setting = 0;
|
||||
if ($value != 0) {
|
||||
//just update prices to match current event
|
||||
if ($form_state['values']['op'] == 'Change to current event') {
|
||||
db_update('booking_price')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
))
|
||||
->condition('pid', $key)
|
||||
->execute();
|
||||
}
|
||||
//either make a price active or inactive
|
||||
else {
|
||||
if ($form_state['values']['op'] == 'Set Active') {
|
||||
$setting = 1;
|
||||
}
|
||||
else {
|
||||
$setting = 0;
|
||||
}
|
||||
db_update('booking_price')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_price_active' => $setting,
|
||||
))
|
||||
->condition('pid', $key)
|
||||
->execute();
|
||||
}
|
||||
|
||||
db_update('booking_price')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_price_active' => $setting,
|
||||
))
|
||||
->condition('pid', $key)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
} //value not 0
|
||||
} //foreach checkbox
|
||||
} //end function
|
||||
|
||||
function booking_price_form($node, &$form_state, $create, $editid = 0)
|
||||
{
|
||||
$form = array ();
|
||||
$form = array();
|
||||
$prefix = "<p>Add a new payment option</p>";
|
||||
|
||||
if ($create == true)
|
||||
|
@@ -17,8 +17,12 @@ function booking_register_page()
|
||||
//figure out if we're allowed to accept bookings
|
||||
$booking_times = db_query("SELECT booking_register_open, booking_register_close FROM {booking_event} where eid = :eid",
|
||||
array(':eid' => $event->eid))->fetchObject();
|
||||
|
||||
$allowed_time_check = ($booking_times->booking_register_open < time()) && ($booking_times->booking_register_close > time());
|
||||
$earlyaccess_time_check = ($booking_times->booking_register_close > time()) && (variable_get('booking_enable_earlyaccess_codes', 0) == 1);
|
||||
$before_regn_open_check = ($booking_times->booking_register_open > time());
|
||||
|
||||
if ($booking_times->booking_register_open < time() && $booking_times->booking_register_close > time()) {
|
||||
if ($allowed_time_check || $earlyaccess_time_check) {
|
||||
//we are within the allowed timeframe for registrations
|
||||
//check if this registration will be on the waiting list
|
||||
if (_booking_check_bookings_full() == True) {
|
||||
@@ -59,9 +63,41 @@ 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;
|
||||
$status_options = array();
|
||||
$payment_type_options = array();
|
||||
@@ -82,41 +118,63 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
$data = $form_state['input'];
|
||||
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
||||
}
|
||||
|
||||
//figure out if we're in the earlybird rate section
|
||||
/*
|
||||
$early = db_query("SELECT booking_earlybird_close FROM {booking_event} where eid = :eid",
|
||||
array(
|
||||
':eid' => $event->eid
|
||||
))->fetchObject();
|
||||
if ($early->booking_earlybird_close > time())
|
||||
$select_early = 1;
|
||||
else {
|
||||
$select_early = 0;
|
||||
//watchdog('booking', 'No longer accepting earlybird prices');
|
||||
}
|
||||
|
||||
$result = db_query("SELECT pid, booking_price_descrip, booking_price, booking_late_price FROM {booking_price} where booking_eventid = :eid " . "and booking_price_active=1 and booking_depositonly = 0", array(
|
||||
':eid' => $event->eid
|
||||
));
|
||||
*/
|
||||
|
||||
$select_early = _booking_is_earlybird();
|
||||
|
||||
$price_query = db_select('booking_price', 'p');
|
||||
$db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')
|
||||
->condition('p.booking_price_active', 1, '=')
|
||||
->condition('p.booking_depositonly', 0, '=');
|
||||
$price_query->condition($db_and);
|
||||
$price_query->fields('p');
|
||||
$result = $price_query->execute();
|
||||
$result = $price_query->execute();
|
||||
|
||||
//figure out if we're in the earlybird rate section and use that for determining pricing
|
||||
// Registrations are open and before early bird closes
|
||||
$earlybird_check = (($event->booking_register_open <= time()) && ($event->booking_earlybird_close > time()));
|
||||
// Early access is allowed and the time now is before registrations would normally open
|
||||
$earlyaccess_check = ((variable_get('booking_enable_earlyaccess_codes', 0) == 1) && ($event->booking_register_open > time()));
|
||||
|
||||
// discounted payments is allowed if:
|
||||
// - early access allowed and before registrations start
|
||||
// - early access not allowed and after earlybird start but before earlybird finish
|
||||
$early_payment_flag = $earlybird_check || $earlyaccess_check;
|
||||
|
||||
foreach ($result as $row) {
|
||||
$price = $select_early == TRUE ? $row->booking_price : $row->booking_late_price;
|
||||
$payment_type_options[$row->pid] = $row->booking_price_descrip . ' ($' . $price . ')';
|
||||
$price = $early_payment_flag == TRUE ? $row->booking_price : $row->booking_late_price;
|
||||
$discount_suffix = $early_payment_flag == TRUE ? " - discounted rate" : "";
|
||||
$payment_type_options[$row->pid] = $row->booking_price_descrip . ' ($' . $price . ')' . $discount_suffix;
|
||||
}
|
||||
|
||||
//form starts here
|
||||
// ------- form starts here ---------
|
||||
|
||||
//add new feature for early registration access
|
||||
if ($inserting == TRUE && $earlyaccess_check) {
|
||||
$form['early-access'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Early Registration Code'
|
||||
);
|
||||
$form['early-access']['booking_earlyaccess_feedback_wrapper'] = array(
|
||||
'#markup' => '<div id="booking_earlyaccess_feedback_wrapper">If you have been given an early-access code for registration, please enter it below. ' .
|
||||
'Without this code, your registration will not be accepted.<br />' .
|
||||
'<p><strong>NOTE: each early-access code can only be used once, so don\'t pass it along to your friends!</strong></p></div><br />',
|
||||
);
|
||||
$form['early-access']['booking_earlyaccess_code'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Unique Early-Access Code'),
|
||||
'#maxlength' => 45,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_earlyaccess_code) ? $data->booking_earlyaccess_code : '',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_earlyaccess_feedback_wrapper',
|
||||
'callback' => 'booking_earlyaccess_feedback_callback',
|
||||
),
|
||||
);
|
||||
$form['booking_earlyaccess'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 1
|
||||
);
|
||||
}
|
||||
|
||||
$form['your-details'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Personal details'
|
||||
@@ -170,11 +228,14 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
$form['your-details']['booking_dob']['#date_year_range'] = $date_year_range;
|
||||
}
|
||||
|
||||
$early_description_text = t("Please note that this is the discounted payment rate. For more information about payment rates, please see !theweek page.",
|
||||
array('!theweek' => l('The Week', 'the-week/whats-happening')));
|
||||
$form['your-details']['booking_payment_id'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Choose your payment type'),
|
||||
'#description' => $early_payment_flag == TRUE ? $early_description_text : "",
|
||||
'#default_value' => $inserting != TRUE ? $data->booking_payment_id : variable_get('booking_payment_id', 'worker'),
|
||||
'#options' => $payment_type_options
|
||||
'#options' => $payment_type_options,
|
||||
);
|
||||
|
||||
// The status field should not be visible unless this registration is being updated...i.e. not at actual registration time...
|
||||
@@ -261,14 +322,27 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
'#options' => _get_tshirt_options()
|
||||
);
|
||||
} //end enable tshirts check
|
||||
|
||||
$form['your-details']['booking_ecclesia'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Ecclesia'),
|
||||
'#maxlength' => 100,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : ''
|
||||
);
|
||||
|
||||
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 : '',
|
||||
);
|
||||
}
|
||||
|
||||
$form['your-details']['booking_baptised'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('I am baptised'),
|
||||
@@ -400,27 +474,10 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
|
||||
//only show the booking agreement tickbox if the node is being created, since this value isn't stored anywhere
|
||||
if ($inserting == TRUE) {
|
||||
/*
|
||||
$form['your-details']['booking_regular_cyc'] = array
|
||||
(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Regularly Attend CYC '),
|
||||
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
|
||||
'#title' => t('I regularly attend CYC events/activities'),
|
||||
); */
|
||||
|
||||
$form['your-details']['booking_agreement'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Aims and Expectations'),
|
||||
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
|
||||
/*
|
||||
'#states' => array(
|
||||
// Only show this field when the checkbox is unchecked.
|
||||
'visible' => array(
|
||||
':input[name="booking_agreement"]' => array('checked' => FALSE),
|
||||
),
|
||||
),
|
||||
*/
|
||||
'#title' => token_replace(variable_get('booking_registration_aims_rules_checkbox'), booking_define_tokens()),
|
||||
'#description' => token_replace(variable_get('booking_registration_aims_rules_text'), booking_define_tokens())
|
||||
);
|
||||
@@ -439,6 +496,15 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
'#required' => 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',
|
||||
@@ -465,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 : ''
|
||||
@@ -575,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,
|
||||
@@ -842,7 +912,9 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
if (variable_get('booking_enable_medcond', 0) == 1) {
|
||||
$form['misc-areas']['booking_medical_conditions'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Please list any medical conditions we need to be aware of. For allegies, please list the reaction to the allergen(s).'),
|
||||
'#title' => 'Medical Conditions',
|
||||
'#description' => t("Please list any allergies you have, including your reaction to the allergen/s.<br />" .
|
||||
"Please list any medical conditions you have.<br />All responses will be kept confidential."),
|
||||
'#cols' => 60,
|
||||
'#rows' => 5,
|
||||
'#resizable' => FALSE,
|
||||
@@ -864,7 +936,7 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
else {
|
||||
$form['misc-areas']['booking_medical_conditions'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => variable_get('booking_medcond_text_definition', "Please contact us to specify your dietary requirements."),
|
||||
'#children' => variable_get('booking_medcond_text_definition', "Please contact us to specify your medical conditions."),
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="booking_medical_conditions_check"]' => array(
|
||||
@@ -900,13 +972,13 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
if (variable_get('booking_enable_roommate', 0) == 1) {
|
||||
$form['misc-areas']['booking_room_mate1'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('List up to two people you would like to share a room with (subject to availability).'),
|
||||
'#title' => t('List up to two people you would like to share a room with (subject to availability)'),
|
||||
'#maxlength' => 200,
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : ''
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
$form['misc-areas']['booking_random_facts'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('List three random facts about yourself (optional).'),
|
||||
@@ -914,8 +986,50 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
'#required' => FALSE,
|
||||
'#default_value' => !empty($data->booking_random_facts) ? $data->booking_random_facts : ''
|
||||
);
|
||||
|
||||
|
||||
*/
|
||||
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' => $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 text (anything you'd like to share)"),
|
||||
'#maxlength' => 500,
|
||||
'#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
|
||||
// And forms get cached differently anyway
|
||||
/*
|
||||
$form['cache'] = array('#cache' => array(
|
||||
'cid' => 'booking_data',
|
||||
'bin' => 'cache_booking',
|
||||
'expire' => time() + 360,
|
||||
),
|
||||
);
|
||||
*/
|
||||
|
||||
if ($inserting == TRUE) {
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
@@ -925,16 +1039,94 @@ function booking_form($node, &$form_state, $inserting = FALSE)
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to verify if an early access code was valid
|
||||
*/
|
||||
function booking_earlyaccess_feedback_callback($form, &$form_state) {
|
||||
global $event;
|
||||
//$node = $form_state['values']['form_id'];
|
||||
$data = $form_state['input'];
|
||||
//watchdog('booking', '<pre>booking_earlyaccess_feedback_callback 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)) {
|
||||
//watchdog('booking', '<pre>booking_earlyaccess_feedback_callback first if statement passed</pre>');
|
||||
if (isset($data['booking_earlyaccess_code']) && $data['booking_earlyaccess_code'] != '') {
|
||||
//watchdog('booking', '<pre>booking_earlyaccess_feedback_callback second if statement passed</pre>');
|
||||
//perform a database lookup against the booking_earlyaccess_codes table
|
||||
$code_check = db_query("SELECT cid " .
|
||||
"FROM {booking_earlyaccess_codes} " .
|
||||
"WHERE booking_earlyaccess_code = :code AND booking_eventid = :eid AND booking_earlyaccess_code_avail = 'Y'",
|
||||
array(
|
||||
':code' => $data['booking_earlyaccess_code'],
|
||||
':eid' => $event->eid,
|
||||
)
|
||||
)->fetchObject();
|
||||
//watchdog('booking', "<pre>booking_earlyaccess_feedback_callback code check:\n@info</pre>", array('@info' => print_r( $code_check, true)));
|
||||
//no matching code found so return an error
|
||||
if (! $code_check) {
|
||||
//watchdog('booking', "<pre>booking_earlyaccess_feedback_callback code check did not pass!</pre>");
|
||||
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#8c2e0b;font-weight: bold;">' .
|
||||
'You have entered an invalid early registration code. If you do not have a code, please wait until normal registrations open.</span><br /><br /></div>';
|
||||
}
|
||||
//matched a code so let the user know everything is fine
|
||||
else {
|
||||
//watchdog('booking', "<pre>booking_earlyaccess_feedback_callback code check matched</pre>");
|
||||
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#234600;font-weight: bold;">' .
|
||||
'Your early registration code has been validated.<br />Please do not share this code, since it will be validated again when you submit the form.</span><br /><br /></div>';
|
||||
}
|
||||
}
|
||||
//no access code entered but we required one
|
||||
else {
|
||||
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#8c2e0b;font-weight: bold;">' .
|
||||
'You must enter an early access code to register now. If you do not have a code, please wait until normal registrations open.</span><br /><br /></div>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#8c2e0b;font-weight: bold;">Unexpected condition.</span><br /><br /></div>';
|
||||
}
|
||||
|
||||
#fallback
|
||||
return '<div id="booking_earlyaccess_feedback_wrapper">If you have been given an early-access code for registration, please enter it below. ' .
|
||||
'Without this code, your registration will not be accepted.<br />' .
|
||||
'<p><strong>NOTE: each early-access code can only be used once, so don\'t pass it along to your friends!</strong></p></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a number of checks to validate user input
|
||||
*/
|
||||
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)) {
|
||||
if (isset($data['booking_earlyaccess_code']) && $data['booking_earlyaccess_code'] != '') {
|
||||
//perform a database lookup against the booking_earlyaccess_codes table
|
||||
$code_check = db_query("SELECT cid " .
|
||||
"FROM {booking_earlyaccess_codes} " .
|
||||
"WHERE booking_earlyaccess_code = :code AND booking_eventid = :eid AND booking_earlyaccess_code_avail = 'Y'",
|
||||
array(
|
||||
':code' => $data['booking_earlyaccess_code'],
|
||||
':eid' => $event->eid,
|
||||
)
|
||||
)->fetchObject();
|
||||
//see if we got a result
|
||||
if (! $code_check) {
|
||||
form_set_error('booking_earlyaccess_code', t('You have entered an invalid early registration code. If you do not have a code, please wait until normal registrations open.'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
form_set_error('booking_earlyaccess_code', t('You must enter an early access code to register now. If you do not have a code, please wait until normal registrations open.'));
|
||||
}
|
||||
}
|
||||
|
||||
//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
|
||||
@@ -962,7 +1154,6 @@ function booking_form_validate($form, &$form_state) {
|
||||
|
||||
//verify partner id is in the correct format
|
||||
if (isset($data['booking_partner_id']) && $data['booking_partner_id'] != '') {
|
||||
|
||||
if (!is_numeric($data['booking_partner_id'])) {
|
||||
form_set_error('booking_partner_id', t('You have entered an invalid partner registration id. Please ensure you are using only the registration reference number your partner received via email. If you believe this to be incorrect, please !contact using the details provided.', array(
|
||||
'!contact' => l('contact us', 'contact')
|
||||
@@ -1078,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'])) {
|
||||
@@ -1087,13 +1278,19 @@ 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()) {
|
||||
watchdog('booking', "<pre>Detected validation error(s):\n@errors\n\n User data:\n@info</pre>", array(
|
||||
@@ -1103,13 +1300,28 @@ function booking_form_validate($form, &$form_state) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the new node for this booking
|
||||
*/
|
||||
function booking_form_submit($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
|
||||
$values = $form_state['input'];
|
||||
|
||||
|
||||
//do some preprocessing on input
|
||||
//convert names from whatever case they're in to Title Case
|
||||
$values['booking_firstname'] = _booking_ucname($values['booking_firstname']);
|
||||
$values['booking_lastname'] = _booking_ucname($values['booking_lastname']);
|
||||
|
||||
//strip any emojis from user input
|
||||
if (variable_get('booking_enable_emoji_removal', 1) == 1) {
|
||||
foreach ($values as $key => $value) {
|
||||
$values[$key] = _booking_remove_emoji($value);
|
||||
}
|
||||
watchdog('booking_debug', "<pre>Form values after emoji removal:\n@info</pre>", array('@info' => print_r($values, TRUE)));
|
||||
}
|
||||
|
||||
//get DOB from form
|
||||
$dob = _datearray_to_ts($values['booking_dob']);
|
||||
|
||||
@@ -1117,14 +1329,23 @@ function booking_form_submit($form, &$form_state)
|
||||
$payment_total_price = db_query("SELECT booking_price FROM {booking_price} where pid = :pid", array(
|
||||
':pid' => $form_state['input']['booking_payment_id']
|
||||
))->fetchObject();
|
||||
|
||||
//lookup the primary key for the early access code, if it is in use
|
||||
if ((variable_get('booking_enable_earlyaccess_codes', 0) == 1) && (!empty($form_state['input']['booking_earlyaccess_code']))) {
|
||||
$earlyaccess_query = db_query("SELECT cid FROM {booking_earlyaccess_codes} where booking_earlyaccess_code = :code",
|
||||
array(':code' => $values['booking_earlyaccess_code']))
|
||||
->fetchObject();
|
||||
}
|
||||
|
||||
//make a new node object
|
||||
$node = new stdClass();
|
||||
$node = node_type_set_defaults();
|
||||
$node->title = t('!event registration: !name', array(
|
||||
$title = t('!event registration: !name', array(
|
||||
'!event' => $event->booking_eventname,
|
||||
'!name' => $values['booking_firstname'] . ' ' . $values['booking_lastname']
|
||||
));
|
||||
//$title = _booking_remove_emoji($title);
|
||||
$node->title = $title;
|
||||
$node->type = 'booking';
|
||||
$node->status = 1; // set published to true
|
||||
$node->promote = 0; // prevent display on front page
|
||||
@@ -1137,33 +1358,7 @@ function booking_form_submit($form, &$form_state)
|
||||
$node->booking_gender = $values['booking_gender'];
|
||||
$node->booking_dob = $dob;
|
||||
$node->booking_status = 0; //zero means not yet coming. Only change to 1 when a payment is made
|
||||
|
||||
//passport details
|
||||
/*
|
||||
$node->booking_passport_num = empty($values['booking_passport_num']) ? '' : $values['booking_passport_num'];
|
||||
$node->booking_passport_issue_location = empty($values['booking_passport_issue_location']) ? '' : $values['booking_passport_issue_location'];
|
||||
$node->booking_passport_issue_name = empty($values['booking_passport_issue_name']) ? '' : $values['booking_passport_issue_name'];
|
||||
$node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']);
|
||||
$node->booking_destination_country = empty($values['booking_destination_country']) ? '' : $values['booking_destination_country'];
|
||||
$node->booking_travel_insurance = empty($values['booking_travel_insurance']) ? '' : $values['booking_travel_insurance'];
|
||||
|
||||
//flight info, which may not be present
|
||||
$node->booking_outflight_bookingnum = empty($values['booking_outflight_bookingnum']) ? '' : $values['booking_outflight_bookingnum'];
|
||||
$node->booking_outflight_flightnum = empty($values['booking_outflight_flightnum']) ? '' : $values['booking_outflight_flightnum'];
|
||||
$node->booking_outflight_origin = empty($values['booking_outflight_origin']) ? '' : $values['booking_outflight_origin'];
|
||||
$node->booking_outflight_origin_ts = empty($values['booking_outflight_origin_ts']) ? '0' : _datetime_array_to_ts($values['booking_outflight_origin_ts']);
|
||||
$node->booking_outflight_connecting_flightnum = empty($values['booking_outflight_connecting_flightnum']) ? '' : $values['booking_outflight_connecting_flightnum'];
|
||||
$node->booking_outflight_destination = empty($values['booking_outflight_destination']) ? '' : $values['booking_outflight_destination'];
|
||||
$node->booking_outflight_destination_ts = empty($values['booking_outflight_destination_ts']) ? '0' : _datetime_array_to_ts($values['booking_outflight_destination_ts']);
|
||||
|
||||
$node->booking_rtrnflight_bookingnum = empty($values['booking_rtrnflight_bookingnum']) ? '' : $values['booking_rtrnflight_bookingnum'];
|
||||
$node->booking_rtrnflight_flightnum = empty($values['booking_rtrnflight_flightnum']) ? '' : $values['booking_rtrnflight_flightnum'];
|
||||
$node->booking_rtrnflight_origin = empty($values['booking_rtrnflight_origin']) ? '' : $values['booking_rtrnflight_origin'];
|
||||
$node->booking_rtrnflight_origin_ts = empty($values['booking_rtrnflight_origin_ts']) ? '0' : _datetime_array_to_ts($values['booking_rtrnflight_origin_ts']);
|
||||
$node->booking_rtrnflight_connecting_flightnum = empty($values['booking_rtrnflight_connecting_flightnum']) ? '' : $values['booking_rtrnflight_connecting_flightnum'];
|
||||
$node->booking_rtrnflight_destination = empty($values['booking_rtrnflight_destination']) ? '' : $values['booking_rtrnflight_destination'];
|
||||
$node->booking_rtrnflight_destination_ts = empty($values['booking_rtrnflight_destination_ts']) ? '0' : _datetime_array_to_ts($values['booking_rtrnflight_destination_ts']);
|
||||
*/
|
||||
|
||||
//payment details
|
||||
$node->booking_payment_id = $values['booking_payment_id'];
|
||||
|
||||
@@ -1200,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');
|
||||
@@ -1229,6 +1425,10 @@ function booking_form_submit($form, &$form_state)
|
||||
$node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details'];
|
||||
$node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N');
|
||||
$node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details'];
|
||||
$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'];
|
||||
@@ -1253,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);
|
||||
@@ -1275,6 +1475,17 @@ function _booking_form_submit_post_triggers($node)
|
||||
{
|
||||
global $event;
|
||||
|
||||
//mark early access code as being used
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1 && $node->booking_earlyaccess_code_id != '') {
|
||||
watchdog('booking_debug', "<pre>Early access code used, node info below\n@info</pre>", array('@info' => print_r($node, true)));
|
||||
|
||||
//update the database to mark the code as being unavailable
|
||||
db_update('booking_earlyaccess_codes')->fields(array(
|
||||
'booking_earlyaccess_code_avail' => 'N',
|
||||
'booking_earlyaccess_code_nid' => $node->nid,
|
||||
))->condition('cid', $node->booking_earlyaccess_code_id)->execute();
|
||||
}
|
||||
|
||||
//do these triggers really do anything? The partner id and bf/gf id won't be set in initial submit
|
||||
|
||||
//if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id
|
||||
|
@@ -4,11 +4,20 @@
|
||||
function booking_node_presave($node) {
|
||||
global $event;
|
||||
|
||||
if($node->type == 'booking')
|
||||
{
|
||||
$node->title = t('!event registration: !name',
|
||||
array('!event' => $event->booking_eventname, '!name' => $node->booking_firstname . ' ' . $node->booking_lastname));
|
||||
//watchdog('booking', 'Presave of person: @info', array('@info' => var_export($node, TRUE)));
|
||||
if($node->type == 'booking') {
|
||||
$title = t('!event registration: !name', array(
|
||||
'!event' => $event->booking_eventname,
|
||||
// no longer needed since applied at node creation
|
||||
'!name' => _booking_ucname($node->booking_firstname . ' ' . $node->booking_lastname),
|
||||
//'!name' => $node->booking_firstname . ' ' . $node->booking_lastname,
|
||||
));
|
||||
|
||||
//strip any emojis from user input if that feature is enabled
|
||||
if (variable_get('booking_enable_emoji_removal', 1) == 1) {
|
||||
$title = _booking_remove_emoji($title);
|
||||
}
|
||||
|
||||
$node->title = $title;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +43,12 @@ function _booking_node_create_mysqlview()
|
||||
$query = db_select('booking_person', 'p');
|
||||
//add price info
|
||||
$query->join('booking_price', 'pr', 'p.booking_payment_id = pr.pid');
|
||||
|
||||
//add the join for earlyaccess code if enabled
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) {
|
||||
$query->leftJoin('booking_earlyaccess_codes', 'c', 'p.nid = c.booking_earlyaccess_code_nid');
|
||||
}
|
||||
|
||||
//add travel form info if it exists
|
||||
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
||||
|
||||
@@ -43,7 +58,7 @@ function _booking_node_create_mysqlview()
|
||||
$query->leftJoin('booking_room_definition', 'r', 'rm.booking_roomid = r.rid');
|
||||
$query->leftJoin('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
|
||||
}
|
||||
|
||||
|
||||
//add the joins to flatten out study groups into columns
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
//get details of the study groups defined for this event
|
||||
@@ -56,7 +71,12 @@ function _booking_node_create_mysqlview()
|
||||
$query->leftJoin('booking_studygroup_mapping', 's' . $id, 'p.nid = s' . $id . '.booking_node_id and s' . $id . '.booking_studygroup_id = ' . $id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//add the joins for variety session info if enabled
|
||||
if (variable_get('booking_enable_variety_sessions', 0) == 1) {
|
||||
$query->leftJoin('booking_variety_regn', 'v', 'p.nid = v.booking_person_nid');
|
||||
}
|
||||
|
||||
//filter the results either by current active event
|
||||
// @todo is this filter really necessary?
|
||||
$query->condition('p.booking_eventid', $event->eid, '=');
|
||||
@@ -65,6 +85,10 @@ function _booking_node_create_mysqlview()
|
||||
$query->fields('p')
|
||||
->fields('t')
|
||||
->fields('pr', array('booking_price', 'booking_price_descrip','booking_late_price'));
|
||||
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) {
|
||||
$query->fields('c', array('cid', 'booking_earlyaccess_code'));
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$query->fields('rm', array('booking_room_bedtype'))
|
||||
@@ -83,6 +107,11 @@ function _booking_node_create_mysqlview()
|
||||
}
|
||||
}
|
||||
|
||||
//add field for variety session registrations if enabled
|
||||
if (variable_get('booking_enable_variety_sessions', 0) == 1) {
|
||||
$query->fields('v', array('booking_variety_ids'));
|
||||
}
|
||||
|
||||
//now that we have built the query as a SelectObject, turn it into a string we can use to create a view
|
||||
$querystring=$query->__toString();
|
||||
$querystring=str_replace("{",'',$querystring);
|
||||
@@ -268,14 +297,26 @@ function booking_load($nodes) {
|
||||
}
|
||||
}
|
||||
|
||||
//watchdog('booking', 'Final loaded node: @info', array('@info' => var_export($nodes, TRUE)));
|
||||
//watchdog('booking', 'Final loaded node: @info', array('@info' => var_export($nodes, TRUE)));
|
||||
// no return necessary since $nodes array members reference objects global to this function
|
||||
}
|
||||
|
||||
function booking_insert($node) {
|
||||
watchdog('booking_debug', "<pre>Inserting node:\n@info</pre>", array('@info' => print_r($node, TRUE)));
|
||||
|
||||
//TODO: Generalise this by using the keys from $node instead of hard coding everything
|
||||
|
||||
$data = array();
|
||||
|
||||
foreach ($node as $key => $value) {
|
||||
//check if the key is a field that belongs in the database
|
||||
if ((strpos($key, "booking_") === 0) || $key === "nid") {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
watchdog('booking_debug', "<pre>Inserting node:\n@info</pre>", array('@info' => print_r($data, TRUE)));
|
||||
db_insert('booking_person')->fields($data)->execute();
|
||||
|
||||
/*
|
||||
db_insert('booking_person')
|
||||
->fields(array(
|
||||
'nid' => $node->nid,
|
||||
@@ -348,6 +389,7 @@ function booking_insert($node) {
|
||||
'booking_comment_field' => $node->booking_comment_field,
|
||||
))
|
||||
->execute();
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,12 +400,77 @@ function booking_insert($node) {
|
||||
*/
|
||||
function booking_update($node) {
|
||||
global $event;
|
||||
$data = array();
|
||||
|
||||
//TODO: make sure these exclusions match with admin selected options (eg passport details)
|
||||
|
||||
//these fields should be stored in the database as Y or N, but come back from the FAPI as 1 or 0
|
||||
$boolean_keys = array('booking_baptised', 'booking_married', 'booking_help_praying', 'booking_help_meditations', 'booking_help_reading',
|
||||
'booking_help_chairing', 'booking_help_readgroup_lead', 'booking_help_discussgroup_lead', 'booking_lifesaver',
|
||||
'booking_firstaid', 'booking_nurse', 'booking_doctor', 'booking_has_mission_experience', 'booking_skills_builder',
|
||||
'booking_skills_cooking', 'booking_skills_childminding', 'booking_skills_language', 'booking_skills_other',
|
||||
'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',
|
||||
'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_variety_ids'
|
||||
);
|
||||
|
||||
//before we update this user, check what their previous registration status was
|
||||
$previous_status = db_query("SELECT booking_status, booking_payment_id, booking_total_pay_reqd, booking_amount_paid FROM {booking_person} where nid = :nid", array(
|
||||
':nid' => $node->nid))
|
||||
->fetchObject();
|
||||
|
||||
// process the input data before updating database
|
||||
foreach ($node as $key => $value) {
|
||||
//check if the key is a field that belongs in the database
|
||||
if ((strpos($key, "booking_") === 0) || $key === "nid") {
|
||||
//what special handling does this field need?
|
||||
|
||||
//handle dates properly
|
||||
if ((strpos($key, "booking_dob") === 0) || (strpos($key, "booking_passport_issue_date") === 0)) {
|
||||
$data[$key] = _date_to_ts($value);
|
||||
}
|
||||
//skip these fields from the update of booking_person
|
||||
elseif (in_array($key, $excluded_keys, FALSE)) {
|
||||
//do nothing
|
||||
}
|
||||
//this field needs 0/1 translated to N/Y
|
||||
elseif (in_array($key, $boolean_keys, FALSE)) {
|
||||
$data[$key] = $value == 1 ? 'Y' : 'N';
|
||||
}
|
||||
//this field has a default value of zero rather than null
|
||||
elseif (in_array($key, $default_zero_keys, FALSE)) {
|
||||
$data[$key] = $value == '' ? 0 : $value;
|
||||
}
|
||||
//just handle this field normally
|
||||
else {
|
||||
if (variable_get('booking_enable_emoji_removal', 1) == 1) {
|
||||
$data[$key] = _booking_remove_emoji($value);
|
||||
}
|
||||
else {
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//make sure the name is the correct case
|
||||
//not really needed for node updates since it now applies at node creation
|
||||
$data['booking_firstname'] = _booking_ucname($data['booking_firstname']);
|
||||
$data['booking_lastname'] = _booking_ucname($data['booking_lastname']);
|
||||
|
||||
//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)));
|
||||
db_update('booking_person')
|
||||
->fields(array (
|
||||
@@ -435,10 +542,12 @@ function booking_update($node) {
|
||||
'booking_random_facts' => $node->booking_random_facts,
|
||||
'booking_status' => $node->booking_status,
|
||||
'booking_comment_field' => $node->booking_comment_field,
|
||||
'booking_song_choice' => $node->booking_song_choice,
|
||||
'booking_freestyle_text' => $node->booking_freestyle_text,
|
||||
))
|
||||
->condition('nid', $node->nid)
|
||||
->execute();
|
||||
|
||||
*/
|
||||
//***now process some post-update triggers***
|
||||
|
||||
//if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id
|
||||
@@ -515,6 +624,9 @@ function booking_update($node) {
|
||||
else {
|
||||
watchdog('booking', 'Still no room on the booked in list though.');
|
||||
}
|
||||
|
||||
// Update waiting list positions
|
||||
_booking_waitinglist_update_trigger();
|
||||
}
|
||||
//check if someone has moved to booked-in list from waiting-list
|
||||
elseif ($previous_status->booking_status == 2 && $node->booking_status == 1) {
|
||||
@@ -540,6 +652,8 @@ function booking_update($node) {
|
||||
$waitinglist_nid = _booking_get_waitinglist_top();
|
||||
}
|
||||
|
||||
// Update waiting list positions
|
||||
_booking_waitinglist_update_trigger();
|
||||
}
|
||||
//check if someone has been demoted to the "missed payment deadline" status from being booked-in
|
||||
elseif ($previous_status->booking_status == 1 && $node->booking_status == 4) {
|
||||
@@ -563,7 +677,7 @@ function booking_update($node) {
|
||||
//-1 means there was no one on the waiting list
|
||||
if ($temp_nid != -1) {
|
||||
//update their registration status
|
||||
_booking_change_status($temp_nid,1);
|
||||
_booking_change_status($temp_nid, 1);
|
||||
//send them an email
|
||||
_booking_promoted_from_waitinglist_email($temp_nid);
|
||||
}
|
||||
@@ -686,11 +800,32 @@ function booking_delete($node) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to update the waiting list position for everyone on the waiting list
|
||||
*/
|
||||
function _booking_waitinglist_update_trigger()
|
||||
{
|
||||
global $event;
|
||||
$waiting_list = _booking_get_waitinglist();
|
||||
$counter = 1;
|
||||
|
||||
foreach ($waiting_list as $person) {
|
||||
//watchdog('booking_debug', "Updating node !nid to have waitlist position of !counter", array('!nid' => $person->nid, '!counter' => $counter));
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_waitlist_pos' => $counter++,
|
||||
))
|
||||
->condition('nid', $person->nid)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
function booking_view($node, $view_mode) {
|
||||
global $event;
|
||||
$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)
|
||||
@@ -735,10 +870,14 @@ function booking_view($node, $view_mode) {
|
||||
$rows[] = array(t('Name:'), t('!first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname)));
|
||||
$rows[] = array(t('Gender:'), t('!gender', array('!gender' => $node->booking_gender == 'M' ? 'Male' : 'Female')));
|
||||
$rows[] = array(t('Status:'), t('!status', array('!status' => _booking_status_generate($node->booking_status))));
|
||||
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1) {
|
||||
$rows[] = array(t('Early Access Code:'), t('!code', array('!code' => $node->booking_earlyaccess_code)));
|
||||
}
|
||||
$rows[] = array(t('Internal comments on this registration:'), t('<i>!comment</i>', array('!comment' => $node->booking_comment_field)));
|
||||
$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'))));
|
||||
@@ -749,10 +888,18 @@ function booking_view($node, $view_mode) {
|
||||
$rows[] = array(t('Total Amount Due:'), t('!amount_paid', array('!amount_paid' => $node->booking_total_pay_reqd)));
|
||||
$rows[] = array(t('Refund Due:'), t('!amount_due', array('!amount_due' => $node->booking_refund_due)));
|
||||
$rows[] = array(t('Refund Processed:'), t('!ans', array('!ans' => ($node->booking_refund_processed == 'Y' ? 'Yes' : 'No'))));
|
||||
$rows[] = array(t('Random Facts:'), t('!facts', array('!facts' => $node->booking_random_facts)));
|
||||
|
||||
//$rows[] = array(t('Random Facts:'), t('!facts', array('!facts' => $node->booking_random_facts)));
|
||||
if (variable_get('booking_enable_songchoice', 0) == 1) {
|
||||
$rows[] = array(t('Song Choice:'), t('!song', array('!song' => $node->booking_song_choice)));
|
||||
}
|
||||
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:'), $node->booking_shirt_size);
|
||||
$rows[] = array(t('Hoodie Size:'), t('!size', array('!size' => $node->booking_shirt_size)));
|
||||
}
|
||||
$rows[] = array(t('Ecclesia:'), t('!ecclesia', array('!ecclesia' => $node->booking_ecclesia)));
|
||||
$rows[] = array(t('Baptised:'), t('!ans', array('!ans' => ($node->booking_baptised == 'Y' ? 'Yes' : 'No'))));
|
||||
|
1695
booking.reports.inc
1695
booking.reports.inc
File diff suppressed because it is too large
Load Diff
@@ -139,11 +139,11 @@ function booking_room_edit_form($node, &$form_state, $nid) {
|
||||
'#title' => t('Room Location'),
|
||||
'#options' => $location_options,
|
||||
'#default_value' => $person->booking_room_location_id,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_roomnum_wrapper',
|
||||
'callback' => 'booking_roomnum_ajax_callback',
|
||||
),
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_roomnum_wrapper',
|
||||
'callback' => 'booking_roomnum_ajax_callback',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking_room_number'] = array(
|
||||
@@ -154,18 +154,18 @@ function booking_room_edit_form($node, &$form_state, $nid) {
|
||||
'#suffix' => '</div>',
|
||||
'#options' => _booking_get_roomedit_roomnum_options($selected_room_location),
|
||||
'#default_value' => isset($form_state['values']['booking_room_number']) ? $form_state['values']['booking_room_number'] : $person->booking_room_number,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_bedtype_wrapper',
|
||||
'callback' => 'booking_bedtype_ajax_callback',
|
||||
),
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_bedtype_wrapper',
|
||||
'callback' => 'booking_bedtype_ajax_callback',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking_room_bedtype'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Bed Type'),
|
||||
'#prefix' => '<div id="booking_bedtype_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#prefix' => '<div id="booking_bedtype_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#options' => _booking_get_roomedit_bedtype_options($selected_room_location, $selected_room_num),
|
||||
'#default_value' => $person->booking_room_bedtype,
|
||||
);
|
||||
|
@@ -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;
|
||||
@@ -44,7 +45,7 @@ function booking_room_view_summary() {
|
||||
*/
|
||||
function booking_roomlocation_define_form($node, &$form_state, $create, $editid = 0)
|
||||
{
|
||||
$form = array ();
|
||||
$form = array();
|
||||
$prefix = "<p>Add a new room location definition</p>";
|
||||
|
||||
if ($create == true)
|
||||
@@ -432,9 +433,13 @@ 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'])) {
|
||||
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.'));
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -4,7 +4,6 @@
|
||||
* @file
|
||||
* Functions for stripe payment integration
|
||||
* @see https://github.com/ericthelast/drupal-stripe-form and https://www.webomelette.com/drupal-stripe-integration
|
||||
* Australian test number is 4000000360000006
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -31,29 +30,52 @@ function _booking_get_stripe_private_key() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to calculate stripe transaction fees
|
||||
*/
|
||||
function _booking_add_stripe_fees($amount, $country) {
|
||||
//add the 30 cent fixed cost
|
||||
$result = '0.00';
|
||||
$result = (float) ($amount + (float) variable_get('booking_stripe_transaction_fee_fixedcost', '0.3'));
|
||||
|
||||
//and the 2.6 percent transaction fee for australian transaction with no currency conversion
|
||||
if ($country == variable_get('booking_default_country', 'Australia')) {
|
||||
$percentage = (float) variable_get('booking_stripe_transaction_fee_percentage', '1.75');
|
||||
} else {
|
||||
$percentage = (float) variable_get('booking_stripe_transaction_fee_percentage_intl', '2.9');
|
||||
}
|
||||
|
||||
//apply the percentage
|
||||
$percentage = (float) $percentage / 100;
|
||||
$result = $result / (1 - $percentage);
|
||||
|
||||
//return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate paypal form for payments
|
||||
*/
|
||||
function _booking_stripe_form($person, $invoiceid, $amount_owing, $button_text) {
|
||||
$payment_form = drupal_get_form('booking_stripe_form', $person, $invoiceid, $amount_owing, $button_text);
|
||||
function _booking_stripe_form($person, $invoiceid, $net_amount_owing, $button_text) {
|
||||
$payment_form = drupal_get_form('booking_stripe_form', $person, $invoiceid, $net_amount_owing, $button_text);
|
||||
return drupal_render($payment_form);
|
||||
}
|
||||
|
||||
function booking_stripe_form($node, &$form_state, $person, $invoiceid, $amount_owing, $button_text) {
|
||||
function booking_stripe_form($node, &$form_state, $person, $invoiceid, $net_amount_owing, $button_text) {
|
||||
global $event;
|
||||
$settings = array();
|
||||
$form = array();
|
||||
|
||||
//set some values for our internal stripe library to help process the form
|
||||
//these will be used by the attached js from booking-strip library to identify which parts of the form to process
|
||||
|
||||
// @todo set name and image in the admin page
|
||||
$setting['booking_stripe'] = array(
|
||||
'pubkey' => _booking_get_stripe_public_key(),
|
||||
'form_selector' => str_replace('_', '-', __FUNCTION__),
|
||||
'name' => 'Study Week',
|
||||
'image' => '',
|
||||
'name' => $event->booking_eventname,
|
||||
'image' => variable_get('booking_stripe_logo', ''),
|
||||
'payment_button_label' => '{{amount}} (plus fees)',
|
||||
);
|
||||
|
||||
//attach settings and javascript to the form
|
||||
$form['#attached'] = array(
|
||||
'js' => array(
|
||||
@@ -63,38 +85,28 @@ function booking_stripe_form($node, &$form_state, $person, $invoiceid, $amount_o
|
||||
array('booking', 'booking-stripe'),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
//paypal specific settings
|
||||
$vars = array(
|
||||
'module' => 'Booking System',
|
||||
'type' => $event->booking_eventname,
|
||||
'nid' => $person->nid,
|
||||
'email' => $person->booking_email,
|
||||
'description' => $event->booking_eventname . ' ' . $person->booking_price_descrip,
|
||||
'invoice' => $invoiceid,
|
||||
'amount' => $amount_owing,
|
||||
'amount' => $net_amount_owing,
|
||||
'gross_amount' => number_format(_booking_add_stripe_fees($net_amount_owing, $person->booking_country), 2, '.', ''),
|
||||
'foreign_gross_amount' => number_format(_booking_add_stripe_fees($net_amount_owing, 'FakeCountry'), 2, '.', ''),
|
||||
'last_name' => $person->booking_lastname,
|
||||
'first_name' => $person->booking_firstname,
|
||||
'uuid' => $person->booking_tempid,
|
||||
'token_id' => '',
|
||||
'token_email' => ''
|
||||
'token_email' => '',
|
||||
'token_client_ip' => '',
|
||||
'card_brand' => '',
|
||||
'card_country' => '',
|
||||
'card_cvc_check' => '',
|
||||
'card_address_zip_check' => '',
|
||||
);
|
||||
|
||||
/*
|
||||
$form['#id'] = 'booking_stripe_form';
|
||||
$form['#attached']['js'] = array(
|
||||
array(
|
||||
'data' => 'https://checkout.stripe.com/checkout.js',
|
||||
'type' => 'external',
|
||||
),
|
||||
array(
|
||||
'data' => drupal_get_path('module', 'booking') . '/booking.stripe.js',
|
||||
'type' => 'file',
|
||||
),
|
||||
);
|
||||
*/
|
||||
|
||||
//turn the array into a form
|
||||
foreach($vars as $name => $value) {
|
||||
$form[$name] = array(
|
||||
@@ -139,25 +151,45 @@ function booking_stripe_checkout_form_validate($form, &$form_state) {
|
||||
*/
|
||||
function booking_stripe_validate_form_payment($form, &$form_state) {
|
||||
global $event;
|
||||
|
||||
if($errors = form_get_errors()) {
|
||||
//@todo log an error via watchdog
|
||||
return;
|
||||
}
|
||||
|
||||
$path = libraries_get_path('stripe');
|
||||
require_once($path . '/init.php');
|
||||
|
||||
\Stripe\Stripe::setApiKey(_booking_get_stripe_private_key());
|
||||
//$token = $form_state['values']['stripeToken'];
|
||||
//$amount = $form_state['values']['amount'] * 100;
|
||||
|
||||
//get values from original form
|
||||
//@todo sanitise this input
|
||||
$token = (isset($form_state['input']['token_id']) ? $form_state['input']['token_id'] : '');
|
||||
$amount = (isset($form_state['input']['amount']) ? $form_state['input']['amount'] : '');
|
||||
$amount = (isset($form_state['input']['gross_amount']) ? $form_state['input']['gross_amount'] : '');
|
||||
$invoice = (isset($form_state['input']['invoice']) ? $form_state['input']['invoice'] : '');
|
||||
$nid = (isset($form_state['input']['nid']) ? $form_state['input']['nid'] : '');
|
||||
$tempid= (isset($form_state['input']['uuid']) ? $form_state['input']['uuid'] : '');
|
||||
$last_name = (isset($form_state['input']['last_name']) ? $form_state['input']['last_name'] : '');
|
||||
$first_name = (isset($form_state['input']['first_name']) ? $form_state['input']['first_name'] : '');
|
||||
watchdog('booking_debug', "<pre>Stripe token:\n@info</pre>", array('@info' => print_r( $token, true)));
|
||||
$card_brand = (isset($form_state['input']['card_brand']) ? $form_state['input']['card_brand'] : '');
|
||||
$card_country = (isset($form_state['input']['card_country']) ? $form_state['input']['card_country'] : '');
|
||||
|
||||
//if card issuer is american express then the transaction fee charged should be the international rate
|
||||
if ($card_brand === 'American Express') {
|
||||
$person = node_load($nid);
|
||||
$amount = (isset($form_state['input']['foreign_gross_amount']) ? $form_state['input']['foreign_gross_amount'] : $amount);
|
||||
watchdog('booking_debug', "Detected Amex card use, setting amount to !amount", array('!amount' => $amount));
|
||||
}
|
||||
//if card is issued from a different country then apply the international rate also
|
||||
//@todo figure out a better way of matching country name to country code
|
||||
// probably via https://api.drupal.org/api/drupal/includes%21locale.inc/function/country_get_list/7.x
|
||||
//NOTE! This will result in incorrect charge amounts when using the test API due to a stripe bug
|
||||
//since the australian test card number gets charged 2.9% instead of 1.75%
|
||||
elseif (variable_get('booking_default_country', 'Australia') === 'Australia' && $card_country !== 'AU') {
|
||||
$person = node_load($nid);
|
||||
$amount = (isset($form_state['input']['foreign_gross_amount']) ? $form_state['input']['foreign_gross_amount'] : $amount);
|
||||
watchdog('booking_debug', "Detected foreign card use (country !country), setting amount to !amount",
|
||||
array('!country' => $card_country, '!amount' => $amount));
|
||||
}
|
||||
|
||||
// Create the charge on Stripe's servers - this will charge the user's card
|
||||
try {
|
||||
@@ -176,9 +208,9 @@ 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, 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', 'Charge created successfully');
|
||||
//watchdog('booking_debug', 'Charge created successfully');
|
||||
_booking_process_stripe_payment($charge, $token);
|
||||
//$form_state['stripeform_charge'] = $charge;
|
||||
// @todo call _booking_process_stripe_payment to store payment
|
||||
@@ -190,40 +222,30 @@ 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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler.
|
||||
*/
|
||||
function booking_stripeform_form_submit($form, &$form_state) {
|
||||
drupal_set_message('Charge successful!');
|
||||
}
|
||||
|
||||
/**
|
||||
* FAPI #pre_render callback.
|
||||
*
|
||||
* Removes the name field form a form element.
|
||||
*/
|
||||
function booking_stripeform_remove_name($element) {
|
||||
unset($element['#name']);
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
||||
function _booking_process_stripe_payment($charge, $token) {
|
||||
function _booking_process_stripe_payment(&$charge, $token) {
|
||||
global $event;
|
||||
$balance_payment = false;
|
||||
$amount_owing = 0;
|
||||
@@ -285,10 +307,9 @@ function _booking_process_stripe_payment($charge, $token) {
|
||||
'booking_first_name' => $charge->metadata->first_name,
|
||||
'booking_last_name' => $charge->metadata->last_name,
|
||||
'booking_buyer_email' => $charge->receipt_email,
|
||||
//'booking_payer_status' => $data['payer_status'],
|
||||
'booking_item_name' => $charge->description,
|
||||
'booking_ipn_track_id' => $charge->id,
|
||||
'booking_stripe_token' => $token,
|
||||
'booking_stripe_response' => $charge->toJSON(),
|
||||
))
|
||||
->execute();
|
||||
|
||||
|
@@ -1,16 +1,20 @@
|
||||
jQuery(document).ready(function($) {
|
||||
var settings = Drupal.settings.booking_stripe;
|
||||
var $stripeForm = $("#" + settings.form_selector);
|
||||
var $settings = Drupal.settings.booking_stripe;
|
||||
var $stripeForm = $("#" + $settings.form_selector);
|
||||
var handler = StripeCheckout.configure({
|
||||
key: settings.pubkey,
|
||||
image: settings.image,
|
||||
key: $settings.pubkey,
|
||||
image: $settings.image,
|
||||
locale: 'auto',
|
||||
token: function(token) {
|
||||
try {
|
||||
// Use the token to create the charge with a server-side script.
|
||||
// You can access the token ID with `token.id`
|
||||
//store relevant parts of the returned token into hidden form elements
|
||||
$(':input[name="token_id"]', $stripeForm).val(token.id);
|
||||
$(':input[name="token_email"]', $stripeForm).val(token.email);
|
||||
$(':input[name="token_client_ip"]', $stripeForm).val(token.client_ip);
|
||||
$(':input[name="card_brand"]', $stripeForm).val(token.card.brand);
|
||||
$(':input[name="card_country"]', $stripeForm).val(token.card.country);
|
||||
$(':input[name="card_cvc_check"]', $stripeForm).val(token.card.cvc_check);
|
||||
$(':input[name="card_address_zip_check"]', $stripeForm).val(token.card.address_zip_check);
|
||||
$stripeForm.get(0).submit();
|
||||
}
|
||||
catch(err) {
|
||||
@@ -21,23 +25,17 @@ jQuery(document).ready(function($) {
|
||||
});
|
||||
|
||||
$('.form-submit').click(function (e) {
|
||||
//currentForm = $(this).closest('form');
|
||||
//if (currentForm === undefined)
|
||||
// return;
|
||||
var settings = Drupal.settings.booking_stripe;
|
||||
var $stripeForm = $("#" + settings.form_selector);
|
||||
//$description = $(':input[name="description"]', $stripeForm).val();
|
||||
//console.log([$description]);
|
||||
//description: currentForm.find('input[name="description"]').val(),
|
||||
//email: currentForm.find('input[name="email"]').val(),
|
||||
//amount: currentForm.find('input[name="amount"]').val() * 100,
|
||||
//alert($(':input[name="description"]', $stripeForm));
|
||||
var $settings = Drupal.settings.booking_stripe;
|
||||
var $stripeForm = $("#" + $settings.form_selector);
|
||||
var $amount = $(':input[name="amount"]', $stripeForm).val() * 100;
|
||||
|
||||
handler.open({
|
||||
name: settings.name,
|
||||
currency: "aud",
|
||||
name: $settings.name,
|
||||
panelLabel: $settings.payment_button_label,
|
||||
currency: "AUD",
|
||||
description: $(':input[name="description"]', $stripeForm).val(),
|
||||
email: $(':input[name="email"]', $stripeForm).val(),
|
||||
amount: $(':input[name="amount"]', $stripeForm).val() * 100,
|
||||
amount: Math.round($amount),
|
||||
zipCode: true,
|
||||
closed: function() {
|
||||
//document.getElementById("booking_stripe_form").submit();
|
||||
@@ -45,8 +43,10 @@ jQuery(document).ready(function($) {
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
/*
|
||||
// Close Checkout on page navigation
|
||||
//$(window).on('popstate', function() {
|
||||
// handler.close();
|
||||
//});
|
||||
$(window).on('popstate', function() {
|
||||
handler.close();
|
||||
});
|
||||
*/
|
||||
});
|
@@ -108,7 +108,7 @@ function _booking_studygroups_retrieve_eligible_people() {
|
||||
FROM (
|
||||
SELECT p.nid, p.booking_firstname, p.booking_lastname, p.booking_state, p.booking_country, p.booking_readinggroup, pay.booking_payment_date, p.booking_status, p.booking_gender, p.booking_dob
|
||||
FROM {booking_person} p, {booking_payment} pay
|
||||
WHERE booking_eventid = :eid and p.nid = pay.booking_person_nid and ( booking_status = 2 or booking_status = 4)
|
||||
WHERE p.booking_eventid = :eid and p.nid = pay.booking_person_nid and ( p.booking_status = 2 or p.booking_status = 4)
|
||||
LIMIT 100
|
||||
) AS booking
|
||||
WHERE booking_gender = \'M\'
|
||||
@@ -197,6 +197,7 @@ function _booking_studygroups_name_autocomplete($string) {
|
||||
|
||||
/**
|
||||
* Function to allow admin to edit leaders and helpers for a study group
|
||||
* Not sure where the original idea came from but https://knackforge.com/blog/selvam/drupal-7-creating-editable-table-form-api is similar
|
||||
*/
|
||||
function booking_studygroup_leadhelp_edit_form($node, &$form_state, $group_id) {
|
||||
global $event;
|
||||
@@ -473,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>");
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@ function booking_available_leadhelp_select_form($node, &$form_state, $group_id)
|
||||
global $event;
|
||||
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
$form = array();
|
||||
$options = array();
|
||||
$group_options = array();
|
||||
$session_options = array();
|
||||
|
||||
@@ -358,8 +358,8 @@ function booking_studygroups_edit_form($node, &$form_state, $nid) {
|
||||
global $event;
|
||||
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
$form = array ();
|
||||
$rows = array ();
|
||||
$form = array();
|
||||
$rows = array();
|
||||
$session_options = array();
|
||||
$readinggroup_options = array();
|
||||
$session_options[0] = '';
|
||||
@@ -786,7 +786,7 @@ function booking_studygroups_update_form($node, &$form_state, $sid) {
|
||||
//if we didn't find an existing record, add it to the list to insert
|
||||
if (! $found && $person->session <> 0) {
|
||||
$message = t('Found no existing study group session for user id !id (!name). Adding to list of inserts for session !session.',
|
||||
array('!id' => $person->nid, '!sid' => $mapping->sid, '!session' => $person->session,
|
||||
array('!id' => $person->nid, '!session' => $person->session,
|
||||
'!name' => $person->booking_firstname . " " . $person->booking_lastname
|
||||
));
|
||||
|
||||
@@ -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',
|
||||
@@ -83,7 +88,7 @@ function booking_studygroups_view_summary() {
|
||||
*/
|
||||
function booking_studygroups_define_form($node, &$form_state, $create, $editid = 0)
|
||||
{
|
||||
$form = array ();
|
||||
$form = array();
|
||||
$prefix = "<p>Add a new study group definition</p>";
|
||||
|
||||
if ($create == true) {
|
||||
@@ -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 "";
|
||||
@@ -43,6 +42,13 @@ function booking_studygroups_csv_report($group_id) {
|
||||
WHERE m.booking_studygroup_id = :sid ORDER BY m.booking_session_id, m.booking_studygroup_role DESC, p.booking_lastname",
|
||||
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) {
|
||||
@@ -66,10 +72,9 @@ 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)));
|
||||
|
||||
|
||||
//calculate the CSV layout
|
||||
$header_array = array_keys($data);
|
||||
$maximums = array();
|
||||
@@ -164,7 +169,8 @@ function booking_studygroups_leadhelp_view_summary() {
|
||||
} //end iterate person list
|
||||
|
||||
//output everything
|
||||
$output .= t("<h3>!event Study Group Leaders and Helpers</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= t("<h3>!event Study Group Leaders and Helpers</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= t("<p>This page lists all males that are either booked in or on the waiting list.</p>");
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
|
||||
return $output;
|
||||
|
@@ -13,7 +13,7 @@ function booking_tokens_admin() {
|
||||
'format' => filter_default_format(),
|
||||
);
|
||||
|
||||
$form = array ();
|
||||
$form = array();
|
||||
$default_aims_and_rules_text = "<p>During [booking:eventname] we ask that you consider the following so that each of us can be free from distraction whilst we grow in Christ together. Christ is our ultimate example so in all actions, thoughts and words we ask that you demonstrate behaviour that emulates him.</p>\n" .
|
||||
"<ul><li>Please leave distractions like iPods, MP3 players, etc at home as this will help us all have a more uplifting time</li>\n" .
|
||||
"<li>No alcohol or illicit drugs are allowed at [booking:eventname]. Not only do these do serious harm to you but can endanger others who attend. Only bring things that better yourself and others</li>\n" .
|
||||
@@ -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
|
||||
/*
|
||||
@@ -361,10 +370,10 @@ function booking_tokens_admin_validate($form, $form_state) {
|
||||
function booking_token_info() {
|
||||
|
||||
$info['types']['booking'] = array(
|
||||
'name' => t('Booking Tokens'),
|
||||
'description' => t('Tokens related to bookings module.'),
|
||||
'needs-data' => 'booking',
|
||||
);
|
||||
'name' => t('Booking Tokens'),
|
||||
'description' => t('Tokens related to bookings module.'),
|
||||
'needs-data' => 'booking',
|
||||
);
|
||||
$info['tokens']['booking']['eventname'] = array(
|
||||
'name' => t('Event Name'),
|
||||
'description' => t('Name of the current event.')
|
||||
@@ -421,6 +430,10 @@ function booking_token_info() {
|
||||
'name' => t('Confirm Payment Link'),
|
||||
'description' => t('If using paypal, the link to the booking confirmation page to complete a registration.')
|
||||
);
|
||||
$info['tokens']['booking']['booking-uuid'] = array(
|
||||
'name' => t('Unique User ID'),
|
||||
'description' => t('The unique user id used to create links to forms such as payment and travel.')
|
||||
);
|
||||
$info['tokens']['booking']['paypal-deposit-amount'] = array(
|
||||
'name' => t('Paypal Deposit Only'),
|
||||
'description' => t('The deposit amount required to confirm the registration including paypal fees.')
|
||||
@@ -436,7 +449,19 @@ function booking_token_info() {
|
||||
$info['tokens']['booking']['paypal-total-form'] = array(
|
||||
'name' => t('Paypal Total Form Button'),
|
||||
'description' => t('The paypal form for the total amount.')
|
||||
);
|
||||
$info['tokens']['booking']['stripe-deposit-amount'] = array(
|
||||
'name' => t('Stripe Deposit Only'),
|
||||
'description' => t('The deposit amount required to confirm the registration including stripe fees. These tokens are only used for display purposes, not in the actual calculations.')
|
||||
);
|
||||
$info['tokens']['booking']['stripe-total-amount'] = array(
|
||||
'name' => t('Stripe Outstanding Balance'),
|
||||
'description' => t('The total amount required to complete the registration including stripe fees.')
|
||||
);
|
||||
$info['tokens']['booking']['stripe-total-amount-intl'] = array(
|
||||
'name' => t('Stripe Outstanding Balance International'),
|
||||
'description' => t('The total amount required to complete the registration including international or amex stripe fees.')
|
||||
);
|
||||
$info['tokens']['booking']['stripe-deposit-form'] = array(
|
||||
'name' => t('Stripe Deposit Form Button'),
|
||||
'description' => t('The stripe popup form for the deposit amount.')
|
||||
@@ -471,8 +496,12 @@ 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'),
|
||||
'description' => t('Details of room allocated to attendee.')
|
||||
@@ -485,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;
|
||||
}
|
||||
|
||||
@@ -517,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];
|
||||
@@ -566,6 +618,7 @@ function booking_define_personspecific_tokens($node)
|
||||
{
|
||||
global $event;
|
||||
$amount_paid = 0;
|
||||
$payment_processor_type = variable_get('booking_payment_processor', 0);
|
||||
|
||||
//get a count of the total number of people booked in to this event
|
||||
//but don't include people who haven't paid or have withdrawn their booking
|
||||
@@ -601,32 +654,78 @@ function booking_define_personspecific_tokens($node)
|
||||
$tokens['lname'] = ucwords(trim($node->booking_lastname));
|
||||
$tokens['dietary'] = ucwords(trim($node->booking_dietary));
|
||||
$tokens['booking-id'] = $node->nid;
|
||||
$tokens['booking-uuid'] = $tempid;
|
||||
$tokens['payment-required'] = _booking_amount_owing($node, $amount_paid, FALSE);
|
||||
$tokens['refund-due'] = $node->booking_refund_due;
|
||||
$tokens['waitinglist-position'] = $result->num_ppl - variable_get('booking_regn_limit',350) + 1;
|
||||
$tokens['payment-transaction-desc'] = $node->nid . ' ' . $node->booking_lastname;
|
||||
$tokens['balance-payment-link'] = url('balance/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['confirm-payment-link'] = url('confirm/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid);
|
||||
$tokens['paypal-deposit-amount'] = _booking_deposit_amount($node, TRUE);
|
||||
$tokens['regn-summary'] = _booking_details_email_summary($node);
|
||||
|
||||
|
||||
// convert the URL into a href if html emails are enabled
|
||||
if (variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$balance_link = url('balance/' . $tempid, array('absolute' => TRUE));
|
||||
$confirm_link = url('confirm/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['balance-payment-link'] = "<a href=\"$balance_link\">$balance_link</a>";
|
||||
$tokens['confirm-payment-link'] = "<a href=\"$confirm_link\">$confirm_link</a>";
|
||||
}
|
||||
else {
|
||||
$tokens['balance-payment-link'] = url('balance/' . $tempid, array('absolute' => TRUE));
|
||||
$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) {
|
||||
$tokens['paypal-deposit-amount'] = _booking_deposit_amount($node, TRUE);
|
||||
$tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid);
|
||||
$tokens['stripe-deposit-amount'] = "";
|
||||
$tokens['stripe-total-amount'] = "";
|
||||
$tokens['stripe-total-amount-intl'] = "";
|
||||
}
|
||||
//if stripe is enabled
|
||||
elseif ($payment_processor_type == 1) {
|
||||
$tokens['paypal-deposit-amount'] = "";
|
||||
$tokens['paypal-total-amount'] = "";
|
||||
$tokens['stripe-deposit-amount'] = _booking_deposit_amount($node, TRUE);
|
||||
$tokens['stripe-total-amount'] = _booking_amount_owing($node, $amount_paid, TRUE, FALSE);
|
||||
$tokens['stripe-total-amount-intl'] = _booking_amount_owing($node, $amount_paid, TRUE, TRUE);
|
||||
}
|
||||
//if travelform is enabled
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$tokens['travel-link'] = url('travel/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['travel-summary'] = _booking_travelform_email_summary($node);
|
||||
} else {
|
||||
// convert the URL into a href if html emails are enabled
|
||||
if (variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$travel_link = url('travel/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['travel-link'] = "<a href=\"$travel_link\">$travel_link</a>";
|
||||
}
|
||||
else {
|
||||
$tokens['travel-link'] = url('travel/' . $tempid, array('absolute' => TRUE));
|
||||
}
|
||||
}
|
||||
// travel form not enabled
|
||||
else {
|
||||
$tokens['travel-link'] = "";
|
||||
$tokens['travel-summary'] = "";
|
||||
}
|
||||
//if studygroups are enabled
|
||||
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);
|
||||
}
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||
{
|
||||
else {
|
||||
$tokens['studygroup-summary'] = "";
|
||||
$tokens['leaderhelper-pair'] = "";
|
||||
}
|
||||
//if room allocations are enabled
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$tokens['room-allocation'] = _booking_room_email_summary($node);
|
||||
$tokens['bed-type'] = _booking_room_bedtype_lookup(empty($node->booking_room_bedtype) ? '0' : $node->booking_room_bedtype);
|
||||
}
|
||||
else {
|
||||
$tokens['room-allocation'] = "";
|
||||
$tokens['bed-type'] = "";
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Person specific tokens:\n@info</pre>", array('@info' => print_r( $tokens, true)));
|
||||
return $tokens;
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ function booking_travel_page()
|
||||
);
|
||||
//actual form
|
||||
$return_array[] = array(
|
||||
'form' => drupal_get_form('travel_form', true, $node, $tokens)
|
||||
'form' => drupal_get_form('travel_form', $node, true, $tokens)
|
||||
);
|
||||
//text after form
|
||||
/*
|
||||
@@ -91,7 +91,8 @@ function booking_travel_page()
|
||||
|
||||
}
|
||||
|
||||
function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tokens = NULL)
|
||||
//function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tokens = NULL)
|
||||
function travel_form($node, &$form_state, $db_node = NULL, $inserting = FALSE, $tokens = NULL)
|
||||
{
|
||||
global $event;
|
||||
date_default_timezone_set(date_default_timezone(FALSE));
|
||||
@@ -99,6 +100,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tok
|
||||
$booking_dietary = '';
|
||||
$booking_medical_conditions = '';
|
||||
$booking_bf_gf_nid = '';
|
||||
$booking_partner_id = '';
|
||||
$booking_roommate = '';
|
||||
|
||||
$transport_type_options = array(
|
||||
@@ -108,33 +110,48 @@ function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tok
|
||||
);
|
||||
|
||||
//there's already info in $node so use that
|
||||
if (!empty($node)) {
|
||||
$data = $node;
|
||||
//watchdog('booking_debug', "<pre>Travel form not-empty node:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
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)));
|
||||
}
|
||||
//otherwise rely on the form state from the previous submission
|
||||
else {
|
||||
$data = $form_state['node'];
|
||||
//watchdog('booking_debug', "<pre>Travel form empty node:\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 about this person from the relevant node id
|
||||
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " .
|
||||
"FROM {booking_person} " . "WHERE nid = :nid ",
|
||||
array(':nid' => isset($node->nid) ? $node->nid : $data->booking_person_nid))->fetchObject();
|
||||
|
||||
if ($person) {
|
||||
//watchdog('booking_debug', "<pre>Person info from database:\n@info</pre>", array('@info' => print_r( $person, true)));
|
||||
$booking_dietary = $person->booking_dietary;
|
||||
$booking_medical_conditions = $person->booking_medical_conditions;
|
||||
//an empty value is zero in this case
|
||||
$booking_bf_gf_nid = $person->booking_bf_gf_nid == 0 ? '' : $person->booking_bf_gf_nid;
|
||||
$booking_roommate = $person->booking_room_mate1;
|
||||
}
|
||||
//get info from the database if we don't have it
|
||||
if (! isset($data->booking_partner_id)) {
|
||||
watchdog('booking_debug', "<pre>Travel form querying database for missing details</pre>");
|
||||
|
||||
$person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " .
|
||||
"FROM {booking_person} " . "WHERE nid = :nid ",
|
||||
array(':nid' => isset($data->booking_person_nid) ? $data->booking_person_nid : $data->nid))->fetchObject();
|
||||
|
||||
//check we got results
|
||||
if ($person) {
|
||||
watchdog('booking_debug', "<pre>Person info from database:\n@info</pre>", array('@info' => print_r( $person, true)));
|
||||
$booking_dietary = $person->booking_dietary;
|
||||
$booking_medical_conditions = $person->booking_medical_conditions;
|
||||
//an empty value is zero in this case
|
||||
$booking_bf_gf_nid = $person->booking_bf_gf_nid == 0 ? '' : $person->booking_bf_gf_nid;
|
||||
$booking_partner_id = $person->booking_partner_id == 0 ? '' : $person->booking_partner_id;
|
||||
$booking_roommate = $person->booking_room_mate1;
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', "<pre>Failed to retrieve person from database using nid from data variable:\n@info</pre>", array('@info' => print_r( $data, true)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', "<pre>Failed to retrieve person from database using nid from data variable:\n@info</pre>", array('@info' => print_r( $data, true)));
|
||||
//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
|
||||
$booking_bf_gf_nid = $data->booking_bf_gf_nid == 0 ? '' : $data->booking_bf_gf_nid;
|
||||
$booking_partner_id = $data->booking_partner_id == 0 ? '' : $data->booking_partner_id;
|
||||
$booking_roommate = $data->booking_room_mate1;
|
||||
}
|
||||
|
||||
|
||||
//form starts here
|
||||
//store the node id
|
||||
$form['personid'] = array(
|
||||
@@ -292,10 +309,10 @@ function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tok
|
||||
*/
|
||||
|
||||
//calculate which fields to show and whether we need to show the fieldset at all
|
||||
$show_dietary = variable_get('booking_enable_dietary', 0) == 1 || $inserting == FALSE;
|
||||
$show_medical = variable_get('booking_enable_medcond', 0) == 1 || $inserting == FALSE;
|
||||
$show_roommate = (variable_get('booking_enable_roommate', 0) == 1 && $person->booking_partner_id == 0) || $inserting == FALSE;
|
||||
$show_bf_gf = $person->booking_partner_id == 0 || $inserting == FALSE;
|
||||
$show_dietary = ((variable_get('booking_enable_dietary', 0) == 1) || ($inserting == FALSE));
|
||||
$show_medical = ((variable_get('booking_enable_medcond', 0) == 1) || ($inserting == FALSE));
|
||||
$show_roommate = (variable_get('booking_enable_roommate', 0) == 1 && $booking_partner_id == 0) || $inserting == FALSE;
|
||||
$show_bf_gf = $booking_partner_id == 0 || $inserting == FALSE;
|
||||
$show_special_requirements = ($show_dietary || $show_medical || $show_roommate || $show_bf_gf);
|
||||
|
||||
if ($show_special_requirements) {
|
||||
|
@@ -1,432 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin pages for configuring a variety session
|
||||
*/
|
||||
|
||||
function booking_variety_admin()
|
||||
{
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
// tableselect with text fields http://drupal.stackexchange.com/questions/75950/tableselect-with-textfields/82763#82763
|
||||
// inline edit buttons http://drupal.stackexchange.com/questions/31942/how-do-i-add-an-edit-button-on-each-row-of-a-tableselect-form-element
|
||||
// tabledrag example http://dropbucket.org/node/204
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
//$prefix = t("<p>!link</p>",
|
||||
// array ('!link' => l('Add New Variety Timeslot', 'admin/config/booking/variety/create')));
|
||||
|
||||
$header = array (
|
||||
'tid' => t('Event ID'),
|
||||
'booking_variety_time_descrip' => t('Description'),
|
||||
'booking_variety_status' => t('Status'),
|
||||
'booking_variety_start' => t('Timeslot Start'),
|
||||
'booking_variety_end' => t('Timeslot End'),
|
||||
'variety_edit' => t('Edit Timeslot'),
|
||||
'variety_session_list' => t('List Sessions'),
|
||||
'variety_session_add' => t('Add Session'),
|
||||
);
|
||||
|
||||
$result = db_query("SELECT * from {booking_variety_times}");
|
||||
|
||||
foreach($result as $data)
|
||||
{
|
||||
$options[$data->tid] = array
|
||||
(
|
||||
'tid' => $data->tid,
|
||||
'booking_variety_time_descrip' => $data->booking_variety_time_descrip,
|
||||
'booking_variety_status' => $data->booking_variety_status,
|
||||
'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))),
|
||||
);
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#multiple' => false,
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
function booking_variety_admin_submit($form, &$form_state)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
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>";
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
$data = $node;
|
||||
}
|
||||
else
|
||||
{
|
||||
//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');
|
||||
return "";
|
||||
}
|
||||
|
||||
$data = db_select ('booking_variety_times', 'v')
|
||||
->condition('v.tid', $editid, '=')
|
||||
->fields('v')
|
||||
->execute()
|
||||
->fetchObject();
|
||||
|
||||
$prefix = t("<p>Update the !event variety session details.</p>", array('!event' => $event->booking_eventname));
|
||||
//add this to the form in a hidden field so we can update the right event
|
||||
$form['tid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $editid,
|
||||
);
|
||||
}
|
||||
|
||||
$form['booking_variety_time_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('The name of this variety session timeslot'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_variety_time_descrip) ? $data->booking_variety_time_descrip : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_status'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Make this variety session timeslot active'),
|
||||
'#default_value' => !empty($data->booking_variety_status) ? $data->booking_variety_status : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_start'] = array(
|
||||
'#type' => 'date_select',
|
||||
'#title' => t('When will this variety session start'),
|
||||
'#default_value' => empty($data->booking_variety_start) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_variety_start),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
);
|
||||
|
||||
$form['booking_variety_end'] = array(
|
||||
'#type' => 'date_select',
|
||||
'#title' => t('When will this variety session end?'),
|
||||
'#default_value' => empty($data->booking_variety_end) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_variety_end),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
);
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
$form['submit'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Create'),
|
||||
);
|
||||
} else {
|
||||
$form['Update'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update'),
|
||||
);
|
||||
$form['Delete'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete'),
|
||||
);
|
||||
}
|
||||
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
function booking_variety_timeslot_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
|
||||
if ($form_state['values']['op'] == 'Create')
|
||||
{
|
||||
db_insert('booking_variety_times')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_time_descrip' => $values['booking_variety_time_descrip'],
|
||||
'booking_variety_start' => _datetime_array_to_ts($values['booking_variety_start']),
|
||||
'booking_variety_end' => _datetime_array_to_ts($values['booking_variety_end']),
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete')
|
||||
{
|
||||
//verify that tid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['tid'])) {
|
||||
drupal_set_message("Error: Invalid variety timeslot ID supplied. Unable to delete entry.", 'error', FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
$num_deleted = db_delete('booking_variety_times')
|
||||
->condition('tid', $values['tid'])
|
||||
->execute();
|
||||
|
||||
$message = t("Successfully deleted !num row(s), corresponding to variety session timeslot '!desc'",
|
||||
array('!num' => $num_deleted, '!desc' => $values['booking_variety_time_descrip']));
|
||||
drupal_set_message($message, $type = 'status');
|
||||
}
|
||||
else
|
||||
{
|
||||
//verify that booking_eid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['tid'])) {
|
||||
drupal_set_message("Error: Invalid variety session timeslot ID supplied. Unable to update entry.", 'error', FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
//update the event
|
||||
db_update('booking_variety_times')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_time_descrip' => $values['booking_variety_time_descrip'],
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_start' => _datetime_array_to_ts($values['booking_variety_start']),
|
||||
'booking_variety_end' => _datetime_array_to_ts($values['booking_variety_end']),
|
||||
))
|
||||
->condition('tid', $values['tid'])
|
||||
->execute();
|
||||
}
|
||||
|
||||
$form_state['redirect'] = array('admin/config/booking/variety');
|
||||
}
|
||||
|
||||
function booking_variety_create_session_form($node, &$form_state, $timeslot_id = 0)
|
||||
{
|
||||
global $event;
|
||||
$form = array ();
|
||||
$prefix = "<p>Add a new variety session to the specified variety session timeslot for the bookings module.</p>";
|
||||
$data = $node;
|
||||
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
drupal_set_message("Error: Invalid variety ID supplied. Unable to update variety session information.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
$data = db_select ('booking_variety_times', 'v')
|
||||
->condition('v.tid', $editid, '=')
|
||||
->fields('v')
|
||||
->execute()
|
||||
->fetchObject();
|
||||
*/
|
||||
|
||||
//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'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_variety_descrip) ? $data->booking_variety_descrip : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_status'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Make this variety session active?'),
|
||||
'#default_value' => !empty($data->booking_variety_status) ? $data->booking_variety_status : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_maxsize'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('The maximum number of people permitted in this variety session'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 5,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_variety_maxsize) ? $data->booking_variety_maxsize : '0',
|
||||
);
|
||||
|
||||
$form['submit'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Create'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
function booking_variety_create_session_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
|
||||
db_insert('booking_variety_options')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_timeslot_id' => $values['tid'],
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_descrip' => $values['booking_variety_descrip'],
|
||||
'booking_variety_maxsize' => $values['booking_variety_maxsize'],
|
||||
'booking_variety_regncount' => 0,
|
||||
))
|
||||
->execute();
|
||||
|
||||
$form_state['redirect'] = array('admin/config/booking/variety');
|
||||
}
|
||||
|
||||
function booking_variety_list_session_form($node, &$form_state, $timeslot_id = 0)
|
||||
{
|
||||
global $event;
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
$data = $node;
|
||||
|
||||
//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');
|
||||
return "";
|
||||
}
|
||||
|
||||
$prefix = t("<p>!link</p>",
|
||||
array ('!link' => l('Add New Variety Session', "admin/config/booking/variety/$timeslot_id/session/create")));
|
||||
|
||||
$query = db_select ('booking_variety_options', 'v');
|
||||
$query->join('booking_variety_times', 't', 'v.booking_variety_timeslot_id = t.tid');
|
||||
$query->condition('v.booking_variety_timeslot_id', $timeslot_id, '=')
|
||||
->fields('v')
|
||||
->fields('t', array('booking_variety_time_descrip'));
|
||||
$result = $query->execute();
|
||||
|
||||
//watchdog('booking', 'Variety session query: @info', array ('@info' => (string)$query));
|
||||
|
||||
$header = array (
|
||||
'variety_timeslot' => t('Variety Timeslot'),
|
||||
'booking_variety_descrip' => t('Variety Session Description'),
|
||||
'booking_variety_status' => t('Status'),
|
||||
'booking_variety_maxsize' => t('Maximum Capacity'),
|
||||
'booking_variety_regncount' => t('Current Registration Count'),
|
||||
'variety_edit' => t('Edit Session')
|
||||
);
|
||||
|
||||
foreach($result as $data)
|
||||
{
|
||||
$options[$data->vid] = array
|
||||
(
|
||||
'variety_timeslot' => $data->booking_variety_time_descrip,
|
||||
'booking_variety_descrip' => $data->booking_variety_descrip,
|
||||
'booking_variety_status' => $data->booking_variety_status == 1 ? 1 : 0,
|
||||
'booking_variety_maxsize' => $data->booking_variety_maxsize,
|
||||
'booking_variety_regncount' => $data->booking_variety_regncount,
|
||||
'variety_edit' => l('Edit Session', t('admin/config/booking/variety/session/!vid/edit', array('!vid' => $data->vid))),
|
||||
);
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#multiple' => false,
|
||||
);
|
||||
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
function booking_variety_edit_session_form()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function booking_variety_regn_form($node, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
$form = array ();
|
||||
$data = $node;
|
||||
$timeslot_count = 0;
|
||||
|
||||
$query = db_query("SELECT * FROM {booking_variety_times} WHERE booking_eventid = :eid AND booking_variety_status = 1",
|
||||
array(':eid' => $event->eid));
|
||||
|
||||
$form['booking_barcode'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Barcode'),
|
||||
'#description' => t('Enter the barcode from your lanyard'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_barcode) ? $data->booking_barcode : '',
|
||||
);
|
||||
|
||||
//for each entry in the variety timeslot table, create a new form select item
|
||||
$result = db_query("SELECT * from {booking_variety_times}");
|
||||
|
||||
foreach($query as $timeslot)
|
||||
{
|
||||
//reset the array
|
||||
$options = array ();
|
||||
$options[''] = '';
|
||||
|
||||
//query for variety sessions in the timeslot
|
||||
$session_query = db_query("SELECT * from {booking_variety_options} WHERE booking_variety_timeslot_id = :id AND booking_variety_status = 1",
|
||||
array(':id' => $timeslot->tid));
|
||||
|
||||
//add all the sessions to the select list
|
||||
foreach($session_query as $session)
|
||||
{
|
||||
$options[$session->vid] = $session->booking_variety_descrip;
|
||||
}
|
||||
|
||||
//create the form element for this timeslot
|
||||
$form['select-variety-' . $timeslot_count] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => '',
|
||||
'#options' => $options,
|
||||
);
|
||||
|
||||
$timeslot_count++;
|
||||
}
|
||||
|
||||
$form['submit'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
|
||||
}
|
914
booking.variety_admin.inc
Normal file
914
booking.variety_admin.inc
Normal file
@@ -0,0 +1,914 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin pages for configuring a variety session
|
||||
* NOTE: This feature is not complete and probably never will be
|
||||
*/
|
||||
|
||||
function booking_variety_admin() {
|
||||
global $event;
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
// tableselect with text fields http://drupal.stackexchange.com/questions/75950/tableselect-with-textfields/82763#82763
|
||||
// inline edit buttons http://drupal.stackexchange.com/questions/31942/how-do-i-add-an-edit-button-on-each-row-of-a-tableselect-form-element
|
||||
// tabledrag example http://dropbucket.org/node/204
|
||||
$form = array();
|
||||
$options = array();
|
||||
|
||||
$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'),
|
||||
'tid' => t('Timeslot ID'),
|
||||
'booking_variety_time_descrip' => t('Description'),
|
||||
'booking_variety_status' => t('Status'),
|
||||
'booking_variety_start' => t('Timeslot Start'),
|
||||
'booking_variety_end' => t('Timeslot End'),
|
||||
'variety_edit' => t('Edit Timeslot'),
|
||||
'variety_session_list' => t('List Sessions'),
|
||||
'variety_session_add' => t('Add Session'),
|
||||
'variety_session_csv' => t('CSV Report'),
|
||||
);
|
||||
|
||||
foreach($result as $data) {
|
||||
$options[$data->tid] = array (
|
||||
'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/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))),
|
||||
);
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#multiple' => false,
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add a new variety session timeslot
|
||||
*/
|
||||
function booking_variety_timeslot_form($node, &$form_state, $create, $editid = 0) {
|
||||
global $event;
|
||||
$form = array();
|
||||
$prefix = t("<p>Add a new variety session timeslot for !event variety sessions.</p>", array('!event' => $event->booking_eventname));
|
||||
|
||||
if ($create == true) {
|
||||
$data = $node;
|
||||
}
|
||||
else {
|
||||
//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/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
$data = db_select ('booking_variety_timeslots', 'v')
|
||||
->condition('v.tid', $editid, '=')
|
||||
->fields('v')
|
||||
->execute()
|
||||
->fetchObject();
|
||||
|
||||
$prefix = t("<p>Update the !event variety session details.</p>", array('!event' => $event->booking_eventname));
|
||||
//add this to the form in a hidden field so we can update the right event
|
||||
$form['tid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $editid,
|
||||
);
|
||||
}
|
||||
|
||||
$form['booking_variety_time_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('The name of this variety session timeslot'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_variety_time_descrip) ? $data->booking_variety_time_descrip : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_status'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Make this variety session timeslot active'),
|
||||
'#default_value' => !empty($data->booking_variety_status) ? $data->booking_variety_status : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_start'] = array(
|
||||
'#type' => 'date_select',
|
||||
'#title' => t('When will this variety session start'),
|
||||
'#default_value' => empty($data->booking_variety_start) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_variety_start),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
);
|
||||
|
||||
$form['booking_variety_end'] = array(
|
||||
'#type' => 'date_select',
|
||||
'#title' => t('When will this variety session end?'),
|
||||
'#default_value' => empty($data->booking_variety_end) ? date("Y-m-d H:i:s") : date("Y-m-d H:i:s", $data->booking_variety_end),
|
||||
'#date_format' => 'd/m/Y H:i',
|
||||
'#date_label_position' => 'within',
|
||||
'#date_year_range' => '0:+5'
|
||||
);
|
||||
|
||||
if ($create == true) {
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Create'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['Update'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update'),
|
||||
);
|
||||
$form['Delete'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete'),
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to submit data for a new variety session timeslot
|
||||
*/
|
||||
function booking_variety_timeslot_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
|
||||
if ($form_state['values']['op'] == 'Create') {
|
||||
db_insert('booking_variety_timeslots')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_time_descrip' => $values['booking_variety_time_descrip'],
|
||||
'booking_variety_start' => _datetime_array_to_ts($values['booking_variety_start']),
|
||||
'booking_variety_end' => _datetime_array_to_ts($values['booking_variety_end']),
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete') {
|
||||
//verify that tid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['tid'])) {
|
||||
drupal_set_message("Error: Invalid variety timeslot ID supplied. Unable to delete entry.", 'error', FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
$num_deleted = db_delete('booking_variety_timeslots')
|
||||
->condition('tid', $values['tid'])
|
||||
->execute();
|
||||
|
||||
$message = t("Successfully deleted !num row(s), corresponding to variety session timeslot '!desc'",
|
||||
array('!num' => $num_deleted, '!desc' => $values['booking_variety_time_descrip']));
|
||||
drupal_set_message($message, $type = 'status');
|
||||
}
|
||||
else {
|
||||
//verify that booking_eid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['tid'])) {
|
||||
drupal_set_message("Error: Invalid variety session timeslot ID supplied. Unable to update entry.", 'error', FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
//update the event
|
||||
db_update('booking_variety_timeslots')
|
||||
->fields(array (
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_time_descrip' => $values['booking_variety_time_descrip'],
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_start' => _datetime_array_to_ts($values['booking_variety_start']),
|
||||
'booking_variety_end' => _datetime_array_to_ts($values['booking_variety_end']),
|
||||
))
|
||||
->condition('tid', $values['tid'])
|
||||
->execute();
|
||||
}
|
||||
|
||||
$form_state['redirect'] = array('admin/booking/variety');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to create or edit a variety session
|
||||
*/
|
||||
function booking_variety_create_session_form($node, &$form_state, $create = TRUE, $timeslot_id = 0, $session_id = 0) {
|
||||
global $event;
|
||||
$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>";
|
||||
}
|
||||
else {
|
||||
//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/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/booking/variety');
|
||||
return "";
|
||||
}
|
||||
$prefix = t("<p>Update the variety session defintion.</p>");
|
||||
$data = db_query("SELECT * FROM {booking_variety_sessions} WHERE vid = :id", array(':id' => $session_id))
|
||||
->fetchObject();
|
||||
|
||||
//add this to the form in a hidden field so we can update the right variety session
|
||||
$form['booking_session_id'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $session_id,
|
||||
);
|
||||
}
|
||||
|
||||
//define the form for variety session configuration if we're not deleting a session
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
$form[] = array (
|
||||
'first_heading' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking_variety_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('The name of the variety session to add to this timeslot'),
|
||||
'#size' => 60,
|
||||
'#maxlength' => 150,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_variety_descrip) ? $data->booking_variety_descrip : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_status'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Make this variety session active?'),
|
||||
'#default_value' => !empty($data->booking_variety_status) ? $data->booking_variety_status : '',
|
||||
);
|
||||
|
||||
$form['booking_variety_maxsize'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('The maximum number of people permitted in this variety session'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 5,
|
||||
'#required' => TRUE,
|
||||
'#default_value' => !empty($data->booking_variety_maxsize) ? $data->booking_variety_maxsize : '0',
|
||||
);
|
||||
|
||||
if ($create == true) {
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Create Session'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['Update'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update Session'),
|
||||
);
|
||||
$form['Delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete Session'),
|
||||
);
|
||||
}
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
} //end checking for delete confirmation
|
||||
else {
|
||||
return confirm_form($form, "Are you sure you wish to delete variety session definition with id " . $session_id . "?",
|
||||
current_path(), NULL, "Delete Session");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function submit data for a variety session timeslot
|
||||
*/
|
||||
function booking_variety_create_session_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
$timeslot_id = $values['tid'];
|
||||
|
||||
//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']))) {
|
||||
//watchdog('booking_debug', "<pre>Variety session deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
$form_state['storage']['confirm'] = TRUE;
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Session') {
|
||||
//delete the variety session
|
||||
watchdog('booking', "Deleting variety session ID !sid", array('!sid' => $values['booking_session_id']));
|
||||
|
||||
db_delete('booking_variety_sessions')
|
||||
->condition('vid', $values['booking_session_id'])
|
||||
->execute();
|
||||
|
||||
//TODO : Remove this variety session from anyone registered for it
|
||||
|
||||
drupal_set_message('Deleted variety session id ' . $values['booking_session_id'] );
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Session') {
|
||||
$result = db_update('booking_variety_sessions')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_descrip' => $values['booking_variety_descrip'],
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_maxsize' => $values['booking_variety_maxsize'],
|
||||
))
|
||||
->condition('vid', $values['booking_session_id'] )
|
||||
->execute();
|
||||
drupal_set_message('Updated variety session id ' . $values['booking_session_id'] );
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Create Session') {
|
||||
db_insert('booking_variety_sessions')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_variety_timeslot_id' => $values['tid'],
|
||||
'booking_variety_status' => $values['booking_variety_status'] == 1 ? 1 : 0,
|
||||
'booking_variety_descrip' => $values['booking_variety_descrip'],
|
||||
'booking_variety_maxsize' => $values['booking_variety_maxsize'],
|
||||
'booking_variety_regncount' => 0,
|
||||
))
|
||||
->execute();
|
||||
drupal_set_message('Created new variety session definition');
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to list all variety sessions for specified timeslot
|
||||
*/
|
||||
function booking_variety_list_session_form($node, &$form_state, $timeslot_id = 0)
|
||||
{
|
||||
global $event;
|
||||
$form = array();
|
||||
$options = array();
|
||||
$data = $node;
|
||||
|
||||
//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/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
$prefix = t("<p>!link</p>",
|
||||
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');
|
||||
$query->condition('v.booking_variety_timeslot_id', $timeslot_id, '=')
|
||||
->fields('v')
|
||||
->fields('t', array('booking_variety_time_descrip'));
|
||||
$result = $query->execute();
|
||||
|
||||
//watchdog('booking', 'Variety session query: @info', array ('@info' => (string)$query));
|
||||
|
||||
$header = array (
|
||||
'variety_timeslot' => t('Variety Timeslot'),
|
||||
'booking_variety_descrip' => t('Variety Session Description'),
|
||||
'booking_variety_status' => t('Status'),
|
||||
'booking_variety_maxsize' => t('Maximum Capacity'),
|
||||
'booking_variety_regncount' => t('Current Registration Count'),
|
||||
'variety_edit' => t('Edit Session')
|
||||
);
|
||||
|
||||
foreach($result as $data) {
|
||||
$options[$data->vid] = array (
|
||||
'variety_timeslot' => $data->booking_variety_time_descrip,
|
||||
'booking_variety_descrip' => $data->booking_variety_descrip,
|
||||
'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/booking/variety/!tid/session/!vid/edit',
|
||||
array('!tid' => $timeslot_id, '!vid' => $data->vid))),
|
||||
);
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#multiple' => false,
|
||||
);
|
||||
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate table listing all variety session registrations
|
||||
*/
|
||||
function booking_variety_sessions_view_summary() {
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('First Name', 'Last Name');
|
||||
$rows = array();
|
||||
$attributes = array('style' => 'max-width:100%');
|
||||
|
||||
//get variety session timeslot definitions
|
||||
$timeslot_query = db_select('booking_variety_timeslots', 't');
|
||||
$timeslot_query->condition('t.booking_eventid', $event->eid, '=')
|
||||
->fields('t')
|
||||
->orderBy('t.booking_variety_start');
|
||||
$timeslot_list = $timeslot_query->execute()->fetchAllAssoc('tid');
|
||||
|
||||
//watchdog('booking_debug', "<pre>Variety Session Report timeslots:\n@info</pre>", array('@info' => print_r( $timeslot_list, true)));
|
||||
|
||||
//get vareity session definitions
|
||||
$sessions_query = db_query("SELECT * FROM {booking_variety_sessions} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$sessions = $sessions_query->fetchAllAssoc('vid');
|
||||
|
||||
//watchdog('booking_debug', "<pre>Variety Session Report sessions:\n@info</pre>", array('@info' => print_r( $sessions, true)));
|
||||
|
||||
foreach ($timeslot_list as $timeslot) {
|
||||
$header[] = $timeslot->booking_variety_time_descrip;
|
||||
}
|
||||
// Add a link at the end to edit a variety session registration
|
||||
$header[] = "Edit Session Registrations";
|
||||
|
||||
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_status = 1 " .
|
||||
" ORDER BY booking_lastname, booking_firstname")->fetchAllAssoc('nid');
|
||||
|
||||
//loop through each matching person
|
||||
foreach ($person_query as $person) {
|
||||
//add the name to an array for this line
|
||||
$newline = array($person->booking_firstname, $person->booking_lastname);
|
||||
$session_ids = drupal_json_decode($person->booking_variety_ids);
|
||||
|
||||
foreach ($timeslot_list as $timeslot) {
|
||||
if (isset($session_ids[$timeslot->tid])) {
|
||||
//get details of the person's variety session for this timeslot
|
||||
$vid = $session_ids[$timeslot->tid];
|
||||
|
||||
//watchdog('booking_debug', 'Person @nid in timeslot @tid registered for session id @vid', array(
|
||||
// '@nid' => $person->nid, '@tid' => $timeslot->tid, '@vid' => $vid,
|
||||
//));
|
||||
|
||||
// in case the person is somehow registered for a session that no longer exists
|
||||
if (isset($sessions[$vid])) {
|
||||
$text = $sessions[$vid]->booking_variety_descrip;
|
||||
}
|
||||
else {
|
||||
$text = "";
|
||||
}
|
||||
$newline[] = $text;
|
||||
}
|
||||
else {
|
||||
$newline[] = "";
|
||||
}
|
||||
} //end iterate variety session timeslot list
|
||||
$newline[] = l('Edit', t('admin/booking/variety/registration/!nid/edit', array('!nid' => $person->nid)));
|
||||
|
||||
//add the line to the array of rows
|
||||
$rows[] = $newline;
|
||||
} //end iterate person list
|
||||
|
||||
//output everything
|
||||
$output .= t("<h3>!event Variety Session Registrations</h3>", array('!event' => $event->booking_eventname));
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate a CSV file listing the session membership for the specified variety session timeslot
|
||||
*/
|
||||
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 '" . $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_variety_timeslot_id', $timeslot_id, '=');
|
||||
$variety_sessions = db_select('booking_variety_sessions', 'v')
|
||||
->condition($db_and)
|
||||
->fields('v')
|
||||
->execute()
|
||||
->fetchAllAssoc('vid');
|
||||
|
||||
//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/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
//set options for the CSV file
|
||||
$csv = '';
|
||||
$delimiter = ',';
|
||||
$enclosure = '"';
|
||||
$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
|
||||
inner join {booking_person} p on p.nid = r.booking_person_nid
|
||||
WHERE p.booking_eventid = :eid ORDER BY r.rid",
|
||||
array(':eid' => $event->eid));
|
||||
$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: Variety Session timeslot $timeslot_id has no members assigned.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
//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)));
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
//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 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
|
||||
$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';
|
||||
}
|
||||
|
||||
watchdog('booking_debug', "<pre>Variety session spreadsheet columns\n@info</pre>",
|
||||
array('@info' => print_r( $column_headings, true)));
|
||||
|
||||
|
||||
// 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 {
|
||||
$output[] = $field;
|
||||
//}
|
||||
} //loop through columns
|
||||
$rows[] = $output;
|
||||
//$row = implode($delimiter, $output) . "\n";
|
||||
//$csv .= $row;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the admin form for editing variety session registrations
|
||||
*/
|
||||
function booking_variety_regn_edit_form($node, &$form_state, $nid)
|
||||
{
|
||||
global $event;
|
||||
$form = array();
|
||||
$data = $node;
|
||||
$redirect_path = "admin/booking/variety/report";
|
||||
|
||||
//verify that $variety_regn_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $nid)) {
|
||||
drupal_set_message("Error: Invalid variety session registration ID supplied. Unable to update variety session registration for user.", 'error', FALSE);
|
||||
drupal_goto($redirect_path);
|
||||
return "";
|
||||
}
|
||||
|
||||
$person = db_query("SELECT * FROM {booking_person_view} WHERE nid = :nid",
|
||||
array(':nid' => $nid))->fetchObject();
|
||||
|
||||
if (! $person) {
|
||||
drupal_set_message("Error: Could not find matching person. Unable to edit variety session registrations.", 'error', FALSE);
|
||||
drupal_goto($redirect_path);
|
||||
return "";
|
||||
}
|
||||
$session_ids = drupal_json_decode($person->booking_variety_ids);
|
||||
$prefix = t("<h3>Edit variety session registration for !first !last.<br /></h3>",
|
||||
array('!first' => $person->booking_firstname, '!last' => $person->booking_lastname));
|
||||
|
||||
// Query the variety timeslot table so we know how many select elements to create
|
||||
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
->fields('v')
|
||||
->orderBy('v.booking_variety_start');
|
||||
$timeslot_result = $timeslot_query->execute();
|
||||
|
||||
// --- Form starts here ---
|
||||
//add the person nid to the form in a hidden field so we can update the right person later
|
||||
$form['nid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $nid,
|
||||
);
|
||||
|
||||
//define the form for variety session configuration if we're not deleting a session
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
$form[] = array (
|
||||
'first_heading' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
);
|
||||
|
||||
$form['variety-sessions'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Select Variety Sessions',
|
||||
'#prefix' => '<div id="booking_variety_session_fieldset_wrapper">',
|
||||
'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
//for each entry in the variety timeslot table, create a new form select item
|
||||
foreach($timeslot_result as $timeslot) {
|
||||
$fieldname = 'select-variety-' . $timeslot->tid;
|
||||
$default = isset($session_ids[$timeslot->tid]) ? $session_ids[$timeslot->tid] : '--';
|
||||
$default_value = isset($form_state['values'][$fieldname]) ? $form_state['values'][$fieldname] : $default;
|
||||
|
||||
//create the form element for this timeslot
|
||||
$form['variety-sessions'][$fieldname] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => $default_value,
|
||||
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||
);
|
||||
}
|
||||
|
||||
$form['Update'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update Session Registration'),
|
||||
);
|
||||
$form['Delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete Session Registration'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
} //end checking for delete confirmation
|
||||
else {
|
||||
return confirm_form($form, "Are you sure you wish to delete all variety session registrations for person id " . $nid . "?",
|
||||
current_path(), NULL, "Delete Session Registration");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function submit data for editing a variety session registration for a person
|
||||
*/
|
||||
function booking_variety_regn_edit_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
$booking_variety_ids = array();
|
||||
$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 ));
|
||||
//build an associative array based on selections
|
||||
foreach ($variety_timeslot_ids as $id) {
|
||||
$selected_session_id = $values['select-variety-' . $id];
|
||||
// Don't try and check availablity for a select element that is still on the default value
|
||||
if ($selected_session_id == 0) {
|
||||
continue;
|
||||
}
|
||||
//store the selected variety sessions in an array of IDs
|
||||
$booking_variety_ids[$id] = $selected_session_id;
|
||||
}
|
||||
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 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)));
|
||||
$form_state['storage']['confirm'] = TRUE;
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Session Registration') {
|
||||
//delete the variety session
|
||||
watchdog('booking', "Deleting variety session registration for person ID !nid", array('!nid' => $values['nid']));
|
||||
|
||||
//decremement regn count for this person's variety sessions
|
||||
foreach ($previous_variety_ids as $previous_tid => $previous_sid) {
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid is no longer registered for any variety sessions so reducing count for @vid by 1', array(
|
||||
'@nid' => $values['nid'], '@tid' => $previous_tid, '@vid' => $previous_sid,
|
||||
));
|
||||
// reduce regn count for old session
|
||||
db_update('booking_variety_sessions')
|
||||
->expression('booking_variety_regncount', 'booking_variety_regncount - :count', array(':count' => 1))
|
||||
->condition('vid', $previous_sid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
//delete this person's entry in the session registration table
|
||||
db_delete('booking_variety_regn')
|
||||
->condition('booking_person_nid', $values['nid'])
|
||||
->execute();
|
||||
|
||||
drupal_set_message('Deleted variety session registration for person id ' . $values['nid'] );
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Session Registration') {
|
||||
// iterate over the new list comparing to the old list
|
||||
foreach ($booking_variety_ids as $new_tid => $new_sid) {
|
||||
//check if there was a previous session ID for this person in this timeslot
|
||||
if (! isset($previous_variety_ids[$new_tid])) {
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid had no previous session id registered but is now @new.', array(
|
||||
'@nid' => $values['nid'], '@tid' => $new_tid, '@new' => $new_sid));
|
||||
|
||||
// increase regn count for new session
|
||||
db_update('booking_variety_sessions')
|
||||
->expression('booking_variety_regncount', 'booking_variety_regncount + :count', array(':count' => 1))
|
||||
->condition('vid', $new_sid)
|
||||
->execute();
|
||||
}
|
||||
else {
|
||||
$previous_sid = $previous_variety_ids[$new_tid];
|
||||
//compare session id in this timeslot to the previous value
|
||||
if ($new_sid != $previous_sid) {
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid previously registered for session id @vid but new value is @new', array(
|
||||
'@nid' => $values['nid'], '@tid' => $new_tid, '@vid' => $previous_sid, '@new' => $new_sid));
|
||||
|
||||
// if variety session has changed then update the counts for old and new
|
||||
if ($new_sid != $previous_sid) {
|
||||
// reduce regn count for old session
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid is no longer registered for variety session @vid so reducing count by 1', array(
|
||||
'@nid' => $values['nid'], '@tid' => $new_tid, '@vid' => $previous_sid));
|
||||
db_update('booking_variety_sessions')
|
||||
->expression('booking_variety_regncount', 'booking_variety_regncount - :count', array(':count' => 1))
|
||||
->condition('vid', $previous_sid)
|
||||
->execute();
|
||||
|
||||
// increase regn count for new session
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid is now registered for variety session @vid so increasing count by 1', array(
|
||||
'@nid' => $values['nid'], '@tid' => $new_tid, '@vid' => $new_sid));
|
||||
db_update('booking_variety_sessions')
|
||||
->expression('booking_variety_regncount', 'booking_variety_regncount + :count', array(':count' => 1))
|
||||
->condition('vid', $new_sid)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', 'Person @nid in timeslot @tid has not changed variety session @vid', array(
|
||||
'@nid' => $values['nid'], '@tid' => $new_tid, '@vid' => $new_sid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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(
|
||||
'@nid' => $values['nid'], '@tid' => $previous_tid, '@vid' => $previous_sid,
|
||||
));
|
||||
// reduce regn count for old session
|
||||
db_update('booking_variety_sessions')
|
||||
->expression('booking_variety_regncount', 'booking_variety_regncount - :count', array(':count' => 1))
|
||||
->condition('vid', $previous_sid)
|
||||
->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(
|
||||
'booking_variety_ids' => drupal_json_encode($booking_variety_ids),
|
||||
))
|
||||
->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;
|
||||
}
|
||||
}
|
302
booking.variety_form.inc
Normal file
302
booking.variety_form.inc
Normal file
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* User facing page for booking into a variety session
|
||||
* NOTE: This feature is not complete
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build the user-facing variety session registration form
|
||||
*/
|
||||
function booking_variety_regn_form($node, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
$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, '=')
|
||||
->fields('v')
|
||||
->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' => 'Enter Your Details',
|
||||
);
|
||||
|
||||
$form['identity']['booking_nid'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Booking Number'),
|
||||
'#description' => t('Please enter your booking number from your lanyard.'),
|
||||
'#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_form_wrapper',
|
||||
'callback' => 'booking_variety_session_form_callback',
|
||||
),
|
||||
);
|
||||
|
||||
$form['variety-sessions'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Select Variety Sessions',
|
||||
//'#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
|
||||
foreach($result as $timeslot) {
|
||||
$fieldname = 'select-variety-' . $timeslot->tid;
|
||||
|
||||
//create the form element for this timeslot
|
||||
$form['variety-sessions'][$fieldname] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => isset($form_state['values'][$fieldname]) ? $form_state['values'][$fieldname] : 0,
|
||||
'#options' => _booking_get_variety_timeslot_options($timeslot->tid),
|
||||
//'#prefix' => '<div id="booking_variety_session_' . $timeslot->tid . '_wrapper">',
|
||||
//'#suffix' => '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to calculate available variety sessions for ajax enabled form booking_variety_regn_form()
|
||||
* @param $timeslot_id - the timeslot ID to query
|
||||
* @return array containing the variety sessions for specified timeslot that still have capacity
|
||||
*/
|
||||
function _booking_get_variety_timeslot_options($timeslot_id) {
|
||||
$session_options = array();
|
||||
$session_options[] = "--";
|
||||
|
||||
$session_query = db_query("SELECT * FROM {booking_variety_sessions} WHERE booking_variety_timeslot_id = :tid AND booking_variety_status = 1",
|
||||
array(':tid' => $timeslot_id));
|
||||
|
||||
// Only add sessions that aren't full to the return result
|
||||
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 left]";
|
||||
}
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Variety Session Options:\n@info</pre>", array('@info' => print_r( $session_options, true)));
|
||||
|
||||
return $session_options;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the submission for the user-facing variety session registration form
|
||||
*/
|
||||
function booking_variety_regn_form_validate($form, &$form_state) {
|
||||
global $event;
|
||||
$values = $form_state['input'];
|
||||
//watchdog('booking_debug', 'booking_variety_regn_form_validate: <pre>@info</pre>', array('@info' => print_r( $form_state, true)));
|
||||
|
||||
// Don't run validation on ajax callback
|
||||
if (isset($form_state['input']['_triggering_element_name'])) {
|
||||
//watchdog('booking_debug', 'booking_variety_regn_form_validate: skipping due to ajax callback');
|
||||
return;
|
||||
}
|
||||
|
||||
// --- Check that the registration number is valid ---
|
||||
|
||||
//verify that user-entered data is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['booking_nid'])) {
|
||||
form_set_error('booking_nid', t('You have entered an invalid booking reference number.'));
|
||||
}
|
||||
|
||||
// Perform lookup on barcode 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', $values['booking_nid'], '=');
|
||||
$db_and->condition('p.booking_lastname', $values['booking_lastname'], '=');
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition($db_and)
|
||||
->fields('p');
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
if (! $person) {
|
||||
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
|
||||
$prev_regn_query = db_select('booking_variety_regn', 'v')
|
||||
->condition('v.booking_person_nid', $values['booking_nid'], '=')
|
||||
->fields('v')
|
||||
->execute();
|
||||
|
||||
if ($prev_regn_query->rowCount() > 0) {
|
||||
form_set_error('booking_nid', t('You have already registered for variety sessions. Existing registration cannot be changed.'));
|
||||
}
|
||||
|
||||
// --- Check there is still space available in the selected variety sessions ---
|
||||
|
||||
//get a list of timeslot IDs from matching form values
|
||||
$variety_timeslot_ids = preg_filter('/^select-variety-(\d+)/', '$1', array_keys( $values ));
|
||||
|
||||
//query the sessions table
|
||||
$sessions_query = db_query("SELECT * FROM {booking_variety_sessions} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$sessions = $sessions_query->fetchAllAssoc('vid');
|
||||
|
||||
//watchdog('booking_debug', 'booking_variety_regn_form_validate sessions query: <pre>@info</pre>', array('@info' => print_r( $sessions, true)));
|
||||
|
||||
//check there is still room
|
||||
foreach ($variety_timeslot_ids as $id) {
|
||||
$selected_session_id = $values['select-variety-' . $id];
|
||||
|
||||
// Don't try and check availablity for a select element that is still on the default value
|
||||
if ($selected_session_id == 0) {
|
||||
form_set_error('select-variety-' . $id, t('You have not selected a variety session.'));
|
||||
continue;
|
||||
}
|
||||
|
||||
$session = $sessions[$selected_session_id];
|
||||
if ($session->booking_variety_regncount >= $session->booking_variety_maxsize) {
|
||||
//watchdog('booking_debug', 'No room in session @id : @count is less than @size', array(
|
||||
// '@id' => $selected_session_id, '@count' => $session->booking_variety_regncount,
|
||||
// '@size' => $session->booking_variety_maxsize
|
||||
//));
|
||||
$form_state['rebuild'] = TRUE;
|
||||
$form_state['flag'] = 1;
|
||||
drupal_set_message('You have selected a session that is now full. Please try again.', 'error', FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the submission for the user-facing variety session registration form
|
||||
*/
|
||||
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)));
|
||||
$booking_variety_ids = array();
|
||||
|
||||
//get a list of timeslot IDs from matching form values
|
||||
$variety_timeslot_ids = preg_filter('/^select-variety-(\d+)/', '$1', array_keys( $values ));
|
||||
|
||||
//query the sessions table
|
||||
$sessions_query = db_query("SELECT * FROM {booking_variety_sessions} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
$sessions = $sessions_query->fetchAllAssoc('vid');
|
||||
|
||||
foreach ($variety_timeslot_ids as $id) {
|
||||
$selected_session_id = $values['select-variety-' . $id];
|
||||
|
||||
// Don't try and check availablity for a select element that is still on the default value
|
||||
if ($selected_session_id == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//use an update query for the regncount field
|
||||
//idea from https://api.drupal.org/comment/19374#comment-19374
|
||||
db_update('booking_variety_sessions')
|
||||
->expression('booking_variety_regncount', 'booking_variety_regncount + :count', array(':count' => 1))
|
||||
->condition('vid', $selected_session_id)
|
||||
->execute();
|
||||
|
||||
//store the selected variety sessions in an array of IDs
|
||||
$booking_variety_ids[$id] = $selected_session_id;
|
||||
}
|
||||
|
||||
//perform the insert to the booking_variety_regn table
|
||||
db_insert('booking_variety_regn')
|
||||
->fields(array(
|
||||
'booking_variety_ids' => drupal_json_encode($booking_variety_ids),
|
||||
'booking_person_nid' => $values['booking_nid'],
|
||||
))
|
||||
->execute();
|
||||
|
||||
drupal_set_message("Thanks for submitting your variety session registration.", $type = 'status');
|
||||
$form_state['redirect'] = array('');
|
||||
}
|
134
deprecated.php
Normal file
134
deprecated.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
// This code doesnt work since we can't use ajax_command_replace to replace form elements
|
||||
// But its a handy reference point for failure
|
||||
|
||||
function booking_variety_session_callback($form, &$form_state) {
|
||||
global $event;
|
||||
$commands = array();
|
||||
//$node = $form_state['values']['form_id'];
|
||||
$data = $form_state['input'];
|
||||
watchdog('booking_debug', 'booking_variety_session_callback:<br /><pre>@info</pre>', array('@info' => print_r( $form, true)));
|
||||
|
||||
// --- Update the wrapper for booking ID validity ---
|
||||
//verify that user-entered data is a number
|
||||
if (! preg_match('/^[0-9]+$/', $data['booking_nid'])) {
|
||||
watchdog('booking_debug', "<pre>booking_variety_session_callback non-numerical input</pre>");
|
||||
$markup = '<div id="booking_variety_regn_feedback_wrapper" class="form-item"><span style="color:#8c2e0b;font-weight: bold;">' .
|
||||
'You have not entered a valid booking reference number.</span></div>';
|
||||
$commands[] = ajax_command_replace('#booking_variety_regn_feedback_wrapper', $markup);
|
||||
}
|
||||
|
||||
// Perform lookup on barcode 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'], '=');
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition($db_and)
|
||||
->fields('p');
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
if ($person) {
|
||||
watchdog('booking_debug', "<pre>booking_variety_session_callback found valid attendee</pre>");
|
||||
|
||||
$markup = '<div id="booking_variety_regn_feedback_wrapper" class="form-item"><span style="color:#234600;font-weight: bold;">' .
|
||||
'Matched booking reference number.</span></div>';
|
||||
$commands[] = ajax_command_replace('#booking_variety_regn_feedback_wrapper', $markup);
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', "<pre>booking_variety_session_callback did not find valid attendee</pre>");
|
||||
|
||||
$markup = '<div id="booking_variety_regn_feedback_wrapper" class="form-item"><span style="color:#8c2e0b;font-weight: bold;">' .
|
||||
'You have not entered a valid booking reference number.</span></div>';
|
||||
$commands[] = ajax_command_replace('#booking_variety_regn_feedback_wrapper', $markup);
|
||||
}
|
||||
|
||||
// --- Update the wrapper for available variety sessions ---
|
||||
// Query the variety timeslot table
|
||||
$timeslot_query = db_select('booking_variety_timeslots', 'v');
|
||||
$timeslot_query->condition('v.booking_eventid', $event->eid, '=')
|
||||
->fields('v')
|
||||
->orderBy('v.booking_variety_start');
|
||||
$result = $timeslot_query->execute();
|
||||
|
||||
//for each entry in the variety timeslot table, create a new form select item
|
||||
foreach($result as $timeslot) {
|
||||
$fieldname = 'select-variety-' . $timeslot->tid;
|
||||
$options = _booking_get_variety_timeslot_options($timeslot->tid);
|
||||
watchdog('booking_debug', 'Timeslot @tid form state value: <pre>@info</pre>',
|
||||
array('@tid' => $timeslot->tid, '@info' => print_r($form_state['values'], true)));
|
||||
watchdog('booking_debug', 'Setting timeslot @tid default value to @value', array(
|
||||
'@tid' => $timeslot->tid,
|
||||
'@value' => isset($form_state['values'][$fieldname]) ? $form_state['values'][$fieldname] : 0)
|
||||
);
|
||||
|
||||
//re-create the form element for this timeslot
|
||||
|
||||
$form['variety-sessions'][$fieldname] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Rebuilt Variety Session: ' . $timeslot->booking_variety_time_descrip),
|
||||
'#required' => TRUE,
|
||||
'#options' => $options,
|
||||
'#prefix' => '<div id="booking_variety_session_' . $timeslot->tid . '_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#default_value' => 1,
|
||||
);
|
||||
|
||||
//$form['variety-sessions'][$fieldname]['#options'] = $options;
|
||||
//$form['variety-sessions'][$fieldname]['#title'] = t('Rebuilt Variety Session: ' . $timeslot->booking_variety_time_descrip);
|
||||
|
||||
// Tell drupal to update the wrapper for this field
|
||||
$commands[] = ajax_command_replace('#booking_variety_session_' . $timeslot->tid . '_wrapper', drupal_render($form['form']['variety-sessions'][$fieldname]));
|
||||
//$commands[] = ajax_command_replace('#booking_variety_session_' . $timeslot->tid . '_wrapper', drupal_render($form));
|
||||
}
|
||||
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
//$page = array('#type' => 'ajax', '#commands' => $commands);
|
||||
//ajax_deliver($page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Callback function to verify if barcode was valid
|
||||
*/
|
||||
function booking_variety_regn_callback($form, &$form_state) {
|
||||
global $event;
|
||||
//$node = $form_state['values']['form_id'];
|
||||
$data = $form_state['input'];
|
||||
watchdog('booking', '<pre>booking_variety_regn_callback validation:\n@info</pre>', array('@info' => print_r( $data, true)));
|
||||
|
||||
//verify that user-entered data is a number
|
||||
if (! preg_match('/^[0-9]+$/', $data['booking_nid'])) {
|
||||
watchdog('booking_debug', "<pre>booking_variety_regn_callback non-numerical input</pre>");
|
||||
return '<div id="booking_variety_regn_feedback_wrapper" class="form-item"><span style="color:#8c2e0b;font-weight: bold;">' .
|
||||
'You have not entered a valid booking reference number.</span></div>';
|
||||
}
|
||||
|
||||
// Perform lookup on barcode 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'], '=');
|
||||
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->condition($db_and)
|
||||
->fields('p');
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
if ($person) {
|
||||
watchdog('booking_debug', "<pre>booking_variety_regn_callback found valid attendee</pre>");
|
||||
return '<div id="booking_variety_regn_feedback_wrapper" class="form-item"><span style="color:#234600;font-weight: bold;">' .
|
||||
'Matched booking reference number.</span></div>';
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', "<pre>booking_variety_regn_callback did not find valid attendee</pre>");
|
||||
return '<div id="booking_variety_regn_feedback_wrapper" class="form-item"><span style="color:#8c2e0b;font-weight: bold;">' .
|
||||
'You have not entered a valid booking reference number.</span></div>';
|
||||
}
|
||||
}
|
BIN
images/Final_Logo.png
Executable file
BIN
images/Final_Logo.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 168 KiB |
BIN
images/Final_White-Landscape-Logo-03-cropped-transparent.png
Normal file
BIN
images/Final_White-Landscape-Logo-03-cropped-transparent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
images/facebook@2x.png
Executable file
BIN
images/facebook@2x.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
images/instagram@2x.png
Executable file
BIN
images/instagram@2x.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
images/twitter@2x.png
Executable file
BIN
images/twitter@2x.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
images/youtube@2x.png
Executable file
BIN
images/youtube@2x.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
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:
|
335
theme/mimemail-message-registration_mail.tpl.php
Normal file
335
theme/mimemail-message-registration_mail.tpl.php
Normal file
@@ -0,0 +1,335 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head>
|
||||
<!--[if gte mso 9]><xml>
|
||||
<o:OfficeDocumentSettings>
|
||||
<o:AllowPNG/>
|
||||
<o:PixelsPerInch>96</o:PixelsPerInch>
|
||||
</o:OfficeDocumentSettings>
|
||||
</xml><![endif]-->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]-->
|
||||
<title></title>
|
||||
<!--Study Week 2018 Template-->
|
||||
|
||||
<style type="text/css" id="media-query">
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
|
||||
table, tr, td {
|
||||
vertical-align: top;
|
||||
border-collapse: collapse; }
|
||||
|
||||
.ie-browser table, .mso-container table {
|
||||
table-layout: fixed; }
|
||||
|
||||
* {
|
||||
line-height: inherit; }
|
||||
|
||||
a[x-apple-data-detectors=true] {
|
||||
color: inherit !important;
|
||||
text-decoration: none !important; }
|
||||
|
||||
[owa] .img-container div, [owa] .img-container button {
|
||||
display: block !important; }
|
||||
|
||||
[owa] .fullwidth button {
|
||||
width: 100% !important; }
|
||||
|
||||
[owa] .block-grid .col {
|
||||
display: table-cell;
|
||||
float: none !important;
|
||||
vertical-align: top; }
|
||||
|
||||
.ie-browser .num12, .ie-browser .block-grid, [owa] .num12, [owa] .block-grid {
|
||||
width: 700px !important; }
|
||||
|
||||
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {
|
||||
line-height: 100%; }
|
||||
|
||||
.ie-browser .mixed-two-up .num4, [owa] .mixed-two-up .num4 {
|
||||
width: 232px !important; }
|
||||
|
||||
.ie-browser .mixed-two-up .num8, [owa] .mixed-two-up .num8 {
|
||||
width: 464px !important; }
|
||||
|
||||
.ie-browser .block-grid.two-up .col, [owa] .block-grid.two-up .col {
|
||||
width: 350px !important; }
|
||||
|
||||
.ie-browser .block-grid.three-up .col, [owa] .block-grid.three-up .col {
|
||||
width: 233px !important; }
|
||||
|
||||
.ie-browser .block-grid.four-up .col, [owa] .block-grid.four-up .col {
|
||||
width: 175px !important; }
|
||||
|
||||
.ie-browser .block-grid.five-up .col, [owa] .block-grid.five-up .col {
|
||||
width: 140px !important; }
|
||||
|
||||
.ie-browser .block-grid.six-up .col, [owa] .block-grid.six-up .col {
|
||||
width: 116px !important; }
|
||||
|
||||
.ie-browser .block-grid.seven-up .col, [owa] .block-grid.seven-up .col {
|
||||
width: 100px !important; }
|
||||
|
||||
.ie-browser .block-grid.eight-up .col, [owa] .block-grid.eight-up .col {
|
||||
width: 87px !important; }
|
||||
|
||||
.ie-browser .block-grid.nine-up .col, [owa] .block-grid.nine-up .col {
|
||||
width: 77px !important; }
|
||||
|
||||
.ie-browser .block-grid.ten-up .col, [owa] .block-grid.ten-up .col {
|
||||
width: 70px !important; }
|
||||
|
||||
.ie-browser .block-grid.eleven-up .col, [owa] .block-grid.eleven-up .col {
|
||||
width: 63px !important; }
|
||||
|
||||
.ie-browser .block-grid.twelve-up .col, [owa] .block-grid.twelve-up .col {
|
||||
width: 58px !important; }
|
||||
|
||||
@media only screen and (min-width: 720px) {
|
||||
.block-grid {
|
||||
width: 700px !important; }
|
||||
.block-grid .col {
|
||||
vertical-align: top; }
|
||||
.block-grid .col.num12 {
|
||||
width: 700px !important; }
|
||||
.block-grid.mixed-two-up .col.num4 {
|
||||
width: 232px !important; }
|
||||
.block-grid.mixed-two-up .col.num8 {
|
||||
width: 464px !important; }
|
||||
.block-grid.two-up .col {
|
||||
width: 350px !important; }
|
||||
.block-grid.three-up .col {
|
||||
width: 233px !important; }
|
||||
.block-grid.four-up .col {
|
||||
width: 175px !important; }
|
||||
.block-grid.five-up .col {
|
||||
width: 140px !important; }
|
||||
.block-grid.six-up .col {
|
||||
width: 116px !important; }
|
||||
.block-grid.seven-up .col {
|
||||
width: 100px !important; }
|
||||
.block-grid.eight-up .col {
|
||||
width: 87px !important; }
|
||||
.block-grid.nine-up .col {
|
||||
width: 77px !important; }
|
||||
.block-grid.ten-up .col {
|
||||
width: 70px !important; }
|
||||
.block-grid.eleven-up .col {
|
||||
width: 63px !important; }
|
||||
.block-grid.twelve-up .col {
|
||||
width: 58px !important; } }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.block-grid, .col {
|
||||
min-width: 320px !important;
|
||||
max-width: 100% !important;
|
||||
display: block !important; }
|
||||
.block-grid {
|
||||
width: calc(100% - 40px) !important; }
|
||||
.col {
|
||||
width: 100% !important; }
|
||||
.col > div {
|
||||
margin: 0 auto; }
|
||||
img.fullwidth {
|
||||
max-width: 100% !important; } }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="clean-body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: <?php print $colors['booking_mailtemplate_background_color'] ?>">
|
||||
<style type="text/css" id="media-query-bodytag">
|
||||
@media (max-width: 520px) {
|
||||
.block-grid {
|
||||
min-width: 320px!important;
|
||||
max-width: 100%!important;
|
||||
width: 100%!important;
|
||||
display: block!important;
|
||||
}
|
||||
|
||||
.col {
|
||||
min-width: 320px!important;
|
||||
max-width: 100%!important;
|
||||
width: 100%!important;
|
||||
display: block!important;
|
||||
}
|
||||
|
||||
.col > div {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
img.fullwidth {
|
||||
max-width: 100%!important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<!--[if IE]><div class="ie-browser"><![endif]-->
|
||||
<!--[if mso]><div class="mso-container"><![endif]-->
|
||||
<div class="nl-container" style="min-width: 320px;Margin: 0 auto;background-color: <?php print $colors['booking_mailtemplate_background_color'] ?>">
|
||||
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: <?php print $colors['booking_mailtemplate_background_color'] ?>;"><![endif]-->
|
||||
|
||||
<div style="background-color:transparent;">
|
||||
<div style="Margin: 0 auto;min-width: 320px;max-width: 700px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: <?php print $colors['booking_mailtemplate_background_color'] ?>;" class="block-grid ">
|
||||
<div style="border-collapse: collapse;display: table;width: 100%;">
|
||||
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 700px;"><tr class="layout-full-width" style="background-color:<?php print $colors['booking_mailtemplate_background_color'] ?>;"><![endif]-->
|
||||
<!--[if (mso)|(IE)]><td align="center" width="700" style=" width:700px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
|
||||
<div class="col num12" style="min-width: 320px;max-width: 700px;display: table-cell;vertical-align: top;background-color: <?php print $colors['booking_mailtemplate_background_color'] ?>;">
|
||||
<div style="background-color: transparent; width: 100% !important;">
|
||||
<!--[if (!mso)&(!IE)]><!--><div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;"><!--<![endif]-->
|
||||
<div style="padding-right: 5px; padding-left: 5px; padding-top: 0px; padding-bottom: 0px;">
|
||||
<!--[if (mso)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 5px;padding-left: 5px; padding-top: 0px; padding-bottom: 0px;"><table width="100%" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
|
||||
<div align="center">
|
||||
<div style="border-top: 0px solid transparent; width:100%; line-height:0px; height:0px; font-size:0px;"> </div>
|
||||
</div>
|
||||
<!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Header image -->
|
||||
<div style="background-color:transparent;">
|
||||
<div style="Margin: 0 auto;min-width: 320px;max-width: 700px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: <?php print $colors['booking_mailtemplate_header_background_color'] ?>;" class="block-grid ">
|
||||
<div style="border-collapse: collapse;display: table;width: 100%;">
|
||||
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width: 700px;"><tr class="layout-full-width" style="background-color:<?php print $colors['booking_mailtemplate_header_background_color'] ?>;"><![endif]-->
|
||||
<!--[if (mso)|(IE)]><td align="center" width="700" style=" width:700px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
|
||||
<div class="col num12" style="min-width: 320px;max-width: 700px;display: table-cell;vertical-align: top;background-color: <?php print $colors['booking_mailtemplate_header_background_color'] ?>;">
|
||||
<div style="background-color: transparent; width: 100% !important;">
|
||||
<!--[if (!mso)&(!IE)]><!--><div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;"><!--<![endif]-->
|
||||
<div align="center" class="img-container center fullwidth" style="padding-right: 0px; padding-left: 0px;">
|
||||
<!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 0px; padding-left: 0px;" align="center"><![endif]-->
|
||||
<div style="line-height:15px;font-size:1px"> </div>
|
||||
<a href="<?php print $colors['booking_mailtemplate_header_link_url'] ?>" target="_blank">
|
||||
<img class="center fullwidth" align="center" border="0" src="<?php print $colors['booking_mailtemplate_header_image_url'] ?>" alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: 0;height: auto;float: none;width: 100%;max-width: 700px" width="700">
|
||||
</a>
|
||||
<div style="line-height:15px;font-size:1px"> </div><!--[if mso]></td></tr></table><![endif]-->
|
||||
</div>
|
||||
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Menu bar -->
|
||||
<div style="background-color:transparent;">
|
||||
<div style="Margin: 0 auto;min-width: 320px;max-width: 700px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: <?php print $colors['booking_mailtemplate_navigation_background_color'] ?>;" class="block-grid three-up">
|
||||
<div style="border-collapse: collapse;display: table;width: 100%;">
|
||||
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="background-color:transparent;" align="center">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width: 700px;">
|
||||
<tr class="layout-full-width" style="background-color:<?php print $colors['booking_mailtemplate_navigation_background_color'] ?>;">
|
||||
<![endif]-->
|
||||
|
||||
<?php foreach ($header_links as $linkitem) : ?>
|
||||
<!--[if (mso)|(IE)]><td align="center" width="233" style=" width:233px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top"><![endif]-->
|
||||
<div class="col num4" style="max-width: 320px;min-width: 233px;display: table-cell;vertical-align: top;background-color: <?php print $colors['booking_mailtemplate_navigation_background_color'] ?>;">
|
||||
<div style="background-color: transparent; width: 100% !important;">
|
||||
<!--[if (!mso)&(!IE)]><!--><div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;"><!--<![endif]-->
|
||||
<div align="center" class="button-container center" style="padding-right: 0px; padding-left: 0px; padding-top:0px; padding-bottom:0px;">
|
||||
<!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing: 0; border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;">
|
||||
<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_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_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]-->
|
||||
</div>
|
||||
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Content section -->
|
||||
<div style="background-color:transparent;">
|
||||
<div style="Margin: 0 auto;min-width: 320px;max-width: 700px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: <?php print $colors['booking_mailtemplate_content_background_color'] ?>;" class="block-grid ">
|
||||
<div style="border-collapse: collapse;display: table;width: 100%;">
|
||||
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td style="background-color:transparent;" align="center">
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="width: 700px;">
|
||||
<tr class="layout-full-width" style="background-color:<?php print $colors['booking_mailtemplate_content_background_color'] ?>;">
|
||||
<td align="center" width="700" style=" width:700px; padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;" valign="top">
|
||||
<![endif]-->
|
||||
<div class="col num12" style="min-width: 320px;max-width: 700px;display: table-cell;vertical-align: top;background-color: <?php print $colors['booking_mailtemplate_content_background_color'] ?>;">
|
||||
<div style="background-color: transparent; width: 100% !important;">
|
||||
<!--[if (!mso)&(!IE)]><!--><div style="border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;"><!--<![endif]-->
|
||||
<!-- Subject -->
|
||||
<!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding-right: 10px; padding-left: 10px; padding-top: 20px; padding-bottom: 10px;"><![endif]-->
|
||||
<div style="font-size:28px;line-height:43px;font-family:Verdana, Geneva, sans-serif;color:<?php print $colors['booking_mailtemplate_subjectheading_text_color'] ?>;text-align:left;">
|
||||
<p style="margin: 0;text-align: center"><strong><?php print $subject ?></strong></p>
|
||||
</div>
|
||||
<!--[if mso]></td></tr></table><![endif]-->
|
||||
<!-- Main body content -->
|
||||
<!--[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;"><![endif]-->
|
||||
<div style="font-family:'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;line-height:150%;color:<?php print $colors['booking_mailtemplate_text_color'] ?>; padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 10px;">
|
||||
<?php print $body ?>
|
||||
</div>
|
||||
<!--[if mso]></td></tr></table><![endif]-->
|
||||
<!-- Dotted dividing line -->
|
||||
<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="90%" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td><![endif]-->
|
||||
<div align="center">
|
||||
<div style="border-top: 2px dotted #DAD8D8; width:90%; line-height:2px; height:2px; font-size:2px;"> </div>
|
||||
</div>
|
||||
<!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
<!-- Footer section -->
|
||||
<!--[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: 25px;"><![endif]-->
|
||||
<div style="font-family:'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;color:#C4C4C4; padding-right: 10px; padding-left: 10px; padding-top: 10px; padding-bottom: 25px;">
|
||||
<div style="font-size:12px;line-height:14px;text-align:left;"><?php print $footer ?></div>
|
||||
</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;">
|
||||
<!--[if (mso)|(IE)]>
|
||||
<table width="151" cellpadding="0" cellspacing="0" border="0"><tr><td style="border-collapse:collapse; padding-right: 10px; padding-left: 10px; padding-bottom: 10px;" align="center">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse; mso-table-lspace: 0pt;mso-table-rspace: 0pt; width:151px;">
|
||||
<tr>
|
||||
<![endif]-->
|
||||
<?php foreach ($social_links as $linkitem) : ?>
|
||||
<?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">
|
||||
<a href="<?php print $linkitem['linkurl'] ?>" title="<?php print $linkitem['text'] ?>" target="_blank">
|
||||
<img src="<?php print $linkitem['imageurl'] ?>" alt="<?php print $linkitem['text'] ?>" title="<?php print $linkitem['text'] ?>" width="32" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: none;height: auto;float: none;max-width: 32px !important">
|
||||
</a>
|
||||
<div style="line-height:5px;font-size:1px"> </div>
|
||||
</td></tr>
|
||||
</tbody></table>
|
||||
<!--[if (mso)|(IE)]></td><![endif]-->
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<!--[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>
|
||||
<!--[if (mso)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
<!--[if (!mso)&(!IE)]><!--></div><!--<![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
<!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]-->
|
||||
</div>
|
||||
</div>
|
||||
</div> <!--[if (mso)|(IE)]></td></tr></table><![endif]-->
|
||||
</div>
|
||||
<!--[if (mso)|(IE)]></div><![endif]-->
|
||||
</body></html>
|
40
theme/mimemail-message.tpl.php
Normal file
40
theme/mimemail-message.tpl.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to format an HTML mail.
|
||||
*
|
||||
* Copy this file in your default theme folder to create a custom themed mail.
|
||||
* Rename it to mimemail-message--[module]--[key].tpl.php to override it for a
|
||||
* specific mail.
|
||||
*
|
||||
* Available variables:
|
||||
* - $recipient: The recipient of the message
|
||||
* - $subject: The message subject
|
||||
* - $body: The message body
|
||||
* - $css: Internal style sheets
|
||||
* - $module: The sending module
|
||||
* - $key: The message identifier
|
||||
*
|
||||
* @see template_preprocess_mimemail_message()
|
||||
*/
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<?php if ($css): ?>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
<?php print $css ?>
|
||||
-->
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
<body id="mimemail-body" <?php if ($module && $key): print 'class="'. $module .'-'. $key .'"'; endif; ?>>
|
||||
<div id="center">
|
||||
<div id="main">
|
||||
<?php print $body ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user