Compare commits
830 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
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 | ||
|
5f8f17e798 | ||
|
a40e6a9d8a | ||
|
3794fece83 | ||
|
a103d34276 | ||
|
72647c02d9 | ||
|
21abb9331a | ||
|
e9c996949d | ||
|
a97f610661 | ||
|
b132ed9682 | ||
|
75e7f08111 | ||
|
578bea1aa6 | ||
|
5c00f6e342 | ||
|
089304cf19 | ||
|
dc01c12ae2 | ||
|
1beffbadf4 | ||
|
ac9b330eb7 | ||
|
b6bcfacead | ||
|
2614e25364 | ||
|
ee93be90d8 | ||
|
6836f3bc00 | ||
|
c0d2e11172 | ||
|
6172866bf4 | ||
|
62060f075a | ||
|
3e6ea4936b | ||
|
cab49b68f5 | ||
|
28df961b87 | ||
|
9a3687e1d1 | ||
|
cb0b3b5cad | ||
|
770a1e1da9 | ||
|
f5dc4836ce | ||
|
c654b83177 | ||
|
28599d8d1f | ||
|
b594364e0d | ||
|
2ffa185fb9 | ||
|
d095db14af | ||
|
9fdc391b8d | ||
|
aef96242a8 | ||
|
2d5e7eb23c | ||
|
9567f9c105 | ||
|
fd9b5e0045 | ||
|
48abf172a8 | ||
|
f76d8be329 | ||
|
ec6b7399e4 | ||
e68ea21185 | |||
350e2fe180 | |||
|
bc881f3abb | ||
e404501cda | |||
f2c6858634 | |||
a6dc9a61d2 | |||
5c8b7d662f | |||
7002020efd | |||
352ef58033 | |||
4512dd9107 | |||
4e4dcf1cc9 | |||
9011220ecc | |||
9ceabb97c7 | |||
af95616e87 | |||
7934d0718c | |||
a4da6d2d93 | |||
a1c091a03c | |||
ecaa11d70d | |||
d6619aa5ee | |||
3694e37db4 | |||
06df0a1856 | |||
69442d30b5 | |||
d5d45512c6 | |||
1aa9f6cfbe | |||
d2dc154518 | |||
b3b4fef4d2 | |||
63226d93f0 | |||
805c639e5d | |||
622c84314b | |||
70168189fb | |||
4550028fd6 | |||
91efbb80d6 | |||
f628e41677 | |||
49b97729f1 | |||
ad31433dad | |||
f09811990d | |||
c8c6f50a04 | |||
ed160830ff | |||
67dd4d6336 | |||
3a0daab0eb | |||
c59f3bda09 | |||
d88159c25a | |||
582110a752 | |||
d44e0d9592 | |||
7e248a8bf3 | |||
|
e30f2f7d6f | ||
|
f97dd6545d | ||
|
4df8c4f059 | ||
|
087f0405ef | ||
|
3bdaa51657 | ||
|
49e93895e8 | ||
|
bfc6de4ba5 | ||
|
66f634f600 | ||
|
2de599cae2 | ||
|
1ac064be32 | ||
|
54984e89e5 | ||
|
d5a810badc | ||
|
d864f9b3bd | ||
|
afdbd91222 | ||
|
39d6a31e3b | ||
|
1322956634 | ||
a38efd654c | |||
eee81539b6 | |||
e52d6ffc65 | |||
b175f1cc24 | |||
83ed03f7ff | |||
e69ebc95bd | |||
4adc2b4ee5 | |||
b310d3a02b | |||
76e2357c78 | |||
d4d1f9e14e | |||
193f6d9400 | |||
|
f7c5a15108 | ||
|
ccac5cd293 | ||
|
eb71552a84 | ||
|
94e7a7049f | ||
|
7288dd7b78 | ||
|
0eba6ef073 | ||
|
6a7fae9bd8 | ||
|
4ae6c21ad4 | ||
|
7c8f325954 | ||
|
065c87b4e2 | ||
|
1214279bda | ||
|
019247c16a | ||
|
4a8e95def3 | ||
|
1ab68096b7 | ||
|
c9d0aca9d3 | ||
|
c7b35cd3fc | ||
|
7ff32988b0 | ||
|
f398980225 | ||
|
af3660d974 | ||
|
bfb3ac9d48 | ||
|
04fd9e3e76 | ||
f270892027 | |||
06f1abbc60 | |||
7847afcf5d | |||
f26af4a0fb | |||
925907cadb | |||
bbd96ea440 | |||
e2f640ab30 | |||
d0e5d370eb | |||
2493f7eb98 | |||
567c141f2a | |||
f73d52ef40 | |||
1d4af9ac39 | |||
5a4ee8054f | |||
9a0aadfbc6 | |||
0aa7d4381e | |||
ee350ed26b | |||
|
1e912f526c | ||
9fe4bfe101 | |||
894a798d96 | |||
7d9c9ee566 | |||
d39e6ba4bc | |||
7cc1ba9be9 | |||
a7f95395bf | |||
33c040453a | |||
9c263eae95 | |||
f6e227ba56 | |||
88da4bd0d0 | |||
87f3dc109e | |||
7366ce52cf | |||
5e6a06f97a | |||
b816de11d2 | |||
|
67112c71b4 | ||
|
f23c896a12 | ||
|
d809089a7f | ||
|
d70b577638 | ||
|
c46966033f | ||
|
04e43f4ccd | ||
|
c96ae20cf8 | ||
|
d54b7e6c12 | ||
|
283fe7d9dd | ||
|
bffc40d2d7 | ||
|
d1d9560d02 | ||
|
527fb363e7 | ||
|
fd64685504 | ||
|
a689917c39 | ||
|
12f75f8445 | ||
|
e3030316d6 | ||
|
4d06713fea | ||
|
ddc3a8c358 | ||
|
5e13321a3c | ||
|
c589d81e14 | ||
|
8e014e2350 | ||
|
0dc753ab3e | ||
6414502cfe | |||
680799e3e4 | |||
d87a3eba86 | |||
804396ddf7 | |||
372c4d4f80 | |||
8cce7121a3 | |||
690ddc268b | |||
42cec9d87f | |||
c4b23351ab | |||
431c0d7eb1 | |||
9f648c755d | |||
450acf310b | |||
d7e321b8a6 | |||
a3a3cb29fa | |||
8ddbce54c1 | |||
004123a9e5 | |||
ab2927844a | |||
de0620fd0a | |||
aabd216aed | |||
a8a9c5c43e | |||
|
cffd8836da | ||
|
ce8bfedda1 | ||
|
48d2c4ad32 | ||
|
875fa6e839 | ||
|
56054b763a | ||
|
4eaf4a3450 | ||
|
b52e63fe15 | ||
|
e37a259c72 | ||
|
0abdebe3bd | ||
|
207c6212e5 | ||
|
940329bdd7 | ||
|
17076469de | ||
|
a2a81303be | ||
|
262340d866 | ||
|
9f02b2de6b | ||
|
ae79dbbc51 | ||
|
c1d4164f81 | ||
|
af1aaa7e81 | ||
|
fcfbb6c885 | ||
|
59f30c70d7 | ||
|
fd084499b4 | ||
|
8b31d1bebf | ||
|
1a519c1ee7 | ||
|
bfc1e642ab | ||
|
d3ef2572a1 | ||
|
8c6c935233 | ||
|
4e4fda63f1 | ||
|
4f81f56c75 | ||
|
6c1eb2528b | ||
|
cf636af9fe | ||
|
7974d9be3f | ||
|
207f1f10da | ||
|
747d1bbc0b | ||
71d37a3bba | |||
8a6681d922 | |||
945a6b77f6 | |||
e5322da7fb | |||
a5fc4f9f50 | |||
66b71fc8ab | |||
deed7bfb5f | |||
b9c032558e | |||
647853326c | |||
243a7691b6 | |||
2d21af7d2f | |||
449605a67d | |||
5443d6377b | |||
03d8681c55 | |||
a01096d1a5 | |||
3f5f80c308 | |||
c67778b652 | |||
d3f8ca0039 | |||
8f2c8fe32a | |||
1c47838b73 | |||
ff90039ed9 | |||
8ecef65d38 | |||
a82e6baa42 | |||
aec30aabd2 | |||
03a184625c | |||
e887776ce5 | |||
333cfa38c4 | |||
a7f474ec56 | |||
4baa283539 | |||
d783b24aed | |||
784fbf5351 | |||
03fc848ec9 | |||
7c4deaa502 | |||
ca2764317b | |||
335902e40f | |||
cda81990ee | |||
02deeef731 | |||
071ccba847 | |||
910d74f905 | |||
ee4b273c8a | |||
2ae35dd927 | |||
368d5d6555 | |||
7336f4d351 | |||
c707f90c97 | |||
e236d67c3f | |||
48f5b4aa0b | |||
df87648071 | |||
04bbca85bb | |||
fbd33d1afc | |||
d0946396b8 | |||
f446a7bf05 | |||
fef0469144 | |||
a1b6ebc381 | |||
369157fc9a | |||
84deb85c82 | |||
072c043ea0 | |||
8c43c3debe | |||
b184847b21 | |||
3aa87394f5 | |||
e06552e3e4 | |||
7c13255859 | |||
5427bd6020 | |||
7beffef6a9 | |||
44927ead8b | |||
ade8355721 | |||
32cbbf1fc9 | |||
f97f7d927b | |||
2cce280d8a | |||
0299adc9a0 | |||
b7e7f77e9a | |||
7f4f3ff411 | |||
235e03a1ab | |||
78eed38378 | |||
d63ac9f570 | |||
edccce94a2 | |||
083fd5aa08 | |||
8cde6fcba0 | |||
c98ae4d095 | |||
ccb9eb7c73 | |||
1444a73331 | |||
c9e7d2dc33 | |||
f0b4e2d310 | |||
b5f46b39b6 | |||
112a29a492 | |||
dca0c2194d | |||
37b9a202c1 | |||
30f6a67954 | |||
2b64a5f511 | |||
673ba97ea9 | |||
c558d2e626 | |||
c6e988945a | |||
d02a367648 | |||
3dd0f58a9b | |||
f6991f9a6b | |||
f7f7e5fedc | |||
ebe5dcb939 | |||
b30b0c9e89 | |||
ccaa107103 | |||
ec6971d42a | |||
3f52d241cf | |||
8b208a5fdb | |||
fa969ee4a0 | |||
a9d35ca97f | |||
99e45f86a3 | |||
e695c26e78 | |||
c03203bec6 | |||
dd780489ec | |||
2730223507 | |||
f4444bb341 | |||
7adfffb739 | |||
7c7310460c | |||
925be26646 | |||
31749b5a2c | |||
4d0c6c8186 | |||
43a8adbe20 | |||
7d03689695 | |||
43558a4771 | |||
08212c03ef | |||
c2cba77dad | |||
e46996adc1 | |||
cf86228bfd | |||
5fa185af69 | |||
64509f414f | |||
25ceaa7e62 | |||
bde2f3800e | |||
563a41a948 | |||
7a08abe8ee | |||
4ab03493d5 | |||
65e29b0be2 | |||
148a6be855 | |||
e4f07d47e4 | |||
fcbd24851e | |||
0906291040 | |||
1ee1435b15 | |||
af5e76f38e | |||
01fe861663 | |||
62454e55f2 | |||
79a3e536d1 | |||
f80a12a299 | |||
6242224d36 | |||
ca14f58237 | |||
78eb0a2b24 | |||
ae609f28da | |||
62ed20a354 | |||
89460e6157 | |||
691e1feeef | |||
e02d863833 | |||
bd665d6110 | |||
4d3bcb4949 | |||
2e09ca1814 | |||
1674c5242f | |||
c230ea32da | |||
929983acaa | |||
d7108b5a71 | |||
eced3d39bc | |||
abd4853ff5 | |||
9b431c6ee3 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
images/Thumbs.db
|
@@ -1 +1,7 @@
|
||||
Drupal 7 module for managing event bookings.
|
||||
Drupal 7 module for managing event bookings.
|
||||
|
||||
To install:
|
||||
- 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
|
||||
|
45
booking.MailSystemInterface.inc
Normal file
45
booking.MailSystemInterface.inc
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
@@ -4,17 +4,28 @@
|
||||
* The administration menu implementations for the booking module configuration pages
|
||||
*/
|
||||
|
||||
function booking_admin()
|
||||
{
|
||||
//regenerate all our menu hooks when loading this form
|
||||
menu_rebuild();
|
||||
|
||||
function booking_admin() {
|
||||
$form = array();
|
||||
|
||||
//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();
|
||||
watchdog('booking_debug', "<pre>SQL View booking_person_view check\n@info</pre>", array('@info' => print_r( $sqlview_check, true)));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
watchdog('booking_debug', "<pre>SQL View booking_person_view check does not exist\n@info</pre>", array('@info' => $e->getMessage()));
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
//form commences here
|
||||
$form['email'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Email Addresses'
|
||||
);
|
||||
'#title' => 'Email Addresses',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['email']['booking_from_email'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -43,18 +54,28 @@ 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(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Logistics Email Address'),
|
||||
'#description' => t("The email address used for logistics information."),
|
||||
'#description' => t("The email address used for logistics information like travel forms etc."),
|
||||
'#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'),
|
||||
@@ -66,7 +87,8 @@ function booking_admin()
|
||||
|
||||
$form['attendee'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Attendee restrictions'
|
||||
'#title' => 'Attendee restrictions',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['attendee']['booking_max_dob'] = array(
|
||||
@@ -112,18 +134,22 @@ function booking_admin()
|
||||
|
||||
$form['paypal'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Paypal Settings'
|
||||
'#title' => 'Paypal Settings',
|
||||
'#collapsible' => TRUE,
|
||||
//'#collapsed' => TRUE,
|
||||
);
|
||||
/*
|
||||
$form['paypal']['booking_use_paypal'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Use Paypal?'),
|
||||
'#description' => t('Select whether to use paypal for automatic payment handling, or process payments manually.'),
|
||||
'#title' => t('Use Paypal? (DEPRECATED)'),
|
||||
'#description' => t('Select whether to use paypal for automatic payment handling, or process payments manually. This option is now deprecated. Use the payment processor option below instead.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_use_paypal', 0)
|
||||
);
|
||||
*/
|
||||
$form['paypal']['booking_paypal_account'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify Paypal Account Address'),
|
||||
@@ -164,10 +190,94 @@ function booking_admin()
|
||||
'#size' => 5,
|
||||
'#description' => 'Percentage of transaction charged as paypal fee for transactions that include currency conversion, currently 3.6% in Australia'
|
||||
);
|
||||
|
||||
//Stripe Settings
|
||||
$form['stripe'] = array (
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Stripe Settings',
|
||||
'#collapsible' => TRUE,
|
||||
//'#collapsed' => TRUE,
|
||||
);
|
||||
$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,
|
||||
);
|
||||
$form['stripe']['booking_stripe_test_secret_key'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify Stripe Test Secret Key'),
|
||||
'#default_value' => variable_get('booking_stripe_test_secret_key', ''),
|
||||
'#description' => '(Secret API key)',
|
||||
);
|
||||
$form['stripe']['booking_stripe_test_public_key'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify Stripe Test Public Key'),
|
||||
'#default_value' => variable_get('booking_stripe_test_public_key', ''),
|
||||
'#description' => '(Public API key)',
|
||||
);
|
||||
$form['stripe']['booking_stripe_live_secret_key'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify Stripe Live Secret Key'),
|
||||
'#default_value' => variable_get('booking_stripe_live_secret_key', ''),
|
||||
'#description' => '(Secret API key)',
|
||||
);
|
||||
$form['stripe']['booking_stripe_live_public_key'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify Stripe Live Public Key'),
|
||||
'#default_value' => variable_get('booking_stripe_live_public_key', ''),
|
||||
'#description' => '(Public API key)',
|
||||
);
|
||||
$form['stripe']['booking_stripe_testmode'] = array (
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Stripe Test mode'),
|
||||
'#description' => t('When in test mode, payments will use test api keys which will not make any charges to cards. Leave this as off unless doing testing.'),
|
||||
'#options' => array (0 => t('Off'), t('On')),
|
||||
'#default_value' => variable_get('booking_stripe_testmode', 0),
|
||||
);
|
||||
$form['stripe']['booking_stripe_transaction_fee_fixedcost'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Stripe fixed cost transaction fee'),
|
||||
'#default_value' => variable_get('booking_stripe_transaction_fee_fixedcost', '0.3'),
|
||||
'#field_prefix' => '$',
|
||||
'#size' => 5,
|
||||
'#description' => 'Transaction fee is currently $0.3 AUD and is added before the percentage fee is applied.',
|
||||
);
|
||||
$form['stripe']['booking_stripe_transaction_fee_percentage'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Stripe Percentage Transaction Fee'),
|
||||
'#default_value' => variable_get('booking_stripe_transaction_fee_percentage', '1.75'),
|
||||
'#field_prefix' => '%',
|
||||
'#size' => 5,
|
||||
'#description' => 'Percentage of transaction charged as stripe fee, currently 1.75% in Australia',
|
||||
);
|
||||
$form['stripe']['booking_stripe_transaction_fee_percentage_intl'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Stripe Percentage Transaction Fee (International)'),
|
||||
'#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. 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',
|
||||
'#title' => t('Select Payment Processor to use'),
|
||||
'#description' => t('Select between Paypal, Stripe or Manaul Payment to use for processing payments.'),
|
||||
'#options' => array (0 => t('Paypal'), t('Stripe'), t('Manual Payments')),
|
||||
'#default_value' => variable_get('booking_payment_processor', 0),
|
||||
);
|
||||
$form['features']['booking_enable_roomallocations'] = array(
|
||||
'#type' => 'radios',
|
||||
@@ -220,7 +330,31 @@ function booking_admin()
|
||||
),
|
||||
'#default_value' => variable_get('booking_publish_readinggroups', 0)
|
||||
);
|
||||
|
||||
|
||||
$form['features']['booking_friendly_csv_groupnames'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Use human-friendly study group names in CSV export?'),
|
||||
'#description' => t('Select whether to use descriptions for study group columns when exporting CSV. If No, internal database field names are used.'),
|
||||
'#options' => array(0 => t('No'), t('Yes')),
|
||||
'#default_value' => variable_get('booking_friendly_csv_groupnames', 0),
|
||||
);
|
||||
$form['features']['booking_studygroup_csv_ages'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Include ages in study group CSV export?'),
|
||||
'#description' => t('Select whether to inclde ages for attendees when exporting study groups to CSV.'),
|
||||
'#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'
|
||||
@@ -280,7 +414,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(
|
||||
@@ -343,17 +478,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?'),
|
||||
@@ -392,10 +516,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'),
|
||||
@@ -403,6 +527,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?'),
|
||||
@@ -429,6 +554,7 @@ function booking_admin()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$form['regn_options']['booking_enable_skills'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable special skills information?'),
|
||||
@@ -449,6 +575,26 @@ function booking_admin()
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_roommate', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_songchoice'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable attendee to specify song choice?'),
|
||||
'#description' => t('Select whether to include questions about song choice in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_songchoice', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_freestyle'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Enable attendee to enter freestyle text'),
|
||||
'#description' => t('Select whether to include freestyle text field in the booking form.'),
|
||||
'#options' => array(
|
||||
0 => t('No'),
|
||||
t('Yes')
|
||||
),
|
||||
'#default_value' => variable_get('booking_enable_freestyle', 0)
|
||||
);
|
||||
$form['regn_options']['booking_enable_dietary'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Allow attendee to specify dietary requirements?'),
|
||||
@@ -501,10 +647,31 @@ 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['management'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Data Management Options'
|
||||
'#title' => 'Data Management Options',
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
$form['management']['booking_csv_exclude_fields'] = array(
|
||||
'#type' => 'textfield',
|
||||
@@ -522,7 +689,31 @@ function booking_admin()
|
||||
'#size' => 150,
|
||||
'#maxlength' => 2000
|
||||
);
|
||||
return system_settings_form($form);
|
||||
|
||||
$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', ''),
|
||||
);
|
||||
|
||||
//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);
|
||||
//$form['#submit'][] = '_booking_node_create_mysqlview';
|
||||
return $form;
|
||||
|
||||
}
|
||||
|
||||
function booking_admin_validate($form, $form_state)
|
||||
|
@@ -1,14 +1,14 @@
|
||||
<?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
|
||||
@@ -29,8 +29,7 @@ function booking_balance_page() {
|
||||
$person = $query->execute()
|
||||
->fetchObject();
|
||||
|
||||
if ($person)
|
||||
{
|
||||
if ($person) {
|
||||
//load all the fields
|
||||
$node = node_load($person->nid);
|
||||
//calculate the invoice ID
|
||||
@@ -45,30 +44,32 @@ function booking_balance_page() {
|
||||
|
||||
//populate tokens and paypal form
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
$tokens['paypal-total-form'] = _booking_paypal_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)) {
|
||||
@@ -44,13 +45,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;
|
||||
|
@@ -108,18 +108,20 @@ function _get_tshirt_options() {
|
||||
* @param $input integer containing role id
|
||||
* @return string for corresponding role
|
||||
*/
|
||||
function _booking_studygroup_role_lookup($input = NULL)
|
||||
{
|
||||
function _booking_studygroup_role_lookup($input = NULL) {
|
||||
$role = array();
|
||||
$role[] = t('No Role');
|
||||
$role[] = t('Leader');
|
||||
$role[] = t('Helper');
|
||||
$role[] = t('Reserve Leader');
|
||||
|
||||
if ($input != NULL)
|
||||
$role[] = t('Reserve Helper');
|
||||
|
||||
if ($input != NULL) {
|
||||
return $role[$input];
|
||||
else
|
||||
}
|
||||
else {
|
||||
return $role;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
33
booking.css
33
booking.css
@@ -1,7 +1,32 @@
|
||||
#leader-row {background: #6495ED;}
|
||||
#helper-row {background: #9dd781;}
|
||||
#reserveleader-row {background: #d4dc5c;}
|
||||
#new-group-row {border-top: thick double #ff0000;}
|
||||
#leader-new-group-row {background: #6495ED; border-top: thick double #ff0000;}
|
||||
#helper-new-group-row {background: #9dd781; border-top: thick double #ff0000;}
|
||||
#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double #ff0000;}
|
||||
#reservehelper-row {background: #d4dc5c;}
|
||||
/*
|
||||
tr.leader-row.odd {background: #6495ED;}
|
||||
tr.leader-row.even {background: #6495ED;}
|
||||
tr.helper-row.odd {background: #9dd781;}
|
||||
tr.helper-row.even {background: #9dd781;}
|
||||
tr.reserveleader-row.odd {background: #d4dc5c;}
|
||||
tr.reserveleader-row.even {background: #d4dc5c;}
|
||||
tr.reservehelper-row.odd {background: #d4dc5c;}
|
||||
tr.reservehelper-row.even {background: #d4dc5c;}
|
||||
*/
|
||||
#new-group-row {border-top: thick double black;}
|
||||
#leader-new-group-row {background: #6495ED; border-top: thick double black;}
|
||||
#helper-new-group-row {background: #9dd781; border-top: thick double black;}
|
||||
#reserveleader-new-group-row {background: #d4dc5c; border-top: thick double black;}
|
||||
#reservehelper-new-group-row {background: #d4dc5c; border-top: thick double black;}
|
||||
|
||||
/* test for email page*/
|
||||
/* tr.normal-row.odd {} */
|
||||
/* tr.normal-row.even {} */
|
||||
tr.welfare-row.odd {background: #c3e06c;}
|
||||
tr.welfare-row.even {background: #c3e06c;}
|
||||
tr.flying-row.odd {background: #c3e06c;}
|
||||
tr.flying-row.even {background: #e5f2c0;}
|
||||
tr.accomm-row.odd {background: #ffb380;}
|
||||
tr.accomm-row.even {background: #ffb380;}
|
||||
div#booking_email_preselection_suffix_wrapper {
|
||||
margin-bottom: 10px;
|
||||
}
|
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;
|
||||
}
|
||||
|
@@ -1,219 +1,45 @@
|
||||
<?php
|
||||
|
||||
function booking_manual_email()
|
||||
{
|
||||
/**
|
||||
* 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;
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
$form = array ();
|
||||
$options = array ();
|
||||
$group_text = "";
|
||||
$prefix = t("<p>Send a manual email to people registered for this event.</p>");
|
||||
$email_options_array = array();
|
||||
$email_options_array['registration'] = 'Registration Successful Email';
|
||||
$email_options_array['balance'] = 'Balance Outstanding Email';
|
||||
$email_options_array['complete'] = 'Payment Complete Email';
|
||||
$email_options_array['withdrawal'] = 'Withdrawal Processed Email';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment Email';
|
||||
$email_options_array['travelrequired'] = 'Travel Form Required Email';
|
||||
$email_options_array['travelcomplete'] = 'Travel Form Complete Email';
|
||||
$output_text = "";
|
||||
|
||||
//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);
|
||||
//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,
|
||||
));
|
||||
}
|
||||
|
||||
$form['email-type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email Type'),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => '',
|
||||
'#options' => $email_options_array,
|
||||
);
|
||||
|
||||
$header = array(
|
||||
'booking_nid' => array('data' => t('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'),
|
||||
);
|
||||
|
||||
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 = 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, '=');
|
||||
|
||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||
$result = $table_sort->execute();
|
||||
|
||||
foreach($result as $data)
|
||||
{
|
||||
$group_text = "";
|
||||
//$paid = _booking_amount_owing($data);
|
||||
//$paid = _booking_amount_owing($data->nid);
|
||||
$options[$data->nid] = array (
|
||||
'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))),
|
||||
'booking_name' => $data->booking_firstname . " " . $data->booking_lastname,
|
||||
'booking_gender' => $data->booking_gender == 'M' ? 'Male' : 'Female',
|
||||
'booking_email' => $data->booking_email,
|
||||
'booking_state' => $data->booking_state,
|
||||
'booking_status' => _booking_status_generate($data->booking_status),
|
||||
'amount_paid' => $data->booking_amount_paid,
|
||||
'amount_reqd' => $data->booking_total_pay_reqd,
|
||||
'booking_fully_paid' => $data->booking_payment_complete == 'Y' ? 'Yes' : 'No',
|
||||
'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No',
|
||||
'travel_form' => $data->tid > 0 ? 'Yes' : 'No',
|
||||
);
|
||||
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
foreach ($group_mapping as $group)
|
||||
{
|
||||
$role = $group->booking_studygroup_role;
|
||||
|
||||
if ($group->booking_node_id == $data->nid && $role > 0)
|
||||
{
|
||||
$text = _booking_studygroup_role_lookup($role);
|
||||
$group_text .= "<b>" . $text . "</b> for " . $group->booking_studygroup_descrip . " #" . $group->booking_session_id . "; ";
|
||||
}
|
||||
}
|
||||
$options[$data->nid]['group_roles'] = $group_text;
|
||||
}
|
||||
|
||||
//$values[$data->nid] = ($paid == 0 || $data->booking_status != 1) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
//'#default_value' => $values,
|
||||
'#empty' => t('No attendees found.'),
|
||||
'#attributes' => array('id' => 'sort-table'),
|
||||
);
|
||||
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
function booking_manual_email_submit($form, &$form_state) {
|
||||
$counter = 0;
|
||||
$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));
|
||||
//watchdog('booking', 'Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, false, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'travelrequired')
|
||||
{
|
||||
$message = t('Processing a manual travel form request email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'balance')
|
||||
{
|
||||
$message = t('Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
_booking_balance_payment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'complete')
|
||||
{
|
||||
$message = t('Processing a manual registration complete email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual registration complete email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, true, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'travelcomplete')
|
||||
{
|
||||
$message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_confirmation_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal')
|
||||
{
|
||||
$message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
_booking_demoted_to_notcoming_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment')
|
||||
{
|
||||
$message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
//watchdog('booking', 'Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
_booking_missedpayment_email($key);
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'custom') !== false)
|
||||
{
|
||||
$message = t('Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
//watchdog('booking', 'Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type']);
|
||||
}
|
||||
//increase the counter of people we've emailed
|
||||
$counter++;
|
||||
//store info about the email
|
||||
$update_messages[] = $message;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
$output_text = $body;
|
||||
}
|
||||
$final_message = "Sent manual email for $counter people.";
|
||||
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.");
|
||||
}
|
||||
|
||||
//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
|
||||
@@ -221,7 +47,7 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
* @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);
|
||||
@@ -232,8 +58,10 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
|
||||
//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;
|
||||
@@ -243,34 +71,36 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
'!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
|
||||
@@ -278,14 +108,14 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
* @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,
|
||||
@@ -295,19 +125,28 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
//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);
|
||||
@@ -321,27 +160,30 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
||||
@@ -351,19 +193,21 @@ function booking_manual_email_submit($form, &$form_state) {
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -373,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);
|
||||
}
|
||||
@@ -407,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);
|
||||
@@ -417,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;
|
||||
}
|
||||
@@ -432,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -455,56 +303,69 @@ 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)
|
||||
{
|
||||
function _booking_custom_email($nid, $email_type, $sender = 'contact') {
|
||||
global $event;
|
||||
global $user;
|
||||
$language = user_preferred_language($user);
|
||||
|
||||
//calculate the drupal variables to use
|
||||
$email_subject_variable = 'booking_email_subject_' . $email_type;
|
||||
$email_body_variable = 'booking_email_' . $email_type;
|
||||
|
||||
|
||||
if ($sender == 'contact') {
|
||||
//watchdog('booking', 'Sending a custom email from the contact email address.');
|
||||
//calculate the from email address for a contact email
|
||||
$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') {
|
||||
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
|
||||
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
}
|
||||
|
||||
//load the node matching this id
|
||||
$node = node_load($nid);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
//calculate the from email address
|
||||
$from = t('!event Registrations <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_contact_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
|
||||
//calculate the remaining parameters
|
||||
$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;
|
||||
|
||||
//send the email to the person
|
||||
drupal_mail('booking', 'booking_email_custom', $to, $language, $params, $from);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the registrant once they move from the waiting list to the coming list
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
@@ -522,16 +383,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 Not 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);
|
||||
}
|
||||
@@ -541,15 +414,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;
|
||||
}
|
||||
@@ -568,16 +439,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);
|
||||
}
|
||||
@@ -587,15 +463,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;
|
||||
}
|
||||
@@ -614,42 +488,44 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee requesting them to complete their travel form
|
||||
* Function to generate email to be sent to the attendee with the _initial_ request to complete their travel form
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
function _booking_travelform_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)
|
||||
{
|
||||
watchdog('booking', 'Not sending travelform confirmation email since that feature is currently disabled.');
|
||||
if (variable_get('booking_auto_workflow_email', 0) == 0) {
|
||||
watchdog('booking', 'Not sending travelform initial request email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
|
||||
//load the node matching this id from the database, ignoring the cache
|
||||
$node = node_load($nid, NULL, TRUE);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
watchdog('booking', 'Sending travelform confirmation email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
//calculate the from email address
|
||||
$from = t('!event Travel <!email>', array('!event' => $event->booking_eventname,
|
||||
@@ -658,37 +534,91 @@ function _booking_travelform_request_email($nid)
|
||||
|
||||
//calculate the remaining parameters
|
||||
$to = $node->booking_email;
|
||||
$subject = token_replace(variable_get('booking_email_travel_required_subject', t('!event', array('!event' => $event->booking_eventname))), $tokens);
|
||||
$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_required_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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee with the _reminder_ request to complete their travel form
|
||||
*
|
||||
* @param $nid - the registration node
|
||||
*/
|
||||
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) {
|
||||
watchdog('booking', 'Not sending travelform reminder request email since that feature is currently disabled.');
|
||||
return;
|
||||
}
|
||||
|
||||
//load the node matching this id from the database, ignoring the cache
|
||||
$node = node_load($nid, NULL, TRUE);
|
||||
$tokens = booking_define_personspecific_tokens($node);
|
||||
|
||||
//calculate the from email address
|
||||
$from = t('!event Travel <!email>', array('!event' => $event->booking_eventname,
|
||||
'!email' => variable_get('booking_logistics_email', variable_get('site_mail', ini_get('sendmail_from')))
|
||||
));
|
||||
|
||||
//calculate the remaining parameters
|
||||
$to = $node->booking_email;
|
||||
$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'] = 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
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to generate email to be sent to the attendee once they complete their travel form
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
@@ -710,16 +640,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);
|
||||
}
|
||||
|
857
booking.emails_admin.inc
Normal file
857
booking.emails_admin.inc
Normal file
@@ -0,0 +1,857 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
$default_email_text = "Dear [booking:fname],\n" .
|
||||
"Congratulations, you are officially booked into [booking:eventname]. " .
|
||||
"Your registration reference number is [booking:booking-id].\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\n" .
|
||||
"________________________________________________________\n" .
|
||||
"The following information shows the details you entered when you registered. " .
|
||||
"If any of this information is incorrect, please reply to this email with the corrections as soon as possible.\n" .
|
||||
"________________________________________________________";
|
||||
$booking_email_regn_complete_text = "Dear [booking:fname],\n" .
|
||||
"Thank-you for completing your payment for [booking:eventname].\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\n" .
|
||||
"________________________________________________________\n" .
|
||||
"The following information shows the details you entered when you registered. " .
|
||||
"If any of this information is incorrect, please reply to this email with the corrections as soon as possible.\n" .
|
||||
"________________________________________________________";
|
||||
$booking_email_waitinglist_text = "Dear [booking:fname],\n" .
|
||||
"Thank-you for registering to attend [booking:eventname]. Unfortunately the venue for this event is full, and you have been placed on the waiting list to attend.\n" .
|
||||
"We will contact you if a position becomes available for you. Please don't hesitate to contact us if you have any queries by replying to this email.\n" .
|
||||
"Love in Jesus,\n[booking:eventname] Registrations Team\n" .
|
||||
"________________________________________________________\n" .
|
||||
"The following information shows the details you entered when you registered. " .
|
||||
"If any of this information is incorrect, please reply to this email with the corrections as soon as possible.\n" .
|
||||
"________________________________________________________";
|
||||
$booking_email_paymentoutstanding_text = "Dear [booking:fname],\n" .
|
||||
"Thank-you for registering to attend [booking:eventname]. Our records indicate that you currently have $[booking:payment-required] outstanding to finalise your registration.\n" .
|
||||
"Please visit [booking:balance-payment-link] in order to make your final payment.\n" .
|
||||
"Love in Jesus,\n[booking:eventname] Registrations Team\n" .
|
||||
"________________________________________________________\n";
|
||||
$booking_email_waitinglistpromotion = "Dear [booking:fname],\n" .
|
||||
"We have some great news for you. A place at [booking:eventname] for you has just become available. " .
|
||||
"If you wish to secure your place at [booking:eventname], please visit [booking:balance-payment-link] to make your final payment. " .
|
||||
"Our records indicate that you currently have $[booking:paypal-total-amount] outstanding (including Paypal transaction fees).\n" .
|
||||
"Once we have received your payment, you will be sent an automatic confirmation email thanking you for paying your outstanding fees. " .
|
||||
"If you are paying via Paypal's eCheque feature, please be aware that payments take 3-5 working days to clear, " .
|
||||
"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(
|
||||
'#theme' => 'token_tree',
|
||||
'#token_types' => array('booking'),
|
||||
);
|
||||
|
||||
/*Text for emails*/
|
||||
$form['emails'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Built-In Workflow Email Definitions',
|
||||
'#collapsible' => 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'),
|
||||
'#description' => t('Email to send to the notification email address (defined in general configuration) when a person has registered'),
|
||||
'#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'),
|
||||
'#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' => 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'),
|
||||
'#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' => 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.'),
|
||||
'#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'),
|
||||
'#description' => t(''),
|
||||
'#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',
|
||||
'#title' => t('Balance Outstanding Email Subject'),
|
||||
'#description' => t('Subject line for email advising attendee they missed the payment deadline'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_paymentoutstanding_subject','[booking:eventname] payment required'),
|
||||
);
|
||||
$form['emails']['booking_email_paymentoutstanding_text'] = array(
|
||||
'#description' => t('Email text to send a person reminding them of how much they owe'),
|
||||
'#title' => t('Balance Outstanding Email 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)'),
|
||||
'#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 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'),
|
||||
'#description' => t('Subject line for email advising attendee their withdrawal has been processed'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_notcoming_demotion_subject','[booking:eventname] withdrawal processed'),
|
||||
);
|
||||
$form['emails']['booking_email_notcoming_demotion'] = array(
|
||||
'#title' => t('Email text to send a person who withdraws their registration'),
|
||||
'#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',
|
||||
'#title' => t('Missed Payment Email Subject'),
|
||||
'#description' => t('Subject line for email advising attendee they missed the payment deadline'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_missedpayment_subject','[booking:eventname] payment deadline missed'),
|
||||
);
|
||||
$form['emails']['booking_email_missedpayment'] = array(
|
||||
'#title' => t('Missed Payment Email Text'),
|
||||
'#description' => t('Email text to send a person who missed the payment deadline'),
|
||||
'#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',
|
||||
'#title' => t('Initial Travel Form Required Subject'),
|
||||
'#description' => t('Subject line for first email requesting attendee to complete the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_initial_email_subject','[booking:eventname] Travel Details Required'),
|
||||
);
|
||||
$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'))),
|
||||
'#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',
|
||||
'#title' => t('Reminder Travel Form Required Subject'),
|
||||
'#description' => t('Subject line for reminder email requesting attendee to complete the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_reminder_email_subject','[booking:eventname] Travel Details Required'),
|
||||
);
|
||||
$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'))),
|
||||
'#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',
|
||||
'#title' => t('Travel Form Complete Subject'),
|
||||
'#description' => t('Subject line for email indicating a person has completed the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_complete_subject','[booking:eventname] Travel Details Received'),
|
||||
);
|
||||
$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'))),
|
||||
'#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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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*/
|
||||
$form['custom-emails'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Custom Email Text Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++) {
|
||||
$subject_fieldname = 'booking_email_subject_custom' . $i;
|
||||
$body_fieldname = 'booking_email_custom' . $i;
|
||||
$form['custom-emails'][$subject_fieldname] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Custom Email ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get($subject_fieldname,'[booking:eventname]'),
|
||||
);
|
||||
$form['custom-emails'][$body_fieldname] = array(
|
||||
'#title' => t('Email text for custom email ' . $i),
|
||||
'#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' => FALSE,
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
//@todo add an admin variable for this
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
$subject_fieldname = 'booking_email_subject_customlogistics' . $i;
|
||||
$body_fieldname = 'booking_email_customlogistics' . $i;
|
||||
$form['custom-logistics-emails'][$subject_fieldname] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Logistics Custom Email ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get($subject_fieldname,'[booking:eventname] Logistics'),
|
||||
);
|
||||
$form['custom-logistics-emails'][$body_fieldname] = array(
|
||||
'#title' => t('Email text for Logistics Custom Email ' . $i),
|
||||
'#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 manually generate and send a workflow or custom email
|
||||
*
|
||||
* @param
|
||||
* @return form render array
|
||||
*/
|
||||
function booking_manual_email_form($form, &$form_state)
|
||||
{
|
||||
global $event;
|
||||
//see http://www.jaypan.com/blog/themeing-drupal-7-forms-tables-checkboxes-or-radios
|
||||
/*
|
||||
create hidden form element that we will populate with JSON data via ajax
|
||||
create select element defining the pre-selections available
|
||||
create submit button that calls ajax to update hidden form element, then calls ajax to check the checkboxes based on the hidden form element
|
||||
|
||||
info on turning JSON data back to array
|
||||
http://stackoverflow.com/questions/29076219/javascript-storing-array-of-objects-in-hidden-field
|
||||
|
||||
ajax references:
|
||||
http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
https://www.drupal.org/node/1028410
|
||||
https://www.drupal.org/node/2046693
|
||||
|
||||
jquery to check the checkboxes:
|
||||
http://jsfiddle.net/nanoquantumtech/dnhwz/
|
||||
*/
|
||||
$form = array();
|
||||
$options = array();
|
||||
$preselection_options = array();
|
||||
$values = array();
|
||||
$group_text = "";
|
||||
$prefix = t("<p>Send a manual email to people registered for this event.</p>");
|
||||
$email_options_array = array();
|
||||
$email_options_array['NULL'] = "---";
|
||||
$email_options_array['registration'] = 'Registration Successful Email';
|
||||
$email_options_array['balance'] = 'Balance Outstanding Email';
|
||||
$email_options_array['complete'] = 'Payment Complete Email';
|
||||
$email_options_array['withdrawal'] = 'Withdrawal Processed Email';
|
||||
$email_options_array['waitinglistpromotion'] = 'Position Available (Balance outstanding)';
|
||||
$email_options_array['waitinglistpromotionfullypaid'] = 'Position Available (Fully Paid)';
|
||||
$email_options_array['missedpayment'] = 'Missed Payment Email';
|
||||
$email_options_array['initialtravelrequired'] = 'Initial Travel Form Required Email';
|
||||
$email_options_array['remindertravelrequired'] = 'Reminder Travel Form Required Email';
|
||||
$email_options_array['travelcomplete'] = 'Travel Form Complete Email';
|
||||
|
||||
$preselection_options['---'] = "---";
|
||||
$preselection_options['notpaid'] = 'People who have not yet paid';
|
||||
$preselection_options['bookedin'] = 'People who are booked-in';
|
||||
$preselection_options['waitinglist'] = 'People on waiting list';
|
||||
$preselection_options['unpaid'] = 'People booked-in with outstanding balance';
|
||||
$preselection_options['refundreqd'] = 'Refund Required';
|
||||
$preselection_options['notravelform'] = "People booked-in no travel form received";
|
||||
$preselection_options['notravelforminclwaiting'] = "People booked-in/waiting no travel form received";
|
||||
$preselection_options['leaderhelper'] = "Leaders/Helpers";
|
||||
|
||||
$header = array(
|
||||
'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
|
||||
'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'),
|
||||
'booking_gender' => array('data' => t('Gender'), 'field' => 'booking_gender'),
|
||||
'booking_email' => array('data' => t('Email'), 'field' => 'booking_email'),
|
||||
'booking_state' => array('data' => t('State'), 'field' => 'booking_state'),
|
||||
'booking_status' => array('data' => t('Status'), 'field' => 'booking_status'),
|
||||
'amount_paid' => array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
|
||||
'amount_reqd' => array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'),
|
||||
'booking_fully_paid' => array('data' => t('Fully paid?'), 'field' => 'booking_payment_complete'),
|
||||
'welfare_required' => array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
|
||||
);
|
||||
|
||||
//add in the custom email types
|
||||
for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++)
|
||||
{
|
||||
$email_options_array['custom' . $i] = variable_get('booking_email_subject_custom' . $i, $event->booking_eventname . ' custom ' . $i);
|
||||
}
|
||||
//add in the custom email types from logistics
|
||||
for ($i = 1; $i <= 5; $i++)
|
||||
{
|
||||
$email_options_array['customlogistics' . $i] = variable_get('booking_email_subject_customlogistics' . $i,
|
||||
$event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**";
|
||||
}
|
||||
|
||||
//attach css so we can customise colours for some people
|
||||
$form['#attached']['css'] = array(
|
||||
drupal_get_path('module', 'booking') . '/booking.css',
|
||||
);
|
||||
//attach js for dynamically setting checkboxes
|
||||
$form['#attached']['js'][] = drupal_get_path("module", "booking")."/booking.js";
|
||||
|
||||
$form['pretext'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => $prefix,
|
||||
);
|
||||
|
||||
//@todo add booking prefix
|
||||
$form['email-type'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Email Type'),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => 'NULL',
|
||||
'#options' => $email_options_array,
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_preview_callback',
|
||||
'wrapper' => 'booking_email_preview_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => "[]",
|
||||
'#prefix' => '<div id="booking_email_default_ids_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#attributes' => array('id' => 'booking_email_default_ids'),
|
||||
);
|
||||
|
||||
$form['booking-email-preselection'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Pre-select attendees from list'),
|
||||
'#description' => t('Use this to select a large group of people based on pre-defined criteria.'),
|
||||
'#options' => $preselection_options,
|
||||
'#default_value' => '---',
|
||||
'#suffix' => '<div id="booking_email_preselection_suffix_wrapper"></div>',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'callback' => '_booking_email_get_default_selection_callback',
|
||||
'wrapper' => 'booking_email_default_ids_wrapper',
|
||||
),
|
||||
);
|
||||
|
||||
$form['booking-email-preview'] = array(
|
||||
'#type' => 'container',
|
||||
'#children' => "<h3>Email Preview</h3><pre>No email type selected.</pre>",
|
||||
'#prefix' => '<div id="booking_email_preview_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$header['travel_form'] = array('data' => t('Travel Submitted?'), 'field' => 'tid');
|
||||
}
|
||||
|
||||
|
||||
//query the database for studygroup info if it is enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
//select entries from the study groups mapping table
|
||||
$query = db_select('booking_studygroup_mapping', 'm');
|
||||
$query->join('booking_studygroup_list', 's', 's.sid = m.booking_studygroup_id');
|
||||
$query->condition('m.booking_eventid', $event->eid, '=');
|
||||
$query->fields('m')->fields('s', array('booking_studygroup_descrip'));
|
||||
$group_mapping = $query->execute()->fetchAllAssoc('sid');
|
||||
//add a column to the table header
|
||||
$header['group_roles'] = array('data' => t('Group Role'));
|
||||
}
|
||||
|
||||
//query for attendee data
|
||||
$query = db_select('booking_person', 'p');
|
||||
$query->join('booking_price', 'pr', 'pr.pid = p.booking_payment_id');
|
||||
$query->leftJoin('booking_travel', 't', 'p.nid = t.booking_person_nid');
|
||||
$query->fields('p')
|
||||
->fields('pr', array('booking_price', 'booking_late_price'))
|
||||
->fields('t')
|
||||
->condition('p.booking_eventid', $event->eid, '=');
|
||||
//make the result user-sortable
|
||||
$table_sort = $query->extend('TableSort')->orderbyHeader($header);
|
||||
$result = $table_sort->execute();
|
||||
|
||||
//generate the tableselect data
|
||||
foreach($result as $data) {
|
||||
$group_text = "";
|
||||
$class = $data->booking_welfare_required == 'Y' ? "welfare-row" : "normal-row";
|
||||
$options[$data->nid] = array (
|
||||
'#attributes' => array('class' => array($class)),
|
||||
'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))),
|
||||
'booking_name' => $data->booking_firstname . " " . $data->booking_lastname,
|
||||
'booking_gender' => $data->booking_gender == 'M' ? 'Male' : 'Female',
|
||||
'booking_email' => $data->booking_email,
|
||||
'booking_state' => $data->booking_state,
|
||||
'booking_status' => _booking_status_generate($data->booking_status),
|
||||
'amount_paid' => $data->booking_amount_paid,
|
||||
'amount_reqd' => $data->booking_total_pay_reqd,
|
||||
'booking_fully_paid' => $data->booking_payment_complete == 'Y' ? 'Yes' : 'No',
|
||||
'welfare_required' => $data->booking_welfare_required == 'Y' ? 'Yes' : 'No',
|
||||
);
|
||||
|
||||
//add optional columns if those features are enabled
|
||||
if (variable_get('booking_enable_travelform', 0) == 1) {
|
||||
$options[$data->nid]['travel_form'] = $data->tid > 0 ? 'Yes' : 'No';
|
||||
}
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
foreach ($group_mapping as $group) {
|
||||
$role = $group->booking_studygroup_role;
|
||||
if ($group->booking_node_id == $data->nid && $role > 0) {
|
||||
$text = _booking_studygroup_role_lookup($role);
|
||||
$group_text .= "<b>" . $text . "</b> for " . $group->booking_studygroup_descrip . " #" . $group->booking_session_id . "; ";
|
||||
}
|
||||
}
|
||||
$options[$data->nid]['group_roles'] = $group_text;
|
||||
}
|
||||
}
|
||||
|
||||
$form['table'] = array (
|
||||
'#type' => 'tableselect',
|
||||
//'#multiple' => TRUE,
|
||||
'#header' => $header,
|
||||
'#options' => $options,
|
||||
'#default_value' => $values,
|
||||
'#empty' => t('No attendees found.'),
|
||||
'#attributes' => array('id' => 'sort-table'),
|
||||
);
|
||||
//watchdog('booking_debug', "<pre>Manual email form default values\n@info</pre>", array('@info' => print_r( $values, true)));
|
||||
//watchdog('booking_debug', "<pre>Manual email form table\n@info</pre>", array('@info' => print_r( $form['table'], true)));
|
||||
|
||||
$form['submit-bottom'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Send Email'),
|
||||
);
|
||||
|
||||
return array (
|
||||
/*
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
*/
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update preview of email that will be sent
|
||||
*
|
||||
*/
|
||||
function _booking_email_get_preview_callback($form, $form_state) {
|
||||
global $event;
|
||||
$text = "";
|
||||
$emailtype = $form_state['values']['email-type'];
|
||||
|
||||
switch ($emailtype) {
|
||||
case "registration":
|
||||
$text = variable_get('booking_email_bookedin_text');
|
||||
break;
|
||||
case "balance":
|
||||
$text = variable_get('booking_email_paymentoutstanding_text');
|
||||
// perform the checking of HTML value now since we're pre-pending text to it
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1) {
|
||||
// no <pre> tags necessary if its a HTML mail
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$text .= "\n<h3>If married</h3>\n";
|
||||
}
|
||||
else {
|
||||
$text .= "\n</pre><h3>If married</h3>\n<pre>";
|
||||
}
|
||||
$married_text = variable_get('booking_email_paymentoutstanding_married_text');
|
||||
// repeat HTML check for rest of preview
|
||||
$text .= isset($married_text['format']) ? $married_text['value'] : $married_text;
|
||||
}
|
||||
break;
|
||||
case "complete":
|
||||
$text = variable_get('booking_email_regn_complete_text');
|
||||
break;
|
||||
case "withdrawal":
|
||||
$text = variable_get('booking_email_notcoming_demotion');
|
||||
break;
|
||||
case "missedpayment":
|
||||
$text = variable_get('booking_email_missedpayment');
|
||||
break;
|
||||
case "initialtravelrequired":
|
||||
$text = variable_get('booking_email_travel_initial_email_text');
|
||||
break;
|
||||
case "remindertravelrequired":
|
||||
$text = variable_get('booking_email_travel_reminder_email_text');
|
||||
break;
|
||||
case "travelcomplete":
|
||||
$text = variable_get('booking_email_travel_complete_text');
|
||||
break;
|
||||
case "waitinglistpromotion":
|
||||
$text = variable_get('booking_email_waitinglistpromotion');
|
||||
break;
|
||||
case "waitinglistpromotionfullypaid":
|
||||
$text = variable_get('booking_email_waitinglistpromotion_fullypaid');
|
||||
break;
|
||||
}
|
||||
//handle custom email types
|
||||
if (strpos($emailtype, 'custom') !== false) {
|
||||
$text = variable_get('booking_email_' . $form_state['values']['email-type']);
|
||||
}
|
||||
|
||||
//use the html value if it is set, otherwise use the plaintext input which is just a string
|
||||
$text = isset($text['format']) ? $text['value'] : $text;
|
||||
//watchdog('booking_debug', "<pre>Email generation:\n@info</pre>", array('@info' => print_r( $text, true)));
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3>";
|
||||
$markup_post = "<br /><br /></div>";
|
||||
}
|
||||
else {
|
||||
$markup_pre = "<div id=\"booking_email_preview_wrapper\"><h3>Email Preview</h3><pre>";
|
||||
$markup_post = "</pre><br /><br /></div>";
|
||||
}
|
||||
|
||||
//generate html that will be used to update div booking_email_preview_wrapper
|
||||
return $markup_pre . $text . $markup_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to update hidden form value with default checkbox details
|
||||
*
|
||||
* Callback element needs only select the portion of the form to be updated.
|
||||
* Since #ajax['callback'] return can be HTML or a renderable array (or an
|
||||
* array of commands), we can just return a piece of the form.
|
||||
* Source: http://www.maged.me/blog/drupal-7-execute-javascript-code-after-ajax-call
|
||||
*/
|
||||
function _booking_email_get_default_selection_callback($form, $form_state) {
|
||||
global $event;
|
||||
$defaults = array();
|
||||
$replacementform_data = array();
|
||||
|
||||
//get type of selection from $form_state['values']['booking-email-preselection']
|
||||
$selection = $form_state['values']['booking-email-preselection'];
|
||||
//load nodes
|
||||
$people = booking_load_query(NULL, TRUE);
|
||||
|
||||
//populate $defaults based on type of selection
|
||||
foreach ($people as $person) {
|
||||
switch ($selection) {
|
||||
case 'notpaid':
|
||||
if ($person->booking_status == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'bookedin':
|
||||
if ($person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'waitinglist':
|
||||
if ($person->booking_status == 2) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'refundreqd':
|
||||
if ($person->booking_status == 3 && $person->booking_refund_processed == 'N') {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'unpaid':
|
||||
if ($person->booking_payment_complete == 'N' && $person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'notravelform':
|
||||
if ($person->booking_status == 1 && $person->tid == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'notravelforminclwaiting':
|
||||
if (($person->booking_status == 1 || $person->booking_status == 2) && $person->tid == 0) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'leaderhelper':
|
||||
foreach ($person as $key => $value) {
|
||||
if (preg_match('/^session(\d+)_role/', $key, $matches) && $value > 0) {
|
||||
//don't add the person multiple times if they're leading/helping multiple groups
|
||||
if (! in_array($person->nid, $defaults)) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} //end switch
|
||||
} //loop attendees
|
||||
|
||||
//create new hidden form element to return
|
||||
$replacementform_data['booking-email-default-ids'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => drupal_json_encode($defaults), //encode the data as json so we can process it with jQuery
|
||||
'#prefix' => '<div id="booking_email_default_ids_wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#attributes' => array('id' => 'booking_email_default_ids'),
|
||||
);
|
||||
|
||||
$output_html = render($replacementform_data['booking-email-default-ids']);
|
||||
$feedback_html = t("<div id=\"booking_email_preselection_suffix_wrapper\">Number of people selected: <b>!num</b></div>",
|
||||
array('!num' => count($defaults)));
|
||||
//watchdog('booking_debug', "<pre>Manual Email ajax html\n@info</pre>", array('@info' => print_r( $output_html, true)));
|
||||
|
||||
//return a sequence of commands to run
|
||||
return array(
|
||||
'#type' => 'ajax',
|
||||
'#commands' => array(
|
||||
ajax_command_replace("#booking_email_default_ids_wrapper", $output_html),
|
||||
ajax_command_replace("#booking_email_preselection_suffix_wrapper", $feedback_html),
|
||||
// This will call the command bookingEmailIDs in our custom JS file.
|
||||
array('command' => 'bookingAjaxCheckboxes',
|
||||
'formDataElement' => 'booking_email_default_ids', //name of the hidden form element that contains the json data
|
||||
'formName' => 'booking-manual-email-form', //note the dashes instead of underscores!
|
||||
'checkboxName' => 'table', //form element for tableselect
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to handle sending the manual emails
|
||||
*/
|
||||
function booking_manual_email_form_submit($form, &$form_state) {
|
||||
$counter = 0;
|
||||
$update_messages = array();
|
||||
$checkboxes = $form_state['values']['table']; //$values['booking_price_active'];
|
||||
//watchdog('booking', 'Formstate when setting buttons: @info', array ('@info' => var_export($form_state['values'], TRUE)));
|
||||
//watchdog('booking', 'Checkboxes when setting buttons: @info', array ('@info' => var_export($checkboxes, TRUE)));
|
||||
|
||||
foreach($checkboxes as $key => $value)
|
||||
{
|
||||
$message = "";
|
||||
|
||||
//do a sanity check on the key => value pair from the form submission
|
||||
if (is_numeric($key) && $value != 0)
|
||||
{
|
||||
//check the person exists in the database
|
||||
$person = db_query("SELECT person.nid " .
|
||||
"FROM {booking_person} person " .
|
||||
"WHERE nid = :nid",
|
||||
array(':nid' => $key))
|
||||
->fetchObject();
|
||||
|
||||
if ($person)
|
||||
{
|
||||
if ($form_state['values']['email-type'] == 'registration') {
|
||||
$message = t('Processing a manual registration email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, false, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'initialtravelrequired') {
|
||||
$message = t('Processing a manual initial travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_initial_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'remindertravelrequired') {
|
||||
$message = t('Processing a manual reminder travel form request email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_reminder_request_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'balance') {
|
||||
$message = t('Processing a manual outstanding balance email to id @info', array ('@info' => $key));
|
||||
_booking_balance_payment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'complete') {
|
||||
$message = t('Processing a manual registration complete email to id @info', array ('@info' => $key));
|
||||
_booking_registration_email($key, true, true);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'travelcomplete') {
|
||||
$message = t('Processing a manual travelform complete email to id @info', array ('@info' => $key));
|
||||
_booking_travelform_confirmation_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'withdrawal') {
|
||||
$message = t('Processing a manual withdrawal email to id @info', array ('@info' => $key));
|
||||
_booking_demoted_to_notcoming_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'missedpayment') {
|
||||
$message = t('Processing a manual missedpayment email to id @info', array ('@info' => $key));
|
||||
_booking_missedpayment_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'waitinglistpromotion') {
|
||||
$message = t('Processing a manual waitinglistpromotion email to id @info', array ('@info' => $key));
|
||||
_booking_promoted_from_waitinglist_email($key);
|
||||
}
|
||||
elseif ($form_state['values']['email-type'] == 'waitinglistpromotionfullypaid') {
|
||||
$message = t('Processing a manual waitinglistpromotionfullypaid email to id @info', array ('@info' => $key));
|
||||
_booking_promoted_from_waitinglist_email($key);
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'customlogistics') !== false) {
|
||||
$message = t('Processing a @custom type email from logistics to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'logistics');
|
||||
}
|
||||
elseif (strpos($form_state['values']['email-type'], 'custom') !== false) {
|
||||
$message = t('Processing a @custom type email to id @info', array ('@custom' => $form_state['values']['email-type'], '@info' => $key));
|
||||
_booking_custom_email($key, $form_state['values']['email-type'], 'contact');
|
||||
}
|
||||
//increase the counter of people we've emailed
|
||||
$counter++;
|
||||
//store info about the email
|
||||
$update_messages[] = $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
$final_message = "Sent manual email for $counter people of type " . $form_state['values']['email-type'];
|
||||
drupal_set_message($final_message, 'status', FALSE);
|
||||
watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>");
|
||||
//watchdog('booking', "Sent manual email for $counter people.");
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
// $Id: booking.events.inc,v 0.1 2012/02/28
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -16,8 +15,8 @@ function booking_event_admin()
|
||||
|
||||
$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'),
|
||||
@@ -33,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),
|
||||
@@ -151,7 +150,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',
|
||||
@@ -159,7 +158,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',
|
||||
@@ -167,7 +166,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',
|
||||
@@ -175,7 +174,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',
|
||||
@@ -183,7 +182,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'
|
||||
);
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -144,8 +214,7 @@ function _booking_get_waitinglist_top()
|
||||
LIMIT 1',
|
||||
array(':eid' => $event->eid));
|
||||
|
||||
foreach ($result as $person)
|
||||
{
|
||||
foreach ($result as $person) {
|
||||
watchdog('booking', "First person on the waiting list: @info", array('@info' => var_export($person, TRUE)));
|
||||
return $person->nid;
|
||||
}
|
||||
@@ -158,8 +227,7 @@ function _booking_get_waitinglist_top()
|
||||
LIMIT 1',
|
||||
array(':eid' => $event->eid));
|
||||
|
||||
foreach ($result as $person)
|
||||
{
|
||||
foreach ($result as $person) {
|
||||
watchdog('booking', "First person on the missed-payment-deadline list: @info", array('@info' => var_export($person, TRUE)));
|
||||
return $person->nid;
|
||||
}
|
||||
@@ -168,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
|
||||
*/
|
||||
@@ -792,60 +905,49 @@ function _booking_generate_statistics($booking_list)
|
||||
}
|
||||
|
||||
//figure out if we're in the right time period for discounted registration rates
|
||||
function _booking_is_earlybird()
|
||||
{
|
||||
function _booking_is_earlybird() {
|
||||
global $event;
|
||||
|
||||
if ($event->booking_earlybird_close > time())
|
||||
if ($event->booking_earlybird_close > time()) {
|
||||
return TRUE;
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function _booking_datepaid_ts($nid)
|
||||
{
|
||||
//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();
|
||||
|
||||
if ($query)
|
||||
if ($query) {
|
||||
return $query->booking_payment_date;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 " .
|
||||
@@ -854,12 +956,21 @@ function _booking_deposit_amount($person, $include_fees = TRUE)
|
||||
->fetchObject();
|
||||
|
||||
if ($deposit) {
|
||||
//if we're using paypal, add the transaction fee
|
||||
if (variable_get('booking_use_paypal', 0) == 1 && $include_fees == TRUE) {
|
||||
$amount_owing = _booking_add_paypal_fees($deposit->booking_price, $person->booking_country);
|
||||
//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);
|
||||
}
|
||||
}
|
||||
//otherwise we're using manual payment processing so don't add any fees
|
||||
else {
|
||||
$amount_owing = $deposit->booking_price;
|
||||
$amount_owing = $deposit->booking_price;
|
||||
}
|
||||
//return the calculated amount rounded to two decimal places
|
||||
return number_format($amount_owing, 2, '.', '');
|
||||
@@ -873,13 +984,11 @@ function _booking_deposit_amount($person, $include_fees = TRUE)
|
||||
/**
|
||||
* Calculate exactly how much a person has already paid
|
||||
*/
|
||||
function _booking_amount_paid($nid, $person = NULL)
|
||||
{
|
||||
function _booking_amount_paid($nid, $person = NULL) {
|
||||
$amount_paid = 0;
|
||||
|
||||
//fetch details about the person if we don't already have them
|
||||
if ($person == NULL)
|
||||
{
|
||||
if ($person == NULL) {
|
||||
$person = db_query("SELECT price.booking_price, price.booking_late_price, person.booking_payment_id, " .
|
||||
"person.booking_total_pay_reqd, person.booking_amount_paid, person.booking_partner_id " .
|
||||
"FROM {booking_person} person, {booking_price} price " .
|
||||
@@ -890,15 +999,13 @@ function _booking_amount_paid($nid, $person = NULL)
|
||||
}
|
||||
|
||||
//check for a spouse
|
||||
if ($person->booking_partner_id > 0)
|
||||
{
|
||||
if ($person->booking_partner_id > 0) {
|
||||
//watchdog('booking', "Checking total paid for married person");
|
||||
|
||||
//look for payments in the payment transaction table
|
||||
|
||||
//if we're combining the payment for married couples
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1) {
|
||||
//check for payments in the paypal transaction table from either spouse
|
||||
$query = db_query("SELECT booking_mc_gross, booking_mc_fee FROM booking_payment " .
|
||||
"WHERE booking_person_nid = :nid OR booking_person_nid = :spousenid",
|
||||
@@ -912,17 +1019,16 @@ function _booking_amount_paid($nid, $person = NULL)
|
||||
}
|
||||
|
||||
//add up all the payments
|
||||
foreach ($query as $payment)
|
||||
foreach ($query as $payment) {
|
||||
$amount_paid += ($payment->booking_mc_gross - $payment->booking_mc_fee);
|
||||
}
|
||||
|
||||
//watchdog('booking', "Total amount paid according to paypal payments table is " . $amount_paid);
|
||||
|
||||
//there were no payment transactions, so rely on what the amount is set to in the individual registration records
|
||||
if ($amount_paid == 0)
|
||||
{
|
||||
//if we're combining the payment for married couples
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1)
|
||||
{
|
||||
if ($amount_paid == 0) {
|
||||
//if we're combining the payment for married couples
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1) {
|
||||
$spouse = db_query("SELECT person.booking_amount_paid " .
|
||||
"FROM {booking_person} person " .
|
||||
"WHERE person.nid = :nid ",
|
||||
@@ -931,17 +1037,15 @@ function _booking_amount_paid($nid, $person = NULL)
|
||||
$amount_paid = $person->booking_amount_paid + $spouse->booking_amount_paid;
|
||||
//watchdog('booking', "Total combined payments for couple based on totals in booking_person table is " . $amount_paid);
|
||||
}
|
||||
else
|
||||
{
|
||||
$amount_paid = $person->booking_amount_paid;
|
||||
else {
|
||||
$amount_paid = $person->booking_amount_paid;
|
||||
//watchdog('booking', "Total amount paid for individual based on totals in booking_person table is " . $amount_paid);
|
||||
}
|
||||
//end combined payments check
|
||||
}
|
||||
}
|
||||
//no spouse found
|
||||
else
|
||||
{
|
||||
else {
|
||||
//Check if there are payment records in the paypal transaction table for this unmarried person
|
||||
//if so, base their payments on the gross amount in there rather than what the person booking_person database says
|
||||
$query = db_query("SELECT booking_mc_gross, booking_mc_fee FROM booking_payment " .
|
||||
@@ -953,8 +1057,9 @@ function _booking_amount_paid($nid, $person = NULL)
|
||||
//watchdog('booking', "Total amount paid according to paypal payments table is " . $amount_paid);
|
||||
|
||||
//if there were no results, $amount_paid will still be 0
|
||||
if ($amount_paid == 0)
|
||||
if ($amount_paid == 0) {
|
||||
$amount_paid = $person->booking_amount_paid;
|
||||
}
|
||||
//in case there has been some manual adjustment
|
||||
//elseif ($amount_paid < $person->booking_amount_paid)
|
||||
// $amount_paid = $person->booking_amount_paid;
|
||||
@@ -992,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;
|
||||
}
|
||||
@@ -1023,26 +1128,12 @@ 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_paypal_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_paypal_fees = TRUE)
|
||||
{
|
||||
//$amount_paid = 0;
|
||||
//$total_due = 0;
|
||||
|
||||
//fetch details about the person
|
||||
/*
|
||||
$person = db_query("SELECT price.booking_price, price.booking_late_price, person.booking_payment_id, " .
|
||||
"person.booking_total_pay_reqd, person.booking_amount_paid, person.booking_partner_id, person.booking_country, person.booking_welfare_required, person.booking_committee_member " .
|
||||
"FROM {booking_person} person, {booking_price} price " .
|
||||
"WHERE person.nid = :nid " .
|
||||
"AND person.booking_payment_id = price.pid",
|
||||
array(':nid' => $nid))
|
||||
->fetchObject();
|
||||
|
||||
//$person = node_load($nid);
|
||||
*/
|
||||
function _booking_amount_owing($person, $amount_paid = 0, $include_fees = TRUE, $international_fees = FALSE) {
|
||||
global $event;
|
||||
//quick sanity check
|
||||
if (! $person->nid) {
|
||||
watchdog('booking', "Unable to find matching person relating to registration id. Details were '" . var_export($person, TRUE) . "' .");
|
||||
@@ -1052,43 +1143,90 @@ function _booking_amount_owing($person, $amount_paid = 0, $include_paypal_fees =
|
||||
$total_due = _booking_total_due($person);
|
||||
|
||||
//if we didn't get the amount paid as a command line parameter, check it now
|
||||
if ($amount_paid == 0)
|
||||
{
|
||||
if ($amount_paid == 0) {
|
||||
$amount_paid = _booking_amount_paid($person->nid, $person);
|
||||
}
|
||||
|
||||
//check if there is anything outstanding
|
||||
//use the original total amount required rather than the late-rate, to cater for people that paid before the late rate
|
||||
if ($amount_paid >= $person->booking_total_pay_reqd)
|
||||
{
|
||||
if ($amount_paid >= $person->booking_total_pay_reqd) {
|
||||
//watchdog('booking', "This person doesn't owe any money: @info", array('@info' => var_export($person, TRUE)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//if we're using paypal, add the transaction fee
|
||||
if (variable_get('booking_use_paypal', 0) == 1 && $include_paypal_fees == TRUE)
|
||||
{
|
||||
$amount_owing = _booking_add_paypal_fees($total_due - $amount_paid, $person->booking_country);
|
||||
/*
|
||||
//add the 30 cent fixed cost
|
||||
$amount_owing = $total_due - $amount_paid + 0.3;
|
||||
//and the 2.4 percent transaction fee
|
||||
if ($person->booking_country === "Australia")
|
||||
$amount_owing = $amount_owing / (1 - 0.026);
|
||||
//paypal charges 3.4 percent if they're doing a currency conversion
|
||||
//assume that everyone not based in Australia will be doing a currency conversion
|
||||
else
|
||||
{
|
||||
$amount_owing = $amount_owing / (1 - 0.036);
|
||||
//watchdog('booking', "This is an international registration.");
|
||||
|
||||
//if we're using paypal or stripe, add the transaction fee
|
||||
$payment_processor_type = variable_get('booking_payment_processor', 0);
|
||||
if ($include_fees == TRUE) {
|
||||
if ($payment_processor_type == 0) {
|
||||
$amount_owing = _booking_add_paypal_fees($total_due - $amount_paid, $person->booking_country);
|
||||
}
|
||||
elseif ($payment_processor_type == 1) {
|
||||
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');
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
//otherwise we're using manual payment processing so don't add any fees
|
||||
else {
|
||||
$amount_owing = $total_due - $amount_paid;
|
||||
}
|
||||
return number_format($amount_owing, 2, '.', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to update the person object when a payment has been made
|
||||
* payment details should be inserted into booking_payment prior to calling this function
|
||||
*
|
||||
* @param $person - the populated node object representing this person including related price information
|
||||
* @param $payment_amount - the gross payment amount that is being processed
|
||||
* @param $balance_payment - boolean to indicate if this transaction was to complete a payment
|
||||
* @return nothing
|
||||
*/
|
||||
function _booking_process_person_payment($person, $payment_amount, $balance_payment) {
|
||||
global $event;
|
||||
|
||||
//calculate their total payment amount
|
||||
$total = $person->booking_amount_paid + $payment_amount;
|
||||
|
||||
//only recalculate their booking status if this is the initial payment, not a payment of the outstanding balance
|
||||
if ($balance_payment == FALSE) {
|
||||
watchdog('booking', 'Processing an initial payment. Booking status is currently ' . $person->booking_status);
|
||||
if ($person->booking_status == 1) {
|
||||
watchdog('booking', 'This registration has been manually assigned to the booked-in list.');
|
||||
$status = 1;
|
||||
}
|
||||
elseif (_booking_check_bookings_full() == True || $person->booking_status == 2) {
|
||||
watchdog('booking', 'This registration belongs on the waiting list.');
|
||||
$status = 2;
|
||||
}
|
||||
else {
|
||||
watchdog('booking', 'This registration made it to the booked-in list.');
|
||||
$status = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//this is a balance payment
|
||||
watchdog('booking', 'Processing a balance payment.');
|
||||
//if this is a payment of outstanding balance, keep the booking_status the same
|
||||
$status = $person->booking_status;
|
||||
}
|
||||
|
||||
//update the database for this person
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_amount_paid' => $total,
|
||||
'booking_status' => $status,
|
||||
))
|
||||
->condition('nid', $person->nid)
|
||||
->execute();
|
||||
|
||||
//handle workflow emails and spouse payment updates
|
||||
_booking_postpayment_trigger($person->nid, $person, $balance_payment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to handle any post-payment notification emails for either paypal or manual payment
|
||||
* still a WIP
|
||||
@@ -1105,8 +1243,7 @@ function _booking_postpayment_trigger($nid, $person, $balance_payment)
|
||||
//If there is no outstanding balance, send a payment complete email
|
||||
$amount_owing = _booking_amount_owing($person);
|
||||
//if ($total >= $person->booking_total_pay_reqd)
|
||||
if ($amount_owing == 0)
|
||||
{
|
||||
if ($amount_owing == 0) {
|
||||
//set the payment complete flag
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
@@ -1198,8 +1335,7 @@ function _booking_process_refund($person)
|
||||
$refund = $paid - _booking_deposit_amount($person, FALSE);
|
||||
|
||||
//if there is a spouse, subtract their deposit too
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $person->booking_partner_id > 0)
|
||||
{
|
||||
if (variable_get('booking_enable_combined_pricing', 0) == 1 && $person->booking_partner_id > 0) {
|
||||
$refund = $refund - _booking_deposit_amount($person, FALSE);
|
||||
}
|
||||
|
||||
@@ -1257,65 +1393,24 @@ function _booking_process_refund($person)
|
||||
return $refund;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to generate paypal form for payments
|
||||
* Helper function to provide a list of columns in the booking_person table
|
||||
* This will be used to select which fields to import/export to/from a CSV
|
||||
*/
|
||||
function _booking_paypal_form($person, $invoiceid, $amount_owing, $button_text) {
|
||||
$form = drupal_get_form('_booking_paypal_form_builder', $person, $invoiceid, $amount_owing, $button_text);
|
||||
return drupal_render($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate form elements for paypal form
|
||||
*/
|
||||
function _booking_paypal_form_builder($node, &$form_state, $person, $invoiceid, $amount_owing, $button_text) {
|
||||
global $event;
|
||||
function _booking_get_person_fields() {
|
||||
$list_of_columns = array();
|
||||
$query = db_query('SHOW COLUMNS FROM {booking_person_view}');
|
||||
$result = $query->fetchAll();
|
||||
|
||||
//get our current path so we can send the user back here if they cancel
|
||||
$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
|
||||
|
||||
//paypal specific settings
|
||||
$vars = array(
|
||||
'module' => 'Booking System',
|
||||
'type' => $event->booking_eventname,
|
||||
//'custom' => $data,
|
||||
'item_name' => $event->booking_eventname . ' ' . $person->booking_price_descrip,
|
||||
'invoice' => $invoiceid,
|
||||
'no_shipping' => TRUE,
|
||||
'no_note' => TRUE,
|
||||
'currency_code' => 'AUD',
|
||||
'return' => url('bookingfinal', array('absolute' => TRUE)),
|
||||
'cancel_return' => url($path, array('absolute' => TRUE)),
|
||||
'rm' => '2',
|
||||
'amount' => $amount_owing,
|
||||
'last_name' => $person->booking_lastname,
|
||||
'first_name' => $person->booking_firstname,
|
||||
'cmd' => '_xclick',
|
||||
'notify_url' => url(BOOKING_PAYPAL_IPN_PATH, array('absolute' => TRUE)),
|
||||
'business' => variable_get('booking_paypal_account', '')
|
||||
);
|
||||
|
||||
$form['#action'] = url(variable_get('booking_paypal_sandbox', 0) ? BOOKING_PAYPAL_SUBMIT_URL_SANDBOX : BOOKING_PAYPAL_SUBMIT_URL, array('absolute' => TRUE));
|
||||
|
||||
//turn the array into a form
|
||||
foreach($vars as $name => $value) {
|
||||
$form[$name] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $value,
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'button',
|
||||
'#value' => t($button_text),
|
||||
);
|
||||
|
||||
//watchdog('booking', 'Booking Balance payment: @info', array ('@info' => var_export($form, TRUE)));
|
||||
return $form;
|
||||
foreach ($result as $column) {
|
||||
$field = $column->Field;
|
||||
$list_of_columns[$field] = $field;
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', "<pre>Database columns for booking_person\n@info</pre>", array('@info' => print_r( $list_of_columns, true)));
|
||||
return $list_of_columns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to format registrations details for summary in the confirmation email
|
||||
*/
|
||||
@@ -1336,14 +1431,26 @@ 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));
|
||||
$rows[] = t('Passport Expiry: !timestamp', array('!timestamp' => _booking_convert_ts($node->booking_passport_expiry_date)->format('d/m/Y')));
|
||||
$rows[] = t('Passport Exact Issued Name: !value', array('!value' => $node->booking_passport_issue_name));
|
||||
$rows[] = t('Passport Issue Location: !value', array('!value' => $node->booking_passport_issue_location));
|
||||
}
|
||||
|
||||
*/
|
||||
$rows[] = t('Email address: !email', array('!email' => $node->booking_email));
|
||||
$rows[] = t('Home Phone Number: !home', array('!home' => $node->booking_phone));
|
||||
$rows[] = t('Mobile Phone Number: !mob', array('!mob' => $node->booking_mobile));
|
||||
@@ -1359,20 +1466,26 @@ 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));
|
||||
}
|
||||
|
||||
$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));
|
||||
}
|
||||
@@ -1419,9 +1532,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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1431,26 +1551,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);
|
||||
@@ -1458,24 +1574,34 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1508,10 +1634,16 @@ function _booking_studygroup_email_summary($node) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1523,58 +1655,37 @@ function _booking_leader_helper_email_summary($node) {
|
||||
$found = FALSE;
|
||||
|
||||
//display study session data if enabled
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1)
|
||||
{
|
||||
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');
|
||||
|
||||
//for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||
//for ($i = 1; $i <= count($studygroups); $i++)
|
||||
foreach ($studygroups as $studygroup)
|
||||
{
|
||||
|
||||
$rows[] = "<ul>";
|
||||
|
||||
foreach ($studygroups as $studygroup) {
|
||||
//don't print info about the readings groups
|
||||
//if ($i == variable_get('booking_readinggroup_id','7'))
|
||||
// continue;
|
||||
|
||||
//if ($studygroups[$i]->booking_is_readinggroup == 'Y')
|
||||
// continue;
|
||||
|
||||
if ($studygroup->booking_is_readinggroup == 'Y')
|
||||
if ($studygroup->booking_is_readinggroup == 'Y') {
|
||||
continue;
|
||||
}
|
||||
|
||||
//calculate the session references
|
||||
//$sessionid = "session" . $i;
|
||||
$sessionid = "session" . $studygroup->sid;
|
||||
$roleid = $sessionid . "_role";
|
||||
$otherperson_name = "TBA";
|
||||
$otherperson_email = "";
|
||||
$otherperson_phone = "";
|
||||
|
||||
//check that this study group session has been defined for this attendee and that they
|
||||
if (!empty($node->$sessionid) && $node->$roleid > 0)
|
||||
{
|
||||
/*
|
||||
//make sure we only add this prefix text once, as soon as we've found a matching role
|
||||
if ($found == FALSE)
|
||||
{
|
||||
$found = TRUE;
|
||||
$rows[] = t("You have been assigned to perform the following roles for study groups:");
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO: use a function for this.
|
||||
//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 ($node->$roleid == 1 || $node->$roleid == 3)
|
||||
{
|
||||
if ($node->$roleid == 1 || $node->$roleid == 3) {
|
||||
$role = "Leader";
|
||||
$otherrole = "Helper";
|
||||
$otherrole_id = 2;
|
||||
}
|
||||
//otherwise the matching person is the leader
|
||||
else
|
||||
{
|
||||
else {
|
||||
$role = "Helper";
|
||||
$otherrole = "Leader";
|
||||
$otherrole_id = 1;
|
||||
@@ -1591,27 +1702,34 @@ function _booking_leader_helper_email_summary($node) {
|
||||
|
||||
//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)));
|
||||
|
||||
foreach ($otherperson as $other)
|
||||
{
|
||||
|
||||
//create the text for the token
|
||||
foreach ($otherperson as $other) {
|
||||
$otherperson_name = $other->booking_firstname . ' ' . $other->booking_lastname;
|
||||
$otherperson_email = $other->booking_email;
|
||||
$otherperson_phone = $other->booking_mobile;
|
||||
}
|
||||
|
||||
$rows[] = t('!role for !descrip (section !id). Your !otherrole is !other. You can contact them on !phone or !email.',
|
||||
$rows[] = t('<li>!role for !descrip. Your !otherrole is !other. You can contact them on !phone or !email.</li>',
|
||||
array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
|
||||
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value)
|
||||
$rows[$key] = wordwrap($value);
|
||||
$rows[] = "</ul>";
|
||||
|
||||
return implode("\n", $rows);
|
||||
//format the output to be used in an email
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key] = wordwrap($value);
|
||||
}
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
return implode("\n<br />", $rows);
|
||||
}
|
||||
else {
|
||||
return implode("\n", $rows);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1636,12 +1754,55 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create the mean, median, mode or average of an array
|
||||
* @see http://www.phpsnips.com/45/Mean,-Median,-Mode,-Range-Of-An-Array
|
||||
*/
|
||||
function _booking_mmmr($array, $output = 'mean'){
|
||||
if(!is_array($array)) {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
switch($output){
|
||||
case 'mean':
|
||||
$count = count($array);
|
||||
$sum = array_sum($array);
|
||||
$total = $sum / $count;
|
||||
break;
|
||||
case 'median':
|
||||
rsort($array);
|
||||
$middle = round(count($array) / 2);
|
||||
$total = $array[$middle-1];
|
||||
break;
|
||||
case 'mode':
|
||||
$v = array_count_values($array);
|
||||
arsort($v);
|
||||
foreach($v as $k => $v){$total = $k; break;}
|
||||
break;
|
||||
case 'range':
|
||||
sort($array);
|
||||
$sml = $array[0];
|
||||
rsort($array);
|
||||
$lrg = $array[0];
|
||||
$total = $lrg - $sml;
|
||||
break;
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Generates a Universally Unique IDentifier, version 4.
|
||||
*
|
||||
|
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
// $Id: booking.import_data.inc,v 0.1
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide functionality to upload csv for bulk update of payment data
|
||||
|
@@ -1,9 +1,9 @@
|
||||
; $Id$
|
||||
name = Booking System
|
||||
description = "A module which provides a booking system for event registration."
|
||||
package = Booking System
|
||||
dependencies[] = date
|
||||
dependencies[] = token
|
||||
dependencies[] = libraries
|
||||
version = 0.2
|
||||
configure = admin/config/booking
|
||||
configure = admin/config/booking/general
|
||||
core = 7.x
|
487
booking.install
487
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)
|
||||
@@ -531,34 +531,304 @@ function booking_update_7232() {
|
||||
db_change_field('booking_person', 'booking_event_id', 'booking_eventid', $spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure SQL View booking_person_view is created
|
||||
*/
|
||||
function booking_update_7233() {
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove deprecated passport and flight details
|
||||
*/
|
||||
function booking_update_7234() {
|
||||
$fields = array(
|
||||
'booking_passport_expiry_date', 'booking_passport_num', 'booking_passport_issue_location',
|
||||
'booking_passport_issue_name', 'booking_destination_country', 'booking_travel_insurance',
|
||||
'booking_outflight_bookingnum', 'booking_outflight_flightnum', 'booking_outflight_origin',
|
||||
'booking_outflight_origin_ts', 'booking_outflight_connecting_flightnum', 'booking_outflight_destination',
|
||||
'booking_outflight_destination_ts', 'booking_rtrnflight_bookingnum', 'booking_rtrnflight_flightnum',
|
||||
'booking_rtrnflight_origin', 'booking_rtrnflight_origin_ts', 'booking_rtrnflight_connecting_flightnum',
|
||||
'booking_rtrnflight_destination', 'booking_rtrnflight_destination_ts'
|
||||
);
|
||||
foreach ($fields as $field) {
|
||||
db_drop_field('booking_person', $field);
|
||||
}
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
/**
|
||||
* Add email address for guardian contact info
|
||||
*/
|
||||
function booking_update_7235() {
|
||||
$spec = array('type' => 'varchar', 'length' => '250', 'not null' => FALSE);
|
||||
db_add_field('booking_person', 'booking_guardian_email', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
/**
|
||||
* Add flag to indicate a studygroup session has been manually assigned
|
||||
*/
|
||||
function booking_update_7236() {
|
||||
$spec = array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N');
|
||||
db_add_field('booking_studygroup_mapping', 'booking_session_manually_allocated', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
/**
|
||||
* Add flag to indicate an attendee that should be kept separate for automated group calculations
|
||||
*/
|
||||
function booking_update_7237() {
|
||||
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0);
|
||||
db_add_field('booking_person', 'booking_keepseparate_id', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add description field to room definitions
|
||||
*/
|
||||
function booking_update_7238() {
|
||||
$spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE);
|
||||
db_add_field('booking_room_definition', 'booking_room_description', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change room number field in room definitions to integer
|
||||
*/
|
||||
function booking_update_7239() {
|
||||
$spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0);
|
||||
db_change_field('booking_room_definition', 'booking_room_number', 'booking_room_number', $spec);
|
||||
//update the view to match the new table definition
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add stripe token field to booking_payments table
|
||||
*/
|
||||
function booking_update_7240() {
|
||||
$spec = array('type' => 'varchar', 'length' => '200', 'not null' => FALSE);
|
||||
db_add_field('booking_payment', 'booking_stripe_token', $spec);
|
||||
//update the view to match the new table definition
|
||||
_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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function booking_install() {
|
||||
// Create some sample data
|
||||
// TODO: Set default values for the config pages too
|
||||
$result = db_insert('booking_price')
|
||||
->fields(array(
|
||||
'booking_eventid' => 1,
|
||||
'booking_price' => '50.00',
|
||||
'booking_price_descrip' => 'Deposit',
|
||||
'booking_buttonid' => '',
|
||||
'booking_price_active' => 1,
|
||||
'booking_depositonly' => 1,
|
||||
))
|
||||
->execute();
|
||||
|
||||
$result = db_insert('booking_event')
|
||||
->fields(array(
|
||||
'booking_eventname' => 'Sample Event',
|
||||
'booking_event_active' => 1,
|
||||
'booking_register_open' => 1312207199,
|
||||
'booking_register_close' => 1340459999,
|
||||
'booking_earlybird_close' => 1328018399,
|
||||
))
|
||||
->execute();
|
||||
|
||||
//earlybird close is 31st Jan 2012 at 13:59:59 UTC
|
||||
$result = db_insert('booking_price')
|
||||
->fields(array(
|
||||
'booking_eventid' => 1,
|
||||
'booking_price' => '50.00',
|
||||
'booking_price_descrip' => 'Deposit',
|
||||
'booking_buttonid' => '',
|
||||
'booking_price_active' => 1,
|
||||
'booking_depositonly' => 1,
|
||||
))
|
||||
->execute();
|
||||
//earlybird close is 31st Jan 2012 at 13:59:59 UTC
|
||||
$result = db_insert('booking_event')
|
||||
->fields(array(
|
||||
'booking_eventname' => 'Sample Event',
|
||||
'booking_event_active' => 1,
|
||||
'booking_register_open' => 1312207199,
|
||||
'booking_register_close' => 1340459999,
|
||||
'booking_earlybird_close' => 1328018399,
|
||||
))
|
||||
->execute();
|
||||
|
||||
//create the sql view booking_person_view when first installing this module
|
||||
_booking_node_create_mysqlview();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,23 +839,49 @@ 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');
|
||||
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),
|
||||
@@ -614,7 +910,8 @@ function booking_schema() {
|
||||
'booking_partner_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
|
||||
'booking_dependant_children' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE, 'default' => 'N'),
|
||||
'booking_bf_gf' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_bf_gf_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
|
||||
'booking_bf_gf_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
|
||||
'booking_keepseparate_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_mate1' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_room_mate2' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
//payment info
|
||||
@@ -629,6 +926,7 @@ function booking_schema() {
|
||||
//emergency contact info
|
||||
'booking_guardian_name' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
|
||||
'booking_guardian_type' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
|
||||
'booking_guardian_email' => array('type' => 'varchar', 'length' => '250', 'not null' => FALSE),
|
||||
'booking_guardian_phone' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_guardian_phone_alt' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_medicare' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
@@ -676,6 +974,7 @@ function booking_schema() {
|
||||
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
|
||||
*/
|
||||
/*
|
||||
//passport info
|
||||
'booking_passport_expiry_date' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_passport_num' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
@@ -699,6 +998,7 @@ function booking_schema() {
|
||||
'booking_rtrnflight_connecting_flightnum' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_rtrnflight_destination' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_rtrnflight_destination_ts' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
*/
|
||||
/*
|
||||
),
|
||||
'foreign keys' => array(
|
||||
@@ -714,59 +1014,59 @@ function booking_schema() {
|
||||
'primary key' => array('nid'),
|
||||
);
|
||||
|
||||
|
||||
|
||||
$schema['booking_event'] = array(
|
||||
'fields' => array(
|
||||
'eid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventname' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
|
||||
'booking_event_active' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'booking_register_open' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_register_close' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_earlybird_close' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_event_start' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_event_end' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'eid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventname' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
|
||||
'booking_event_active' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'booking_register_open' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_register_close' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_earlybird_close' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_event_start' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_event_end' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
),
|
||||
'primary key' => array('eid'),
|
||||
);
|
||||
$schema['booking_price'] = array(
|
||||
'fields' => array(
|
||||
'pid' => 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_price' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_late_price' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_price_descrip' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
|
||||
'booking_buttonid' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_late_buttonid' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_price_active' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'booking_earlybird_rate' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'booking_depositonly' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'pid' => 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_price' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_late_price' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_price_descrip' => array('type' => 'varchar', 'length' => '100', 'not null' => TRUE),
|
||||
'booking_buttonid' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_late_buttonid' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_price_active' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'booking_earlybird_rate' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
'booking_depositonly' => array('type' => 'varchar', 'length' => '1', 'default' => 0, 'not null' => TRUE),
|
||||
),
|
||||
'primary key' => array('pid'),
|
||||
);
|
||||
$schema['booking_payment'] = array(
|
||||
'fields' => array(
|
||||
'payid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_mc_gross' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_mc_currency' => array('type' => 'varchar', 'length' => '10', 'not null' => FALSE),
|
||||
'booking_mc_fee' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_quantity' => array('type' => 'int', 'length' => 11, 'not null' => FALSE, 'default' => 0),
|
||||
'booking_invoice' => array('type' => 'varchar', 'length' => '150', 'not null' => FALSE),
|
||||
'booking_payer_id' => array('type' => 'varchar', 'length' => '150', 'not null' => FALSE),
|
||||
'booking_payment_date' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_payment_status' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_first_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_last_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_buyer_email' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_payer_status' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_item_name' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_ipn_track_id' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE)),
|
||||
'primary key' => array('payid'),
|
||||
'payid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_mc_gross' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_mc_currency' => array('type' => 'varchar', 'length' => '10', 'not null' => FALSE),
|
||||
'booking_mc_fee' => array('type' => 'numeric', 'not null' => FALSE, 'default' => 0, 'precision' => '7', 'scale' => '2'),
|
||||
'booking_quantity' => array('type' => 'int', 'length' => 11, 'not null' => FALSE, 'default' => 0),
|
||||
'booking_invoice' => array('type' => 'varchar', 'length' => '150', 'not null' => FALSE),
|
||||
'booking_payer_id' => array('type' => 'varchar', 'length' => '150', 'not null' => FALSE),
|
||||
'booking_payment_date' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_payment_status' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_first_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_last_name' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_buyer_email' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_payer_status' => array('type' => 'varchar', 'length' => '50', 'not null' => FALSE),
|
||||
'booking_item_name' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_ipn_track_id' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_stripe_token' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
),
|
||||
'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'),
|
||||
@@ -779,7 +1079,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'),
|
||||
@@ -794,28 +1094,28 @@ 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'),
|
||||
);
|
||||
|
||||
$schema['booking_travel'] = array(
|
||||
'fields' => array(
|
||||
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_transport_type' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_transport_from_morriset_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_transport_to_morriset_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_flightnum_inbound' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_flight_datetime_inbound' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_flightnum_outbound' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_flight_datetime_outbound' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_accom_before_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_accom_before_staying_with' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_accom_after_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_accom_after_staying_with' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
),
|
||||
'tid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_person_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_transport_type' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_transport_from_morriset_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_transport_to_morriset_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_flightnum_inbound' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_flight_datetime_inbound' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_flightnum_outbound' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
|
||||
'booking_flight_datetime_outbound' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11'),
|
||||
'booking_accom_before_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_accom_before_staying_with' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
'booking_accom_after_reqd' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_accom_after_staying_with' => array('type' => 'varchar', 'length' => '200', 'not null' => FALSE),
|
||||
),
|
||||
'primary key' => array('tid'),
|
||||
);
|
||||
|
||||
@@ -839,13 +1139,13 @@ function booking_schema() {
|
||||
'booking_node_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_studygroup_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_session_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10', 'default' => 0),
|
||||
//'booking_is_leader' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
//'booking_is_helper' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE),
|
||||
'booking_session_manually_allocated' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_studygroup_role' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE, 'default' => 0),
|
||||
),
|
||||
'primary key' => array('sid'),
|
||||
);
|
||||
|
||||
//this table isn't currently in use
|
||||
$schema['booking_readinggroup_definition'] = array(
|
||||
'fields' => array(
|
||||
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
@@ -859,11 +1159,12 @@ function booking_schema() {
|
||||
'fields' => array(
|
||||
'rid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'),
|
||||
'booking_room_location_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_number' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE),
|
||||
'booking_room_number' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_singlebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_doublebeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_queenbeds' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10', 'default' => 0),
|
||||
'booking_room_ensuite' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE, 'default' => 'N'),
|
||||
'booking_room_description' => array('type' => 'varchar', 'length' => '200', 'not null' => TRUE),
|
||||
),
|
||||
'primary key' => array('rid'),
|
||||
);
|
||||
@@ -888,5 +1189,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;
|
||||
}
|
||||
|
18
booking.js
Normal file
18
booking.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Drupal AJAX framework command.
|
||||
*/
|
||||
Drupal.ajax.prototype.commands.bookingAjaxCheckboxes = function(ajax, response, status) {
|
||||
jQuery(function($) {
|
||||
var arr = $.parseJSON($('input#' + response.formDataElement).val())
|
||||
$('#' + response.formName).find(':checkbox[name^="' + response.checkboxName + '"]').each(function () {
|
||||
//.prop() doesn't exist in Drupal's old version of jQuery so use .attr() instead
|
||||
if ($.inArray($(this).val(), arr) != -1) {
|
||||
$(this).attr("checked", true);
|
||||
$(this).closest('tr').addClass("selected");
|
||||
} else {
|
||||
$(this).attr("checked", false);
|
||||
$(this).closest('tr').removeClass("selected");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
233
booking.mailtemplate_admin.inc
Normal file
233
booking.mailtemplate_admin.inc
Normal file
@@ -0,0 +1,233 @@
|
||||
<?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_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_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));
|
||||
}
|
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>");
|
||||
}
|
1632
booking.module
1632
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)) {
|
||||
@@ -91,7 +123,7 @@ function booking_paypal_ipn() {
|
||||
}
|
||||
*/
|
||||
|
||||
//TODO: Handle refund and payment dispute IPNs
|
||||
//@todo Handle refund and payment dispute IPNs
|
||||
|
||||
if (empty($ipn['payment_status']) || ($ipn['payment_status'] != 'Completed' && variable_get('booking_paypal_sandbox', 0) == 0))
|
||||
return;
|
||||
@@ -104,19 +136,18 @@ function booking_paypal_ipn() {
|
||||
}
|
||||
|
||||
//Insert record into database and remove temporary booking id field from user
|
||||
_booking_process_payment($ipn);
|
||||
_booking_store_paypal_payment($ipn);
|
||||
|
||||
}
|
||||
|
||||
function _booking_process_payment($data) {
|
||||
function _booking_store_paypal_payment($data) {
|
||||
global $event;
|
||||
$balance_payment = false;
|
||||
$amount_owing = 0;
|
||||
|
||||
//extract the person node id from the invoice
|
||||
$pos = strpos($data['invoice'], "_");
|
||||
if (($pos === false) || ($pos == 0))
|
||||
{
|
||||
if (($pos === false) || ($pos == 0)) {
|
||||
watchdog('booking', 'Unable to process payment with invalid invoice information: !id', array('!id' => $data['invoice']), WATCHDOG_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -125,20 +156,16 @@ function _booking_process_payment($data) {
|
||||
//get the data between the first and second underscore
|
||||
$eid = substr($data['invoice'], $pos + 1, strrpos($data['invoice'], "_") - $pos - 1);
|
||||
|
||||
if (substr($eid,0,3) == "bal")
|
||||
{
|
||||
if (substr($eid,0,3) == "bal") {
|
||||
$balance_payment = true;
|
||||
watchdog('booking', 'Balance payment for user with node id: !id', array('!id' => $nid));
|
||||
}
|
||||
|
||||
//verify paypal hasn't already sent through a notification for this payment
|
||||
$duplicate_check = db_query("SELECT payid, booking_person_nid FROM {booking_payment} where booking_ipn_track_id = :ipn_id ",
|
||||
array(':ipn_id' => $data['ipn_track_id']))
|
||||
->fetchObject();
|
||||
|
||||
if ($duplicate_check)
|
||||
{
|
||||
watchdog('booking', 'Detected duplicate paypal notifications for transaction id !id, registration id !nid', array('!id' => $data['ipn_track_id'], '!nid' => $nid), WATCHDOG_ERROR);
|
||||
array(':ipn_id' => $data['ipn_track_id']))->fetchObject();
|
||||
if ($duplicate_check) {
|
||||
watchdog('booking', 'Detected duplicate paypal notifications for transaction id !id, registration id !nid', array('!id' => $data['ipn_track_id'], '!nid' => $nid), WATCHDOG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -165,135 +192,117 @@ function _booking_process_payment($data) {
|
||||
))
|
||||
->execute();
|
||||
|
||||
//Get the person's info
|
||||
//Get the person's info so we can update their total amount paid and booking status
|
||||
$person = node_load($nid);
|
||||
|
||||
//check if we found a person matching this payment
|
||||
if ($person)
|
||||
{
|
||||
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment', array('!id' => $nid, '!eid' => $eid,
|
||||
'!payment' => $person->booking_amount_paid));
|
||||
//if successful, update their total payment amount
|
||||
$total = $person->booking_amount_paid + $data['mc_gross'];
|
||||
|
||||
//only recalculate their booking status if this is the initial payment, not a payment of the outstanding balance
|
||||
if ($balance_payment == FALSE)
|
||||
{
|
||||
watchdog('booking', 'Processing an initial payment. Booking status is currently ' . $person->booking_status);
|
||||
if ($person->booking_status == 1)
|
||||
{
|
||||
watchdog('booking', 'This registration has been manually assigned to the booked-in list.');
|
||||
$status = 1;
|
||||
}
|
||||
elseif (_booking_check_bookings_full() == True || $person->booking_status == 2)
|
||||
{
|
||||
watchdog('booking', 'This registration belongs on the waiting list.');
|
||||
$status = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
watchdog('booking', 'This registration made it to the booked-in list.');
|
||||
$status = 1;
|
||||
}
|
||||
}
|
||||
else //this is a balance payment
|
||||
{
|
||||
watchdog('booking', 'Processing a balance payment.');
|
||||
//if this is a payment of outstanding balance, keep the booking_status the same
|
||||
$status = $person->booking_status;
|
||||
//$status = $person->booking_status == 2 ? 2 : 1;
|
||||
}
|
||||
|
||||
//update the database for this person
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_amount_paid' => $total,
|
||||
'booking_status' => $status,
|
||||
))
|
||||
->condition('nid', $nid)
|
||||
->execute();
|
||||
|
||||
//replace the code below with a call to the helper function
|
||||
_booking_postpayment_trigger($nid, $person, $balance_payment);
|
||||
|
||||
/*
|
||||
//If there is no outstanding balance, send a payment complete email
|
||||
$amount_owing = _booking_amount_owing($person);
|
||||
//if ($total >= $person->booking_total_pay_reqd)
|
||||
if ($amount_owing == 0)
|
||||
{
|
||||
//set the payment complete flag
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_payment_complete' => 'Y',
|
||||
))
|
||||
->condition('nid', $nid)
|
||||
->execute();
|
||||
|
||||
//this should always be a balance payment type email, since that tells the user that their payment is completed
|
||||
_booking_registration_email($nid, TRUE);
|
||||
|
||||
//if we are combining payments, and this person has a linked spouse
|
||||
if ((variable_get('booking_enable_combined_pricing', 0) == 1) && ($person->booking_partner_id > 0))
|
||||
{
|
||||
//check spouse booking_status and payment info
|
||||
$spouse = db_select('booking_person', 'p')
|
||||
->condition('p.nid', $person->booking_partner_id,'=')
|
||||
->fields('p', array('booking_amount_paid', 'booking_status', 'booking_total_pay_reqd'))
|
||||
->execute()
|
||||
->fetchObject();
|
||||
|
||||
//update the spouse's status from "not paid" if required
|
||||
$spouse_status = $spouse->booking_status == 0 ? 1 : $spouse->booking_status;
|
||||
watchdog('booking', 'Setting status for spouse id !id to !new from !status', array('!id' => $person->booking_partner_id,
|
||||
'!new' => $spouse_status, '!status' => $spouse->booking_status));
|
||||
|
||||
//set the spouse's payment required to be zero or equal to their previous payment total
|
||||
$spouse_new_amount_reqd = $spouse->booking_amount_paid > 0 ? $spouse->booking_amount_paid : 0;
|
||||
watchdog('booking', 'Setting amount owing for spouse id !id to !new from !old.', array('!id' => $person->booking_partner_id,
|
||||
'!new' => $spouse_new_amount_reqd, '!old' => $spouse->booking_total_pay_reqd));
|
||||
|
||||
//update the database for this person
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_total_pay_reqd' => $spouse_new_amount_reqd,
|
||||
'booking_status' => $spouse_status,
|
||||
'booking_payment_complete' => 'Y',
|
||||
))
|
||||
->condition('nid', $person->booking_partner_id)
|
||||
->execute();
|
||||
|
||||
//send an email to the spouse
|
||||
_booking_registration_email($person->booking_partner_id, TRUE);
|
||||
}
|
||||
}
|
||||
//if this was an initial payment we might need to send a notification
|
||||
elseif ($balance_payment == FALSE)
|
||||
{
|
||||
//send a notification email if we didn't automatically send one earlier
|
||||
if (variable_get('booking_auto_confirm_email', 0) == 0)
|
||||
{
|
||||
_booking_registration_email($nid, FALSE);
|
||||
}
|
||||
}
|
||||
else //this person still has an outstanding balance so just send a confirmation email
|
||||
{
|
||||
watchdog('booking', 'This balance payment of !payment was insufficient for !id to completely pay the total outstanding of !outstanding.',
|
||||
array('!id' => $nid, '!payment' => $data['mc_gross'], '!outstanding' => $amount_owing));
|
||||
//send the person an email thanking them for their partial payment
|
||||
_booking_partialbalance_payment_email($nid);
|
||||
//TODO: create an email specifically for partial-balance payments
|
||||
//_booking_registration_email($nid, $balance_payment);
|
||||
}
|
||||
|
||||
*/
|
||||
if ($person) {
|
||||
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment',
|
||||
array('!id' => $nid, '!eid' => $eid, '!payment' => $person->booking_amount_paid));
|
||||
_booking_process_person_payment($person, $data['mc_gross'], $balance_payment);
|
||||
}
|
||||
else //couldn't find a matching nid for this invoice
|
||||
{
|
||||
else {
|
||||
//couldn't find a matching nid for this invoice
|
||||
watchdog('booking', "Unable to process payment for user with node id: '!id'", array('!id' => $nid), WATCHDOG_ERROR);
|
||||
//db_query("UPDATE {booking_person} SET booking_tempid='' WHERE nid = %d", $nid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Landing page after returning from paypal
|
||||
*/
|
||||
function booking_payment_completed_page() {
|
||||
//get some configuration information
|
||||
global $event;
|
||||
$output = "";
|
||||
$return_array = array();
|
||||
/*
|
||||
$parameters = drupal_get_query_parameters();
|
||||
|
||||
//check if we got a transaction token from paypal
|
||||
if (isset($parameters['token'])) {
|
||||
//check to make sure the value is something we're expecting
|
||||
$paypal_token = $parameters['token'];
|
||||
if (! preg_match('/^[0-9A-Fa-f\-]+$/', $paypal_token)) {
|
||||
//parameter from url is not what we were expecting so ignore it and just use the site-wide tokens for this page
|
||||
$tokens = booking_define_tokens();
|
||||
}
|
||||
else {
|
||||
//query the payments table to find the attendee that this paypal token belongs to
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
//set the page title
|
||||
$bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event';
|
||||
drupal_set_title($bookingTitle . ' Registration Completed');
|
||||
$input = variable_get('booking_regn_completed_page');
|
||||
//watchdog('booking_debug', "<pre>Paypal landing page token:\n@info</pre>", array('@info' => print_r($input['value'] , true)));
|
||||
|
||||
|
||||
$output = token_replace($input['value'], booking_define_tokens());
|
||||
$return_array[] = array(
|
||||
'paragraph' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $output
|
||||
)
|
||||
);
|
||||
|
||||
return $return_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate paypal form for payments
|
||||
*/
|
||||
function _booking_paypal_form($person, $invoiceid, $amount_owing, $button_text) {
|
||||
$form = drupal_get_form('_booking_paypal_form_builder', $person, $invoiceid, $amount_owing, $button_text);
|
||||
return drupal_render($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to generate form elements for paypal form
|
||||
*/
|
||||
function _booking_paypal_form_builder($node, &$form_state, $person, $invoiceid, $amount_owing, $button_text) {
|
||||
global $event;
|
||||
|
||||
}
|
||||
//get our current path so we can send the user back here if they cancel
|
||||
$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
|
||||
|
||||
//paypal specific settings
|
||||
$vars = array(
|
||||
'module' => 'Booking System',
|
||||
'type' => $event->booking_eventname,
|
||||
//'custom' => $data,
|
||||
'item_name' => $event->booking_eventname . ' ' . $person->booking_price_descrip,
|
||||
'invoice' => $invoiceid,
|
||||
'no_shipping' => TRUE,
|
||||
'no_note' => TRUE,
|
||||
'currency_code' => 'AUD',
|
||||
'return' => url('bookingfinal', array('absolute' => TRUE)),
|
||||
'cancel_return' => url($path, array('absolute' => TRUE)),
|
||||
'rm' => '2',
|
||||
'amount' => $amount_owing,
|
||||
'last_name' => $person->booking_lastname,
|
||||
'first_name' => $person->booking_firstname,
|
||||
'cmd' => '_xclick',
|
||||
'notify_url' => url(BOOKING_PAYPAL_IPN_PATH, array('absolute' => TRUE)),
|
||||
'business' => variable_get('booking_paypal_account', '')
|
||||
);
|
||||
|
||||
$form['#action'] = url(variable_get('booking_paypal_sandbox', 0) ? BOOKING_PAYPAL_SUBMIT_URL_SANDBOX : BOOKING_PAYPAL_SUBMIT_URL, array('absolute' => TRUE));
|
||||
|
||||
//turn the array into a form
|
||||
foreach($vars as $name => $value) {
|
||||
$form[$name] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $value,
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'button',
|
||||
'#value' => t($button_text),
|
||||
);
|
||||
|
||||
//watchdog('booking', 'Booking Balance payment: @info', array ('@info' => var_export($form, TRUE)));
|
||||
return $form;
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ function booking_price_admin()
|
||||
|
||||
$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,23 +95,36 @@ 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)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,14 +4,142 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to create a mysql view of all information relating to an attendee
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
function _booking_node_create_mysqlview()
|
||||
{
|
||||
global $event;
|
||||
$studygroups = array();
|
||||
|
||||
//sometimes we will execute when hook_init hasn't been called
|
||||
//for example at install or upgrade time
|
||||
//so query the database directly for the event currently active
|
||||
if ($event == NULL) {
|
||||
watchdog('booking_debug', "Calling _booking_node_create_mysqlview() when hook_init not yet run.");
|
||||
$event = db_query("SELECT * from {booking_event} where booking_event_active=1")->fetchObject();
|
||||
}
|
||||
|
||||
$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');
|
||||
|
||||
//add the joins for room allocation info if enabled
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$query->leftJoin('booking_room_mapping', 'rm', 'p.nid = rm.booking_nodeid');
|
||||
$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
|
||||
//but when this function gets called we don't have the global $event variable populated, so do the join here ourselves
|
||||
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} l INNER JOIN {booking_event} e ON l.booking_eventid = e.eid WHERE e.booking_event_active=1");
|
||||
$studygroups = $studygroups_query->fetchAllAssoc('sid');
|
||||
|
||||
foreach ($studygroups as $studygroup) {
|
||||
$id = $studygroup->sid;
|
||||
$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, '=');
|
||||
|
||||
//add the database fields we always want to retrieve
|
||||
$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'))
|
||||
->fields('r', array('rid', 'booking_room_location_id', 'booking_room_number'))
|
||||
->fields('l');
|
||||
}
|
||||
|
||||
//now add the study group fields if applicable
|
||||
if (variable_get('booking_enable_studygroups', 0) == 1) {
|
||||
|
||||
foreach ($studygroups as $studygroup)
|
||||
{
|
||||
$id = $studygroup->sid;
|
||||
$query->addField('s' . $id, 'booking_session_id', 'session' . $id);
|
||||
$query->addField('s' . $id, 'booking_studygroup_role', 'session' . $id . '_role');
|
||||
}
|
||||
}
|
||||
|
||||
//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);
|
||||
$querystring=str_replace("}",'',$querystring);
|
||||
foreach($query->getArguments() as $key=> $item) {
|
||||
if(!$item) {
|
||||
$item = 'NULL';
|
||||
}
|
||||
$querystring=str_replace($key.')',$item.')',$querystring);
|
||||
}
|
||||
$querystring = "CREATE OR REPLACE VIEW booking_person_view AS " . $querystring;
|
||||
watchdog('booking_debug', "<pre>Booking Person View creation query string:\n@info</pre>", array('@info' => print_r($querystring, true)));
|
||||
$viewquery = db_query($querystring)->execute();
|
||||
//$result = $viewquery->fetchObject();
|
||||
watchdog('booking_debug', "<pre>Booking Person View creation result:\n@info</pre>", array('@info' => print_r($viewquery, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to add single quote marks around a string
|
||||
* @see booking_load_query
|
||||
*
|
||||
* @param $input - string to add quote marks around
|
||||
* @return quoted string
|
||||
*/
|
||||
function _booking_quote_string($input) {
|
||||
return sprintf("'%s'", $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to query the database for the complete object representing a registration
|
||||
*
|
||||
@@ -20,7 +148,29 @@ function booking_node_presave($node) {
|
||||
*/
|
||||
function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
||||
{
|
||||
global $event;
|
||||
//filter the results either by specific nodes if passed as a parameter or by all nodes matching the event id
|
||||
if (! is_null($node_ids)) {
|
||||
$nid_string = implode(',', array_map('_booking_quote_string', $node_ids));
|
||||
$query_string = "SELECT * FROM {booking_person_view} WHERE nid IN ( " . $nid_string . " )";
|
||||
//watchdog('booking_debug', "<pre>Loading node query:\n@info</pre>", array('@info' => print_r($query_string, true)));
|
||||
$result = db_query($query_string)->fetchAllAssoc('nid');
|
||||
}
|
||||
else {
|
||||
$result = db_query("SELECT * FROM {booking_person_view}")->fetchAllAssoc('nid');
|
||||
}
|
||||
|
||||
//watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to query the database for the complete object representing a registration
|
||||
*
|
||||
* @param $node_ids - a list of node IDs to query for
|
||||
* @return list of objects
|
||||
*/
|
||||
function booking_load_query_old($node_ids = NULL, $fetchAssoc = FALSE)
|
||||
{
|
||||
//$studygroup_count = variable_get('booking_studygroup_count','0');
|
||||
$studygroups = array();
|
||||
|
||||
@@ -108,7 +258,8 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
watchdog('booking_debug', "<pre>Loading node query:\n@info</pre>", array('@info' => print_r( (string)$query, true)));
|
||||
|
||||
//get the query result as either an associative array
|
||||
if ($fetchAssoc == TRUE)
|
||||
{
|
||||
@@ -118,11 +269,18 @@ function booking_load_query($node_ids = NULL, $fetchAssoc = FALSE)
|
||||
{
|
||||
$result = $query->execute();
|
||||
}
|
||||
|
||||
|
||||
//watchdog('booking', "<pre>Loading node query output:\n@info</pre>", array('@info' => print_r( $result, true)));
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function implementing hook_load for the node-type booking
|
||||
* @see booking_load_query
|
||||
*
|
||||
* @param $nodes - An array of the nodes being loaded, keyed by nid
|
||||
* @return nothing
|
||||
*/
|
||||
function booking_load($nodes) {
|
||||
global $event;
|
||||
|
||||
@@ -139,15 +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', 'Inserting node: @info', array('@info' => var_export($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,
|
||||
@@ -156,28 +325,7 @@ function booking_insert($node) {
|
||||
'booking_lastname' => $node->booking_lastname,
|
||||
'booking_dob' => $node->booking_dob,
|
||||
'booking_barcode' => $node->booking_barcode,
|
||||
'booking_luckynum' => $node->booking_luckynum,
|
||||
'booking_passport_num' => $node->booking_passport_num,
|
||||
'booking_passport_issue_location' => $node->booking_passport_issue_location,
|
||||
'booking_passport_issue_name' => $node->booking_passport_issue_name,
|
||||
'booking_passport_expiry_date' => $node->booking_passport_expiry_date,
|
||||
'booking_destination_country' => $node->booking_destination_country,
|
||||
'booking_travel_insurance' => $node->booking_travel_insurance,
|
||||
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
||||
'booking_outflight_flightnum' => $node->booking_outflight_flightnum,
|
||||
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
||||
'booking_outflight_origin' => $node->booking_outflight_origin,
|
||||
'booking_outflight_origin_ts' => $node->booking_outflight_origin_ts,
|
||||
'booking_outflight_connecting_flightnum' => $node->booking_outflight_connecting_flightnum,
|
||||
'booking_outflight_destination' => $node->booking_outflight_destination,
|
||||
'booking_outflight_destination_ts' => $node->booking_outflight_destination_ts,
|
||||
'booking_rtrnflight_bookingnum' => $node->booking_rtrnflight_bookingnum,
|
||||
'booking_rtrnflight_flightnum' => $node->booking_rtrnflight_flightnum,
|
||||
'booking_rtrnflight_origin' => $node->booking_rtrnflight_origin,
|
||||
'booking_rtrnflight_origin_ts' => $node->booking_rtrnflight_origin_ts,
|
||||
'booking_rtrnflight_connecting_flightnum' => $node->booking_rtrnflight_connecting_flightnum,
|
||||
'booking_rtrnflight_destination' => $node->booking_rtrnflight_destination,
|
||||
'booking_rtrnflight_destination_ts' => $node->booking_rtrnflight_destination_ts,
|
||||
'booking_luckynum' => $node->booking_luckynum,
|
||||
'booking_gender' => $node->booking_gender,
|
||||
'booking_street' => $node->booking_street,
|
||||
'booking_suburb' => $node->booking_suburb,
|
||||
@@ -211,7 +359,8 @@ function booking_insert($node) {
|
||||
'booking_amount_paid' => $node->booking_amount_paid,
|
||||
'booking_total_pay_reqd' => $node->booking_total_pay_reqd,
|
||||
'booking_guardian_name' => $node->booking_guardian_name,
|
||||
'booking_guardian_type' => $node->booking_guardian_type,
|
||||
'booking_guardian_type' => $node->booking_guardian_type,
|
||||
'booking_guardian_email' => $node->booking_guardian_email,
|
||||
'booking_guardian_phone' => $node->booking_guardian_phone,
|
||||
'booking_guardian_phone_alt' => $node->booking_guardian_phone_alt,
|
||||
'booking_medicare' => empty($node->booking_medicare) ? '' : $node->booking_medicare,
|
||||
@@ -240,6 +389,7 @@ function booking_insert($node) {
|
||||
'booking_comment_field' => $node->booking_comment_field,
|
||||
))
|
||||
->execute();
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,12 +400,75 @@ 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');
|
||||
|
||||
//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'
|
||||
);
|
||||
|
||||
//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', 'Updating node: @info', 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 (
|
||||
@@ -263,28 +476,7 @@ function booking_update($node) {
|
||||
'booking_lastname' => $node->booking_lastname,
|
||||
'booking_dob' => _date_to_ts($node->booking_dob),
|
||||
'booking_barcode' => $node->booking_barcode,
|
||||
'booking_luckynum' => $node->booking_luckynum == '' ? 0 : $node->booking_luckynum,
|
||||
'booking_passport_num' => $node->booking_passport_num,
|
||||
'booking_passport_issue_location' => $node->booking_passport_issue_location,
|
||||
'booking_passport_issue_name' => $node->booking_passport_issue_name,
|
||||
'booking_passport_expiry_date' => _date_to_ts($node->booking_passport_expiry_date),
|
||||
'booking_destination_country' => $node->booking_destination_country,
|
||||
'booking_travel_insurance' => $node->booking_travel_insurance,
|
||||
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
||||
'booking_outflight_flightnum' => $node->booking_outflight_flightnum,
|
||||
'booking_outflight_bookingnum' => $node->booking_outflight_bookingnum,
|
||||
'booking_outflight_origin' => $node->booking_outflight_origin,
|
||||
'booking_outflight_origin_ts' => _datetime_to_ts($node->booking_outflight_origin_ts),
|
||||
'booking_outflight_connecting_flightnum' => $node->booking_outflight_connecting_flightnum,
|
||||
'booking_outflight_destination' => $node->booking_outflight_destination,
|
||||
'booking_outflight_destination_ts' => _datetime_to_ts($node->booking_outflight_destination_ts),
|
||||
'booking_rtrnflight_bookingnum' => $node->booking_rtrnflight_bookingnum,
|
||||
'booking_rtrnflight_flightnum' => $node->booking_rtrnflight_flightnum,
|
||||
'booking_rtrnflight_origin' => $node->booking_rtrnflight_origin,
|
||||
'booking_rtrnflight_origin_ts' => _datetime_to_ts($node->booking_rtrnflight_origin_ts),
|
||||
'booking_rtrnflight_connecting_flightnum' => $node->booking_rtrnflight_connecting_flightnum,
|
||||
'booking_rtrnflight_destination' => $node->booking_rtrnflight_destination,
|
||||
'booking_rtrnflight_destination_ts' => _datetime_to_ts($node->booking_rtrnflight_destination_ts),
|
||||
'booking_luckynum' => $node->booking_luckynum == '' ? 0 : $node->booking_luckynum,
|
||||
'booking_gender' => $node->booking_gender,
|
||||
'booking_street' => $node->booking_street,
|
||||
'booking_suburb' => $node->booking_suburb,
|
||||
@@ -302,6 +494,7 @@ function booking_update($node) {
|
||||
'booking_partner_id' => $node->booking_partner_id,
|
||||
'booking_dependant_children' => $node->booking_dependant_children,
|
||||
'booking_bf_gf_nid' => $node->booking_bf_gf_nid == '' ? 0 : $node->booking_bf_gf_nid,
|
||||
'booking_keepseparate_id' => $node->booking_keepseparate_id == '' ? 0 : $node->booking_keepseparate_id,
|
||||
'booking_room_mate1' => $node->booking_room_mate1,
|
||||
'booking_room_mate2' => $node->booking_room_mate2,
|
||||
'booking_random_facts' => $node->booking_random_facts,
|
||||
@@ -320,7 +513,8 @@ function booking_update($node) {
|
||||
'booking_amount_paid' => $node->booking_amount_paid,
|
||||
'booking_refund_due' => $node->booking_refund_due == '' ? 0 : $node->booking_refund_due,
|
||||
'booking_guardian_name' => $node->booking_guardian_name,
|
||||
'booking_guardian_type' => $node->booking_guardian_type,
|
||||
'booking_guardian_type' => $node->booking_guardian_type,
|
||||
'booking_guardian_email' => $node->booking_guardian_email,
|
||||
'booking_guardian_phone' => $node->booking_guardian_phone,
|
||||
'booking_guardian_phone_alt' => $node->booking_guardian_phone_alt,
|
||||
'booking_medicare' => $node->booking_medicare,
|
||||
@@ -346,20 +540,20 @@ 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
|
||||
if ($node->booking_partner_id != 0)
|
||||
{
|
||||
if ($node->booking_partner_id != 0) {
|
||||
$partner = db_query("Select booking_partner_id from {booking_person} where nid = :nid",
|
||||
array(':nid' => $node->booking_partner_id))
|
||||
->fetchObject();
|
||||
if ($partner->booking_partner_id == 0)
|
||||
{
|
||||
if ($partner->booking_partner_id == 0) {
|
||||
watchdog('booking', 'Updating partner node !partner to refer to this node !nid',
|
||||
array('!partner' => $node->booking_partner_id, '!nid' => $node->nid));
|
||||
//update the partner id of the partner to refer to this node
|
||||
@@ -371,6 +565,24 @@ function booking_update($node) {
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
//repeat the process for bf/gf
|
||||
if ($node->booking_bf_gf_nid != 0) {
|
||||
$partner = db_query("Select booking_bf_gf_nid from {booking_person} where nid = :nid",
|
||||
array(':nid' => $node->booking_bf_gf_nid))
|
||||
->fetchObject();
|
||||
if ($partner->booking_bf_gf_nid == 0) {
|
||||
watchdog('booking', 'Updating bf/gf node !partner to refer to this node !nid',
|
||||
array('!partner' => $node->booking_bf_gf_nid, '!nid' => $node->nid));
|
||||
//update the partner id of the partner to refer to this node
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_bf_gf_nid' => $node->nid,
|
||||
))
|
||||
->condition('nid', $node->booking_bf_gf_nid)
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
//status change triggers start here
|
||||
|
||||
@@ -394,27 +606,28 @@ function booking_update($node) {
|
||||
_booking_person_rooms_cleanup($node->nid);
|
||||
|
||||
//check if there is room on the booked-in list
|
||||
if (_booking_check_bookings_full() == False)
|
||||
{
|
||||
if (_booking_check_bookings_full() == False) {
|
||||
watchdog('booking', 'Looks like there was room on the booked in list, so lets tell the next person');
|
||||
//find the first person on the waiting list
|
||||
$temp_nid = _booking_get_waitinglist_top();
|
||||
|
||||
if ($temp_nid != -1) //-1 means there was no one on the waiting list
|
||||
{
|
||||
//-1 means there was no one on the waiting list
|
||||
if ($temp_nid != -1) {
|
||||
//update their registration status
|
||||
_booking_change_status($temp_nid,1);
|
||||
|
||||
//send them an email
|
||||
_booking_promoted_from_waitinglist_email($temp_nid);
|
||||
}
|
||||
}
|
||||
else
|
||||
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)
|
||||
{
|
||||
elseif ($previous_status->booking_status == 2 && $node->booking_status == 1) {
|
||||
watchdog('booking', 'Detected person moving from Waiting list to Booked In');
|
||||
|
||||
//send them an email
|
||||
@@ -437,10 +650,11 @@ 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)
|
||||
{
|
||||
elseif ($previous_status->booking_status == 1 && $node->booking_status == 4) {
|
||||
watchdog('booking', 'Detected person moving from Booked In list to Missed Payment Deadline list.');
|
||||
|
||||
//let this person know they're no longer "booked in"
|
||||
@@ -453,29 +667,25 @@ function booking_update($node) {
|
||||
_booking_person_rooms_cleanup($node->nid);
|
||||
|
||||
//check if there is room on the booked-in list
|
||||
if (_booking_check_bookings_full() == False)
|
||||
{
|
||||
if (_booking_check_bookings_full() == False) {
|
||||
watchdog('booking', 'Position available, so lets tell the next person');
|
||||
//find the first person on the waiting list
|
||||
$temp_nid = _booking_get_waitinglist_top();
|
||||
|
||||
if ($temp_nid != -1) //-1 means there was no one on the waiting list
|
||||
{
|
||||
//-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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
watchdog('booking', 'Still no room on the booked in list.');
|
||||
}
|
||||
}
|
||||
//if someone is moving to the not-coming list from the waiting list
|
||||
elseif ($previous_status->booking_status == 2 && $node->booking_status == 3)
|
||||
{
|
||||
elseif ($previous_status->booking_status == 2 && $node->booking_status == 3) {
|
||||
watchdog('booking', 'Detected person moving from waiting list to No Longer Coming');
|
||||
//let this person know their request has been processed
|
||||
_booking_demoted_to_notcoming_email($node->nid);
|
||||
@@ -490,8 +700,7 @@ function booking_update($node) {
|
||||
}
|
||||
//if we're not automatically sending emails on registration
|
||||
//and someone moved from not-paid to booked-in (ie, manual payment process)
|
||||
elseif (variable_get('booking_auto_confirm_email', 0) == 0 && $previous_status->booking_status == 0 && $node->booking_status == 1)
|
||||
{
|
||||
elseif (variable_get('booking_auto_confirm_email', 0) == 0 && $previous_status->booking_status == 0 && $node->booking_status == 1) {
|
||||
watchdog('booking', 'Detected person moving from Not Paid list to Booked In list');
|
||||
|
||||
//make sure the booked in list isn't full
|
||||
@@ -504,11 +713,9 @@ function booking_update($node) {
|
||||
}
|
||||
}
|
||||
//if someone moved from the not-paid list to waiting list by manual update
|
||||
elseif ($previous_status->booking_status == 0 && $node->booking_status == 2)
|
||||
{
|
||||
elseif ($previous_status->booking_status == 0 && $node->booking_status == 2) {
|
||||
watchdog('booking', 'Detected person moving from Not Paid list to Waiting List');
|
||||
|
||||
|
||||
//create a manual payment entry of zero dollars
|
||||
//so things like the waiting list report work
|
||||
$result = db_insert('booking_payment')
|
||||
@@ -537,8 +744,7 @@ function booking_update($node) {
|
||||
}
|
||||
|
||||
//if the payment ID has changed then update the total pay required
|
||||
if ($previous_status->booking_payment_id != $node->booking_payment_id)
|
||||
{
|
||||
if ($previous_status->booking_payment_id != $node->booking_payment_id) {
|
||||
$total_due = 0;
|
||||
watchdog('booking', 'Detected payment type change for attendee');
|
||||
|
||||
@@ -592,6 +798,25 @@ 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;
|
||||
@@ -600,36 +825,35 @@ function booking_view($node, $view_mode) {
|
||||
|
||||
//calculate the price owed by this person
|
||||
//if (_booking_is_earlybird() == true || _booking_amount_owing($node->nid) == 0)
|
||||
if (_booking_is_earlybird() == true || _booking_amount_owing($node) == 0 || $node->booking_committee_member == 'Y' || $node->booking_welfare_required == 'Y')
|
||||
{
|
||||
if (_booking_is_earlybird() == true || _booking_amount_owing($node) == 0 || $node->booking_committee_member == 'Y' || $node->booking_welfare_required == 'Y') {
|
||||
$price = $node->booking_price;
|
||||
}
|
||||
else
|
||||
else {
|
||||
$price = $node->booking_late_price;
|
||||
}
|
||||
//include the price description to display with this view
|
||||
$payment_type = $node->booking_price_descrip . ' ($' . $price . ')';
|
||||
|
||||
//look up the actual name for a linked partner
|
||||
if ($node->booking_partner_id != 0)
|
||||
{
|
||||
if ($node->booking_partner_id != 0) {
|
||||
$query = db_query("Select booking_firstname, booking_lastname from {booking_person} where nid = :nid",
|
||||
array(':nid' => $node->booking_partner_id))
|
||||
->fetchObject();
|
||||
$partner_name = $query->booking_firstname . " " . $query->booking_lastname;
|
||||
}
|
||||
else
|
||||
else {
|
||||
$partner_name = "N/A";
|
||||
|
||||
}
|
||||
//also 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";
|
||||
}
|
||||
|
||||
//define column widths along with the header
|
||||
$header = array(
|
||||
@@ -642,69 +866,42 @@ 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('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'))));
|
||||
$rows[] = array(t('Email address:'), t('!email', array('!email' => $node->booking_email)));
|
||||
|
||||
if (variable_get('booking_enable_passport', 1) == 1)
|
||||
{
|
||||
$rows[] = array(t('Passport Number:'), $node->booking_passport_num);
|
||||
$rows[] = array(t('Passport Expiry:'), t('!timestamp', array('!timestamp' => _booking_convert_ts($node->booking_passport_expiry_date)->format('d/m/Y'))));
|
||||
$rows[] = array(t('Passport Exact Issued Name:'), $node->booking_passport_issue_name);
|
||||
$rows[] = array(t('Passport Issue Location:'), $node->booking_passport_issue_location);
|
||||
$rows[] = array(t('Destination Country:'), $node->booking_destination_country);
|
||||
$rows[] = array(t('Travel Insurance details:'), $node->booking_travel_insurance);
|
||||
|
||||
//outbound flight
|
||||
$flight_rows[] = array(t('Internal Flight Booking Reference:'), $node->booking_outflight_bookingnum);
|
||||
$flight_rows[] = array(t('Internal Flight Number:'), $node->booking_outflight_flightnum);
|
||||
$flight_rows[] = array(t('Internal Flight Origin to Destination:'), $node->booking_outflight_origin);
|
||||
$flight_rows[] = array(t('Internal Flight Departure Time:'),
|
||||
$node->booking_outflight_origin_ts == 0 ? '' : format_date($node->booking_outflight_origin_ts, 'custom', 'd/m/Y H:i') );
|
||||
$flight_rows[] = array(t('Connecting Flight Number:'), $node->booking_outflight_connecting_flightnum);
|
||||
$flight_rows[] = array(t('Connecting Flight Origin to Destination:'), $node->booking_outflight_destination);
|
||||
$flight_rows[] = array(t('Internal Flight Arrival Time:'),
|
||||
$node->booking_outflight_destination_ts == 0 ? '' : format_date($node->booking_outflight_destination_ts, 'custom', 'd/m/Y H:i') );
|
||||
//return flight
|
||||
$flight_rows[] = array(t('Return Internal Flight Booking Reference:'), $node->booking_rtrnflight_bookingnum);
|
||||
$flight_rows[] = array(t('Return Internal Flight Number:'), $node->booking_rtrnflight_flightnum);
|
||||
$flight_rows[] = array(t('Return Internal Flight Origin to Destination:'), $node->booking_rtrnflight_origin);
|
||||
$flight_rows[] = array(t('Return Internal Flight Departure Time:'),
|
||||
$node->booking_rtrnflight_origin_ts == 0 ? '' : format_date($node->booking_rtrnflight_origin_ts, 'custom', 'd/m/Y H:i') );
|
||||
$flight_rows[] = array(t('Connecting Flight Number:'), $node->booking_rtrnflight_connecting_flightnum);
|
||||
$flight_rows[] = array(t('Connecting Flight Origin to Destination:'), $node->booking_rtrnflight_destination);
|
||||
$flight_rows[] = array(t('Return Internal Flight Arrival Time:'),
|
||||
$node->booking_rtrnflight_destination_ts == 0 ? '' : format_date($node->booking_rtrnflight_destination_ts, 'custom', 'd/m/Y H:i') );
|
||||
|
||||
//add the flight info to a new section
|
||||
$flight_heading = t("<h2>Internal Flight Details</h2>");
|
||||
$node->content['flight-heading'] = array(
|
||||
'#markup' => $flight_heading,
|
||||
'#weight' => 2,
|
||||
);
|
||||
$node->content['flight-details'] = array(
|
||||
'#markup' => theme('table', array('header' => $header, 'rows' => $flight_rows)),
|
||||
'#weight' => 3,
|
||||
);
|
||||
}
|
||||
|
||||
$rows[] = array(t('Payment Type Selected:'), t('!amount_paid', array('!amount_paid' => $payment_type)));
|
||||
$rows[] = array(t('Amount Paid:'), t('!amount_paid', array('!amount_paid' => $node->booking_amount_paid)));
|
||||
$rows[] = array(t('Payment Complete Flag:'), t('!ans', array('!ans' => $node->booking_payment_complete == 'Y' ? 'Yes' : 'No')));
|
||||
$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('Reading Group:'), t('!group', array('!group' => $node->booking_readinggroup)));
|
||||
$rows[] = array(t('Random Facts:'), t('!facts', array('!facts' => $node->booking_random_facts)));
|
||||
|
||||
if (variable_get('booking_enable_tshirts', 0) == 1)
|
||||
{
|
||||
$rows[] = array(t('Hoodie Size:'), $node->booking_shirt_size);
|
||||
//$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_tshirts', 0) == 1) {
|
||||
$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'))));
|
||||
$rows[] = array(t('Married:'), t('!ans', array('!ans' => ($node->booking_married == 'Y' ? 'Yes' : 'No'))));
|
||||
if (variable_get('booking_ask_dependant_children', 0) == 1) {
|
||||
$rows[] = array(t('Bringing dependant children:'), t('!ans', array('!ans' => ($node->booking_dependant_children == 'Y' ? 'Yes' : 'No'))));
|
||||
}
|
||||
$rows[] = array(t('Linked Partner:'), t($partner_name));
|
||||
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
|
||||
$rows[] = array(t('Node ID to keep separate:'), $node->booking_keepseparate_id == 0 ? 'N/A' : $node->booking_keepseparate_id);
|
||||
$rows[] = array(t('Home Phone Number:'), t('!home', array('!home' => $node->booking_phone)));
|
||||
$rows[] = array(t('Mobile Phone Number:'), t('!mob', array('!mob' => $node->booking_mobile)));
|
||||
$rows[] = array(t('Postal Address:'), t('!street<br />!suburb !state !code<br />!country',
|
||||
@@ -712,34 +909,24 @@ function booking_view($node, $view_mode) {
|
||||
'!state' => ($node->booking_state == 'N/A' ? '' : $node->booking_state),
|
||||
'!code' => $node->booking_postcode,
|
||||
'!country' => $node->booking_country)));
|
||||
$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'))));
|
||||
$rows[] = array(t('Married:'), t('!ans', array('!ans' => ($node->booking_married == 'Y' ? 'Yes' : 'No'))));
|
||||
|
||||
if (variable_get('booking_ask_dependant_children', 0) == 1)
|
||||
{
|
||||
$rows[] = array(t('Bringing dependant children:'), t('!ans', array('!ans' => ($node->booking_dependant_children == 'Y' ? 'Yes' : 'No'))));
|
||||
}
|
||||
|
||||
$rows[] = array(t('Linked Partner:'), t($partner_name));
|
||||
$rows[] = array(t('Linked Boyfriend/Girlfriend:'), t($bf_gf));
|
||||
|
||||
$rows[] = array(t('Emergency Contact Name:'), $node->booking_guardian_name);
|
||||
$rows[] = array(t('Emergency Contact Relationship:'), $node->booking_guardian_type);
|
||||
$rows[] = array(t('Emergency Contact Email Address:'), $node->booking_guardian_email);
|
||||
$rows[] = array(t('Emergency Contact Phone:'), $node->booking_guardian_phone);
|
||||
$rows[] = array(t('Emergency Contact Alternate Phone:'), $node->booking_guardian_phone_alt);
|
||||
if (variable_get('booking_enable_medicare', 1) == 1)
|
||||
|
||||
if (variable_get('booking_enable_medicare', 1) == 1) {
|
||||
$rows[] = array(t('Medicare Number:'), $node->booking_medicare);
|
||||
|
||||
}
|
||||
$rows[] = array(t('Special Dietary Requirements:'), $node->booking_dietary);
|
||||
$rows[] = array(t('Special Medical Conditions:'), $node->booking_medical_conditions);
|
||||
|
||||
if (variable_get('booking_enable_roommate', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_roommate', 0) == 1) {
|
||||
$rows[] = array(t('Preferred room-mates:'), t('!room', array('!room' => $node->booking_room_mate1 . ' ' . $node->booking_room_mate2)));
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_helpareas', 1) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_helpareas', 1) == 1) {
|
||||
$rows[] = array(t('Qualified Life Saver:'), $node->booking_lifesaver == 'Y' ? 'Yes' : 'No');
|
||||
$rows[] = array(t('Qualified First Aider:'), $node->booking_firstaid == 'Y' ? 'Yes' : 'No');
|
||||
$rows[] = array(t('Qualified Nurse:'), $node->booking_nurse == 'Y' ? 'Yes' : 'No');
|
||||
@@ -763,8 +950,7 @@ function booking_view($node, $view_mode) {
|
||||
$rows[] = array(t('Help areas:'), t('!help', array('!help' => $help_areas)));
|
||||
}
|
||||
|
||||
if (variable_get('booking_enable_skills', 1) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_skills', 1) == 1) {
|
||||
$skill_areas = '';
|
||||
if ($node->booking_skills_builder == 'Y')
|
||||
$skill_areas .= 'builder, ';
|
||||
@@ -780,11 +966,9 @@ function booking_view($node, $view_mode) {
|
||||
$rows[] = array(t('Previous Mission Experience:'), $node->booking_mission_experience_details);
|
||||
}
|
||||
$rows[] = array(t('Temporary UUID:'), $node->booking_tempid);
|
||||
$rows[] = array(t('Lanyard lucky number:'), $node->booking_luckynum);
|
||||
|
||||
//display room allocation data if enabled
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1)
|
||||
{
|
||||
if (variable_get('booking_enable_roomallocations', 0) == 1) {
|
||||
$room_heading = t("<h2>Room Allocation</h2><p>!link</p>",
|
||||
array('!link' => l(t('Edit Room Allocation'), t('admin/booking/!id/edit-room', array('!id' => $node->nid)), array('query' => drupal_get_destination()) )
|
||||
));
|
||||
@@ -806,8 +990,7 @@ function booking_view($node, $view_mode) {
|
||||
}
|
||||
|
||||
//add the travel info if it has been defined for this attendee
|
||||
if (! empty($node->tid))
|
||||
{
|
||||
if (! empty($node->tid)) {
|
||||
$travel_heading = t("<h2>Travel Details</h2><p>!link</p>",
|
||||
array('!link' => l(t('Edit Travel Details'), t('node/!id/edit', array('!id' => $node->tid)))
|
||||
));
|
||||
@@ -849,8 +1032,7 @@ function booking_view($node, $view_mode) {
|
||||
|
||||
//watchdog('booking', "<pre>Displaying node studygroups query output:\n@info</pre>", array('@info' => print_r( $studygroups, true)));
|
||||
|
||||
foreach ($studygroups as $studygroup)
|
||||
{
|
||||
foreach ($studygroups as $studygroup) {
|
||||
//calculate the session references
|
||||
$sessionid = "session" . $studygroup->sid;
|
||||
$roleid = $sessionid . "_role";
|
||||
@@ -858,22 +1040,9 @@ function booking_view($node, $view_mode) {
|
||||
$group_rows[] = array(t('<b>' . $studygroup->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
|
||||
$group_rows[] = array(t('Role'), _booking_studygroup_role_lookup($node->$roleid));
|
||||
}
|
||||
|
||||
/*
|
||||
for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
|
||||
{
|
||||
//calculate the session references
|
||||
$sessionid = "session" . $i;
|
||||
$roleid = $sessionid . "_role";
|
||||
|
||||
$group_rows[] = array(t('<b>' . $studygroups[$i]->booking_studygroup_descrip . '</b> group number'), $node->$sessionid);
|
||||
$group_rows[] = array(t('Role'), _booking_studygroup_role_lookup($node->$roleid));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//only add to the render array if there were some study groups found
|
||||
if (count($group_rows) > 0)
|
||||
{
|
||||
if (count($group_rows) > 0) {
|
||||
$node->content['group-heading'] = array(
|
||||
'#markup' => $studygroup_heading,
|
||||
'#weight' => 8,
|
||||
@@ -884,7 +1053,6 @@ function booking_view($node, $view_mode) {
|
||||
'#weight' => 9,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$node->content['details'] = array(
|
||||
|
1590
booking.reports.inc
1590
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,
|
||||
);
|
||||
@@ -419,18 +419,18 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
|
||||
drupal_goto('admin/booking/rooms');
|
||||
return "";
|
||||
}
|
||||
|
||||
//@todo reduce the number of queries by using some joins
|
||||
|
||||
$location_description = db_query("SELECT booking_roomlocation_descrip FROM {booking_room_locations} where lid = :id",
|
||||
array(':id' => $location_id))
|
||||
->fetchObject();
|
||||
|
||||
//$prefix = t("<h2>Room Allocations for !room</h2>", array('!room' => _booking_room_location_lookup($location_id)));
|
||||
$prefix = t("<h2>Room Allocations for !room</h2>", array('!room' => $location_description->booking_roomlocation_descrip));
|
||||
|
||||
array(':id' => $location_id))
|
||||
->fetchObject();
|
||||
//use the query result to include a human friendly group name
|
||||
$prefix = t("<h2>Room Allocations for !room</h2>", array('!room' => $location_description->booking_roomlocation_descrip));
|
||||
//query for room definitions
|
||||
$room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid",
|
||||
$room_query = db_query("SELECT * FROM {booking_room_definition} WHERE booking_room_location_id = :lid ORDER BY booking_room_number",
|
||||
array(':lid' => $location_id));
|
||||
|
||||
|
||||
//query for existing room allocations
|
||||
$room_mapping_query = db_query("SELECT * FROM {booking_room_mapping} WHERE booking_eventid = :eid",
|
||||
array(':eid' => $event->eid));
|
||||
@@ -444,110 +444,98 @@ function booking_rooms_view_form($node, &$form_state, $location_id) {
|
||||
array(':eid' => $event->eid))->fetchAllAssoc('nid');
|
||||
|
||||
//define the header
|
||||
$header = array (
|
||||
$header = array(
|
||||
'booking_room_number' => array('data' => t('Room Number')),
|
||||
'booking_room_description' => array('data' => t('Room Label')),
|
||||
'booking_room_ensuite' => array('data' => t('Ensuite?')),
|
||||
'booking_room_singlebed' => array('data' => t('Single Bed')),
|
||||
'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')),
|
||||
'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')),
|
||||
'booking_room_queenbed_p1' => array('data' => t('Queen Bed Person 1')),
|
||||
'booking_room_queenbed_p2' => array('data' => t('Queen Bed Person 2')),
|
||||
);
|
||||
|
||||
//define the default fields in a table row
|
||||
$default_row = array();
|
||||
$default_row['booking_room_number'] = "";
|
||||
$default_row['booking_room_description'] = "";
|
||||
$default_row['booking_room_ensuite'] = "";
|
||||
$default_row['booking_room_singlebed'] = "";
|
||||
$default_row['booking_room_doublebed_p1'] = "";
|
||||
$default_row['booking_room_doublebed_p2'] = "";
|
||||
$default_row['booking_room_queenbed_p1'] = "";
|
||||
$default_row['booking_room_queenbed_p2'] = "";
|
||||
|
||||
foreach ($room_query as $data)
|
||||
{
|
||||
foreach ($room_query as $data) {
|
||||
//create a row that contains just the room location and number and the custom css id for a separating line between the rooms
|
||||
$new_row = _booking_clone_array($default_row);
|
||||
$new_row['booking_room_number'] = $data->booking_room_number;
|
||||
$new_row['booking_room_description'] = $data->booking_room_description;
|
||||
$new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No";
|
||||
$rows[] = array(
|
||||
'data' => $new_row,
|
||||
'id' => array("new-group-row"),
|
||||
);
|
||||
|
||||
//load the existing bed mappings for this room
|
||||
$existing_beds = array();
|
||||
for ($i = 1; $i <= 3; $i++)
|
||||
{
|
||||
foreach ($room_mapping as $mapping)
|
||||
{
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
foreach ($room_mapping as $mapping) {
|
||||
//check that the room id in the mapping table matches the room that we're currently adding to the table
|
||||
//and also the bed type matches the first dimension in the array
|
||||
if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i)
|
||||
{
|
||||
if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) {
|
||||
$existing_beds[$i][] = $mapping->booking_nodeid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//create a row that contains just the room location and number
|
||||
$rows[] = array (
|
||||
'data' => array(
|
||||
$data->booking_room_number,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
),
|
||||
'id' => array("new-group-row"),
|
||||
);
|
||||
|
||||
} //end creating existing room mappings for this room
|
||||
|
||||
//create an additional row for each single bed
|
||||
for ($i = 0; $i < $data->booking_room_singlebeds; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $data->booking_room_singlebeds; $i++) {
|
||||
//retrieve the default value if one exists
|
||||
$nid = (!empty($existing_beds[1][$i])) ? $existing_beds[1][$i] : 0;
|
||||
|
||||
$rows[] = array (
|
||||
'data' => array(
|
||||
"",
|
||||
_booking_rooms_view_formatperson($attendees, $nid),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
),
|
||||
);
|
||||
$new_row = _booking_clone_array($default_row);
|
||||
$new_row['booking_room_singlebed'] = _booking_rooms_view_formatperson($attendees, $nid);
|
||||
$rows[] = array(
|
||||
'data' => $new_row,
|
||||
);
|
||||
}
|
||||
|
||||
//create an additional row for each double bed
|
||||
//$j is our counter that increments twice as fast as $i to cater for both beds
|
||||
$j = 0;
|
||||
for ($i = 0; $i < $data->booking_room_doublebeds; $i++)
|
||||
{
|
||||
$rows[] = array (
|
||||
'data' => array(
|
||||
"",
|
||||
"",
|
||||
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0),
|
||||
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0),
|
||||
"",
|
||||
"",
|
||||
),
|
||||
);
|
||||
for ($i = 0; $i < $data->booking_room_doublebeds; $i++) {
|
||||
$new_row = _booking_clone_array($default_row);
|
||||
$new_row['booking_room_doublebed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0);
|
||||
$new_row['booking_room_doublebed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[2][$j])) ? $existing_beds[2][$j++] : 0);
|
||||
$rows[] = array(
|
||||
'data' => $new_row,
|
||||
);
|
||||
}
|
||||
|
||||
//create an additional row for each queen bed
|
||||
//$j is our counter that increments twice as fast as $i to cater for both beds
|
||||
$j = 0;
|
||||
for ($i = 1; $i <= $data->booking_room_queenbeds; $i++)
|
||||
{
|
||||
$rows[] = array (
|
||||
'data' => array(
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0),
|
||||
_booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0),
|
||||
),
|
||||
for ($i = 1; $i <= $data->booking_room_queenbeds; $i++) {
|
||||
$new_row = _booking_clone_array($default_row);
|
||||
$new_row['booking_room_queenbed_p1'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0);
|
||||
$new_row['booking_room_queenbed_p2'] = _booking_rooms_view_formatperson($attendees, (!empty($existing_beds[3][$j])) ? $existing_beds[3][$j++] : 0);
|
||||
$rows[] = array(
|
||||
'data' => $new_row,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
} //end room iteration loop
|
||||
|
||||
//watchdog('booking', "<pre>Room assignment report rows:\n@info</pre>", array('@info' => print_r( $rows, true)));
|
||||
|
||||
$result = array (
|
||||
'#attached' => array (
|
||||
$result = array(
|
||||
'#attached' => array(
|
||||
'css' => array(drupal_get_path('module', 'booking') . '/booking.css')
|
||||
),
|
||||
'first_para' => array (
|
||||
'first_para' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
'table' => array (
|
||||
'table' => array(
|
||||
'#theme' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
@@ -570,8 +558,7 @@ function _booking_rooms_view_formatperson(&$attendees, $nid) {
|
||||
|
||||
$output = "Empty";
|
||||
|
||||
if ($nid > 0 && !empty($attendees[$nid]))
|
||||
{
|
||||
if ($nid > 0 && !empty($attendees[$nid])) {
|
||||
$output = $attendees[$nid]->booking_firstname . " " . $attendees[$nid]->booking_lastname;
|
||||
}
|
||||
|
||||
|
@@ -225,18 +225,20 @@ function booking_rooms_view_definitions() {
|
||||
$definition_query->join('booking_room_locations', 'l', 'l.lid = r.booking_room_location_id');
|
||||
$definition_query->condition('l.booking_roomlocation_active', 'Y', '=')
|
||||
->fields('r')
|
||||
->fields('l');
|
||||
->fields('l')
|
||||
->orderBy('lid')->orderBy('booking_room_number');
|
||||
$definition_result = $definition_query->execute();
|
||||
|
||||
$location_header = array (
|
||||
'booking_roomlocation_descrip' => t('Location Description'),
|
||||
'booking_roomlocation_active' => t('Location Active?'),
|
||||
'booking_roomlocation_descrip' => t('Location Description'),
|
||||
'booking_roomlocation_active' => t('Location Active?'),
|
||||
'booking_location_edit' => t('Edit Location'),
|
||||
);
|
||||
|
||||
$definition_header = array (
|
||||
'booking_room_location_description' => t('Room Location'),
|
||||
'booking_room_number' => t('Room Number'),
|
||||
'booking_room_location_description' => t('Room Location'),
|
||||
'booking_room_number' => t('Room Number'),
|
||||
'booking_room_description' => t('Room Description'),
|
||||
'booking_room_singlebeds' => t('Number Single Beds'),
|
||||
'booking_room_doublebeds' => t('Number Double Beds'),
|
||||
'booking_room_queenbeds' => t('Number Queen Beds'),
|
||||
@@ -244,8 +246,7 @@ function booking_rooms_view_definitions() {
|
||||
'booking_room_edit' => t('Edit Room'),
|
||||
);
|
||||
|
||||
foreach($location_result as $data)
|
||||
{
|
||||
foreach($location_result as $data) {
|
||||
$location_rows[] = array (
|
||||
$data->booking_roomlocation_descrip,
|
||||
$data->booking_roomlocation_active == 'Y' ? 'Yes' : 'No',
|
||||
@@ -253,12 +254,12 @@ function booking_rooms_view_definitions() {
|
||||
);
|
||||
}
|
||||
|
||||
foreach($definition_result as $data)
|
||||
{
|
||||
foreach($definition_result as $data) {
|
||||
$definition_rows[] = array (
|
||||
//_booking_room_location_lookup($data->booking_room_location_id),
|
||||
//_booking_room_location_lookup($data->booking_room_location_id),
|
||||
$data->booking_roomlocation_descrip,
|
||||
$data->booking_room_number,
|
||||
$data->booking_room_number,
|
||||
$data->booking_room_description,
|
||||
$data->booking_room_singlebeds,
|
||||
$data->booking_room_doublebeds,
|
||||
$data->booking_room_queenbeds,
|
||||
@@ -309,33 +310,30 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
|
||||
$query = db_query("SELECT * FROM {booking_room_locations} where booking_roomlocation_active='Y'");
|
||||
|
||||
foreach($query as $row)
|
||||
{
|
||||
foreach($query as $row) {
|
||||
$location_options[$row->lid] = $row->booking_roomlocation_descrip;
|
||||
}
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
if ($create == true) {
|
||||
$data = $node;
|
||||
$prefix = t("<p>Create new room defintion.</p>");
|
||||
//watchdog('booking', 'Creating new room definition: @info', array ('@info' => var_export($node, TRUE)));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $room_id)) {
|
||||
drupal_set_message("Error: Invalid room ID supplied. Unable to update room definition.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/rooms');
|
||||
return "";
|
||||
}
|
||||
|
||||
//$data = $form_state['input'];
|
||||
$data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id",
|
||||
array(':id' => $room_id))
|
||||
->fetchObject();
|
||||
$prefix = t("<p>Update the room defintions.</p>");
|
||||
|
||||
//$data = $form_state['input'];
|
||||
$data = db_query("SELECT * FROM {booking_room_definition} WHERE rid = :id", array(':id' => $room_id))
|
||||
->fetchObject();
|
||||
|
||||
//add this to the form in a hidden field so we can update the right price
|
||||
$form['booking_rid'] = array (
|
||||
$form['booking_rid'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $room_id,
|
||||
);
|
||||
@@ -343,15 +341,14 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
}
|
||||
|
||||
//create the options array for bed counts
|
||||
for ($i = 0; $i <= 15; $i++)
|
||||
for ($i = 0; $i <= 15; $i++) {
|
||||
$bedcount_options[$i] = $i;
|
||||
}
|
||||
|
||||
//define the form for adding to the room definitions
|
||||
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
|
||||
$form[] = array (
|
||||
'first_heading' => array (
|
||||
'first_heading' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
),
|
||||
@@ -363,26 +360,33 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
'#options' => $location_options,
|
||||
'#default_value' => !empty($data->booking_room_location_id) ? $data->booking_room_location_id : ''
|
||||
);
|
||||
$form['booking_room_number'] = array (
|
||||
$form['booking_room_number'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify room number'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 10,
|
||||
'#default_value' => !empty($data->booking_room_number) ? $data->booking_room_number : '',
|
||||
);
|
||||
$form['booking_room_singlebeds'] = array (
|
||||
$form['booking_room_description'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Specify room label (not mandatory)'),
|
||||
'#size' => 50,
|
||||
'#maxlength' => 100,
|
||||
'#default_value' => !empty($data->booking_room_description) ? $data->booking_room_description : '',
|
||||
);
|
||||
$form['booking_room_singlebeds'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Specify number of single beds'),
|
||||
'#options' => $bedcount_options,
|
||||
'#default_value' => !empty($data->booking_room_singlebeds) ? $data->booking_room_singlebeds : '',
|
||||
);
|
||||
$form['booking_room_doublebeds'] = array (
|
||||
$form['booking_room_doublebeds'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Specify number of double beds'),
|
||||
'#options' => $bedcount_options,
|
||||
'#default_value' => !empty($data->booking_room_doublebeds) ? $data->booking_room_doublebeds : '',
|
||||
);
|
||||
$form['booking_room_queenbeds'] = array (
|
||||
$form['booking_room_queenbeds'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Specify number of queen beds'),
|
||||
'#options' => $bedcount_options,
|
||||
@@ -394,21 +398,18 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
'#default_value' => (!empty($data->booking_room_ensuite) && $data->booking_room_ensuite == 'Y') ? 1 : 0,
|
||||
);
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
$form['submit'] = array
|
||||
(
|
||||
if ($create == true) {
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Add Room'),
|
||||
);
|
||||
} else {
|
||||
$form['Update'] = array
|
||||
(
|
||||
}
|
||||
else {
|
||||
$form['Update'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Update Room'),
|
||||
);
|
||||
$form['Delete'] = array
|
||||
(
|
||||
$form['Delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete Room'),
|
||||
);
|
||||
@@ -418,12 +419,22 @@ function booking_rooms_definition_form($node, &$form_state, $create, $room_id =
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return confirm_form($form, "Are you sure you wish to delete room definition with id " . $room_id . "?",
|
||||
current_path(), NULL, "Delete Room");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the form for adding room definitions
|
||||
*/
|
||||
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.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,30 +448,28 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
|
||||
//watchdog('booking', "<pre>Room definition submission:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
|
||||
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||
if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm'])))
|
||||
{
|
||||
if($form_state['values']['op'] == 'Delete Room' && (!isset($form_state['storage']['confirm']))) {
|
||||
//watchdog('booking', "<pre>Room 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 Room')
|
||||
{
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Room') {
|
||||
//delete the room
|
||||
watchdog('booking', "Deleting room ID !rid", array('!rid' => $values['booking_rid']));
|
||||
|
||||
|
||||
db_delete('booking_room_definition')
|
||||
->condition('rid', $values['booking_rid'])
|
||||
->execute();
|
||||
|
||||
|
||||
drupal_set_message('Deleted room id ' . $values['booking_rid'] );
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Room')
|
||||
{
|
||||
elseif ($form_state['values']['op'] == 'Update Room') {
|
||||
$result = db_update('booking_room_definition')
|
||||
->fields(array(
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_description' => $values['booking_room_description'],
|
||||
'booking_room_singlebeds' => $values['booking_room_singlebeds'],
|
||||
'booking_room_doublebeds' => $values['booking_room_doublebeds'],
|
||||
'booking_room_queenbeds' => $values['booking_room_queenbeds'],
|
||||
@@ -475,8 +484,9 @@ function booking_rooms_definition_form_submit($form, &$form_state) {
|
||||
{
|
||||
db_insert('booking_room_definition')
|
||||
->fields(array(
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_location_id' => $values['booking_room_location_id'],
|
||||
'booking_room_number' => $values['booking_room_number'],
|
||||
'booking_room_description' => $values['booking_room_description'],
|
||||
'booking_room_singlebeds' => $values['booking_room_singlebeds'],
|
||||
'booking_room_doublebeds' => $values['booking_room_doublebeds'],
|
||||
'booking_room_queenbeds' => $values['booking_room_queenbeds'],
|
||||
|
@@ -11,7 +11,10 @@ function _booking_rooms_name_autocomplete($string) {
|
||||
|
||||
$query = db_select('booking_person', 'p')
|
||||
->fields('p', array('nid', 'booking_firstname', 'booking_lastname'));
|
||||
$db_or = db_or()->condition('p.booking_lastname', '%' . db_like($string) . '%', 'LIKE')->condition('p.booking_firstname', '%' . db_like($string) . '%', 'LIKE');
|
||||
$db_or = db_or()
|
||||
->condition('p.booking_lastname', '%' . db_like($string) . '%', 'LIKE')
|
||||
->condition('p.booking_firstname', '%' . db_like($string) . '%', 'LIKE')
|
||||
->condition('p.nid', $string, "=");
|
||||
$db_and = db_and()->condition($db_or)->condition('p.booking_eventid', $event->eid, '=');
|
||||
$result = $query->condition($db_and)
|
||||
->execute();
|
||||
@@ -68,6 +71,8 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
|
||||
$header = array (
|
||||
'booking_room_location' => array('data' => t('Room Location'), 'field' => 'booking_room_location_id'),
|
||||
'booking_room_number' => array('data' => t('Room Number')),
|
||||
'booking_room_description' => array('data' => t('Room Label')),
|
||||
'booking_room_ensuite' => array('data' => t('Ensuite?')),
|
||||
'booking_room_singlebed' => array('data' => t('Single Bed')),
|
||||
'booking_room_doublebed_p1' => array('data' => t('Double Bed Person 1')),
|
||||
'booking_room_doublebed_p2' => array('data' => t('Double Bed Person 2')),
|
||||
@@ -94,24 +99,22 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
|
||||
$default_row = array();
|
||||
$default_row['booking_room_location'] = "";
|
||||
$default_row['booking_room_number'] = "";
|
||||
$default_row['booking_room_description'] = "";
|
||||
$default_row['booking_room_ensuite'] = "";
|
||||
$default_row['booking_room_singlebed'] = "";
|
||||
$default_row['booking_room_doublebed_p1'] = "";
|
||||
$default_row['booking_room_doublebed_p2'] = "";
|
||||
$default_row['booking_room_queenbed_p1'] = "";
|
||||
$default_row['booking_room_queenbed_p2'] = "";
|
||||
|
||||
foreach ($room_query as $data)
|
||||
{
|
||||
foreach ($room_query as $data) {
|
||||
//create an array representing the existing bed mappings for this room
|
||||
$existing_beds = array();
|
||||
for ($i = 1; $i <= 3; $i++)
|
||||
{
|
||||
foreach ($room_mapping as $mapping)
|
||||
{
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
foreach ($room_mapping as $mapping) {
|
||||
//check that the room id in the mapping table matches the room that we're currently adding to the table
|
||||
//and also the bed type matches the first dimension in the array
|
||||
if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i)
|
||||
{
|
||||
if ($mapping->booking_roomid == $data->rid && $mapping->booking_room_bedtype == $i) {
|
||||
$existing_beds[$i][] = $mapping->booking_lastname . ', ' . $mapping->booking_firstname . ' [' . $mapping->booking_nodeid . ']';
|
||||
}
|
||||
}
|
||||
@@ -122,6 +125,8 @@ function booking_rooms_allocate_form($node, &$form_state, $location_id) {
|
||||
//$new_row['booking_room_location'] = _booking_room_location_lookup($data->booking_room_location_id);
|
||||
$new_row['booking_room_location'] = $data->booking_roomlocation_descrip;
|
||||
$new_row['booking_room_number'] = $data->booking_room_number;
|
||||
$new_row['booking_room_description'] = $data->booking_room_description;
|
||||
$new_row['booking_room_ensuite'] = $data->booking_room_ensuite == 'Y' ? "Yes" : "No";
|
||||
$form['rooms']['#rows'][$counter++] = array(
|
||||
'data' => $new_row,
|
||||
'id' => array("new-group-row"),
|
||||
|
65
booking.stripe-old.js
Normal file
65
booking.stripe-old.js
Normal file
@@ -0,0 +1,65 @@
|
||||
(function($) {
|
||||
$(function() {
|
||||
Stripe.setPublishableKey(Drupal.settings.booking_stripeform.pubkey);
|
||||
});
|
||||
Drupal.behaviors.booking_stripeform = {
|
||||
attach: function(context, settings) {
|
||||
$("#" + settings.booking_stripeform.form_selector, context).submit(function(e) {
|
||||
e.preventDefault();
|
||||
var $form = $(this);
|
||||
var $obj;
|
||||
var $submitBtn = $("#edit-submit", context);
|
||||
settings.booking_stripeform.submitBtnText = $submitBtn.val();
|
||||
try {
|
||||
var $ccnum = $(':input[data-stripe="number"]', $form);
|
||||
var $exp_month = $(':input[data-stripe="exp-month"]', $form);
|
||||
var $exp_year = $(':input[data-stripe="exp-year"]', $form);
|
||||
var $cvc = $(':input[data-stripe="cvc"]', $form);
|
||||
if(!Stripe.card.validateCardNumber($(':input[data-stripe="number"]', $form).val())) {
|
||||
$obj = $ccnum;
|
||||
throw "Invalid credit card number";
|
||||
}
|
||||
if(!Stripe.card.validateExpiry($exp_month.val(), $exp_year.val())) {
|
||||
$obj = $exp_month;
|
||||
throw "Invalid expiration month/year";
|
||||
}
|
||||
if(!Stripe.card.validateCVC($cvc.val())) {
|
||||
$obj = $cvc;
|
||||
throw "Invalid CVC";
|
||||
}
|
||||
} catch(err) {
|
||||
$.each([$ccnum, $exp_month, $exp_year, $cvc], function(i, e) {
|
||||
e.addClass('error');
|
||||
});
|
||||
$obj.parents('div.control-group').toggleClass('error');
|
||||
reportError(err, $obj);
|
||||
return false;
|
||||
}
|
||||
$submitBtn.val('Please wait...').attr('disabled', true);
|
||||
Stripe.createToken($form, stripeResponseHandler);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var stripeResponseHandler = function(status, response) {
|
||||
var $form = $("#" + Drupal.settings.booking_stripeform.form_selector);
|
||||
if (response.error) {
|
||||
alert(response.error.message);
|
||||
} else {
|
||||
// token contains id, last4, and card type
|
||||
var token = response.id;
|
||||
// Insert the token into the form so it gets submitted to the server
|
||||
$('input[name=stripeToken]', $form).val(token);
|
||||
// and submit
|
||||
$form.get(0).submit();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses Bootstrap's popover to alert the user.
|
||||
*/
|
||||
function reportError(msg, $el) {
|
||||
console.log([$el, msg]);
|
||||
}
|
||||
}(jQuery));
|
322
booking.stripe.inc
Normal file
322
booking.stripe.inc
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functions for stripe payment integration
|
||||
* @see https://github.com/ericthelast/drupal-stripe-form and https://www.webomelette.com/drupal-stripe-integration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the current stripe api public key
|
||||
*/
|
||||
function _booking_get_stripe_public_key() {
|
||||
if (variable_get('booking_stripe_testmode', 0) == 1) {
|
||||
return variable_get('booking_stripe_test_public_key', '');
|
||||
}
|
||||
else {
|
||||
return variable_get('booking_stripe_live_public_key', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current stripe api private key
|
||||
*/
|
||||
function _booking_get_stripe_private_key() {
|
||||
if (variable_get('booking_stripe_testmode', 0) == 1) {
|
||||
return variable_get('booking_stripe_test_secret_key', '');
|
||||
}
|
||||
else {
|
||||
return variable_get('booking_stripe_live_secret_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, $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, $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
|
||||
$setting['booking_stripe'] = array(
|
||||
'pubkey' => _booking_get_stripe_public_key(),
|
||||
'form_selector' => str_replace('_', '-', __FUNCTION__),
|
||||
'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(
|
||||
array('data' => $setting, 'type' => 'setting'),
|
||||
),
|
||||
'library' => array(
|
||||
array('booking', 'booking-stripe'),
|
||||
),
|
||||
);
|
||||
|
||||
//paypal specific settings
|
||||
$vars = array(
|
||||
'nid' => $person->nid,
|
||||
'email' => $person->booking_email,
|
||||
'description' => $event->booking_eventname . ' ' . $person->booking_price_descrip,
|
||||
'invoice' => $invoiceid,
|
||||
'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_client_ip' => '',
|
||||
'card_brand' => '',
|
||||
'card_country' => '',
|
||||
'card_cvc_check' => '',
|
||||
'card_address_zip_check' => '',
|
||||
);
|
||||
|
||||
//turn the array into a form
|
||||
foreach($vars as $name => $value) {
|
||||
$form[$name] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $value,
|
||||
);
|
||||
};
|
||||
|
||||
$form['submit'] = array(
|
||||
'#id' => 'stripe-submit',
|
||||
'#type' => 'button',
|
||||
'#value' => t($button_text),
|
||||
);
|
||||
$form['#after_build'][] = 'booking_stripe_add_final_validation';
|
||||
|
||||
//watchdog('booking', 'Booking Balance payment: @info', array ('@info' => var_export($form, TRUE)));
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to add final validation after all else has been added through alters.
|
||||
*/
|
||||
function booking_stripe_add_final_validation($form) {
|
||||
$form['#validate'][] = 'booking_stripe_validate_form_payment';
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation callback.
|
||||
*/
|
||||
function booking_stripe_checkout_form_validate($form, &$form_state) {
|
||||
// Validate normal form elements as needed.
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the stripe payment.
|
||||
*
|
||||
* We do this here so that if the payment fails,
|
||||
* we're still in a validation stage and can return
|
||||
* early. If success, we'll pass the charge on
|
||||
* to the submission callback.
|
||||
*/
|
||||
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());
|
||||
|
||||
//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']['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'] : '');
|
||||
$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 {
|
||||
$charge = \Stripe\Charge::create(array(
|
||||
"amount" => $amount * 100,
|
||||
"currency" => "aud",
|
||||
"card" => $token,
|
||||
"statement_descriptor" => substr($event->booking_eventname, 0, 21), //this field is limited to 22 characters
|
||||
"expand" => array('balance_transaction'),
|
||||
"description" => $form_state['input']['description'],
|
||||
"receipt_email" => $form_state['input']['email'],
|
||||
"metadata" => array(
|
||||
"invoice" => $invoice,
|
||||
"nid" => $nid,
|
||||
"last_name" => $last_name,
|
||||
"first_name" => $first_name,
|
||||
),
|
||||
));
|
||||
watchdog('booking_debug', "<pre>Stripe payment charge results:\n@info</pre>", array('@info' => print_r( $charge->__toJSON(), true)));
|
||||
if ($charge && $charge->paid) {
|
||||
//watchdog('booking_debug', 'Charge created successfully');
|
||||
_booking_process_stripe_payment($charge, $token);
|
||||
//$form_state['stripeform_charge'] = $charge;
|
||||
// @todo call _booking_process_stripe_payment to store payment
|
||||
drupal_goto('bookingfinal/' . $tempid);
|
||||
}
|
||||
else {
|
||||
watchdog('booking', 'Charge was not created successfully');
|
||||
drupal_set_message('Card does not seem to have been charged successfully. Please try again', 'error');
|
||||
}
|
||||
}
|
||||
catch(\Stripe\Error\Card $e) {
|
||||
$e_json = $e->getJsonBody();
|
||||
$error = $e_json['error'];
|
||||
watchdog('booking', $e->getMessage());
|
||||
drupal_set_message($error['message'], 'error');
|
||||
}
|
||||
catch (\Stripe\Error\ApiConnection $e) {
|
||||
watchdog('booking', $e->getMessage());
|
||||
drupal_set_message($error['message'], 'error');
|
||||
}
|
||||
catch (\Stripe\Error\Api $e) {
|
||||
watchdog('booking', $e->getMessage());
|
||||
drupal_set_message($error['message'], 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function _booking_process_stripe_payment(&$charge, $token) {
|
||||
global $event;
|
||||
$balance_payment = false;
|
||||
$amount_owing = 0;
|
||||
//$invoice = $data->metadata;
|
||||
|
||||
//verify the status of the charge
|
||||
if (empty($charge->status) || ($charge->status != 'succeeded')) {
|
||||
$successful = FALSE;
|
||||
}
|
||||
else {
|
||||
$successful = TRUE;
|
||||
}
|
||||
|
||||
//extract the person node id from the invoice
|
||||
$pos = strpos($charge->metadata->invoice, "_");
|
||||
if (($pos === false) || ($pos == 0)) {
|
||||
watchdog('booking', 'Unable to process payment with invalid invoice information: !id', array('!id' => $charge->metadata->invoice), WATCHDOG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
//get the part of the invoice up to the first underscore
|
||||
$nid = substr($charge->metadata->invoice, 0, $pos);
|
||||
//get the data between the first and second underscore
|
||||
$eid = substr($charge->metadata->invoice, $pos + 1, strrpos($charge->metadata->invoice, "_") - $pos - 1);
|
||||
|
||||
if (substr($eid,0,3) == "bal") {
|
||||
$balance_payment = true;
|
||||
watchdog('booking_debug', 'Balance payment via stripe for user with node id: !id and status !status.',
|
||||
array('!id' => $nid, '!status' => $charge->status));
|
||||
}
|
||||
else {
|
||||
watchdog('booking_debug', 'Initial payment via stripe for user with node id: !id and status !status.',
|
||||
array('!id' => $nid, '!status' => $charge->status));
|
||||
}
|
||||
|
||||
//this shouldn't ever happen, since stripe is sending this notification synchronously
|
||||
//but just in case, check for an existing transaction that matches this one
|
||||
$duplicate_check = db_query("SELECT payid, booking_person_nid FROM {booking_payment} where booking_ipn_track_id = :ipn_id ",
|
||||
array(':ipn_id' => $charge->id))->fetchObject();
|
||||
|
||||
if ($duplicate_check) {
|
||||
watchdog('booking', 'Detected duplicate stripe transaction notifications for transaction id !id, registration id !nid',
|
||||
array('!id' => $charge->id, '!nid' => $nid), WATCHDOG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
$gross_amount = $charge->amount / 100;
|
||||
$result = db_insert('booking_payment')
|
||||
->fields(array(
|
||||
'booking_person_nid' => $nid,
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_mc_gross' => $gross_amount,
|
||||
'booking_mc_currency' => $charge->balance_transaction->currency,
|
||||
'booking_mc_fee' => $charge->balance_transaction->fee / 100,
|
||||
'booking_invoice' => $charge->metadata->invoice,
|
||||
'booking_payer_id' => $charge->source->id,
|
||||
'booking_payment_date' => $charge->created,
|
||||
'booking_payment_status' => $charge->status,
|
||||
'booking_first_name' => $charge->metadata->first_name,
|
||||
'booking_last_name' => $charge->metadata->last_name,
|
||||
'booking_buyer_email' => $charge->receipt_email,
|
||||
'booking_item_name' => $charge->description,
|
||||
'booking_ipn_track_id' => $charge->id,
|
||||
'booking_stripe_response' => $charge->__toJSON(),
|
||||
))
|
||||
->execute();
|
||||
|
||||
//Get the person's info so we can update their total amount paid and booking status
|
||||
$person = node_load($nid);
|
||||
|
||||
//check if we found a person matching this payment
|
||||
if ($person) {
|
||||
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment',
|
||||
array('!id' => $nid, '!eid' => $eid, '!payment' => $person->booking_amount_paid));
|
||||
_booking_process_person_payment($person, $gross_amount, $balance_payment);
|
||||
}
|
||||
else {
|
||||
//couldn't find a matching nid for this invoice
|
||||
watchdog('booking', "Unable to process payment for user with node id: '!id'", array('!id' => $nid), WATCHDOG_ERROR);
|
||||
//db_query("UPDATE {booking_person} SET booking_tempid='' WHERE nid = %d", $nid);
|
||||
}
|
||||
}
|
52
booking.stripe.js
Normal file
52
booking.stripe.js
Normal file
@@ -0,0 +1,52 @@
|
||||
jQuery(document).ready(function($) {
|
||||
var $settings = Drupal.settings.booking_stripe;
|
||||
var $stripeForm = $("#" + $settings.form_selector);
|
||||
var handler = StripeCheckout.configure({
|
||||
key: $settings.pubkey,
|
||||
image: $settings.image,
|
||||
locale: 'auto',
|
||||
token: function(token) {
|
||||
try {
|
||||
//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) {
|
||||
console.log([err]);
|
||||
alert(err.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('.form-submit').click(function (e) {
|
||||
var $settings = Drupal.settings.booking_stripe;
|
||||
var $stripeForm = $("#" + $settings.form_selector);
|
||||
var $amount = $(':input[name="amount"]', $stripeForm).val() * 100;
|
||||
|
||||
handler.open({
|
||||
name: $settings.name,
|
||||
panelLabel: $settings.payment_button_label,
|
||||
currency: "AUD",
|
||||
description: $(':input[name="description"]', $stripeForm).val(),
|
||||
email: $(':input[name="email"]', $stripeForm).val(),
|
||||
amount: Math.round($amount),
|
||||
zipCode: true,
|
||||
closed: function() {
|
||||
//document.getElementById("booking_stripe_form").submit();
|
||||
}
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
/*
|
||||
// Close Checkout on page navigation
|
||||
$(window).on('popstate', function() {
|
||||
handler.close();
|
||||
});
|
||||
*/
|
||||
});
|
@@ -2,11 +2,9 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functions for calculating leaders and helpers for discussion groups
|
||||
* Functions for automatically calculating leaders and helpers for discussion groups
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function for calculating and assigning leaders and helpers to active study group sessions
|
||||
*/
|
||||
@@ -66,20 +64,16 @@ function _booking_get_next_studygroup($type, $studygroups) {
|
||||
|
||||
$count = count($studygroups) - 1;
|
||||
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
{
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$group = $studygroups[$i];
|
||||
$leader = $group->leader_nid;
|
||||
//watchdog('booking_debug', "<pre>Study Group Element at index $i:\n@info</pre>", array('@info' => print_r( $group, true)));
|
||||
//watchdog('booking_debug', "<pre>Study Group Leader NID at index $i:\n@info</pre>", array('@info' => var_dump($group)));
|
||||
|
||||
if ($leader == 0)
|
||||
{
|
||||
if ($leader == 0) {
|
||||
return $i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,9 +95,7 @@ function _booking_studygroups_retrieve_eligible_people() {
|
||||
$bookedin_result = $query->execute();
|
||||
|
||||
//iterate over the attendee associative array and add some fields
|
||||
foreach ($bookedin_result as $person)
|
||||
{
|
||||
|
||||
foreach ($bookedin_result as $person) {
|
||||
$person->processed = 0;
|
||||
$person->leading = array();
|
||||
$person->helping = array();
|
||||
@@ -116,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\'
|
||||
@@ -124,9 +116,7 @@ function _booking_studygroups_retrieve_eligible_people() {
|
||||
array(':eid' => $event->eid));
|
||||
|
||||
//iterate over the attendee associative array and add some fields
|
||||
foreach ($result2 as $person)
|
||||
{
|
||||
|
||||
foreach ($result2 as $person){
|
||||
$person->processed = 0;
|
||||
$person->leading = array();
|
||||
$person->helping = array();
|
||||
@@ -140,8 +130,6 @@ function _booking_studygroups_retrieve_eligible_people() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function for
|
||||
*/
|
||||
@@ -158,11 +146,9 @@ function _booking_studygroups_retrieve_groups() {
|
||||
//assume they all have the same number of sessions
|
||||
//$num_sessions = $studygroup->booking_num_group_sessions;
|
||||
|
||||
foreach ($group_mapping as $group)
|
||||
{
|
||||
foreach ($group_mapping as $group) {
|
||||
//watchdog('booking_debug', "<pre>Study Group Element:\n@info</pre>", array('@info' => print_r( $group, true)));
|
||||
for ($i = 1; $i <= 16; $i++)
|
||||
{
|
||||
for ($i = 1; $i <= 16; $i++) {
|
||||
$new_group = clone $group;
|
||||
|
||||
$new_group->session_id = $i;
|
||||
@@ -178,4 +164,338 @@ function _booking_studygroups_retrieve_groups() {
|
||||
//watchdog('booking', "<pre>Study Group Sessions:\n@info</pre>", array('@info' => print_r( $groups, true)));
|
||||
return $groups;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* autocomplete helper to look up names for room allocations
|
||||
* based on https://www.drupal.org/node/854216
|
||||
* $string = string for search
|
||||
*/
|
||||
function _booking_studygroups_name_autocomplete($string) {
|
||||
global $event;
|
||||
$matches = array();
|
||||
|
||||
$query = db_select('booking_person', 'p')
|
||||
->fields('p', array('nid', 'booking_firstname', 'booking_lastname'));
|
||||
$db_or = db_or()
|
||||
->condition('p.booking_lastname', '%' . db_like($string) . '%', 'LIKE')
|
||||
->condition('p.booking_firstname', '%' . db_like($string) . '%', 'LIKE')
|
||||
->condition('p.nid', $string, "=");
|
||||
$db_and = db_and()->condition($db_or)->condition('p.booking_eventid', $event->eid, '=');
|
||||
$result = $query->condition($db_and)
|
||||
->execute();
|
||||
|
||||
// save the query to matches
|
||||
foreach ($result as $row) {
|
||||
$name = $row->booking_lastname . ', ' . $row->booking_firstname . ' [' . $row->nid . ']';
|
||||
$matches[$name] = $name;
|
||||
}
|
||||
|
||||
// Return the result to the form in json
|
||||
drupal_json_output($matches);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
//verify that $group_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $group_id)) {
|
||||
drupal_set_message("Error: Invalid study group ID '" . $group_id . "' supplied. Unable to edit group leaders and helpers.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/studygroups');
|
||||
return "";
|
||||
}
|
||||
|
||||
//try to select the study group for this $group_id
|
||||
$studygroup = db_query("SELECT * FROM {booking_studygroup_list} WHERE sid = :sid", array(':sid' => $group_id))
|
||||
->fetchObject();
|
||||
|
||||
if (! $studygroup) {
|
||||
drupal_set_message("Error: Could not find matching study group ID. Unable to edit leaders/helpers.", 'error', FALSE);
|
||||
drupal_goto('admin/booking/studygroups');
|
||||
return "";
|
||||
}
|
||||
|
||||
//define the table header
|
||||
$header = array (
|
||||
'sid' => array('data' => t('Study Group Session ID'), 'field' => 'sid'),
|
||||
'booking_assign_leader' => array('data' => t('Leader')),
|
||||
'booking_assign_helper' => array('data' => t('Helper')),
|
||||
'booking_assign_reserveleader' => array('data' => t('Reserve Leader')),
|
||||
'booking_assign_reservehelper' => array('data' => t('Reserve Helper')),
|
||||
);
|
||||
|
||||
//attach the custom css
|
||||
$form['#attached']['css'] = array(
|
||||
drupal_get_path('module', 'booking') . '/booking.css',
|
||||
);
|
||||
|
||||
$prefix = t("<h2>Edit Leaders/Helpers for Study Group ‐ !descrip</h2>",
|
||||
array('!descrip' => $studygroup->booking_studygroup_descrip));
|
||||
$prefix .= "<p>Enter part of a person's name in the text field and wait for the blue spinning circle to autocomplete with the person's details. " .
|
||||
"Make sure you click on the person from the dropdown list that appears.</p>";
|
||||
$form['first_para'] = array (
|
||||
'#type' => 'markup',
|
||||
'#markup' => $prefix,
|
||||
);
|
||||
|
||||
//add this to the form in a hidden field so we can update the right studygroup
|
||||
$form['booking_gid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $group_id,
|
||||
);
|
||||
|
||||
//create the container element for the whole table
|
||||
$form['studygroups'] = array(
|
||||
'#prefix' => '<div id="studygroups">',
|
||||
'#suffix' => '</div>',
|
||||
'#tree' => TRUE,
|
||||
'#theme' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => array(),
|
||||
);
|
||||
|
||||
//get the list of study group session memberships
|
||||
$session_members_query = db_query("SELECT m.*, p.* FROM {booking_studygroup_mapping} m
|
||||
inner join {booking_person} p on p.nid = m.booking_node_id
|
||||
WHERE m.booking_studygroup_id = :gid AND m.booking_studygroup_role > 0",
|
||||
array(':gid' => $group_id));
|
||||
$session_members = $session_members_query->fetchAllAssoc('booking_node_id');
|
||||
|
||||
//create an array representing the existing leaders/helpers for this group
|
||||
$existing_leaders = array();
|
||||
foreach ($session_members as $person) {
|
||||
$existing_leaders[$person->booking_session_id][$person->booking_studygroup_role] =
|
||||
$person->booking_lastname . ', ' . $person->booking_firstname . ' [' . $person->booking_node_id . ']';
|
||||
}
|
||||
|
||||
//create the rows for the individual sessions (instances really) of this study group
|
||||
for ($i = 1; $i <= $studygroup->booking_num_group_sessions; $i++) {
|
||||
$leader = array (
|
||||
'#id' => 'booking-studygroup-leader-' . $i,
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Name',
|
||||
'#title_display' => 'invisible',
|
||||
'#name' => 'booking_studygroup_leader[' . $i . ']',
|
||||
'#size' => 100,
|
||||
'#autocomplete_path' => 'booking/studygroups/autocomplete',
|
||||
'#value' => (!empty($existing_leaders[$i][1])) ? $existing_leaders[$i][1] : '',
|
||||
'#attributes' => array('style' => array('width:200px')),
|
||||
);
|
||||
|
||||
$helper = array (
|
||||
'#id' => 'booking-studygroup-helper-' . $i,
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Name',
|
||||
'#title_display' => 'invisible',
|
||||
'#name' => 'booking_studygroup_helper[' . $i . ']',
|
||||
'#size' => 100,
|
||||
'#autocomplete_path' => 'booking/studygroups/autocomplete',
|
||||
'#value' => (!empty($existing_leaders[$i][2])) ? $existing_leaders[$i][2] : '',
|
||||
'#attributes' => array('style' => array('width:200px')),
|
||||
);
|
||||
|
||||
$reserveleader = array (
|
||||
'#id' => 'booking-studygroup-reserveleader-' . $i,
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Name',
|
||||
'#title_display' => 'invisible',
|
||||
'#name' => 'booking_studygroup_reserveleader[' . $i . ']',
|
||||
'#size' => 100,
|
||||
'#autocomplete_path' => 'booking/studygroups/autocomplete',
|
||||
'#value' => (!empty($existing_leaders[$i][3])) ? $existing_leaders[$i][3] : '',
|
||||
'#attributes' => array('style' => array('width:200px')),
|
||||
);
|
||||
|
||||
$reservehelper = array (
|
||||
'#id' => 'booking-studygroup-reservehelper-' . $i,
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Name',
|
||||
'#title_display' => 'invisible',
|
||||
'#name' => 'booking_studygroup_reservehelper[' . $i . ']',
|
||||
'#size' => 100,
|
||||
'#autocomplete_path' => 'booking/studygroups/autocomplete',
|
||||
'#value' => (!empty($existing_leaders[$i][4])) ? $existing_leaders[$i][4] : '',
|
||||
'#attributes' => array('style' => array('width:200px')),
|
||||
);
|
||||
|
||||
$form['studygroups'][$i] = array(
|
||||
'booking-studygroup-leader' => &$leader,
|
||||
'booking-studygroup-helper' => &$helper,
|
||||
'booking-studygroup-reserveleader' => &$reserveleader,
|
||||
'booking-studygroup-reservehelper' => &$reservehelper,
|
||||
);
|
||||
|
||||
$new_row = array();
|
||||
//handle readings group differently
|
||||
if ($studygroup->booking_is_readinggroup == 'Y') {
|
||||
$new_row['sid'] = _booking_readinggroup_colour_lookup($i);
|
||||
}
|
||||
//non readings groups just show the session ID
|
||||
else {
|
||||
$new_row['sid'] = $i;
|
||||
}
|
||||
$new_row['booking_studygroup_leader'] = array('data' => &$leader);
|
||||
$new_row['booking_studygroup_helper'] = array('data' => &$helper);
|
||||
$new_row['booking_studygroup_reserveleader'] = array('data' => &$reserveleader);
|
||||
$new_row['booking_studygroup_reservehelper'] = array('data' => &$reservehelper);
|
||||
$form['studygroups']['#rows'][$i] = $new_row;
|
||||
|
||||
//clean up references
|
||||
unset($leader);
|
||||
unset($helper);
|
||||
unset($reserveleader);
|
||||
unset($reservehelper);
|
||||
}
|
||||
|
||||
//record whether this was a reading group, so we can update colours if necessary
|
||||
$form['booking_readinggroup'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $studygroup->booking_is_readinggroup,
|
||||
);
|
||||
|
||||
//close out the form
|
||||
$form['submit'] = array (
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
);
|
||||
|
||||
return array (
|
||||
'form' => $form,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the submission for leaders/helpers
|
||||
*/
|
||||
function booking_studygroup_leadhelp_edit_form_submit($form, &$form_state) {
|
||||
global $event;
|
||||
|
||||
$values = $form_state['input'];
|
||||
$group_id = $form_state['values']['booking_gid'];
|
||||
$update_messages = array();
|
||||
$counter = 0;
|
||||
//watchdog('booking_debug', "<pre>Studygroup leader/helper test submission form :\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
|
||||
$role_types = array(
|
||||
'booking_studygroup_leader' => 1,
|
||||
'booking_studygroup_helper' => 2,
|
||||
'booking_studygroup_reserveleader' => 3,
|
||||
'booking_studygroup_reservehelper' => 4,
|
||||
);
|
||||
|
||||
//iterate over the different role types
|
||||
foreach ($role_types as $type => $type_id) {
|
||||
//iterate over the sessions for that role type
|
||||
foreach ($values[$type] as $session_id => $person) {
|
||||
//get the previous value
|
||||
$previous_value = _booking_studygroup_leadhelp_edit_get_previous_value($form, $type, $type . '[' . $session_id . ']');
|
||||
//watchdog('booking_debug', "<pre>Studygroup assignment previous value:\n@info\nCurrent value:\n@current</pre>",
|
||||
// array('@info' => print_r( $previous_value, true), '@current' => print_r( $person, true)));
|
||||
//compare it against $person
|
||||
//if $person is now empty, set the person's role to zero
|
||||
if (empty($person) && $previous_value != 0) {
|
||||
$update_messages[] = t("Clearing leader/helper role for nid @id and session @session in group @group. Used to have role @role.",
|
||||
array('@id' => $previous_value, '@group' => $group_id, '@role' => $type_id, '@session' => $session_id));
|
||||
db_update('booking_studygroup_mapping')
|
||||
->fields(array(
|
||||
'booking_studygroup_role' => 0,
|
||||
))
|
||||
->condition('booking_studygroup_id', $group_id)
|
||||
->condition('booking_node_id', $previous_value)
|
||||
->condition('booking_session_id', $session_id)
|
||||
->execute();
|
||||
$counter++;
|
||||
}
|
||||
elseif (!empty($person)) {
|
||||
preg_match('/[\s\w,]+\s\[(\d+)\]/i', $person, $matches);
|
||||
$person_nid = $matches[1];
|
||||
//if $person is now different, run an update query
|
||||
if ($person_nid != $previous_value) {
|
||||
//check if this person is already a member of this studygroup
|
||||
$group_query = db_query("SELECT * FROM {booking_studygroup_mapping} " .
|
||||
"WHERE booking_eventid = :eid AND booking_node_id = :nid AND booking_studygroup_id = :gid",
|
||||
array(':eid' => $event->eid, ':nid' => $person_nid, ':gid' => $group_id))
|
||||
->fetchObject();
|
||||
|
||||
if (! $group_query) {
|
||||
//this person doesn't seem to already be in this study group so insert a record
|
||||
$update_messages[] = t("Adding via insert: role @role to nid @id in group @group and session @session.",
|
||||
array('@id' => $person_nid, '@group' => $group_id, '@role' => $type_id, '@session' => $session_id));
|
||||
db_insert('booking_studygroup_mapping')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
'booking_node_id' => $person_nid,
|
||||
'booking_studygroup_id' => $group_id,
|
||||
'booking_session_id' => $session_id,
|
||||
'booking_studygroup_role' => $type_id,
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
else {
|
||||
//update the role for the new person
|
||||
$update_messages[] = t("Adding via update: role @role to nid @id in group @group and session @session.",
|
||||
array('@id' => $person_nid, '@group' => $group_id, '@role' => $type_id, '@session' => $session_id));
|
||||
db_update('booking_studygroup_mapping')
|
||||
->fields(array(
|
||||
'booking_studygroup_role' => $type_id,
|
||||
'booking_session_id' => $session_id,
|
||||
))
|
||||
->condition('booking_studygroup_id', $group_id)
|
||||
->condition('booking_node_id', $person_nid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
$counter++;
|
||||
//remove the role from the old person if there was someone else there before
|
||||
if ($previous_value != 0) {
|
||||
$update_messages[] = t("Removing role @role from nid @id in group @group and session @session.",
|
||||
array('@id' => $previous_value, '@group' => $group_id, '@role' => $type_id, '@session' => $session_id));
|
||||
db_update('booking_studygroup_mapping')
|
||||
->fields(array(
|
||||
'booking_studygroup_role' => 0,
|
||||
))
|
||||
->condition('booking_studygroup_id', $group_id)
|
||||
->condition('booking_node_id', $previous_value)
|
||||
->condition('booking_session_id', $session_id)
|
||||
->execute();
|
||||
$counter++;
|
||||
} //end previous value check
|
||||
} //end different person check
|
||||
} //end empty person check
|
||||
} //iterate session
|
||||
} //iterate role type
|
||||
|
||||
//do we need to update colours for reading group?
|
||||
if ($form_state['values']['booking_readinggroup'] == 'Y') {
|
||||
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.";
|
||||
drupal_set_message($final_message, 'status', FALSE);
|
||||
watchdog('booking', "<pre>" . $final_message . "\n" . implode("\n", $update_messages) . "</pre>");
|
||||
}
|
||||
|
||||
/**
|
||||
* look through the previous form data and return the matching element
|
||||
*/
|
||||
function _booking_studygroup_leadhelp_edit_get_previous_value(&$form, $type, $name) {
|
||||
foreach($form['form']['studygroups']['#rows'] as $key => $value) {
|
||||
//watchdog('booking_debug', "<pre>Studygroup assignment checker for type !type in session !name:\n@info</pre>",
|
||||
// array('!session' => $name, '!type' => $type, '@info' => print_r( $value, true)));
|
||||
//return;
|
||||
if ((!empty($value[$type]['data']['#value'])) && ($value[$type]['data']['#name'] == $name)) {
|
||||
//found the correct element, extract the node id
|
||||
$person = $value[$type]['data']['#value'];
|
||||
if (preg_match('/[\s\w,]+\s\[(\d+)\]/i', $person, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//in case there was no matching value, return an empty string
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,6 @@ function booking_studygroups_admin() {
|
||||
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes));
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +65,7 @@ function booking_studygroups_view_summary() {
|
||||
$group->booking_is_readinggroup == 'Y' ? 'Yes' : 'No',
|
||||
l(t('Current Membership', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/view', array('!id' => $group->sid))),
|
||||
l(t('Compute Membership Update', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/update', array('!id' => $group->sid))),
|
||||
l(t('Edit Leaders/Helpers', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/selectleaders', array('!id' => $group->sid))),
|
||||
l(t('Edit Leaders/Helpers', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/editleaders', array('!id' => $group->sid))),
|
||||
l(t('Download', array('!id' => $group->sid)), t('admin/booking/studygroups/!id/view/csv', array('!id' => $group->sid))),
|
||||
);
|
||||
}
|
||||
@@ -87,14 +86,12 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
$form = array ();
|
||||
$prefix = "<p>Add a new study group definition</p>";
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
if ($create == true) {
|
||||
drupal_set_title('Add Study Group');
|
||||
$data = $node;
|
||||
watchdog('booking', 'Creating new study group: @info', array ('@info' => var_export($node, TRUE)));
|
||||
watchdog('booking_debug', 'Creating new study group: @info', array ('@info' => var_export($form_state, TRUE)));
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
drupal_set_title('Edit Study Group');
|
||||
//verify that $editid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $editid)) {
|
||||
@@ -104,21 +101,17 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
}
|
||||
|
||||
$data = db_query("SELECT * FROM {booking_studygroup_list} WHERE sid = :id",
|
||||
array(':id' => $editid))
|
||||
->fetchObject();
|
||||
array(':id' => $editid))->fetchObject();
|
||||
$prefix = t("<p>Update the "!event " study group definition.</p>", array('!event' => $data->booking_studygroup_descrip));
|
||||
//add this to the form in a hidden field so we can update the right price
|
||||
$form['booking_sid'] = array (
|
||||
'#type' => 'hidden',
|
||||
'#value' => $editid,
|
||||
);
|
||||
watchdog('booking', 'Editing study group definition: @info',
|
||||
array ('@info' => var_export($data, TRUE)));
|
||||
watchdog('booking_debug', "<pre>Editing study group definition:\n@info</pre>", array ('@info' => print_r($data, TRUE)));
|
||||
}
|
||||
|
||||
|
||||
if(!isset($form_state['storage']['confirm']))
|
||||
{
|
||||
if(!isset($form_state['storage']['confirm'])) {
|
||||
$form['booking_studygroup_descrip'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Description of this study group (eg Monday)'),
|
||||
@@ -144,15 +137,15 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
'#options' => array (0 => t('No'), t('Yes')),
|
||||
'#default_value' => !empty($data->booking_is_readinggroup) ? ($data->booking_is_readinggroup == 'Y' ? 1 : 0) : 0,
|
||||
);
|
||||
|
||||
if ($create == true)
|
||||
{
|
||||
//create the buttons
|
||||
if ($create == true) {
|
||||
$form['submit'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Create Study Group'),
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$form['Update'] = array
|
||||
(
|
||||
'#type' => 'submit',
|
||||
@@ -164,7 +157,7 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
'#value' => t("Delete Study Group Definition"),
|
||||
);
|
||||
}
|
||||
|
||||
//return the render array
|
||||
return array (
|
||||
'first_para' => array (
|
||||
'#type' => 'markup',
|
||||
@@ -174,15 +167,16 @@ function booking_studygroups_define_form($node, &$form_state, $create, $editid =
|
||||
);
|
||||
}
|
||||
//confirm delete
|
||||
else
|
||||
{
|
||||
else {
|
||||
return confirm_form($form, "Are you sure you wish to delete studygroup definition with id " . $editid . "?",
|
||||
current_path(), NULL, "Delete Study Group Definition");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process addition/update/delete of a studygroup definition
|
||||
*/
|
||||
function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
|
||||
global $event;
|
||||
@@ -195,8 +189,7 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
array(':eid' => $event->eid))->fetchObject();
|
||||
|
||||
//watchdog('booking', 'Checkboxes when setting buttons: @info', array ('@info' => var_export($checkboxes, TRUE)));
|
||||
if ($form_state['values']['op'] == 'Create Study Group')
|
||||
{
|
||||
if ($form_state['values']['op'] == 'Create Study Group') {
|
||||
db_insert('booking_studygroup_list')
|
||||
->fields(array(
|
||||
'booking_eventid' => $event->eid,
|
||||
@@ -209,33 +202,27 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
$new_count = $count->num + 1;
|
||||
}
|
||||
//if we're deleting, add the confirmation to the form if it hasn't been defined yet
|
||||
elseif($form_state['values']['op'] == "Delete Study Group Definition" && (!isset($form_state['storage']['confirm'])))
|
||||
{
|
||||
elseif($form_state['values']['op'] == "Delete Study Group Definition" && (!isset($form_state['storage']['confirm']))) {
|
||||
watchdog('booking', "<pre>Studygroup deletion confirmation being set:\n@info</pre>", array('@info' => print_r( $form_state, true)));
|
||||
$form_state['storage']['confirm'] = TRUE;
|
||||
$form_state['rebuild'] = TRUE;
|
||||
|
||||
$new_count = $count->num;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Study Group Definition')
|
||||
{
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Delete Study Group Definition') {
|
||||
//verify that booking_pid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['booking_sid'])) {
|
||||
drupal_set_message("Error: Invalid studygroup ID supplied. Unable to delete entry.", 'error', FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
//TODO: Confirmation
|
||||
//return confirm_form($form, "Really delete price?", 'admin/config/booking/prices');
|
||||
|
||||
|
||||
$num_deleted = db_delete('booking_studygroup_list')
|
||||
->condition('sid', $values['booking_sid'])
|
||||
->execute();
|
||||
|
||||
$new_count = $count->num - 1;
|
||||
}
|
||||
elseif ($form_state['values']['op'] == 'Update Study Group')
|
||||
{
|
||||
elseif ($form_state['values']['op'] == 'Update Study Group') {
|
||||
|
||||
//verify that booking_sid is a number
|
||||
if (! preg_match('/^[0-9]+$/', $values['booking_sid'])) {
|
||||
@@ -259,6 +246,8 @@ function booking_studygroups_define_form_submit($form, &$form_state) {
|
||||
|
||||
//update the number of study groups now defined
|
||||
variable_set('booking_studygroup_count', $new_count);
|
||||
|
||||
//call the mysql view update function so that the view matches the new number of study groups
|
||||
_booking_node_create_mysqlview();
|
||||
//redirect to the specified path now that the form has been processed
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
@@ -38,9 +38,9 @@ function booking_studygroups_csv_report($group_id) {
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
|
||||
//get the list of study group session memberships
|
||||
$session_members_query = db_query("SELECT m.*, p.booking_firstname, p.booking_lastname FROM {booking_studygroup_mapping} m
|
||||
$session_members_query = db_query("SELECT m.*, p.* FROM {booking_studygroup_mapping} m
|
||||
inner join {booking_person} p on p.nid = m.booking_node_id
|
||||
WHERE m.booking_studygroup_id = :sid ORDER BY m.booking_session_id, m.booking_studygroup_role DESC",
|
||||
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();
|
||||
|
||||
@@ -49,12 +49,21 @@ function booking_studygroups_csv_report($group_id) {
|
||||
if (! isset($data[$member->booking_session_id])) {
|
||||
$data[$member->booking_session_id] = array();
|
||||
}
|
||||
// lookup the name and role for this entry in the study group session
|
||||
$text = array($member->booking_firstname, $member->booking_lastname);
|
||||
// lookup the name and role for this entry in the study group session and optionally include age
|
||||
if (variable_get('booking_studygroup_csv_ages', 0) == 1) {
|
||||
$text = array($member->booking_firstname, $member->booking_lastname, '[' . _booking_get_age_years($member->booking_dob) .']');
|
||||
}
|
||||
else {
|
||||
$text = array($member->booking_firstname, $member->booking_lastname);
|
||||
}
|
||||
//add their role if they're leading/helping etc
|
||||
if ($member->booking_studygroup_role > 0) {
|
||||
array_push($text, '(' . _booking_studygroup_role_lookup($member->booking_studygroup_role) . ')');
|
||||
}
|
||||
//also tag committee members
|
||||
if ($member->booking_committee_member == 'Y') {
|
||||
array_push($text, '(committee)');
|
||||
}
|
||||
//add the spaces and put this element in the right array
|
||||
$data[$member->booking_session_id][] = implode(' ', $text);
|
||||
|
||||
@@ -68,7 +77,12 @@ function booking_studygroups_csv_report($group_id) {
|
||||
foreach ($header_array as $column) {
|
||||
$maximums[] = count($data[$column]);
|
||||
//make the column headings a bit more user friendly
|
||||
$column_headings[] = "Session " . $column;
|
||||
if ($group->booking_is_readinggroup == 'Y') {
|
||||
$column_headings[] = _booking_readinggroup_colour_lookup($column);
|
||||
}
|
||||
else {
|
||||
$column_headings[] = "Session " . $column;
|
||||
}
|
||||
}
|
||||
|
||||
//add the column headings to the CSV
|
||||
@@ -99,4 +113,60 @@ function booking_studygroups_csv_report($group_id) {
|
||||
drupal_add_http_header("Content-Disposition", "attachment; filename=" . $name . ".csv");
|
||||
print $csv;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to generate table listing all males and groups they're leading/helping
|
||||
*/
|
||||
function booking_studygroups_leadhelp_view_summary() {
|
||||
global $event;
|
||||
$output = "";
|
||||
$header = array('First Name', 'Last Name');
|
||||
$rows = array();
|
||||
$attributes = array('style' => 'max-width:100%');
|
||||
|
||||
//get study group definitions
|
||||
$query = db_select('booking_studygroup_list', 's')
|
||||
->fields('s')
|
||||
->condition('s.booking_eventid', $event->eid, '=')
|
||||
->orderBy('sid');
|
||||
$studygroup_list = $query->execute()->fetchAllAssoc('sid');
|
||||
|
||||
//add columns for the study groups
|
||||
foreach ($studygroup_list as $group) {
|
||||
$header[] = $group->booking_studygroup_descrip;
|
||||
}
|
||||
|
||||
$person_query = db_query("SELECT * FROM {booking_person_view} WHERE booking_gender = 'M' " .
|
||||
" AND (booking_status = 1 OR booking_status = 2)" .
|
||||
" 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);
|
||||
|
||||
foreach ($studygroup_list as $group) {
|
||||
$session = 'session' . $group->sid;
|
||||
$session_role = 'session' . $group->sid . '_role';
|
||||
//add details if they have a role for this studygroup
|
||||
if ($person->$session_role > 0) {
|
||||
$text = _booking_studygroup_role_lookup($person->$session_role);
|
||||
$newline[] .= "<b>" . $text . "</b>, session #" . $person->$session;
|
||||
}
|
||||
//otherwise put a blank entry for this studygroup
|
||||
else {
|
||||
$newline[] = "";
|
||||
}
|
||||
} //end iterate studygroup list
|
||||
//add the line to the array of rows
|
||||
$rows[] = $newline;
|
||||
} //end iterate person list
|
||||
|
||||
//output everything
|
||||
$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;
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
// $Id: booking.admin.inc,v 0.1 2011/07/12
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -47,50 +46,7 @@ function booking_tokens_admin() {
|
||||
"Even though our registrations have reached maximum capacity, you can still <a href=\"/booking\">register</a> to join the waiting list.</p>\n<br />\n";
|
||||
$booking_waitingpage_pre_nowaitlist_text = "<p>There's no one on the waiting list yet. If you haven't already done so, go ahead and <a href=\"/booking\">register</a>.</p>\n<br />\n";
|
||||
$booking_waitingpage_post_text = "<p></p>\n";
|
||||
|
||||
$default_email_text = "Dear [booking:fname],\n" .
|
||||
"Congratulations, you are officially booked into [booking:eventname]. " .
|
||||
"Your registration reference number is [booking:booking-id].\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\n" .
|
||||
"________________________________________________________\n" .
|
||||
"The following information shows the details you entered when you registered. " .
|
||||
"If any of this information is incorrect, please reply to this email with the corrections as soon as possible.\n" .
|
||||
"________________________________________________________";
|
||||
$booking_email_regn_complete_text = "Dear [booking:fname],\n" .
|
||||
"Thank-you for completing your payment for [booking:eventname].\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\n" .
|
||||
"________________________________________________________\n" .
|
||||
"The following information shows the details you entered when you registered. " .
|
||||
"If any of this information is incorrect, please reply to this email with the corrections as soon as possible.\n" .
|
||||
"________________________________________________________";
|
||||
$booking_email_waitinglist_text = "Dear [booking:fname],\n" .
|
||||
"Thank-you for registering to attend [booking:eventname]. Unfortunately the venue for this event is full, and you have been placed on the waiting list to attend.\n" .
|
||||
"We will contact you if a position becomes available for you. Please don't hesitate to contact us if you have any queries by replying to this email.\n" .
|
||||
"Love in Jesus,\n[booking:eventname] Registrations Team\n" .
|
||||
"________________________________________________________\n" .
|
||||
"The following information shows the details you entered when you registered. " .
|
||||
"If any of this information is incorrect, please reply to this email with the corrections as soon as possible.\n" .
|
||||
"________________________________________________________";
|
||||
$booking_email_paymentoutstanding_text = "Dear [booking:fname],\n" .
|
||||
"Thank-you for registering to attend [booking:eventname]. Our records indicate that you currently have $[booking:payment-required] outstanding to finalise your registration.\n" .
|
||||
"Please visit [booking:balance-payment-link] in order to make your final payment.\n" .
|
||||
"Love in Jesus,\n[booking:eventname] Registrations Team\n" .
|
||||
"________________________________________________________\n";
|
||||
$booking_email_waitinglistpromotion = "Dear [booking:fname],\n" .
|
||||
"We have some great news for you. A place at [booking:eventname] for you has just become available. " .
|
||||
"If you wish to secure your place at [booking:eventname], please visit [booking:balance-payment-link] to make your final payment. " .
|
||||
"Our records indicate that you currently have $[booking:paypal-total-amount] outstanding (including Paypal transaction fees).\n" .
|
||||
"Once we have received your payment, you will be sent an automatic confirmation email thanking you for paying your outstanding fees. " .
|
||||
"If you are paying via Paypal's eCheque feature, please be aware that payments take 3-5 working days to clear, " .
|
||||
"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_notcoming_demotion = "";
|
||||
$booking_email_paymentoutstanding_married_text = "";
|
||||
|
||||
$booking_confirmation_text = "<p>Thanks for filling out the registration form.</p>\n" .
|
||||
"<p>To complete your booking, please make a payment of <strong>$[booking:payment-required]</strong> into the following bank account<br />\n" .
|
||||
" Account Name: blah<br />\n BSB: blah<br />\n Account Number: blah</p>\n" .
|
||||
@@ -193,17 +149,7 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_regn_confirm_married_text', $booking_regn_confirm_married_text),
|
||||
);
|
||||
//$booking_regn_completed_page_default = variable_get('booking_regn_completed_page');
|
||||
//$booking_regn_completed_page = isset($booking_regn_completed_page_default['value']) ? $booking_regn_completed_page_default['value'] : '';
|
||||
$form['confirmation']['booking_regn_completed_page'] = array(
|
||||
'#title' => t('Text to use for landing page on return from paypal website'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
//'#default_value' => $booking_regn_completed_page,
|
||||
'#default_value' => isset(variable_get('booking_regn_completed_page')['value']) ? variable_get('booking_regn_completed_page')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
|
||||
/*Text for the balance payment page*/
|
||||
$form['balance'] = array(
|
||||
'#type' => 'fieldset',
|
||||
@@ -311,6 +257,40 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
$form['travel']['booking_travelform_page'] = array(
|
||||
'#title' => t('Text to use at the start of the travel form for a non-married person.'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_travelform_page')['value']) ? variable_get('booking_travelform_page')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
$form['travel']['booking_travelform_married_page'] = array(
|
||||
'#title' => t('Text to use at the start of the travel form for a married couple. Only applies if combined pricing is enabled.'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_travelform_married_page')['value']) ? variable_get('booking_travelform_married_page')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
$form['travel']['booking_travelform_page_post_text'] = array(
|
||||
'#title' => t('Text to use at the end of the travel form. This is not displayed on the "travel form completed" page defined below.'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_travelform_page_post_text')['value']) ? variable_get('booking_travelform_page_post_text')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
$form['travel']['booking_travelform_completed_page'] = array(
|
||||
'#title' => t('Text to use on the travel form if the form has already been submitted.'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => isset(variable_get('booking_travelform_completed_page')['value']) ? variable_get('booking_travelform_completed_page')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
|
||||
/*
|
||||
$form['travel']['booking_travelform_page'] = array(
|
||||
'#title' => t('Text to use at the start of the travel form for a non-married person.'),
|
||||
'#type' => 'textarea',
|
||||
@@ -322,172 +302,34 @@ $booking_registration_intro_text = variable_get('booking_registration_intro_text
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_travelform_married_page', ''),
|
||||
);
|
||||
);
|
||||
$form['travel']['booking_travelform_completed_page'] = array(
|
||||
'#title' => t('Text to use on the travel form if the form has already been submitted.'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get('booking_travelform_completed_page', ''),
|
||||
);
|
||||
*/
|
||||
|
||||
/*Text for emails*/
|
||||
$form['emails'] = array(
|
||||
//other pages like paypal landing page
|
||||
$form['otherpages'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Built-In Workflow Email Definitions',
|
||||
'#title' => 'Miscellaneous pages',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
$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]'),
|
||||
);
|
||||
$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),
|
||||
);
|
||||
$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),
|
||||
);
|
||||
$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),
|
||||
);
|
||||
$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', ''),
|
||||
);
|
||||
$form['emails']['booking_email_paymentoutstanding_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Balance Outstanding Email Subject'),
|
||||
'#description' => t('Subject line for email advising attendee they missed the payment deadline'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_paymentoutstanding_subject','[booking:eventname] payment required'),
|
||||
);
|
||||
$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),
|
||||
);
|
||||
|
||||
$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),
|
||||
);
|
||||
$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),
|
||||
);
|
||||
$form['emails']['booking_email_notcoming_demotion_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Withdrawal Processed Email'),
|
||||
'#description' => t('Subject line for email advising attendee their withdrawal has been processed'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_notcoming_demotion_subject','[booking:eventname] withdrawal processed'),
|
||||
);
|
||||
$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),
|
||||
);
|
||||
$form['emails']['booking_email_missedpayment_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Missed Payment Email Subject'),
|
||||
'#description' => t('Subject line for email advising attendee they missed the payment deadline'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_missedpayment_subject','[booking:eventname] payment deadline missed'),
|
||||
);
|
||||
$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', ''),
|
||||
);
|
||||
$form['emails']['booking_email_travel_required_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Travel Form Required Subject'),
|
||||
'#description' => t('Subject line for email requesting attendee to complete the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_required_subject','[booking:eventname] Travel Details Required'),
|
||||
);
|
||||
$form['emails']['booking_email_travel_required_text'] = array(
|
||||
'#title' => t('Travel Form Required Text'),
|
||||
'#description' => t('Email text 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_required_text', ''),
|
||||
);
|
||||
$form['emails']['booking_email_travel_complete_subject'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Travel Form Complete Subject'),
|
||||
'#description' => t('Subject line for email indicating a person has completed the travel form'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get('booking_email_travel_complete_subject','[booking:eventname] Travel Details Received'),
|
||||
);
|
||||
$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', ''),
|
||||
);
|
||||
|
||||
/*Text for emails*/
|
||||
$form['custom-emails'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Custom Email Text Definitions',
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
//add a bunch of custom emails
|
||||
for ($i = 1; $i <= variable_get('booking_custom_email_count','5'); $i++)
|
||||
{
|
||||
$subject_fieldname = 'booking_email_subject_custom' . $i;
|
||||
$body_fieldname = 'booking_email_custom' . $i;
|
||||
$form['custom-emails'][$subject_fieldname] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Custom Email ' . $i),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#default_value' => variable_get($subject_fieldname,'[booking:eventname]'),
|
||||
);
|
||||
$form['custom-emails'][$body_fieldname] = array(
|
||||
'#title' => t('Email text for custom email ' . $i),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
'#default_value' => variable_get($body_fieldname, ''),
|
||||
);
|
||||
|
||||
}
|
||||
//$booking_regn_completed_page_default = variable_get('booking_regn_completed_page');
|
||||
//$booking_regn_completed_page = isset($booking_regn_completed_page_default['value']) ? $booking_regn_completed_page_default['value'] : '';
|
||||
$form['otherpages']['booking_regn_completed_page'] = array(
|
||||
'#title' => t('Text to use for landing page on return from paypal website'),
|
||||
'#type' => 'textarea',
|
||||
'#description' => t(''),
|
||||
//'#default_value' => $booking_regn_completed_page,
|
||||
'#default_value' => isset(variable_get('booking_regn_completed_page')['value']) ? variable_get('booking_regn_completed_page')['value'] : $defaults,
|
||||
'#type' => 'text_format',
|
||||
'#format' => 'full_html',
|
||||
);
|
||||
|
||||
//see http://drupal.org/node/820816#comment-3100356
|
||||
//and http://drupal.org/node/823362
|
||||
@@ -539,6 +381,10 @@ function booking_token_info() {
|
||||
'name' => t('Event Contact Email'),
|
||||
'description' => t('Contact email address for the current event.')
|
||||
);
|
||||
$info['tokens']['booking']['logistics-email'] = array(
|
||||
'name' => t('Event Logistics Email'),
|
||||
'description' => t('Logistics email address for the current event.')
|
||||
);
|
||||
$info['tokens']['booking']['eventdates'] = array(
|
||||
'name' => t('Event Dates'),
|
||||
'description' => t('Dates of the current event.')
|
||||
@@ -575,6 +421,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.')
|
||||
@@ -590,6 +440,26 @@ 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.')
|
||||
);
|
||||
$info['tokens']['booking']['stripe-total-form'] = array(
|
||||
'name' => t('Stripe Total Form Button'),
|
||||
'description' => t('The stripe popup form for the total amount.')
|
||||
);
|
||||
$info['tokens']['booking']['booking-id'] = array(
|
||||
'name' => t('Booking ID'),
|
||||
@@ -696,6 +566,7 @@ function booking_define_tokens()
|
||||
date("Y-m-d", $booking_times->booking_event_end));
|
||||
$tokens['contact-us'] = l('contact us', 'contact-us');
|
||||
$tokens['contact-email'] = variable_get('booking_contact_email');
|
||||
$tokens['logistics-email'] = variable_get('booking_logistics_email');
|
||||
$tokens['regn-count'] = $regncount_query->num_ppl;
|
||||
$tokens['regn-limit'] = variable_get('booking_regn_limit',0);
|
||||
return $tokens;
|
||||
@@ -711,6 +582,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
|
||||
@@ -740,34 +612,84 @@ function booking_define_personspecific_tokens($node)
|
||||
$tokens = array();
|
||||
$tokens['eventname'] = $event->booking_eventname;
|
||||
$tokens['contact-email'] = variable_get('booking_contact_email');
|
||||
$tokens['logistics-email'] = variable_get('booking_logistics_email');
|
||||
$tokens['team-colour'] = ucwords($node->booking_readinggroup);
|
||||
$tokens['fname'] = ucwords(trim($node->booking_firstname));
|
||||
$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);
|
||||
|
||||
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);
|
||||
|
||||
// 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-summary'] = _booking_travelform_email_summary($node);
|
||||
// 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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
1348
booking.travel.inc
1348
booking.travel.inc
File diff suppressed because it is too large
Load Diff
@@ -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,
|
||||
);
|
||||
|
||||
}
|
841
booking.variety_admin.inc
Normal file
841
booking.variety_admin.inc
Normal file
@@ -0,0 +1,841 @@
|
||||
<?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 ();
|
||||
$result = db_query("SELECT * from {booking_variety_timeslots}");
|
||||
|
||||
$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' => $event->booking_eventname,
|
||||
'tid' => $data->tid,
|
||||
'booking_variety_time_descrip' => $data->booking_variety_time_descrip,
|
||||
'booking_variety_status' => $data->booking_variety_status == 1 ? "Enabled" : "Disabled",
|
||||
'booking_variety_start' => date("Y-m-d H:i", $data->booking_variety_start),
|
||||
'booking_variety_end' => date("Y-m-d H:i", $data->booking_variety_end),
|
||||
'variety_edit' => l('Edit Timeslot', t('admin/config/booking/variety/!tid/edit', array('!tid' => $data->tid))),
|
||||
'variety_session_list' => l('List Sessions', t('admin/config/booking/variety/!tid/session/list', array('!tid' => $data->tid))),
|
||||
'variety_session_add' => l('Add Session', t('admin/config/booking/variety/!tid/session/create', array('!tid' => $data->tid))),
|
||||
'variety_session_csv' => l('CSV Report', t('admin/config/booking/variety/!tid/csv', array('!tid' => $data->tid))),
|
||||
);
|
||||
}
|
||||
|
||||
$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 = "<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_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/config/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 = "";
|
||||
|
||||
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/config/booking/variety');
|
||||
return "";
|
||||
}
|
||||
//verify that $session_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $session_id)) {
|
||||
drupal_set_message("Error: Invalid session ID supplied. Unable to update specified variety session.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
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,
|
||||
),
|
||||
);
|
||||
|
||||
//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',
|
||||
);
|
||||
|
||||
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'];
|
||||
$redirect_path = "admin/config/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/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_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/config/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/config/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();
|
||||
|
||||
//verify that $timeslot_id is a number
|
||||
if (! preg_match('/^[0-9]+$/', $timeslot_id)) {
|
||||
drupal_set_message("Error: Invalid variety session timeslot ID '" . $group_id . "' supplied.", 'error', FALSE);
|
||||
drupal_goto('admin/config/booking/variety');
|
||||
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/config/booking/variety');
|
||||
return "";
|
||||
}
|
||||
|
||||
//set options for the CSV file
|
||||
$name = 'bookings-timeslot-' . $timeslot_id . '-variety-sessions-' . format_date(time(), 'custom', 'Y-m-d-His');
|
||||
$filename = file_directory_temp() . '/' . $name;
|
||||
$csv = '';
|
||||
$delimiter = ',';
|
||||
$enclosure = '"';
|
||||
$encloseAll = true;
|
||||
$nullToMysqlNull = true;
|
||||
$delimiter_esc = preg_quote($delimiter, '/');
|
||||
$enclosure_esc = preg_quote($enclosure, '/');
|
||||
|
||||
//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();
|
||||
|
||||
watchdog('booking_debug', 'booking_varietysessions_csv_report session members: <pre>@info</pre>', array('@info' => print_r( $session_members, true)));
|
||||
|
||||
//generate the row data
|
||||
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
|
||||
$sid = $session_ids[$timeslot_id];
|
||||
|
||||
if (! isset($data[$sid])) {
|
||||
$data[$sid] = array();
|
||||
}
|
||||
$text = array($member->booking_firstname, $member->booking_lastname);
|
||||
|
||||
//add the spaces and put this element in the right array
|
||||
$data[$sid][] = implode(' ', $text);
|
||||
|
||||
}
|
||||
//watchdog('booking_debug', "<pre>Study Group CSV Report\n@info</pre>", array('@info' => print_r( $data_array, true)));
|
||||
|
||||
//calculate the CSV layout
|
||||
$header_array = array_keys($data);
|
||||
$maximums = array();
|
||||
$column_headings = array();
|
||||
foreach ($header_array as $column) {
|
||||
$maximums[] = count($data[$column]);
|
||||
//make the column headings a bit more user friendly
|
||||
$column_headings[] = $variety_sessions[$column]->booking_variety_descrip;
|
||||
}
|
||||
|
||||
//add the column headings to the CSV
|
||||
$header = implode($delimiter, $column_headings);
|
||||
$csv .= $header . "\n";
|
||||
|
||||
//generate each row for the CSV
|
||||
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
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/config/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/config/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 and compare them
|
||||
$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
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// 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']));
|
||||
|
||||
$form_state['redirect'] = $redirect_path;
|
||||
}
|
||||
}
|
238
booking.variety_form.inc
Normal file
238
booking.variety_form.inc
Normal file
@@ -0,0 +1,238 @@
|
||||
<?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;
|
||||
|
||||
// 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['identity'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => 'Select Person',
|
||||
);
|
||||
|
||||
$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 : '',
|
||||
'#ajax' => array(
|
||||
'event' => 'change',
|
||||
'wrapper' => 'booking_variety_session_fieldset_wrapper',
|
||||
'callback' => 'booking_variety_session_form_callback',
|
||||
),
|
||||
);
|
||||
|
||||
$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($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]";
|
||||
}
|
||||
}
|
||||
//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) {
|
||||
$form_state['rebuild'] = TRUE;
|
||||
return $form['form']['variety-sessions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'], '=');
|
||||
|
||||
$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.'));
|
||||
}
|
||||
|
||||
// --- 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 |
342
theme/mimemail-message-registration_mail.tpl.php
Normal file
342
theme/mimemail-message-registration_mail.tpl.php
Normal file
@@ -0,0 +1,342 @@
|
||||
<!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_text_color'] ?>; font-family:Verdana, Geneva, sans-serif; font-size:18px;">
|
||||
<![endif]-->
|
||||
<a href="<?php print $linkitem['link'] ?>" target="_blank" style="display: inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: <?php print $colors['booking_mailtemplate_text_color'] ?>;background-color: transparent;border-radius: 4px;-webkit-border-radius: 4px;-moz-border-radius: 4px;max-width: 165px;width: auto;border-top: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-left: 0px solid transparent;padding-top: 5px;padding-right: 20px;padding-bottom: 5px;padding-left: 20px;font-family: Verdana, Geneva, sans-serif;mso-border-alt: none">
|
||||
<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]-->
|
||||
|
||||
|
||||
|
||||
|
||||
<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'])) : ?>
|
||||
<!--[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