mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-06 20:28:25 +00:00
Compare commits
840 Commits
feature-ad
...
deploy/qui
| Author | SHA1 | Date | |
|---|---|---|---|
| 96d302ccf7 | |||
|
|
0b5daa6c33 | ||
| 662e5f967c | |||
| 802125edc6 | |||
| 028c3e0c31 | |||
| e4adafafc8 | |||
| 54316d148c | |||
| 3c5a2a65df | |||
| 741ef7b40d | |||
| e7384343b2 | |||
| 1e2a920200 | |||
| b5a78fa341 | |||
| d9c1f52894 | |||
|
|
f05f7415bd | ||
|
|
5553c7314c | ||
| 7dc70baf57 | |||
|
|
34af401a98 | ||
| 5bae8dc5bf | |||
| 6e277e99ae | |||
| 2688c0f0ce | |||
|
|
0135f5184e | ||
| fd698419e8 | |||
| 4a864a0b14 | |||
| 55dc0d3f9f | |||
| 85835c8b0d | |||
|
|
ab1edee9fb | ||
| 6154e0912b | |||
| 0388428c6f | |||
| 7ac55275c2 | |||
| 1119e20a49 | |||
| ea2870eef8 | |||
|
|
93a44d8303 | ||
|
|
8109415e05 | ||
|
|
514fe6163a | ||
| 9d9be7f831 | |||
|
|
4cf3cc8353 | ||
| 2a974e1269 | |||
| beca41774e | |||
| dd991e3572 | |||
| 0640631821 | |||
| e845d9ba90 | |||
|
|
6f8231f6f6 | ||
|
|
048161e300 | ||
| b705c5910f | |||
| 6f1209eaf5 | |||
| 020759180b | |||
| 3748b4fbf4 | |||
|
|
4f49292178 | ||
| 6eaffcae49 | |||
|
|
f92d710a26 | ||
|
|
bc6ba88acd | ||
| 61c2934d64 | |||
| 28b4d9562c | |||
| e06aded1ec | |||
| 3a81124e04 | |||
|
|
b72d45d9db | ||
| 2a1f5cbad1 | |||
| e8566fd006 | |||
| cd6b5c9a39 | |||
| 9aa3974071 | |||
| a8bf478ee8 | |||
| a35f3363b2 | |||
| 0b117e5158 | |||
| 7cae9e1769 | |||
| a43e6c12a0 | |||
| abe012de60 | |||
| aaa9a1ec7b | |||
| 25f2d17097 | |||
| 4fd43310c0 | |||
| c85ca894b8 | |||
| fe22e6c7dc | |||
| cb67605bd2 | |||
| d26e08324c | |||
| e55a2691b7 | |||
|
|
aa5c7f333e | ||
| 0afe277b04 | |||
| 981b9299ad | |||
|
|
36eb247995 | ||
| 2cda6ceebf | |||
| 1ceabec400 | |||
|
|
91c5cd74f7 | ||
|
|
b7f2e189dc | ||
|
|
ab8deb036b | ||
|
|
ac47a75a75 | ||
|
|
4e6454d7de | ||
| 92a95d4186 | |||
|
|
c23ada3533 | ||
| b72b1bd4c7 | |||
| ca9ae3874c | |||
| 7fb4616aa6 | |||
| ac4cf43753 | |||
| 5a4a0a3617 | |||
| 2cc1274ee0 | |||
| 154fa4719d | |||
| 193e7b4c7e | |||
| 80c2bd285f | |||
| 133c0ac1ac | |||
| c8d5c2c67b | |||
| 0754d20622 | |||
| 99d6e030ca | |||
| 5d38d193e2 | |||
| 86f7b116a9 | |||
| bcab5a1211 | |||
| 65a6607112 | |||
| 1cd376bf86 | |||
| 84f6f9b44d | |||
| b53f6af8d8 | |||
| 34d6452286 | |||
| c04ccef4cd | |||
|
|
d8afbc4a40 | ||
| 95edbc673c | |||
| 07ffdfab86 | |||
| 50be29308d | |||
| d1e0d997ac | |||
|
|
504b2efacf | ||
| 4c3c67344a | |||
| 40fcb09082 | |||
| aa4a9e874a | |||
| 3abfdbf6fd | |||
| 07cc394abd | |||
| 99337c4aa6 | |||
| 04ccca092b | |||
|
|
b3792f6714 | ||
| e1f01a47f8 | |||
| dc79e1a02d | |||
| 7a6117a264 | |||
|
|
1a204312f3 | ||
| 1b1a25edc4 | |||
| 5ab7f7a37b | |||
| b174397823 | |||
| 9d35e4efbb | |||
| 0e9933ca41 | |||
|
|
3d14f00cac | ||
| 0add757230 | |||
| 2bf65dfadb | |||
| a7ecd08d78 | |||
|
|
bccaf5ad6e | ||
| 585a19e803 | |||
| b801b75eb9 | |||
| f1120af59e | |||
| 9d58356b90 | |||
| a7131653c9 | |||
| 9f3cd943cb | |||
|
|
970635dfad | ||
|
|
c8297b2230 | ||
| 994cce41e5 | |||
| 86e41fb877 | |||
| f8b97b96f4 | |||
| 27907e7558 | |||
|
|
38712de462 | ||
| fd7c7388d9 | |||
| ef55d2cf7f | |||
|
|
8406c30c8e | ||
|
|
901ae47ce6 | ||
|
|
951160982d | ||
|
|
e2633a2a79 | ||
|
|
1cfc29caf7 | ||
|
|
5b72eeb147 | ||
|
|
1b9d8fab61 | ||
|
|
801af209a1 | ||
|
|
06daf35e96 | ||
| 38bff2e42f | |||
| e68a5405a1 | |||
| 8bd20c9c78 | |||
| 54997e5893 | |||
|
|
35d35c9f40 | ||
|
|
49d022ef55 | ||
| 78ca61c82e | |||
| b68de1f2e9 | |||
| 68ecff253a | |||
|
|
db545f9fe6 | ||
|
|
86d764c097 | ||
|
|
cf8b9ec172 | ||
|
|
23528e7a5c | ||
|
|
a258905c59 | ||
|
|
84913553e8 | ||
|
|
916209e402 | ||
|
|
3ec212df93 | ||
| e95d8fbc7a | |||
|
|
ce88fe158f | ||
| efdfd10e49 | |||
|
|
000ae6c2cb | ||
|
|
7c26f0a56c | ||
| f827e50431 | |||
| 41617295c1 | |||
| b2c1d75fc5 | |||
| 17c3ecbabe | |||
| de024b405f | |||
| 51399b21b9 | |||
| c40019da8f | |||
| 1df759e970 | |||
|
|
92b4adc113 | ||
| 807d3674fc | |||
| af740fd87d | |||
| 45dc8ed661 | |||
| ecc8b929ca | |||
|
|
c378f59f5a | ||
| 4fd6d38187 | |||
|
|
f3a7556bca | ||
|
|
14db7265fe | ||
|
|
f22461af1b | ||
|
|
1b709d39a4 | ||
|
|
81e8a4562b | ||
|
|
1e72247546 | ||
|
|
670ba1713a | ||
|
|
5daf5cbe84 | ||
|
|
331cdf13ca | ||
| f25365f651 | |||
| cbadcb4980 | |||
| b2ce5fca38 | |||
| 38c06977ca | |||
|
|
1551ea796d | ||
| 3e39dd9a1e | |||
| 89734c680c | |||
|
|
4c025184b4 | ||
| 6fed008ff2 | |||
| 057bdf6a6a | |||
|
|
6f2c219e3b | ||
|
|
550aaacaab | ||
| f9758eff5b | |||
| abc79249a2 | |||
| f7bb9ac327 | |||
| 3c727d1c65 | |||
| ac211337d6 | |||
| 30668ca67f | |||
| 5da0be24ff | |||
|
|
dd78e9759c | ||
|
|
1b36d9b1ab | ||
| 7fddf1d5e0 | |||
| 315fc7f63a | |||
| 3c889db41a | |||
| 71f794c4d9 | |||
| e135b98072 | |||
| e14205ae1d | |||
|
|
e14a125bf3 | ||
| 8a5650a705 | |||
| 18217f53e8 | |||
| 79ec182ca3 | |||
| 1433af8e95 | |||
| e91596ae12 | |||
|
|
9375c2cf86 | ||
|
|
db77224b9f | ||
| 1c42bf6400 | |||
| c9da72fa0d | |||
| 3b3855089c | |||
| 265ace0b4c | |||
| 0e1bbbfee9 | |||
| ebf896ac74 | |||
| 31befaa339 | |||
| 780c14cfbe | |||
| 8183c028f8 | |||
| 97bba861c9 | |||
| 8d7d170f11 | |||
| c126f680ae | |||
|
|
6a42edd460 | ||
| 0aa909f060 | |||
| f27957e91b | |||
| ed891b224f | |||
|
|
76d945f2a7 | ||
|
|
7d13bc7cfe | ||
|
|
66b54bad31 | ||
|
|
9d32ccbcad | ||
| 4dc82bc207 | |||
| 2384281532 | |||
| 7c94824c20 | |||
| a922e397f8 | |||
| be13f8f65b | |||
| 12f83abccc | |||
|
|
63c3b5a970 | ||
| 1967d6ea4c | |||
| 5cb076495a | |||
|
|
03a7ec389b | ||
| 604e78f35e | |||
|
|
f39fe05dd5 | ||
| eeffa3191e | |||
|
|
6c126b0581 | ||
| 84d5fb936e | |||
|
|
5ee824d1c2 | ||
| 7933aaed1c | |||
|
|
6d20476b81 | ||
|
|
2b5ed5e5a3 | ||
| 0fe70d00ec | |||
| e5905902cc | |||
| 48e5809008 | |||
| a947634f30 | |||
| 3e3c9dc894 | |||
| 574b5dcbd0 | |||
| c1ba892811 | |||
|
|
6f68349f57 | ||
|
|
d513be2fce | ||
|
|
7a33c37b51 | ||
|
|
a6c4b4eb55 | ||
|
|
160c7f2c31 | ||
|
|
aff140230c | ||
|
|
31468aeae0 | ||
| 3e57ff3ffa | |||
| 6cbbce03c4 | |||
|
|
e52c94aabd | ||
| ef98111a2f | |||
| 55fa16ce56 | |||
|
|
7e1b7b7e9f | ||
|
|
39dca2a9ca | ||
| 80ccb76794 | |||
|
|
878ee5d9c7 | ||
|
|
541fe8f1ad | ||
|
|
bb71b9f908 | ||
|
|
7b67ef5db2 | ||
| 330234981c | |||
| a323e84357 | |||
| c33f577f5a | |||
|
|
0ce814cf52 | ||
|
|
d806a074a7 | ||
|
|
14a9d9c739 | ||
| 502a629dc8 | |||
| 4ace2fef99 | |||
|
|
4a1ebc1c4c | ||
|
|
4553051271 | ||
|
|
743d6cd0bf | ||
|
|
0f635ca51a | ||
| 987815471c | |||
| d9a3e117b2 | |||
|
|
f6d4d32ce4 | ||
| 937be1af3a | |||
| 32b3d74a1b | |||
|
|
43fb020272 | ||
|
|
f26fafb2f2 | ||
|
|
e1e3051d00 | ||
|
|
a659263af6 | ||
|
|
9333b6d2df | ||
| 4d0cfbb396 | |||
| e9caa7b4b8 | |||
| 261acdfd24 | |||
| 17481798fb | |||
| edb8aa1dfe | |||
| 93a67c9ab9 | |||
| 980a305456 | |||
| 0158c6f2ed | |||
| ff5b0bc258 | |||
| a133f56dce | |||
|
|
c4e226d0bd | ||
| fa556bbba1 | |||
| e8f3c499ee | |||
| cfd9f1bab1 | |||
| c6949490a4 | |||
|
|
8011293b28 | ||
|
|
7992f09aea | ||
| abede56d68 | |||
| 9ab032c943 | |||
| 4562ed46db | |||
| cd52f7e6e8 | |||
| 126ffc55bf | |||
| f49c54d51f | |||
| 1410213258 | |||
| 35e0b98687 | |||
| 8f1091b8a3 | |||
| c269bfe278 | |||
| 041b1dfc51 | |||
| 718d6c2375 | |||
| 158b572879 | |||
| 68059a9938 | |||
| 543f6b20dd | |||
| e95d756e71 | |||
| 992734bb72 | |||
| 741ed84918 | |||
| 5822736f19 | |||
| 66776eed01 | |||
| ace3b1969e | |||
| edc86af659 | |||
| e123ee5d03 | |||
| 87ba68971c | |||
| 94bcbac06a | |||
| 74520330b1 | |||
| 666c1e7ae7 | |||
|
|
935006eae3 | ||
| 622c254cc4 | |||
| a19fd51600 | |||
|
|
165012b302 | ||
|
|
057db09847 | ||
| 56242f9b5a | |||
| 549f3a4c78 | |||
| 9ec2a62fb6 | |||
| 65ac9a47b4 | |||
| b1d7e543fc | |||
| b89cffce68 | |||
|
|
063076d0cb | ||
|
|
bcf2b9d834 | ||
| 968e6914b2 | |||
| 52ee8c5a9a | |||
|
|
64d28106c8 | ||
| 0a5d20b16f | |||
| 85dda8b680 | |||
| 2c49afe549 | |||
| 2e1201418a | |||
| a9fb916843 | |||
| 6631e853b4 | |||
| e26e3ac67b | |||
| 562c72f7bb | |||
| 6602e1b286 | |||
| b69aaeafd9 | |||
| aa473b5f70 | |||
| 124e36b9d4 | |||
| b88765c344 | |||
| f3427d6754 | |||
| df00ac66f5 | |||
| 2b12e61fbd | |||
| 151e8deaeb | |||
| acbe93f9cf | |||
| 358410cde1 | |||
| 06c74ed5ed | |||
| 25c986cc61 | |||
| cad8174333 | |||
| 6c8f1f77ff | |||
| 75c586fbf8 | |||
| 2cb9dfc250 | |||
| 3b2d4142c1 | |||
| 9a6bab7ba2 | |||
| c2bbee299c | |||
| f4db9be557 | |||
| 5449efdd97 | |||
| 7896d288e7 | |||
| b98d6fa505 | |||
| e4d1b951a3 | |||
| ae8e5bc2e3 | |||
| 9b66f7a83f | |||
|
|
13d5b7078e | ||
| 37996651c4 | |||
|
|
679665d9db | ||
|
|
1d4edd5b7b | ||
|
|
f1c77277f3 | ||
| 6264171c0c | |||
| 902d8b52d3 | |||
| caeb75ce13 | |||
| 2f27674e05 | |||
| ce9070e641 | |||
| 5350a09951 | |||
| 31252461c9 | |||
| 73790db700 | |||
|
|
72795be040 | ||
| fc2a2da75f | |||
|
|
e88e9b1a6f | ||
|
|
f7dea7f041 | ||
|
|
57a35f88be | ||
|
|
1b1eb45d15 | ||
|
|
65859f62f3 | ||
|
|
4cc308c936 | ||
|
|
2f28cb16ef | ||
|
|
73ee77b8b2 | ||
|
|
830cda64e0 | ||
|
|
3bc510d116 | ||
|
|
5f8a506c84 | ||
|
|
bbb9dc2561 | ||
|
|
b51575fc49 | ||
|
|
fee37b5af3 | ||
|
|
0afcf3d79e | ||
|
|
743b456030 | ||
| 0dbd42ba5b | |||
| 7efbf2fce8 | |||
| 9b1a66c992 | |||
|
|
cb897cfef1 | ||
|
|
bafbc2dd74 | ||
| 74541f360b | |||
| 20a14c9ff4 | |||
| cdade50d76 | |||
| d4f96ee25f | |||
| ca33580831 | |||
| 64e37c5235 | |||
| bf576e171c | |||
| 3f2fe6a138 | |||
| f18ccce814 | |||
| 2386a35eb7 | |||
| 1fbda740a7 | |||
| d35e1fe21e | |||
| 771b9eb616 | |||
| 4261ddcde4 | |||
| 6ee03b7ebb | |||
| 1217578202 | |||
| c7b6788288 | |||
| 02f1d2ff8a | |||
| bb677152c9 | |||
| ad6519fb87 | |||
| d08f2e0e11 | |||
| 73aeca0916 | |||
| 080a54231f | |||
| b403569b16 | |||
| 3abfb02962 | |||
| 11a6d08023 | |||
| 69ecc42055 | |||
| 5f74c5297a | |||
| 34fcefa1bd | |||
| c9e6935f15 | |||
| 21cc0007fb | |||
| ebe3bc5f7b | |||
| 132f11298e | |||
| 21f75c8a63 | |||
| c1e1f65715 | |||
|
|
5cc5e6a1f7 | ||
|
|
1f4735caac | ||
|
|
d672a29dda | ||
| 68ebd60bc8 | |||
| 4d12796289 | |||
| 857298b8b8 | |||
| 220f1ea0eb | |||
| a88acd34fd | |||
| 8ae113c872 | |||
| 098a2ea620 | |||
| 6a62b46dec | |||
|
|
2bae684df9 | ||
| 8bd75429c1 | |||
|
|
8fe00b4c2b | ||
| 199e5a73d8 | |||
| 54d03275cf | |||
| 8683f8faf3 | |||
| 821b67723c | |||
| ae1146c79c | |||
| 050c325195 | |||
| 5e0d869d9b | |||
|
|
c59cf3f0df | ||
|
|
890b8db5dd | ||
| 32b8de8997 | |||
| 9f1f7ad3f7 | |||
| 9da4c1ebeb | |||
| 9b7a52064a | |||
| faad3f5f47 | |||
|
|
7595d70ada | ||
|
|
484259c8ab | ||
|
|
a6e0b16032 | ||
|
|
9d34968b88 | ||
| f548121312 | |||
| 1ecb1abc80 | |||
| 28a45992c6 | |||
| c39097f164 | |||
| 30b127bc88 | |||
| 25d7fc36a4 | |||
| 03bd1674e1 | |||
| b018a50a7e | |||
| 4440cf8a24 | |||
| 6bd7a0105d | |||
|
|
51c2408878 | ||
| 242c77a30c | |||
| 22aa4afc02 | |||
| 04e9e30972 | |||
| d536da3581 | |||
| 27f49b2aa3 | |||
| 912a8d53af | |||
| 9ef397e935 | |||
| eca8172c6d | |||
| f3802e36b3 | |||
| 2f9c7c38b5 | |||
|
|
d73fd697dd | ||
| f35889339d | |||
| 8e95166c24 | |||
| 30c53b17f7 | |||
| 2610730219 | |||
| 5dd99d201b | |||
| d327dae9fa | |||
| 2bdbb20154 | |||
| 14bd211a5f | |||
| 35627203e6 | |||
| f978636d57 | |||
| e095cac7e0 | |||
| c5b0d6e2bd | |||
|
|
905cb66011 | ||
| eaac97221f | |||
|
|
893c38fba4 | ||
|
|
f867f4985d | ||
|
|
aebeefcf80 | ||
|
|
3fc6c0c479 | ||
|
|
ce854cb58f | ||
|
|
ed4f1344c2 | ||
|
|
86dbe527d8 | ||
|
|
69a56fb433 | ||
|
|
a7fad0ca1b | ||
|
|
9b8c34a9be | ||
| 5acc78507e | |||
| 1722cf721e | |||
| 75ba07f181 | |||
| 5b635fbe58 | |||
| e0dc0a8fdb | |||
| 2aa13dceff | |||
| ea477a9842 | |||
| 73653744d7 | |||
| 55264da092 | |||
| 38f5854c6d | |||
| 3c6d3f30d2 | |||
| a6d6a962cd | |||
| 6256d6a19e | |||
| 8841af8d2b | |||
| 0a9b8ba0b0 | |||
| 9710f8be63 | |||
| d872bf65dd | |||
| c3ef8d112c | |||
| f2a4347de7 | |||
| 51a4880fdb | |||
| a4d22b0fcb | |||
| 8d051800a4 | |||
|
|
c0b59162a1 | ||
| 0e53a081c7 | |||
| d76f6d716f | |||
| f1d5d9840e | |||
| f3eb418409 | |||
| 3e85529468 | |||
| 05798688d0 | |||
| 01f35eed04 | |||
| aef97cca32 | |||
| 87e2ac9386 | |||
| 4a04628d5b | |||
| 0af78f814c | |||
| 929d40ff6e | |||
| 68f6642ff2 | |||
| 91e4d585ff | |||
| eac42581a6 | |||
|
|
4e50d0ace9 | ||
|
|
0b54adeb59 | ||
|
|
5d23de4862 | ||
|
|
eda454cb9d | ||
| 6da8f1c107 | |||
| 4fb487dcef | |||
| 0d6a339b53 | |||
| c6525be444 | |||
| cb846891d6 | |||
| 2aed37757e | |||
| 444159b52a | |||
| 7aed8e83ea | |||
| f7a807473d | |||
| f8e91c325d | |||
| a448405ce5 | |||
| a4989f99d6 | |||
| 3f64db3b3a | |||
|
|
7ee5ca0753 | ||
| 41254db72f | |||
|
|
15e301b889 | ||
| 061a7dd537 | |||
|
|
c3926991ac | ||
|
|
ea0b2407df | ||
| 569679238c | |||
| ed17f78da5 | |||
| dfd9230541 | |||
| 65b751642f | |||
| d6fd827f8b | |||
| 162b0099b2 | |||
| e0b689174a | |||
| edf4430fb1 | |||
| 040884a039 | |||
| f7c08f02c2 | |||
|
|
2fe38945d2 | ||
| cece152c0b | |||
| 4e31b3e424 | |||
| 109bf5ec5d | |||
| 4f3f16d9b0 | |||
|
|
fe5745831c | ||
| 3447117742 | |||
| 143f8f43fa | |||
| 36326a2a70 | |||
| 52637c2919 | |||
| f3a8552829 | |||
| bfdfd19711 | |||
|
|
efb9bc938a | ||
| dcd1856ebb | |||
| 43f3270171 | |||
| b7fcac8f39 | |||
| e521d06702 | |||
| a260274549 | |||
| b37a7d2690 | |||
| 242c2b31a3 | |||
| 57c420e9dd | |||
| ac67f56b09 | |||
| b24eb93c57 | |||
| 0f59be04a7 | |||
| 54eb15ea35 | |||
| a85f170e2d | |||
| 226f71ab2b | |||
| a887326611 | |||
| 8ed2e7585d | |||
| 7a1ad24f0e | |||
|
|
b934c2eeaf | ||
| de0e3f7dfd | |||
| 44c9a65505 | |||
| 038d7ad2e1 | |||
|
|
c1b727b1c8 | ||
| a63c38b6aa | |||
| 8915c42008 | |||
| 503293a359 | |||
| 7bdf71315a | |||
| 6f5d457122 | |||
| b4274264a7 | |||
| 8002725c87 | |||
| 2c9edf3741 | |||
| 3f562449e1 | |||
| 1cce39bcb5 | |||
| c93d5ceb16 | |||
| ad690db886 | |||
|
|
1b8462b40d | ||
|
|
8c98f2cf6e | ||
| f3260f57a4 | |||
| b4ad0128e4 | |||
| e1c8278f71 | |||
|
|
ed3f46ce7f | ||
|
|
1f838d9c5a | ||
| 33457d3cbc | |||
| 6df8e6dec8 | |||
| f9b8f13dd6 | |||
| e919b4322e | |||
| 7503c845df | |||
|
|
c6cd785262 | ||
|
|
e453e24203 | ||
| 3686a294d3 | |||
|
|
115a14fcba | ||
|
|
fc172fdb1f | ||
| b6131379f9 | |||
| e1fcc41ace | |||
| f2a04cebe6 | |||
| c693002ddb | |||
| ee77c8540a | |||
| a536d2780e | |||
| f880598052 | |||
| e7985ea52f | |||
| f56dc65021 | |||
|
|
4770758aee | ||
| 90fe484d81 | |||
| 2b8bbe019d | |||
|
|
1f1b9c594f | ||
| 9e1c151402 | |||
| 088e522292 | |||
|
|
f836114d84 | ||
| b8e6e98a74 | |||
|
|
4fd13440c6 | ||
|
|
4d8afd53ad | ||
| 2db847ada2 | |||
| 07e0692783 | |||
| e78d53064b | |||
| e6fcb5ff22 | |||
| f02e33fda7 | |||
| 1bbec9efae | |||
| 3b53c4451c | |||
| 30f490959b | |||
|
|
0a894b0db1 | ||
| c20e9507d5 | |||
| f89c690f1b | |||
|
|
7819c1204c | ||
|
|
f61af9d02a | ||
|
|
e470a6a97e | ||
|
|
cd8c47449b | ||
| 120e7cade5 | |||
| ac550e05e8 | |||
| d6e7fadb4f | |||
|
|
2be1c08c44 | ||
|
|
86c177bbbb | ||
|
|
d426d28ba0 | ||
|
|
72e69fc0b3 | ||
| cc8de353d4 | |||
| 4495a5d33b | |||
| 9dffe30aad | |||
| d393e74896 | |||
| daf083dc88 | |||
|
|
ce859697b5 | ||
|
|
1587c762f8 | ||
|
|
17c01d9b46 | ||
| a1bb9ea352 | |||
|
|
a1895ec65f | ||
|
|
c5faa0b99d | ||
|
|
e9d142f3e8 | ||
|
|
91860afd80 | ||
|
|
bec0700d39 | ||
|
|
05d3d7f5c7 | ||
|
|
ebff36d257 | ||
|
|
a709b3afb6 | ||
|
|
69a3c6a9b2 | ||
|
|
8c33d876e8 | ||
|
|
1ec2fbcc16 | ||
|
|
bc4e29141b | ||
|
|
e90ea31683 | ||
|
|
7c99f0b3e0 | ||
|
|
c089960707 | ||
|
|
0b2f29f1e8 | ||
|
|
9a4f50472a | ||
|
|
7d1a1c4004 | ||
|
|
ebd58d4229 | ||
|
|
dd48795f64 | ||
| 3d45b6687f | |||
| 35e6d36ce0 | |||
| 4900c81c11 | |||
| 52472b0ec3 | |||
| ec68e6f761 | |||
|
|
82d8556f24 | ||
| 25bd170f6b | |||
| 6939b4a313 | |||
| d18922ed98 | |||
| e8bf242c42 | |||
| 2050460bb3 | |||
|
|
4add30e895 | ||
| e1dbfdafd7 | |||
| 75becb2294 | |||
| 94e494361f | |||
| cab3b1059d | |||
|
|
d27bdf68fb | ||
|
|
82b82920e1 | ||
| 4bb3eadf91 | |||
| 4c82e65c1f | |||
| cf4d7df7ad | |||
| 86d13410c3 | |||
| 19fdf2a503 | |||
| 3a0c25c871 | |||
| 083338da8d | |||
| 37e5c9ceaa | |||
|
|
5448238697 | ||
|
|
c5250a1059 | ||
| b2c1a7b8de | |||
| b4583fc6dc | |||
| f7c508939c | |||
| 4cf77a9b0e | |||
| a2160bef7d | |||
|
|
c2a4a95eba | ||
| 8641d6bdce | |||
| 5f4d513aa6 | |||
| f47b15de39 | |||
| 7426dc02cf | |||
| a570160aed | |||
| 7596bd5a06 | |||
| 01f9d03b14 | |||
| 66426f5102 | |||
|
|
45671bda52 | ||
|
|
934eef4db4 | ||
|
|
31e8dea965 | ||
|
|
05ebdefd47 | ||
|
|
c233c481b6 | ||
|
|
68d9778c00 | ||
|
|
8acd852070 | ||
|
|
a9420f0339 | ||
|
|
207e5bf01d | ||
|
|
cb5cf5763e | ||
|
|
ff450215c6 | ||
|
|
dad8fd5378 | ||
|
|
37b395ee52 | ||
|
|
03243605da | ||
|
|
48e2d2ceab | ||
|
|
777fb25860 | ||
|
|
03601b9707 | ||
|
|
580dc71218 | ||
|
|
24a7d7b34b | ||
| c205bbddd3 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ docs/build/
|
|||||||
/phpunit.xml
|
/phpunit.xml
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
###< phpunit/phpunit ###
|
###< phpunit/phpunit ###
|
||||||
|
|
||||||
|
|||||||
@@ -11,14 +11,15 @@ before_script:
|
|||||||
- PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
- PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
||||||
# Install and run Composer
|
# Install and run Composer
|
||||||
- curl -sS https://getcomposer.org/installer | php
|
- curl -sS https://getcomposer.org/installer | php
|
||||||
- php composer.phar install
|
- php -d memory_limit=2G composer.phar install
|
||||||
- php tests/app/bin/console doctrine:migrations:migrate -n
|
- php tests/app/bin/console doctrine:migrations:migrate -n
|
||||||
- php tests/app/bin/console doctrine:fixtures:load -n
|
- php -d memory_limit=2G tests/app/bin/console doctrine:fixtures:load -n
|
||||||
|
- echo "before_script finished"
|
||||||
|
|
||||||
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
|
# Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service
|
||||||
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
|
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
|
||||||
services:
|
services:
|
||||||
- name: postgres:12
|
- name: postgis/postgis:12-3.1-alpine
|
||||||
alias: db
|
alias: db
|
||||||
- name: redis
|
- name: redis
|
||||||
alias: redis
|
alias: redis
|
||||||
@@ -30,8 +31,12 @@ variables:
|
|||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
# fetch the chill-app using git submodules
|
# fetch the chill-app using git submodules
|
||||||
GIT_SUBMODULE_STRATEGY: recursive
|
GIT_SUBMODULE_STRATEGY: recursive
|
||||||
|
REDIS_HOST: redis
|
||||||
|
REDIS_PORT: 6379
|
||||||
|
REDIS_URL: redis://redis:6379
|
||||||
|
|
||||||
|
|
||||||
# Run our tests
|
# Run our tests
|
||||||
test:
|
test:
|
||||||
script:
|
script:
|
||||||
- bin/phpunit --colors=never
|
- php -d memory_limit=3G bin/phpunit --colors=never
|
||||||
|
|||||||
25
.php_cs.dist
25
.php_cs.dist
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
$config = require __DIR__ . '/vendor/drupol/php-conventions/config/php73/php_cs_fixer.config.php';
|
|
||||||
|
|
||||||
$config
|
|
||||||
->getFinder()
|
|
||||||
->ignoreDotFiles(false)
|
|
||||||
->name(['.php_cs.dist']);
|
|
||||||
|
|
||||||
$rules = $config->getRules();
|
|
||||||
|
|
||||||
$rules['header_comment']['header'] = trim(file_get_contents(__DIR__ . '/resource/header.txt'));
|
|
||||||
|
|
||||||
return $config->setRules($rules);
|
|
||||||
8
LICENSE
8
LICENSE
@@ -629,12 +629,12 @@ to attach them to the start of each source file to most effectively
|
|||||||
state the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
chill-bundles
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) 2021 Chill Project
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
it under the terms of the GNU Affero General Public License as published
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
|
|||||||
9
README.md
Normal file
9
README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Chill framework
|
||||||
|
|
||||||
|
Documentation of the Chill software.
|
||||||
|
|
||||||
|
The online documentation can be found at http://docs.chill.social
|
||||||
|
|
||||||
|
See the [`docs`][1] directory for more.
|
||||||
|
|
||||||
|
[1]: docs/README.md
|
||||||
@@ -58,13 +58,13 @@
|
|||||||
"symfony/css-selector": "^5.2",
|
"symfony/css-selector": "^5.2",
|
||||||
"twig/markdown-extra": "^3.3",
|
"twig/markdown-extra": "^3.3",
|
||||||
"erusev/parsedown": "^1.7",
|
"erusev/parsedown": "^1.7",
|
||||||
"symfony/serializer": "^5.2"
|
"symfony/serializer": "^5.2",
|
||||||
|
"symfony/webpack-encore-bundle": "^1.11"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/symfony": "*"
|
"symfony/symfony": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"drupol/php-conventions": "4.*",
|
|
||||||
"fakerphp/faker": "^1.13",
|
"fakerphp/faker": "^1.13",
|
||||||
"phpunit/phpunit": "^7.0",
|
"phpunit/phpunit": "^7.0",
|
||||||
"symfony/dotenv": "^5.1",
|
"symfony/dotenv": "^5.1",
|
||||||
@@ -74,7 +74,8 @@
|
|||||||
"symfony/web-profiler-bundle": "^5.0",
|
"symfony/web-profiler-bundle": "^5.0",
|
||||||
"symfony/var-dumper": "4.*",
|
"symfony/var-dumper": "4.*",
|
||||||
"symfony/debug-bundle": "^5.1",
|
"symfony/debug-bundle": "^5.1",
|
||||||
"symfony/phpunit-bridge": "^5.2"
|
"symfony/phpunit-bridge": "^5.2",
|
||||||
|
"nelmio/alice": "^3.8"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"auto-scripts": {
|
"auto-scripts": {
|
||||||
@@ -83,6 +84,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
"vendor-dir": "tests/app/vendor",
|
||||||
"bin-dir": "bin"
|
"bin-dir": "bin"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,128 +1,123 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Export\Filter;
|
namespace Chill\PersonBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\Query\Expr;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Validator\Constraints;
|
||||||
|
use Symfony\Component\Form\FormEvent;
|
||||||
|
use Symfony\Component\Form\FormEvents;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
use Chill\MainBundle\Form\Type\Export\FilterType;
|
||||||
|
use Symfony\Component\Form\FormError;
|
||||||
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
|
|
||||||
class BirthdateFilter implements ExportElementValidatedInterface, FilterInterface
|
class BirthdateFilter implements FilterInterface, ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
// add specific role for this filter
|
// add specific role for this filter
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
// we do not need any new role for this filter, so we return null
|
// we do not need any new role for this filter, so we return null
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// here, we alter the query created by Export
|
|
||||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
|
||||||
{
|
|
||||||
$where = $qb->getDQLPart('where');
|
|
||||||
// we create the clause here
|
|
||||||
$clause = $qb->expr()->between(
|
|
||||||
'person.birthdate',
|
|
||||||
':date_from',
|
|
||||||
':date_to'
|
|
||||||
);
|
|
||||||
|
|
||||||
// we have to take care **not to** remove previous clauses...
|
|
||||||
if ($where instanceof Expr\Andx) {
|
|
||||||
$where->add($clause);
|
|
||||||
} else {
|
|
||||||
$where = $qb->expr()->andX($clause);
|
|
||||||
}
|
|
||||||
|
|
||||||
$qb->add('where', $where);
|
|
||||||
// we add parameters from $data. $data contains the parameters from the form
|
|
||||||
$qb->setParameter('date_from', $data['date_from']);
|
|
||||||
$qb->setParameter('date_to', $data['date_to']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// we give information on which type of export this filter applies
|
// we give information on which type of export this filter applies
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
return 'person';
|
return 'person';
|
||||||
}
|
}
|
||||||
|
|
||||||
// we build a form to collect some parameters from the users
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
|
||||||
{
|
|
||||||
$builder->add('date_from', DateType::class, [
|
|
||||||
'label' => 'Born after this date',
|
|
||||||
'data' => new DateTime(),
|
|
||||||
'attr' => ['class' => 'datepicker'],
|
|
||||||
'widget' => 'single_text',
|
|
||||||
'format' => 'dd-MM-yyyy',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$builder->add('date_to', DateType::class, [
|
|
||||||
'label' => 'Born before this date',
|
|
||||||
'data' => new DateTime(),
|
|
||||||
'attr' => ['class' => 'datepicker'],
|
|
||||||
'widget' => 'single_text',
|
|
||||||
'format' => 'dd-MM-yyyy',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// here, we create a simple string which will describe the action of
|
|
||||||
// the filter in the Response
|
|
||||||
public function describeAction($data, $format = 'string')
|
|
||||||
{
|
|
||||||
return ['Filtered by person\'s birtdate: '
|
|
||||||
. 'between %date_from% and %date_to%', [
|
|
||||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
|
||||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
|
||||||
], ];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return 'Filter by person\'s birthdate';
|
return 'Filter by person\'s birthdate';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we build a form to collect some parameters from the users
|
||||||
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('date_from', DateType::class, array(
|
||||||
|
'label' => "Born after this date",
|
||||||
|
'data' => new \DateTime(),
|
||||||
|
'attr' => array('class' => 'datepicker'),
|
||||||
|
'widget'=> 'single_text',
|
||||||
|
'format' => 'dd-MM-yyyy',
|
||||||
|
));
|
||||||
|
|
||||||
|
$builder->add('date_to', DateType::class, array(
|
||||||
|
'label' => "Born before this date",
|
||||||
|
'data' => new \DateTime(),
|
||||||
|
'attr' => array('class' => 'datepicker'),
|
||||||
|
'widget'=> 'single_text',
|
||||||
|
'format' => 'dd-MM-yyyy',
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// the form created above must be validated. The process of validation
|
// the form created above must be validated. The process of validation
|
||||||
// is executed here. This function is added by the interface
|
// is executed here. This function is added by the interface
|
||||||
// `ExportElementValidatedInterface`, and can be ignore if there is
|
// `ExportElementValidatedInterface`, and can be ignore if there is
|
||||||
// no need for a validation
|
// no need for a validation
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
$date_from = $data['date_from'];
|
$date_from = $data['date_from'];
|
||||||
$date_to = $data['date_to'];
|
$date_to = $data['date_to'];
|
||||||
|
|
||||||
if (null === $date_from) {
|
if ($date_from === null) {
|
||||||
$context->buildViolation('The "date from" should not be empty')
|
$context->buildViolation('The "date from" should not be empty')
|
||||||
//->atPath('date_from')
|
//->atPath('date_from')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $date_to) {
|
if ($date_to === null) {
|
||||||
$context->buildViolation('The "date to" should not be empty')
|
$context->buildViolation('The "date to" should not be empty')
|
||||||
//->atPath('date_to')
|
//->atPath('date_to')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(null !== $date_from && null !== $date_to)
|
($date_from !== null && $date_to !== null)
|
||||||
&& $date_from >= $date_to
|
&&
|
||||||
|
$date_from >= $date_to
|
||||||
) {
|
) {
|
||||||
$context->buildViolation('The date "date to" should be after the '
|
$context->buildViolation('The date "date to" should be after the '
|
||||||
. 'date given in "date from" field')
|
. 'date given in "date from" field')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// here, we alter the query created by Export
|
||||||
|
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$where = $qb->getDQLPart('where');
|
||||||
|
// we create the clause here
|
||||||
|
$clause = $qb->expr()->between('person.birthdate', ':date_from',
|
||||||
|
':date_to');
|
||||||
|
|
||||||
|
// we have to take care **not to** remove previous clauses...
|
||||||
|
if ($where instanceof Expr\Andx) {
|
||||||
|
$where->add($clause);
|
||||||
|
} else {
|
||||||
|
$where = $qb->expr()->andX($clause);
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->add('where', $where);
|
||||||
|
// we add parameters from $data. $data contains the parameters from the form
|
||||||
|
$qb->setParameter('date_from', $data['date_from']);
|
||||||
|
$qb->setParameter('date_to', $data['date_to']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// here, we create a simple string which will describe the action of
|
||||||
|
// the filter in the Response
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
return array('Filtered by person\'s birtdate: '
|
||||||
|
. 'between %date_from% and %date_to%', array(
|
||||||
|
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||||
|
'%date_to%' => $data['date_to']->format('d-m-Y')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,121 +1,118 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Export\Export;
|
namespace Chill\PersonBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\ExportInterface;
|
use Chill\MainBundle\Export\ExportInterface;
|
||||||
use Chill\MainBundle\Export\FormatterInterface;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Chill\MainBundle\Export\FormatterInterface;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class CountPerson implements ExportInterface
|
class CountPerson implements ExportInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityManagerInterface
|
* @var EntityManagerInterface
|
||||||
*/
|
*/
|
||||||
protected $entityManager;
|
protected $entityManager;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManagerInterface $em
|
EntityManagerInterface $em
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
$this->entityManager = $em;
|
$this->entityManager = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
|
||||||
{
|
|
||||||
// this export does not add any form
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllowedFormattersTypes()
|
|
||||||
{
|
|
||||||
return [FormatterInterface::TYPE_TABULAR];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDescription()
|
|
||||||
{
|
|
||||||
return 'Count peoples by various parameters.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
|
||||||
{
|
|
||||||
// the Closure which will be executed by the formatter.
|
|
||||||
return function ($value) {
|
|
||||||
switch ($value) {
|
|
||||||
case '_header':
|
|
||||||
// we have to process specifically the '_header' string,
|
|
||||||
// which will be used by the formatter to show a column title
|
|
||||||
return $this->getTitle();
|
|
||||||
|
|
||||||
default:
|
|
||||||
// for all value, we do not process them and return them
|
|
||||||
// immediatly
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
|
||||||
{
|
|
||||||
// this array match the result keys in the query. We have only
|
|
||||||
// one column.
|
|
||||||
return ['export_result'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResult($qb, $data)
|
|
||||||
{
|
|
||||||
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Count peoples';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
return Declarations::PERSON_TYPE;
|
return Declarations::PERSON_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function getDescription()
|
||||||
{
|
{
|
||||||
// we gather all center the user choose.
|
return "Count peoples by various parameters.";
|
||||||
$centers = array_map(static function ($el) {
|
|
||||||
return $el['center'];
|
|
||||||
}, $acl);
|
|
||||||
|
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
|
||||||
|
|
||||||
$qb->select('COUNT(person.id) AS export_result')
|
|
||||||
->from('ChillPersonBundle:Person', 'person')
|
|
||||||
->join('person.center', 'center')
|
|
||||||
->andWhere('center IN (:authorized_centers)')
|
|
||||||
->setParameter('authorized_centers', $centers);
|
|
||||||
|
|
||||||
return $qb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return "Count peoples";
|
||||||
|
}
|
||||||
|
|
||||||
public function requiredRole()
|
public function requiredRole()
|
||||||
{
|
{
|
||||||
return new Role(PersonVoter::STATS);
|
return new Role(PersonVoter::STATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
|
||||||
|
{
|
||||||
|
// we gather all center the user choose.
|
||||||
|
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
||||||
|
|
||||||
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
|
$qb->select('COUNT(person.id) AS export_result')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
->join('person.center', 'center')
|
||||||
|
->andWhere('center IN (:authorized_centers)')
|
||||||
|
->setParameter('authorized_centers', $centers);
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
return $qb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResult($qb, $data)
|
||||||
|
{
|
||||||
|
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryKeys($data)
|
||||||
|
{
|
||||||
|
// this array match the result keys in the query. We have only
|
||||||
|
// one column.
|
||||||
|
return array('export_result');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
|
||||||
|
// the Closure which will be executed by the formatter.
|
||||||
|
return function($value) {
|
||||||
|
switch($value) {
|
||||||
|
case '_header':
|
||||||
|
// we have to process specifically the '_header' string,
|
||||||
|
// which will be used by the formatter to show a column title
|
||||||
|
return $this->getTitle();
|
||||||
|
default:
|
||||||
|
// for all value, we do not process them and return them
|
||||||
|
// immediatly
|
||||||
|
return $value;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllowedFormattersTypes()
|
||||||
|
{
|
||||||
|
return array(FormatterInterface::TYPE_TABULAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder) {
|
||||||
|
// this export does not add any form
|
||||||
|
}
|
||||||
|
|
||||||
public function supportsModifiers()
|
public function supportsModifiers()
|
||||||
{
|
{
|
||||||
// explain the export manager which formatters and filters are allowed
|
// explain the export manager which formatters and filters are allowed
|
||||||
return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN];
|
return array(Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
747
docs/source/development/api.rst
Normal file
747
docs/source/development/api.rst
Normal file
@@ -0,0 +1,747 @@
|
|||||||
|
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||||
|
Permission is granted to copy, distribute and/or modify this document
|
||||||
|
under the terms of the GNU Free Documentation License, Version 1.3
|
||||||
|
or any later version published by the Free Software Foundation;
|
||||||
|
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||||
|
A copy of the license is included in the section entitled "GNU
|
||||||
|
Free Documentation License".
|
||||||
|
|
||||||
|
.. _api:
|
||||||
|
|
||||||
|
API
|
||||||
|
###
|
||||||
|
|
||||||
|
Chill provides a basic framework to build REST api.
|
||||||
|
|
||||||
|
Basic configuration
|
||||||
|
*******************
|
||||||
|
|
||||||
|
Configure a route
|
||||||
|
=================
|
||||||
|
|
||||||
|
Follow those steps to build a REST api:
|
||||||
|
|
||||||
|
1. Create your model;
|
||||||
|
2. Configure the API;
|
||||||
|
|
||||||
|
You can also:
|
||||||
|
|
||||||
|
* hook into the controller to customize some steps;
|
||||||
|
* add more route and steps
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Useful links:
|
||||||
|
|
||||||
|
* `How to use annotation to configure serialization <https://symfony.com/doc/current/serializer.html>`_
|
||||||
|
* `How to create your custom normalizer <https://symfony.com/doc/current/serializer/custom_normalizer.html>`_
|
||||||
|
|
||||||
|
Auto-loading the routes
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Ensure that those lines are present in your file `app/config/routing.yml`:
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
chill_cruds:
|
||||||
|
resource: 'chill_main_crud_route_loader:load'
|
||||||
|
type: service
|
||||||
|
|
||||||
|
|
||||||
|
Create your model
|
||||||
|
=================
|
||||||
|
|
||||||
|
Create your model on the usual way:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\OriginRepository;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity(repositoryClass=OriginRepository::class)
|
||||||
|
* @ORM\Table(name="chill_person_accompanying_period_origin")
|
||||||
|
*/
|
||||||
|
class Origin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json")
|
||||||
|
*/
|
||||||
|
private $label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="date_immutable", nullable=true)
|
||||||
|
*/
|
||||||
|
private $noActiveAfter;
|
||||||
|
|
||||||
|
// .. getters and setters
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Configure api
|
||||||
|
=============
|
||||||
|
|
||||||
|
Configure the api using Yaml (see the full configuration: :ref:`api_full_configuration`):
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# config/packages/chill_main.yaml
|
||||||
|
chill_main:
|
||||||
|
apis:
|
||||||
|
accompanying_period_origin:
|
||||||
|
base_path: '/api/1.0/person/accompanying-period/origin'
|
||||||
|
class: 'Chill\PersonBundle\Entity\AccompanyingPeriod\Origin'
|
||||||
|
name: accompanying_period_origin
|
||||||
|
base_role: 'ROLE_USER'
|
||||||
|
actions:
|
||||||
|
_index:
|
||||||
|
methods:
|
||||||
|
GET: true
|
||||||
|
HEAD: true
|
||||||
|
_entity:
|
||||||
|
methods:
|
||||||
|
GET: true
|
||||||
|
HEAD: true
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
If you are working on a shared bundle (aka "The chill bundles"), you should define your configuration inside the class :code:`ChillXXXXBundleExtension`, using the "prependConfig" feature:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\DependencyInjection;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ChillPersonExtension
|
||||||
|
* Loads and manages your bundle configuration
|
||||||
|
*
|
||||||
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||||
|
* @package Chill\PersonBundle\DependencyInjection
|
||||||
|
*/
|
||||||
|
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||||
|
{
|
||||||
|
public function prepend(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$this->prependCruds($container);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ContainerBuilder $container
|
||||||
|
*/
|
||||||
|
protected function prependCruds(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$container->prependExtensionConfig('chill_main', [
|
||||||
|
'apis' => [
|
||||||
|
[
|
||||||
|
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Origin::class,
|
||||||
|
'name' => 'accompanying_period_origin',
|
||||||
|
'base_path' => '/api/1.0/person/accompanying-period/origin',
|
||||||
|
'controller' => \Chill\PersonBundle\Controller\OpeningApiController::class,
|
||||||
|
'base_role' => 'ROLE_USER',
|
||||||
|
'actions' => [
|
||||||
|
'_index' => [
|
||||||
|
'methods' => [
|
||||||
|
Request::METHOD_GET => true,
|
||||||
|
Request::METHOD_HEAD => true
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'_entity' => [
|
||||||
|
'methods' => [
|
||||||
|
Request::METHOD_GET => true,
|
||||||
|
Request::METHOD_HEAD => true
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
The :code:`_index` and :code:`_entity` action
|
||||||
|
*********************************************
|
||||||
|
|
||||||
|
The :code:`_index` and :code:`_entity` action are default actions:
|
||||||
|
|
||||||
|
* they will call a specific method in the default controller;
|
||||||
|
* they will generate defined routes:
|
||||||
|
|
||||||
|
Index:
|
||||||
|
Name: :code:`chill_api_single_accompanying_period_origin__index`
|
||||||
|
|
||||||
|
Path: :code:`/api/1.0/person/accompanying-period/origin.{_format}`
|
||||||
|
|
||||||
|
Entity:
|
||||||
|
Name: :code:`chill_api_single_accompanying_period_origin__entity`
|
||||||
|
|
||||||
|
Path: :code:`/api/1.0/person/accompanying-period/origin/{id}.{_format}`
|
||||||
|
|
||||||
|
Role
|
||||||
|
****
|
||||||
|
|
||||||
|
By default, the key `base_role` is used to check ACL. Take care of creating the :code:`Voter` required to take that into account.
|
||||||
|
|
||||||
|
For index action, the role will be called with :code:`NULL` as :code:`$subject`. The retrieved entity will be the subject for single queries.
|
||||||
|
|
||||||
|
You can also define a role for each method. In this case, this role is used for the given method, and, if any, the base role is taken into account.
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# config/packages/chill_main.yaml
|
||||||
|
chill_main:
|
||||||
|
apis:
|
||||||
|
accompanying_period_origin:
|
||||||
|
base_path: '/api/1.0/person/bla/bla'
|
||||||
|
class: 'Chill\PersonBundle\Entity\Blah'
|
||||||
|
name: bla
|
||||||
|
actions:
|
||||||
|
_entity:
|
||||||
|
methods:
|
||||||
|
GET: true
|
||||||
|
HEAD: true
|
||||||
|
roles:
|
||||||
|
GET: MY_ROLE_SEE
|
||||||
|
HEAD: MY ROLE_SEE
|
||||||
|
|
||||||
|
Customize the controller
|
||||||
|
************************
|
||||||
|
|
||||||
|
You can customize the controller by hooking into the default actions. Take care of extending :code:`Chill\MainBundle\CRUD\Controller\ApiController`.
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class OpeningApiController extends ApiController
|
||||||
|
{
|
||||||
|
protected function customizeQuery(string $action, Request $request, $qb): void
|
||||||
|
{
|
||||||
|
$qb->where($qb->expr()->gt('e.noActiveAfter', ':now'))
|
||||||
|
->orWhere($qb->expr()->isNull('e.noActiveAfter'));
|
||||||
|
$qb->setParameter('now', new \DateTime('now'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
And set your controller in configuration:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
chill_main:
|
||||||
|
apis:
|
||||||
|
accompanying_period_origin:
|
||||||
|
base_path: '/api/1.0/person/accompanying-period/origin'
|
||||||
|
class: 'Chill\PersonBundle\Entity\AccompanyingPeriod\Origin'
|
||||||
|
name: accompanying_period_origin
|
||||||
|
# add a controller
|
||||||
|
controller: 'Chill\PersonBundle\Controller\OpeningApiController'
|
||||||
|
base_role: 'ROLE_USER'
|
||||||
|
actions:
|
||||||
|
_index:
|
||||||
|
methods:
|
||||||
|
GET: true
|
||||||
|
HEAD: true
|
||||||
|
_entity:
|
||||||
|
methods:
|
||||||
|
GET: true
|
||||||
|
HEAD: true
|
||||||
|
|
||||||
|
Create your own actions
|
||||||
|
***********************
|
||||||
|
|
||||||
|
You can add your own actions:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
chill_main:
|
||||||
|
apis:
|
||||||
|
-
|
||||||
|
class: Chill\PersonBundle\Entity\AccompanyingPeriod
|
||||||
|
name: accompanying_course
|
||||||
|
base_path: /api/1.0/person/accompanying-course
|
||||||
|
controller: Chill\PersonBundle\Controller\AccompanyingCourseApiController
|
||||||
|
actions:
|
||||||
|
# add a custom participation:
|
||||||
|
participation:
|
||||||
|
methods:
|
||||||
|
POST: true
|
||||||
|
DELETE: true
|
||||||
|
GET: false
|
||||||
|
HEAD: false
|
||||||
|
PUT: false
|
||||||
|
roles:
|
||||||
|
POST: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
DELETE: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
GET: null
|
||||||
|
HEAD: null
|
||||||
|
PUT: null
|
||||||
|
single-collection: single
|
||||||
|
|
||||||
|
The key :code:`single-collection` with value :code:`single` will add a :code:`/{id}/ + "action name"` (in this example, :code:`/{id}/participation`) into the path, after the base path. If the value is :code:`collection`, no id will be set, but the action name will be append to the path.
|
||||||
|
|
||||||
|
Then, create the corresponding action into your controller:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
|
||||||
|
class AccompanyingCourseApiController extends ApiController
|
||||||
|
{
|
||||||
|
protected EventDispatcherInterface $eventDispatcher;
|
||||||
|
|
||||||
|
protected ValidatorInterface $validator;
|
||||||
|
|
||||||
|
public function __construct(EventDispatcherInterface $eventDispatcher, $validator)
|
||||||
|
{
|
||||||
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
$this->validator = $validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function participationApi($id, Request $request, $_format)
|
||||||
|
{
|
||||||
|
/** @var AccompanyingPeriod $accompanyingPeriod */
|
||||||
|
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
|
||||||
|
$person = $this->getSerializer()
|
||||||
|
->deserialize($request->getContent(), Person::class, $_format, []);
|
||||||
|
|
||||||
|
if (NULL === $person) {
|
||||||
|
throw new BadRequestException('person id not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->onPostCheckACL('participation', $request, $accompanyingPeriod, $_format);
|
||||||
|
|
||||||
|
switch ($request->getMethod()) {
|
||||||
|
case Request::METHOD_POST:
|
||||||
|
$participation = $accompanyingPeriod->addPerson($person);
|
||||||
|
break;
|
||||||
|
case Request::METHOD_DELETE:
|
||||||
|
$participation = $accompanyingPeriod->removePerson($person);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BadRequestException("This method is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = $this->validator->validate($accompanyingPeriod);
|
||||||
|
|
||||||
|
if ($errors->count() > 0) {
|
||||||
|
// only format accepted
|
||||||
|
return $this->json($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getDoctrine()->getManager()->flush();
|
||||||
|
|
||||||
|
return $this->json($participation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Managing association
|
||||||
|
********************
|
||||||
|
|
||||||
|
ManyToOne association
|
||||||
|
=====================
|
||||||
|
|
||||||
|
In ManyToOne association, you can add associated entities using the :code:`PATCH` request. By default, the serializer deserialize entities only with their id and discriminator type, if any.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
curl -X 'PATCH' \
|
||||||
|
'http://localhost:8001/api/1.0/person/accompanying-course/2668.json' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
# see the data sent to the server: \
|
||||||
|
-d '{
|
||||||
|
"type": "accompanying_period",
|
||||||
|
"id": 2668,
|
||||||
|
"origin": { "id": 11 }
|
||||||
|
}'
|
||||||
|
|
||||||
|
ManyToMany associations
|
||||||
|
=======================
|
||||||
|
|
||||||
|
In OneToMany association, you can easily create route for adding and removing entities, using :code:`POST` and :code:`DELETE` requests.
|
||||||
|
|
||||||
|
Prepare your entity, creating the methods :code:`addYourEntity` and :code:`removeYourEntity`:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AccompanyingPeriod Class
|
||||||
|
*
|
||||||
|
* @ORM\Entity
|
||||||
|
* @ORM\Table(name="chill_person_accompanying_period")
|
||||||
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
|
* "accompanying_period"=AccompanyingPeriod::class
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
class AccompanyingPeriod
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Collection
|
||||||
|
* @ORM\ManyToMany(
|
||||||
|
* targetEntity=Scope::class,
|
||||||
|
* cascade={}
|
||||||
|
* )
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
private $scopes;
|
||||||
|
|
||||||
|
public function addScope(Scope $scope): self
|
||||||
|
{
|
||||||
|
$this->scopes[] = $scope;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeScope(Scope $scope): void
|
||||||
|
{
|
||||||
|
$this->scopes->removeElement($scope);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Create your route into the configuration:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
chill_main:
|
||||||
|
apis:
|
||||||
|
-
|
||||||
|
class: Chill\PersonBundle\Entity\AccompanyingPeriod
|
||||||
|
name: accompanying_course
|
||||||
|
base_path: /api/1.0/person/accompanying-course
|
||||||
|
controller: Chill\PersonBundle\Controller\AccompanyingCourseApiController
|
||||||
|
actions:
|
||||||
|
scope:
|
||||||
|
methods:
|
||||||
|
POST: true
|
||||||
|
DELETE: true
|
||||||
|
GET: false
|
||||||
|
HEAD: false
|
||||||
|
PUT: false
|
||||||
|
PATCH: false
|
||||||
|
roles:
|
||||||
|
POST: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
DELETE: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
GET: null
|
||||||
|
HEAD: null
|
||||||
|
PUT: null
|
||||||
|
PATCH: null
|
||||||
|
controller_action: null
|
||||||
|
path: null
|
||||||
|
single-collection: single
|
||||||
|
|
||||||
|
This will create a new route, which will accept two methods: DELETE and POST:
|
||||||
|
|
||||||
|
.. code-block:: raw
|
||||||
|
|
||||||
|
+--------------+---------------------------------------------------------------------------------------+
|
||||||
|
| Property | Value |
|
||||||
|
+--------------+---------------------------------------------------------------------------------------+
|
||||||
|
| Route Name | chill_api_single_accompanying_course_scope |
|
||||||
|
| Path | /api/1.0/person/accompanying-course/{id}/scope.{_format} |
|
||||||
|
| Path Regex | {^/api/1\.0/person/accompanying\-course/(?P<id>[^/]++)/scope\.(?P<_format>[^/]++)$}sD |
|
||||||
|
| Host | ANY |
|
||||||
|
| Host Regex | |
|
||||||
|
| Scheme | ANY |
|
||||||
|
| Method | POST|DELETE |
|
||||||
|
| Requirements | {id}: \d+ |
|
||||||
|
| Class | Symfony\Component\Routing\Route |
|
||||||
|
| Defaults | _controller: csapi_accompanying_course_controller:scopeApi |
|
||||||
|
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
|
||||||
|
+--------------+---------------------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Then, create the controller action. Call the method:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
|
||||||
|
class MyController extends ApiController
|
||||||
|
{
|
||||||
|
public function scopeApi($id, Request $request, string $_format): Response
|
||||||
|
{
|
||||||
|
return $this->addRemoveSomething('scope', $id, $request, $_format, 'scope', Scope::class, [ 'groups' => [ 'read' ] ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
This will allow to add a scope by his id, and delete them.
|
||||||
|
|
||||||
|
Curl requests:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# add a scope with id 5
|
||||||
|
curl -X 'POST' \
|
||||||
|
'http://localhost:8001/api/1.0/person/accompanying-course/2868/scope.json' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"type": "scope",
|
||||||
|
"id": 5
|
||||||
|
}'
|
||||||
|
|
||||||
|
# remove a scope with id 5
|
||||||
|
curl -X 'DELETE' \
|
||||||
|
'http://localhost:8001/api/1.0/person/accompanying-course/2868/scope.json' \
|
||||||
|
-H 'accept: */*' \
|
||||||
|
-H 'Content-Type: application/json' \
|
||||||
|
-d '{
|
||||||
|
"id": 5,
|
||||||
|
"type": "scope"
|
||||||
|
}'
|
||||||
|
|
||||||
|
Deserializing an association where multiple types are allowed
|
||||||
|
=============================================================
|
||||||
|
|
||||||
|
Sometimes, multiples types are allowed as association to one entity:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
class Resource
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||||
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
*/
|
||||||
|
private $thirdParty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||||
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
*/
|
||||||
|
private $person;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param $resource Person|ThirdParty
|
||||||
|
*/
|
||||||
|
public function setResource($resource): self
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ThirdParty|Person
|
||||||
|
* @Groups({"read", "write"})
|
||||||
|
*/
|
||||||
|
public function getResource()
|
||||||
|
{
|
||||||
|
return $this->person ?? $this->thirdParty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
This is not well taken into account by the Symfony serializer natively.
|
||||||
|
|
||||||
|
You must, then, create your own CustomNormalizer. You can help yourself using this:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||||
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\ResourceRepository;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||||
|
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
|
||||||
|
use Symfony\Component\Serializer\Exception;
|
||||||
|
use Chill\MainBundle\Serializer\Normalizer\DiscriminatedObjectDenormalizer;
|
||||||
|
|
||||||
|
|
||||||
|
class AccompanyingPeriodResourceNormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||||
|
{
|
||||||
|
use DenormalizerAwareTrait;
|
||||||
|
use ObjectToPopulateTrait;
|
||||||
|
|
||||||
|
public function __construct(ResourceRepository $repository)
|
||||||
|
{
|
||||||
|
$this->repository = $repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function denormalize($data, string $type, string $format = null, array $context = [])
|
||||||
|
{
|
||||||
|
// .. snipped for brevity
|
||||||
|
|
||||||
|
if ($resource === NULL) {
|
||||||
|
$resource = new Resource();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\array_key_exists('resource', $data)) {
|
||||||
|
$res = $this->denormalizer->denormalize(
|
||||||
|
$data['resource'],
|
||||||
|
// call for a "multiple type"
|
||||||
|
DiscriminatedObjectDenormalizer::TYPE,
|
||||||
|
$format,
|
||||||
|
// into the context, we add the list of allowed types:
|
||||||
|
[
|
||||||
|
DiscriminatedObjectDenormalizer::ALLOWED_TYPES =>
|
||||||
|
[
|
||||||
|
Person::class, ThirdParty::class
|
||||||
|
]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$resource->setResource($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function supportsDenormalization($data, string $type, string $format = null)
|
||||||
|
{
|
||||||
|
return $type === Resource::class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Serialization for collection
|
||||||
|
****************************
|
||||||
|
|
||||||
|
A specific model has been defined for returning collection:
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
|
{
|
||||||
|
"count": 49,
|
||||||
|
"results": [
|
||||||
|
],
|
||||||
|
"pagination": {
|
||||||
|
"more": true,
|
||||||
|
"next": "/api/1.0/search.json&q=xxxx......&page=2",
|
||||||
|
"previous": null,
|
||||||
|
"first": 0,
|
||||||
|
"items_per_page": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Where this is relevant, this model should be re-used in custom controller actions.
|
||||||
|
|
||||||
|
In custom actions, this can be achieved quickly by assembling results into a :code:`Chill\MainBundle\Serializer\Model\Collection`. The pagination information is given by using :code:`Paginator` (see :ref:`Pagination <pagination-ref>`).
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
|
||||||
|
class MyController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function serializeCollection(PaginatorInterface $paginator, $entities): Response
|
||||||
|
{
|
||||||
|
$model = new Collection($entities, $paginator);
|
||||||
|
|
||||||
|
return $this->json($model, Response::HTTP_OK, [], $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.. _api_full_configuration:
|
||||||
|
|
||||||
|
Full configuration example
|
||||||
|
**************************
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
apis:
|
||||||
|
-
|
||||||
|
class: Chill\PersonBundle\Entity\AccompanyingPeriod
|
||||||
|
name: accompanying_course
|
||||||
|
base_path: /api/1.0/person/accompanying-course
|
||||||
|
controller: Chill\PersonBundle\Controller\AccompanyingCourseApiController
|
||||||
|
actions:
|
||||||
|
_entity:
|
||||||
|
roles:
|
||||||
|
GET: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
HEAD: null
|
||||||
|
POST: null
|
||||||
|
DELETE: null
|
||||||
|
PUT: null
|
||||||
|
controller_action: null
|
||||||
|
path: null
|
||||||
|
single-collection: single
|
||||||
|
methods:
|
||||||
|
GET: true
|
||||||
|
HEAD: true
|
||||||
|
POST: false
|
||||||
|
DELETE: false
|
||||||
|
PUT: false
|
||||||
|
participation:
|
||||||
|
methods:
|
||||||
|
POST: true
|
||||||
|
DELETE: true
|
||||||
|
GET: false
|
||||||
|
HEAD: false
|
||||||
|
PUT: false
|
||||||
|
roles:
|
||||||
|
POST: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
DELETE: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
||||||
|
GET: null
|
||||||
|
HEAD: null
|
||||||
|
PUT: null
|
||||||
|
controller_action: null
|
||||||
|
# the requirements for the route. Will be set to `[ 'id' => '\d+' ]` if left empty.
|
||||||
|
requirements: []
|
||||||
|
path: null
|
||||||
|
single-collection: single
|
||||||
|
base_role: null
|
||||||
|
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ As Chill rely on the `symfony <http://symfony.com>`_ framework, reading the fram
|
|||||||
|
|
||||||
Instructions to create a new bundle <create-a-new-bundle.rst>
|
Instructions to create a new bundle <create-a-new-bundle.rst>
|
||||||
CRUD (Create - Update - Delete) for one entity <crud.rst>
|
CRUD (Create - Update - Delete) for one entity <crud.rst>
|
||||||
|
Helpers for building a REST API <api.rst>
|
||||||
Routing <routing.rst>
|
Routing <routing.rst>
|
||||||
Menus <menus.rst>
|
Menus <menus.rst>
|
||||||
Forms <forms.rst>
|
Forms <forms.rst>
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
Free Documentation License".
|
Free Documentation License".
|
||||||
|
|
||||||
|
|
||||||
|
.. _pagination-ref:
|
||||||
|
|
||||||
Pagination
|
Pagination
|
||||||
##########
|
##########
|
||||||
|
|
||||||
@@ -15,7 +17,7 @@ The Bundle :code:`Chill\MainBundle` provides a **Pagination** api which allow yo
|
|||||||
A simple example
|
A simple example
|
||||||
****************
|
****************
|
||||||
|
|
||||||
In the controller, get the :class:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
|
In the controller, get the :code:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
|
||||||
|
|
||||||
|
|
||||||
.. literalinclude:: pagination/example.php
|
.. literalinclude:: pagination/example.php
|
||||||
|
|||||||
@@ -1,51 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\MyBundle\Controller;
|
namespace Chill\MyBundle\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class example extends Controller
|
|
||||||
{
|
class ItemController extends Controller {
|
||||||
public function yourAction()
|
|
||||||
|
public function yourAction()
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
// first, get the number of total item are available
|
// first, get the number of total item are available
|
||||||
$total = $em
|
$total = $em
|
||||||
->createQuery('SELECT COUNT (item.id) FROM ChillMyBundle:Item item')
|
->createQuery("SELECT COUNT (item.id) FROM ChillMyBundle:Item item")
|
||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
|
|
||||||
// get the PaginatorFactory
|
// get the PaginatorFactory
|
||||||
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
||||||
|
|
||||||
// create a pagination instance. This instance is only valid for
|
// create a pagination instance. This instance is only valid for
|
||||||
// the current route and parameters
|
// the current route and parameters
|
||||||
$paginator = $paginatorFactory->create($total);
|
$paginator = $paginatorFactory->create($total);
|
||||||
|
|
||||||
// launch your query on item. Limit the query to the results
|
// launch your query on item. Limit the query to the results
|
||||||
// for the current page using the paginator
|
// for the current page using the paginator
|
||||||
$items = $em->createQuery('SELECT item FROM ChillMyBundle:Item item WHERE <your clause>')
|
$items = $em->createQuery("SELECT item FROM ChillMyBundle:Item item WHERE <your clause>")
|
||||||
// use the paginator to get the first item number
|
// use the paginator to get the first item number
|
||||||
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
||||||
// use the paginator to get the number of items to display
|
// use the paginator to get the number of items to display
|
||||||
->setMaxResults($paginator->getItemsPerPage());
|
->setMaxResults($paginator->getItemsPerPage());
|
||||||
|
|
||||||
return $this->render(
|
return $this->render('ChillMyBundle:Item:list.html.twig', array(
|
||||||
'ChillMyBundle:Item:list.html.twig',
|
|
||||||
[
|
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'paginator' => $paginator,
|
'paginator' => $paginator
|
||||||
]
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ The has the following signature :
|
|||||||
*
|
*
|
||||||
* @param string $context
|
* @param string $context
|
||||||
* @param mixed[] $args the argument to the context.
|
* @param mixed[] $args the argument to the context.
|
||||||
* @return string[]
|
* @return TimelineSingleQuery
|
||||||
* @throw \LogicException if the context is not supported
|
* @throw \LogicException if the context is not supported
|
||||||
*/
|
*/
|
||||||
public function fetchQuery($context, array $args);
|
public function fetchQuery($context, array $args);
|
||||||
@@ -163,18 +163,16 @@ The has the following signature :
|
|||||||
The `fetchQuery` function
|
The `fetchQuery` function
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The fetchQuery function help to build the UNION query to gather events. This function should return an associative array MUST have the following key :
|
The fetchQuery function help to build the UNION query to gather events. This function should return an instance of :code:`TimelineSingleQuery`. For you convenience, this object may be build using an associative array with the following keys:
|
||||||
|
|
||||||
* `id` : the name of the id column
|
* `id` : the name of the id column
|
||||||
* `type`: a string to indicate the type
|
* `type`: a string to indicate the type
|
||||||
* `date`: the name of the datetime column, used to order entities by date
|
* `date`: the name of the datetime column, used to order entities by date
|
||||||
* `FROM` (in capital) : the FROM clause. May contains JOIN instructions
|
* `FROM`: the FROM clause. May contains JOIN instructions
|
||||||
|
* `WHERE`: the WHERE clause;
|
||||||
|
* `parameters`: the parameters to pass to the query
|
||||||
|
|
||||||
Those key are optional:
|
The parameters should be replaced into the query by :code:`?`. They will be replaced into the query using prepared statements.
|
||||||
|
|
||||||
* `WHERE` (in capital) : the WHERE clause.
|
|
||||||
|
|
||||||
Where relevant, the data must be quoted to avoid SQL injection.
|
|
||||||
|
|
||||||
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
||||||
|
|
||||||
@@ -186,6 +184,15 @@ For instance, if the context is `'person'`, the args will be this array :
|
|||||||
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
For the context :code:`center`, the args will be:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
array(
|
||||||
|
'centers' => [ ] // an array of \Chill\MainBundle\Entity\Center entities
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -199,13 +206,12 @@ Example of an implementation :
|
|||||||
namespace Chill\ReportBundle\Timeline;
|
namespace Chill\ReportBundle\Timeline;
|
||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
|
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide report for inclusion in timeline
|
* Provide report for inclusion in timeline
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
* @author Champs Libres <info@champs-libres.coop>
|
|
||||||
*/
|
*/
|
||||||
class TimelineReportProvider implements TimelineProviderInterface
|
class TimelineReportProvider implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
@@ -227,16 +233,17 @@ Example of an implementation :
|
|||||||
|
|
||||||
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
||||||
|
|
||||||
return array(
|
return TimelineSingleQuery::fromArray([
|
||||||
'id' => $metadata->getColumnName('id'),
|
'id' => $metadata->getColumnName('id'),
|
||||||
'type' => 'report',
|
'type' => 'report',
|
||||||
'date' => $metadata->getColumnName('date'),
|
'date' => $metadata->getColumnName('date'),
|
||||||
'FROM' => $metadata->getTableName(),
|
'FROM' => $metadata->getTableName(),
|
||||||
'WHERE' => sprintf('%s = %d',
|
'WHERE' => sprintf('%s = ?',
|
||||||
$metadata
|
$metadata
|
||||||
->getAssociationMapping('person')['joinColumns'][0]['name'],
|
->getAssociationMapping('person')['joinColumns'][0]['name'])
|
||||||
$args['person']->getId())
|
)
|
||||||
);
|
'parameters' => [ $args['person']->getId() ]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//....
|
//....
|
||||||
|
|||||||
@@ -1,55 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\HealthBundle\Controller;
|
namespace Chill\HealthBundle\Controller;
|
||||||
|
|
||||||
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
|
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
|
||||||
class ConsultationController extends Controller
|
class ConsultationController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param int $id personId
|
* @param int $id personId
|
||||||
*
|
|
||||||
* @throws type
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
* @throws type
|
||||||
*/
|
*/
|
||||||
public function listAction($id)
|
public function listAction($id)
|
||||||
{
|
{
|
||||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||||
$person = $this->get('chill.person.repository.person')
|
$person = $this->get('chill.person.repository.person')
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
if (null === $person) {
|
if ($person === null) {
|
||||||
throw $this->createNotFoundException('The person is not found');
|
throw $this->createNotFoundException("The person is not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||||
|
|
||||||
/** @var \Chill\MainBundle\Security\Authorization\AuthorizationHelper $authorizationHelper */
|
/* @var $authorizationHelper \Chill\MainBundle\Security\Authorization\AuthorizationHelper */
|
||||||
$authorizationHelper = $this->get('chill.main.security.'
|
$authorizationHelper = $this->get('chill.main.security.'
|
||||||
. 'authorization.helper');
|
. 'authorization.helper');
|
||||||
|
|
||||||
$circles = $authorizationHelper->getReachableCircles(
|
$circles = $authorizationHelper->getReachableCircles(
|
||||||
$this->getUser(),
|
$this->getUser(),
|
||||||
new Role(ConsultationVoter::SEE),
|
new Role(ConsultationVoter::SEE),
|
||||||
$person->getCenter()
|
$person->getCenter()
|
||||||
);
|
);
|
||||||
|
|
||||||
// create a query which take circles into account
|
// create a query which take circles into account
|
||||||
$consultations = $this->getDoctrine()->getManager()
|
$consultations = $this->getDoctrine()->getManager()
|
||||||
->createQuery('SELECT c FROM ChillHealthBundle:Consultation c '
|
->createQuery('SELECT c FROM ChillHealthBundle:Consultation c '
|
||||||
. 'WHERE c.patient = :person AND c.circle IN(:circles) '
|
. 'WHERE c.patient = :person AND c.circle IN(:circles) '
|
||||||
@@ -57,10 +45,11 @@ class ConsultationController extends Controller
|
|||||||
->setParameter('person', $person)
|
->setParameter('person', $person)
|
||||||
->setParameter('circles', $circles)
|
->setParameter('circles', $circles)
|
||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
return $this->render('ChillHealthBundle:Consultation:list.html.twig', [
|
return $this->render('ChillHealthBundle:Consultation:list.html.twig', array(
|
||||||
'person' => $person,
|
'person' => $person,
|
||||||
'consultations' => $consultations,
|
'consultations' => $consultations
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,70 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
|
# Chill\MainBundle\DependencyInjection\Configuration.php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\DependencyInjection;
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
// Chill\MainBundle\DependencyInjection\Configuration.php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\DependencyInjection;
|
|
||||||
|
|
||||||
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
|
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
|
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the main bundle.
|
* Configure the main bundle
|
||||||
*/
|
*/
|
||||||
class ChillMainConfiguration implements ConfigurationInterface
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
use AddWidgetConfigurationTrait;
|
|
||||||
|
use AddWidgetConfigurationTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var ContainerBuilder
|
||||||
|
*/
|
||||||
|
private $containerBuilder;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ContainerBuilder
|
public function __construct(array $widgetFactories = array(),
|
||||||
*/
|
ContainerBuilder $containerBuilder)
|
||||||
private $containerBuilder;
|
{
|
||||||
|
// we register here widget factories (see below)
|
||||||
|
$this->setWidgetFactories($widgetFactories);
|
||||||
|
// we will need the container builder later...
|
||||||
|
$this->containerBuilder = $containerBuilder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getConfigTreeBuilder()
|
||||||
|
{
|
||||||
|
$treeBuilder = new TreeBuilder();
|
||||||
|
$rootNode = $treeBuilder->root('chill_main');
|
||||||
|
|
||||||
public function __construct(
|
$rootNode
|
||||||
array $widgetFactories,
|
->children()
|
||||||
ContainerBuilder $containerBuilder
|
|
||||||
) {
|
|
||||||
// we register here widget factories (see below)
|
|
||||||
$this->setWidgetFactories($widgetFactories);
|
|
||||||
// we will need the container builder later...
|
|
||||||
$this->containerBuilder = $containerBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// ...
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getConfigTreeBuilder()
|
|
||||||
{
|
|
||||||
$treeBuilder = new TreeBuilder();
|
|
||||||
$rootNode = $treeBuilder->root('chill_main');
|
|
||||||
|
|
||||||
$rootNode
|
->arrayNode('widgets')
|
||||||
->children()
|
->canBeDisabled()
|
||||||
|
->children()
|
||||||
|
// we declare here all configuration for homepage place
|
||||||
|
->append($this->addWidgetsConfiguration('homepage', $this->containerBuilder))
|
||||||
|
->end() // end of widgets/children
|
||||||
|
->end() // end of widgets
|
||||||
|
->end() // end of root/children
|
||||||
|
->end() // end of root
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
return $treeBuilder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ...
|
|
||||||
->arrayNode('widgets')
|
|
||||||
->canBeDisabled()
|
|
||||||
->children()
|
|
||||||
// we declare here all configuration for homepage place
|
|
||||||
->append($this->addWidgetsConfiguration('homepage', $this->containerBuilder))
|
|
||||||
->end() // end of widgets/children
|
|
||||||
->end() // end of widgets
|
|
||||||
->end() // end of root/children
|
|
||||||
->end() // end of root
|
|
||||||
;
|
|
||||||
|
|
||||||
return $treeBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,23 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
#Chill\MainBundle\DependencyInjection\ChillMainExtension.php
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
//Chill\MainBundle\DependencyInjection\ChillMainExtension.php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\DependencyInjection;
|
namespace Chill\MainBundle\DependencyInjection;
|
||||||
|
|
||||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader;
|
||||||
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||||
|
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
||||||
|
use Chill\MainBundle\DependencyInjection\Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class load config for chillMainExtension.
|
* This class load config for chillMainExtension.
|
||||||
@@ -25,42 +18,42 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|||||||
class ChillMainExtension extends Extension implements Widget\HasWidgetFactoriesExtensionInterface
|
class ChillMainExtension extends Extension implements Widget\HasWidgetFactoriesExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* widget factory.
|
* widget factory
|
||||||
*
|
*
|
||||||
* @var WidgetFactoryInterface[]
|
* @var WidgetFactoryInterface[]
|
||||||
*/
|
*/
|
||||||
protected $widgetFactories = [];
|
protected $widgetFactories = array();
|
||||||
|
|
||||||
public function addWidgetFactory(WidgetFactoryInterface $factory)
|
public function addWidgetFactory(WidgetFactoryInterface $factory)
|
||||||
{
|
{
|
||||||
$this->widgetFactories[] = $factory;
|
$this->widgetFactories[] = $factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
return new Configuration($this->widgetFactories, $container);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return WidgetFactoryInterface[]
|
* @return WidgetFactoryInterface[]
|
||||||
*/
|
*/
|
||||||
public function getWidgetFactories()
|
public function getWidgetFactories()
|
||||||
{
|
{
|
||||||
return $this->widgetFactories;
|
return $this->widgetFactories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
// configuration for main bundle
|
// configuration for main bundle
|
||||||
$configuration = $this->getConfiguration($configs, $container);
|
$configuration = $this->getConfiguration($configs, $container);
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
// add the key 'widget' without the key 'enable'
|
// add the key 'widget' without the key 'enable'
|
||||||
$container->setParameter(
|
$container->setParameter('chill_main.widgets',
|
||||||
'chill_main.widgets',
|
array('homepage' => $config['widgets']['homepage']));
|
||||||
['homepage' => $config['widgets']['homepage']]
|
|
||||||
);
|
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
return new Configuration($this->widgetFactories, $container);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,77 +1,69 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
# Chill/PersonBundle/Widget/PersonListWidgetFactory
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
// Chill/PersonBundle/Widget/PersonListWidgetFactory
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Widget;
|
namespace Chill\PersonBundle\Widget;
|
||||||
|
|
||||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
|
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
|
||||||
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add configuration for the person_list widget.
|
* add configuration for the person_list widget.
|
||||||
*/
|
*/
|
||||||
class ChillPersonAddAPersonListWidgetFactory extends AbstractWidgetFactory
|
class PersonListWidgetFactory extends AbstractWidgetFactory
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* append the option to the configuration
|
* append the option to the configuration
|
||||||
* see http://symfony.com/doc/current/components/config/definition.html
|
* see http://symfony.com/doc/current/components/config/definition.html
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function configureOptions($place, NodeBuilder $node)
|
public function configureOptions($place, NodeBuilder $node)
|
||||||
{
|
{
|
||||||
$node->booleanNode('only_active')
|
$node->booleanNode('only_active')
|
||||||
->defaultTrue()
|
->defaultTrue()
|
||||||
->end();
|
->end();
|
||||||
$node->integerNode('number_of_items')
|
$node->integerNode('number_of_items')
|
||||||
->defaultValue(50)
|
->defaultValue(50)
|
||||||
->end();
|
->end();
|
||||||
$node->scalarNode('filtering_class')
|
$node->scalarNode('filtering_class')
|
||||||
->defaultNull()
|
->defaultNull()
|
||||||
->end();
|
->end();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* return an array with the allowed places where the widget can be rendered.
|
* return an array with the allowed places where the widget can be rendered
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getAllowedPlaces()
|
public function getAllowedPlaces()
|
||||||
{
|
{
|
||||||
return ['homepage'];
|
return array('homepage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the widget alias
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWidgetAlias()
|
||||||
|
{
|
||||||
|
return 'person_list';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return the service id for the service which will render the widget.
|
* return the service id for the service which will render the widget.
|
||||||
*
|
*
|
||||||
* this service must implements `Chill\MainBundle\Templating\Widget\WidgetInterface`
|
* this service must implements `Chill\MainBundle\Templating\Widget\WidgetInterface`
|
||||||
*
|
*
|
||||||
* the service must exists in the container, and it is not required that the service
|
* the service must exists in the container, and it is not required that the service
|
||||||
* has the `chill_main` tag.
|
* has the `chill_main` tag.
|
||||||
*/
|
*/
|
||||||
public function getServiceId(ContainerBuilder $containerBuilder, $place, $order, array $config)
|
public function getServiceId(ContainerBuilder $containerBuilder, $place, $order, array $config)
|
||||||
{
|
{
|
||||||
return 'chill_person.widget.person_list';
|
return 'chill_person.widget.person_list';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* return the widget alias.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getWidgetAlias()
|
|
||||||
{
|
|
||||||
return 'person_list';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,77 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
|
# Chill/PersonBundle/Widget/PersonListWidget.php
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
// Chill/PersonBundle/Widget/PersonListWidget.php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Widget;
|
namespace Chill\PersonBundle\Widget;
|
||||||
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Chill\MainBundle\Templating\Widget\WidgetInterface;
|
use Chill\MainBundle\Templating\Widget\WidgetInterface;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use DateTime;
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Twig_Environment;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a widget with person list.
|
* add a widget with person list.
|
||||||
*
|
*
|
||||||
* The configuration is defined by `PersonListWidgetFactory`
|
* The configuration is defined by `PersonListWidgetFactory`
|
||||||
*/
|
*/
|
||||||
class ChillPersonAddAPersonWidget implements WidgetInterface
|
class PersonListWidget implements WidgetInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the authorization helper.
|
* Repository for persons
|
||||||
*
|
*
|
||||||
* @var AuthorizationHelper;
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $authorizationHelper;
|
protected $personRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entity manager.
|
* The entity manager
|
||||||
*
|
*
|
||||||
* @var EntityManager
|
* @var EntityManager
|
||||||
*/
|
*/
|
||||||
protected $entityManager;
|
protected $entityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository for persons.
|
* the authorization helper
|
||||||
*
|
*
|
||||||
* @var EntityRepository
|
* @var AuthorizationHelper;
|
||||||
*/
|
*/
|
||||||
protected $personRepository;
|
protected $authorizationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TokenStorage
|
* @var TokenStorage
|
||||||
*/
|
*/
|
||||||
protected $tokenStorage;
|
protected $tokenStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var UserInterface
|
* @var UserInterface
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityRepository $personRepostory,
|
EntityRepository $personRepostory,
|
||||||
EntityManager $em,
|
EntityManager $em,
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
TokenStorage $tokenStorage
|
TokenStorage $tokenStorage
|
||||||
) {
|
) {
|
||||||
$this->personRepository = $personRepostory;
|
$this->personRepository = $personRepostory;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
@@ -79,24 +68,27 @@ class ChillPersonAddAPersonWidget implements WidgetInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @param type $place
|
* @param type $place
|
||||||
*
|
* @param array $context
|
||||||
|
* @param array $config
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function render(Twig_Environment $env, $place, array $context, array $config)
|
public function render(\Twig_Environment $env, $place, array $context, array $config)
|
||||||
{
|
{
|
||||||
$qb = $this->personRepository
|
$qb = $this->personRepository
|
||||||
->createQueryBuilder('person');
|
->createQueryBuilder('person');
|
||||||
|
|
||||||
// show only the person from the authorized centers
|
// show only the person from the authorized centers
|
||||||
$and = $qb->expr()->andX();
|
$and = $qb->expr()->andX();
|
||||||
$centers = $this->authorizationHelper
|
$centers = $this->authorizationHelper
|
||||||
->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
|
->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
|
||||||
$and->add($qb->expr()->in('person.center', ':centers'));
|
$and->add($qb->expr()->in('person.center', ':centers'));
|
||||||
$qb->setParameter('centers', $centers);
|
$qb->setParameter('centers', $centers);
|
||||||
|
|
||||||
|
|
||||||
// add the "only active" where clause
|
// add the "only active" where clause
|
||||||
if (true === $config['only_active']) {
|
if ($config['only_active'] === true) {
|
||||||
$qb->join('person.accompanyingPeriods', 'ap');
|
$qb->join('person.accompanyingPeriods', 'ap');
|
||||||
$or = new Expr\Orx();
|
$or = new Expr\Orx();
|
||||||
// add the case where closingDate IS NULL
|
// add the case where closingDate IS NULL
|
||||||
@@ -106,30 +98,32 @@ class ChillPersonAddAPersonWidget implements WidgetInterface
|
|||||||
$or->add($andWhenClosingDateIsNull);
|
$or->add($andWhenClosingDateIsNull);
|
||||||
// add the case when now is between opening date and closing date
|
// add the case when now is between opening date and closing date
|
||||||
$or->add(
|
$or->add(
|
||||||
(new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate')
|
(new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate')
|
||||||
);
|
);
|
||||||
$and->add($or);
|
$and->add($or);
|
||||||
$qb->setParameter('now', new DateTime(), Type::DATE);
|
$qb->setParameter('now', new \DateTime(), Type::DATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// adding the where clause to the query
|
// adding the where clause to the query
|
||||||
$qb->where($and);
|
$qb->where($and);
|
||||||
|
|
||||||
$qb->setFirstResult(0)->setMaxResults($config['number_of_items']);
|
$qb->setFirstResult(0)->setMaxResults($config['number_of_items']);
|
||||||
|
|
||||||
$persons = $qb->getQuery()->getResult();
|
$persons = $qb->getQuery()->getResult();
|
||||||
|
|
||||||
return $env->render(
|
return $env->render(
|
||||||
'ChillPersonBundle:Widget:homepage_person_list.html.twig',
|
'ChillPersonBundle:Widget:homepage_person_list.html.twig',
|
||||||
['persons' => $persons]
|
array('persons' => $persons)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return UserInterface
|
* @return UserInterface
|
||||||
*/
|
*/
|
||||||
private function getUser()
|
private function getUser()
|
||||||
{
|
{
|
||||||
// return a user
|
// return a user
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
# Chill/PersonBundle/DependencyInjection/ChillPersonExtension.php
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
// Chill/PersonBundle/DependencyInjection/ChillPersonExtension.php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\DependencyInjection;
|
namespace Chill\PersonBundle\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader;
|
||||||
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||||
|
use Chill\MainBundle\DependencyInjection\MissingBundleException;
|
||||||
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that loads and manages your bundle configuration.
|
* This is the class that loads and manages your bundle configuration
|
||||||
*
|
*
|
||||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||||
*/
|
*/
|
||||||
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function load(array $configs, ContainerBuilder $container)
|
public function load(array $configs, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a widget "add a person" on the homepage, automatically.
|
*
|
||||||
*
|
* Add a widget "add a person" on the homepage, automatically
|
||||||
|
*
|
||||||
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
|
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
|
||||||
*/
|
*/
|
||||||
public function prepend(ContainerBuilder $container)
|
public function prepend(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$container->prependExtensionConfig('chill_main', [
|
$container->prependExtensionConfig('chill_main', array(
|
||||||
'widgets' => [
|
'widgets' => array(
|
||||||
'homepage' => [
|
'homepage' => array(
|
||||||
[
|
array(
|
||||||
'widget_alias' => 'add_person',
|
'widget_alias' => 'add_person',
|
||||||
'order' => 2,
|
'order' => 2
|
||||||
],
|
)
|
||||||
],
|
)
|
||||||
],
|
)
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Chill will be available at ``http://localhost:8001.`` Currently, there isn't any
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
docker-compose exec --user $(id -u) php bin/console doctrine:fixtures:load
|
docker-compose exec --user $(id -u) php bin/console doctrine:fixtures:load --purge-with-truncate
|
||||||
|
|
||||||
There are several users available:
|
There are several users available:
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
imports:
|
|
||||||
- { resource: vendor/drupol/php-conventions/config/php73/grumphp.yml }
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
tasks.phpcsfixer.config: .php_cs.dist
|
|
||||||
tasks.license.name: AGPL-3.0
|
|
||||||
tasks.license.holder: Champs-Libres
|
|
||||||
tasks.license.date_from: 2001
|
|
||||||
@@ -18,12 +18,20 @@
|
|||||||
<testsuite name="MainBundle">
|
<testsuite name="MainBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
|
||||||
<testsuite name="PersonBundle">
|
<testsuite name="PersonBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
||||||
|
<!-- test for export will be runned later -->
|
||||||
|
<exclude>src/Bundle/ChillPersonBundle/Tests/Export/*</exclude>
|
||||||
|
<!-- we are rewriting accompanying periods... Work in progress -->
|
||||||
|
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php</exclude>
|
||||||
|
<!-- we are rewriting address, Work in progress -->
|
||||||
|
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php</exclude>
|
||||||
|
<!-- find a solution to create multiple configs -->
|
||||||
|
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php</exclude>
|
||||||
|
<!-- temporarily removed, the time to find a fix -->
|
||||||
|
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php</exclude>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
</testsuites>
|
|
||||||
|
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
Chill is a software for social workers.
|
|
||||||
|
|
||||||
For the full copyright and license information, please view
|
|
||||||
the LICENSE file that was distributed with this source code.
|
|
||||||
|
|
||||||
@see https://www.champs-libres.coop/
|
|
||||||
@@ -1,16 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle;
|
namespace Chill\ActivityBundle;
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
|
|||||||
@@ -1,468 +1,481 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
use Symfony\Component\Form\Form;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Form\ActivityType;
|
use Chill\ActivityBundle\Form\ActivityType;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Chill\PersonBundle\Privacy\PrivacyEvent;
|
|
||||||
use DateTime;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ActivityController
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Controller
|
||||||
|
*/
|
||||||
class ActivityController extends AbstractController
|
class ActivityController extends AbstractController
|
||||||
{
|
{
|
||||||
/**
|
protected EventDispatcherInterface $eventDispatcher;
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $authorizationHelper;
|
|
||||||
|
|
||||||
/**
|
protected AuthorizationHelper $authorizationHelper;
|
||||||
* @var EventDispatcherInterface
|
|
||||||
*/
|
|
||||||
protected $eventDispatcher;
|
|
||||||
|
|
||||||
/**
|
protected LoggerInterface $logger;
|
||||||
* @var LoggerInterface
|
|
||||||
*/
|
protected SerializerInterface $serializer;
|
||||||
protected $logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ActivityController constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
LoggerInterface $logger
|
LoggerInterface $logger,
|
||||||
|
SerializerInterface $serializer
|
||||||
) {
|
) {
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->serializer = $serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Activity entity.
|
* Lists all Activity entities.
|
||||||
*
|
|
||||||
* @param mixed $person_id
|
|
||||||
*/
|
*/
|
||||||
public function createAction($person_id, Request $request)
|
public function listAction(Request $request): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
$view = null;
|
||||||
|
// TODO: add pagination
|
||||||
|
|
||||||
if (null === $person) {
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
throw $this->createNotFoundException('person not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
if ($person instanceof Person) {
|
||||||
|
$reachableScopes = $this->authorizationHelper
|
||||||
|
->getReachableCircles($this->getUser(), new Role('CHILL_ACTIVITY_SEE'),
|
||||||
|
$person->getCenter());
|
||||||
|
|
||||||
$entity = new Activity();
|
$activities = $em->getRepository(Activity::class)
|
||||||
$entity->setPerson($person);
|
->findByPersonImplied($person, $reachableScopes)
|
||||||
$form = $this->createCreateForm($entity, $person);
|
;
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isValid()) {
|
$event = new PrivacyEvent($person, array(
|
||||||
$em = $this->getDoctrine()->getManager();
|
'element_class' => Activity::class,
|
||||||
|
'action' => 'list'
|
||||||
|
));
|
||||||
|
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted(
|
$view = 'ChillActivityBundle:Activity:listPerson.html.twig';
|
||||||
'CHILL_ACTIVITY_CREATE',
|
} elseif ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
$entity,
|
$activities = $em->getRepository('ChillActivityBundle:Activity')->findBy(
|
||||||
'creation of this activity not allowed'
|
['accompanyingPeriod' => $accompanyingPeriod],
|
||||||
|
['date' => 'DESC'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$view = 'ChillActivityBundle:Activity:listAccompanyingCourse.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($view, array(
|
||||||
|
'activities' => $activities,
|
||||||
|
'person' => $person,
|
||||||
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectTypeAction(Request $request): Response
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$view = null;
|
||||||
|
|
||||||
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:selectTypeAccompanyingCourse.html.twig';
|
||||||
|
} elseif ($person instanceof Person) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:selectTypePerson.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
$activityTypeCategories = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityTypeCategory::class)
|
||||||
|
->findBy(['active' => true], ['ordering' => 'ASC']);
|
||||||
|
|
||||||
|
foreach ($activityTypeCategories as $activityTypeCategory) {
|
||||||
|
$activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
|
||||||
|
->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
|
||||||
|
|
||||||
|
$data[] = [
|
||||||
|
'activityTypeCategory' => $activityTypeCategory,
|
||||||
|
'activityTypes' => $activityTypes,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($view === null) {
|
||||||
|
throw $this->createNotFoundException('Template not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($view, [
|
||||||
|
'person' => $person,
|
||||||
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
|
'data' => $data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newAction(Request $request): Response
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:newAccompanyingCourse.html.twig';
|
||||||
|
} elseif ($person instanceof Person) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:newPerson.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
$activityType_id = $request->get('activityType_id', 0);
|
||||||
|
$activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
|
||||||
|
->find($activityType_id);
|
||||||
|
|
||||||
|
if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType ||
|
||||||
|
!$activityType->isActive()) {
|
||||||
|
|
||||||
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
|
return $this->redirectToRoute('chill_activity_activity_select_type', $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity = new Activity();
|
||||||
|
$entity->setUser($this->getUser());
|
||||||
|
|
||||||
|
if ($person instanceof Person) {
|
||||||
|
$entity->setPerson($person);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
|
$entity->setAccompanyingPeriod($accompanyingPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity->setType($activityType);
|
||||||
|
$entity->setDate(new \DateTime('now'));
|
||||||
|
|
||||||
|
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
|
||||||
|
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity);
|
||||||
|
|
||||||
|
$form = $this->createForm(ActivityType::class, $entity, [
|
||||||
|
'center' => $entity->getCenter(),
|
||||||
|
'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
||||||
|
'activityType' => $entity->getType(),
|
||||||
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
|
])->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->get('session')
|
$this->addFlash('success', $this->get('translator')->trans('Success : activity created!'));
|
||||||
->getFlashBag()
|
|
||||||
->add(
|
|
||||||
'success',
|
|
||||||
$this->get('translator')
|
|
||||||
->trans('Success : activity created!')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirect(
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
$this->generateUrl(
|
$params['id'] = $entity->getId();
|
||||||
'chill_activity_activity_show',
|
|
||||||
['id' => $entity->getId(), 'person_id' => $person_id]
|
return $this->redirectToRoute('chill_activity_activity_show', $params);
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->get('session')
|
if ($view === null) {
|
||||||
->getFlashBag()->add(
|
throw $this->createNotFoundException('Template not found');
|
||||||
'danger',
|
}
|
||||||
$this->get('translator')
|
|
||||||
->trans('The form is not valid. The activity has not been created !')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:new.html.twig', [
|
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||||
|
|
||||||
|
return $this->render($view, [
|
||||||
|
'person' => $person,
|
||||||
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'person' => $person,
|
'activity_json' => $activity_array
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function showAction(Request $request, $id): Response
|
||||||
* Deletes a Activity entity.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
* @param mixed $person_id
|
|
||||||
*/
|
|
||||||
public function deleteAction(Request $request, $id, $person_id)
|
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
/** @var Activity $activity */
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
$activity = $em->getRepository('ChillActivityBundle:Activity')
|
|
||||||
->find($id);
|
|
||||||
$person = $activity->getPerson();
|
|
||||||
|
|
||||||
if (!$activity) {
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:showAccompanyingCourse.html.twig';
|
||||||
|
} elseif ($person instanceof Person) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:showPerson.html.twig';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
||||||
|
|
||||||
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
if (null !== $accompanyingPeriod) {
|
||||||
|
$entity->personsAssociated = $entity->getPersonsAssociated();
|
||||||
$form = $this->createDeleteForm($id, $person);
|
$entity->personsNotAssociated = $entity->getPersonsNotAssociated();
|
||||||
|
|
||||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$this->logger->notice('An activity has been removed', [
|
|
||||||
'by_user' => $this->getUser()->getUsername(),
|
|
||||||
'activity_id' => $activity->getId(),
|
|
||||||
'person_id' => $activity->getPerson()->getId(),
|
|
||||||
'comment' => $activity->getComment()->getComment(),
|
|
||||||
'scope_id' => $activity->getScope()->getId(),
|
|
||||||
'reasons_ids' => $activity->getReasons()
|
|
||||||
->map(static function ($ar) {
|
|
||||||
return $ar->getId();
|
|
||||||
})
|
|
||||||
->toArray(),
|
|
||||||
'type_id' => $activity->getType()->getId(),
|
|
||||||
'duration' => $activity->getDurationTime()->format('U'),
|
|
||||||
'date' => $activity->getDate()->format('Y-m-d'),
|
|
||||||
'attendee' => $activity->getAttendee(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$em->remove($activity);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')
|
|
||||||
->trans('The activity has been successfully removed.'));
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl(
|
|
||||||
'chill_activity_activity_list',
|
|
||||||
[
|
|
||||||
'person_id' => $person_id,
|
|
||||||
]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:confirm_delete.html.twig', [
|
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
|
||||||
'activity' => $activity,
|
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity);
|
||||||
'delete_form' => $form->createView(),
|
|
||||||
]);
|
$deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
/*
|
||||||
|
$event = new PrivacyEvent($person, array(
|
||||||
|
'element_class' => Activity::class,
|
||||||
|
'element_id' => $entity->getId(),
|
||||||
|
'action' => 'show'
|
||||||
|
));
|
||||||
|
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($view === null) {
|
||||||
|
throw $this->createNotFoundException('Template not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($view, array(
|
||||||
|
'person' => $person,
|
||||||
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
|
'entity' => $entity,
|
||||||
|
'delete_form' => $deleteForm->createView(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing Activity entity.
|
* Displays a form to edit an existing Activity entity.
|
||||||
*
|
*
|
||||||
* @param mixed $person_id
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
*/
|
||||||
public function editAction($person_id, $id)
|
public function editAction($id, Request $request): Response
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
|
||||||
|
|
||||||
if (!$person) {
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
throw $this->createNotFoundException('person not found');
|
|
||||||
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:editAccompanyingCourse.html.twig';
|
||||||
|
} elseif ($person instanceof Person) {
|
||||||
|
$view = 'ChillActivityBundle:Activity:editPerson.html.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);
|
// TODO
|
||||||
|
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);
|
||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$form = $this->createForm(ActivityType::class, $entity, [
|
||||||
$deleteForm = $this->createDeleteForm($id, $person);
|
'center' => $entity->getCenter(),
|
||||||
|
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
||||||
|
'activityType' => $entity->getType(),
|
||||||
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
|
])->handleRequest($request);
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, [
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
'element_class' => Activity::class,
|
$em->persist($entity);
|
||||||
'element_id' => $entity->getId(),
|
|
||||||
'action' => 'edit',
|
|
||||||
]);
|
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:edit.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'edit_form' => $editForm->createView(),
|
|
||||||
'delete_form' => $deleteForm->createView(),
|
|
||||||
'person' => $person,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists all Activity entities.
|
|
||||||
*
|
|
||||||
* @param mixed $person_id
|
|
||||||
*/
|
|
||||||
public function listAction($person_id, Request $request)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
|
||||||
|
|
||||||
if (null === $person) {
|
|
||||||
throw $this->createNotFoundException('Person not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
|
||||||
|
|
||||||
$reachableScopes = $this->authorizationHelper
|
|
||||||
->getReachableScopes(
|
|
||||||
$this->getUser(),
|
|
||||||
new Role('CHILL_ACTIVITY_SEE'),
|
|
||||||
$person->getCenter()
|
|
||||||
);
|
|
||||||
|
|
||||||
$activities = $em->getRepository('ChillActivityBundle:Activity')
|
|
||||||
->findBy(
|
|
||||||
['person' => $person, 'scope' => $reachableScopes],
|
|
||||||
['date' => 'DESC']
|
|
||||||
);
|
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, [
|
|
||||||
'element_class' => Activity::class,
|
|
||||||
'action' => 'list',
|
|
||||||
]);
|
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:list.html.twig', [
|
|
||||||
'activities' => $activities,
|
|
||||||
'person' => $person,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a form to create a new Activity entity.
|
|
||||||
*
|
|
||||||
* @param mixed $person_id
|
|
||||||
*/
|
|
||||||
public function newAction($person_id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
|
||||||
|
|
||||||
if (null === $person) {
|
|
||||||
throw $this->createNotFoundException('Person not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
|
||||||
|
|
||||||
$entity = new Activity();
|
|
||||||
$entity->setUser($this->get('security.token_storage')->getToken()->getUser());
|
|
||||||
$entity->setPerson($person);
|
|
||||||
$entity->setDate(new DateTime('now'));
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity);
|
|
||||||
|
|
||||||
$form = $this->createCreateForm($entity, $person);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:new.html.twig', [
|
|
||||||
'person' => $person,
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds and displays a Activity entity.
|
|
||||||
*
|
|
||||||
* @param mixed $person_id
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function showAction($person_id, $id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
|
||||||
|
|
||||||
if (!$person) {
|
|
||||||
throw $this->createNotFoundException('person not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_SEE', $entity);
|
|
||||||
|
|
||||||
$deleteForm = $this->createDeleteForm($id, $person);
|
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, [
|
|
||||||
'element_class' => Activity::class,
|
|
||||||
'element_id' => $entity->getId(),
|
|
||||||
'action' => 'show',
|
|
||||||
]);
|
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:show.html.twig', [
|
|
||||||
'person' => $person,
|
|
||||||
'entity' => $entity,
|
|
||||||
'delete_form' => $deleteForm->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edits an existing Activity entity.
|
|
||||||
*
|
|
||||||
* @param mixed $person_id
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function updateAction(Request $request, $person_id, $id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$person = $em->getRepository('ChillPersonBundle:Person')->find($person_id);
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find Activity entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity);
|
|
||||||
|
|
||||||
$deleteForm = $this->createDeleteForm($id, $person);
|
|
||||||
$editForm = $this->createEditForm($entity);
|
|
||||||
$editForm->handleRequest($request);
|
|
||||||
|
|
||||||
$event = new PrivacyEvent($person, [
|
|
||||||
'element_class' => Activity::class,
|
|
||||||
'element_id' => $entity->getId(),
|
|
||||||
'action' => 'update',
|
|
||||||
]);
|
|
||||||
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
|
||||||
|
|
||||||
if ($editForm->isValid()) {
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$this->get('session')
|
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
|
||||||
->getFlashBag()
|
|
||||||
->add(
|
|
||||||
'success',
|
|
||||||
$this->get('translator')
|
|
||||||
->trans('Success : activity updated!')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activity_show', ['id' => $id, 'person_id' => $person_id]));
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
|
$params['id'] = $id;
|
||||||
|
return $this->redirectToRoute('chill_activity_activity_show', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->get('session')
|
$deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod);
|
||||||
->getFlashBag()
|
|
||||||
->add(
|
|
||||||
'error',
|
|
||||||
$this->get('translator')
|
|
||||||
->trans('This form contains errors')
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:Activity:edit.html.twig', [
|
/*
|
||||||
'person' => $entity->getPerson(),
|
* TODO
|
||||||
'entity' => $entity,
|
$event = new PrivacyEvent($person, array(
|
||||||
'edit_form' => $editForm->createView(),
|
'element_class' => Activity::class,
|
||||||
|
'element_id' => $entity->getId(),
|
||||||
|
'action' => 'edit'
|
||||||
|
));
|
||||||
|
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($view === null) {
|
||||||
|
throw $this->createNotFoundException('Template not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||||
|
|
||||||
|
return $this->render($view, array(
|
||||||
|
'entity' => $entity,
|
||||||
|
'edit_form' => $form->createView(),
|
||||||
'delete_form' => $deleteForm->createView(),
|
'delete_form' => $deleteForm->createView(),
|
||||||
]);
|
'person' => $person,
|
||||||
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
|
'activity_json' => $activity_array
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form to create a Activity entity.
|
* Deletes a Activity entity.
|
||||||
*
|
*
|
||||||
* @param Activity $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
*/
|
||||||
private function createCreateForm(Activity $entity)
|
public function deleteAction(Request $request, $id)
|
||||||
{
|
{
|
||||||
return $this->createForm(
|
$em = $this->getDoctrine()->getManager();
|
||||||
ActivityType::class,
|
|
||||||
$entity,
|
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
[
|
|
||||||
'action' => $this->generateUrl('chill_activity_activity_create', [
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
'person_id' => $entity->getPerson()->getId(),
|
$view = 'ChillActivityBundle:Activity:confirm_deleteAccompanyingCourse.html.twig';
|
||||||
]),
|
} elseif ($person instanceof Person) {
|
||||||
'method' => 'POST',
|
$view = 'ChillActivityBundle:Activity:confirm_deletePerson.html.twig';
|
||||||
'center' => $entity->getCenter(),
|
}
|
||||||
'role' => new Role('CHILL_ACTIVITY_CREATE'),
|
|
||||||
]
|
/* @var $activity Activity */
|
||||||
);
|
$activity = $em->getRepository('ChillActivityBundle:Activity')->find($id);
|
||||||
|
|
||||||
|
if (!$activity) {
|
||||||
|
throw $this->createNotFoundException('Unable to find Activity entity.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_DELETE', $activity);
|
||||||
|
|
||||||
|
$form = $this->createDeleteForm($id, $person, $accompanyingPeriod);
|
||||||
|
|
||||||
|
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
|
||||||
|
$this->logger->notice("An activity has been removed", array(
|
||||||
|
'by_user' => $this->getUser()->getUsername(),
|
||||||
|
'activity_id' => $activity->getId(),
|
||||||
|
'person_id' => $activity->getPerson() ? $activity->getPerson()->getId() : null,
|
||||||
|
'comment' => $activity->getComment()->getComment(),
|
||||||
|
'scope_id' => $activity->getScope() ? $activity->getScope()->getId() : null,
|
||||||
|
'reasons_ids' => $activity->getReasons()
|
||||||
|
->map(function ($ar) { return $ar->getId(); })
|
||||||
|
->toArray(),
|
||||||
|
'type_id' => $activity->getType()->getId(),
|
||||||
|
'duration' => $activity->getDurationTime() ? $activity->getDurationTime()->format('U') : null,
|
||||||
|
'date' => $activity->getDate()->format('Y-m-d'),
|
||||||
|
'attendee' => $activity->getAttendee()
|
||||||
|
));
|
||||||
|
|
||||||
|
$em->remove($activity);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->get('translator')
|
||||||
|
->trans("The activity has been successfully removed."));
|
||||||
|
|
||||||
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
|
return $this->redirectToRoute('chill_activity_activity_list', $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($view === null) {
|
||||||
|
throw $this->createNotFoundException('Template not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($view, array(
|
||||||
|
'activity' => $activity,
|
||||||
|
'delete_form' => $form->createView(),
|
||||||
|
'person' => $person,
|
||||||
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a form to delete a Activity entity by id.
|
* Creates a form to delete a Activity entity by id.
|
||||||
*
|
|
||||||
* @param mixed $id The entity id
|
|
||||||
* @param mixed $person
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
*/
|
||||||
private function createDeleteForm($id, $person)
|
private function createDeleteForm(int $id, ?Person $person, ?AccompanyingPeriod $accompanyingPeriod): Form
|
||||||
{
|
{
|
||||||
|
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
||||||
|
$params['id'] = $id;
|
||||||
|
|
||||||
return $this->createFormBuilder()
|
return $this->createFormBuilder()
|
||||||
->setAction($this->generateUrl(
|
->setAction($this->generateUrl('chill_activity_activity_delete', $params))
|
||||||
'chill_activity_activity_delete',
|
|
||||||
['id' => $id, 'person_id' => $person->getId()]
|
|
||||||
))
|
|
||||||
->setMethod('DELETE')
|
->setMethod('DELETE')
|
||||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||||
->getForm();
|
->getForm()
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function getEntity(Request $request): array
|
||||||
* Creates a form to edit a Activity entity.
|
|
||||||
*
|
|
||||||
* @param Activity $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createEditForm(Activity $entity)
|
|
||||||
{
|
{
|
||||||
return $this->createForm(ActivityType::class, $entity, [
|
$em = $this->getDoctrine()->getManager();
|
||||||
'action' => $this->generateUrl(
|
$person = $accompanyingPeriod = null;
|
||||||
'chill_activity_activity_update',
|
|
||||||
[
|
if ($request->query->has('person_id')) {
|
||||||
'id' => $entity->getId(),
|
$person_id = $request->get('person_id');
|
||||||
'person_id' => $entity->getPerson()->getId(),
|
$person = $em->getRepository(Person::class)->find($person_id);
|
||||||
]
|
|
||||||
),
|
if ($person === null) {
|
||||||
'method' => 'PUT',
|
throw $this->createNotFoundException('Person not found');
|
||||||
'center' => $entity->getCenter(),
|
}
|
||||||
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
|
||||||
]);
|
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||||
|
} elseif ($request->query->has('accompanying_period_id')) {
|
||||||
|
$accompanying_period_id = $request->get('accompanying_period_id');
|
||||||
|
$accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($accompanying_period_id);
|
||||||
|
|
||||||
|
if ($accompanyingPeriod === null) {
|
||||||
|
throw $this->createNotFoundException('Accompanying Period not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Add permission
|
||||||
|
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
|
||||||
|
} else {
|
||||||
|
throw $this->createNotFoundException("Person or Accompanying Period not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
$person, $accompanyingPeriod
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildParamsToUrl(
|
||||||
|
?Person $person,
|
||||||
|
?AccompanyingPeriod $accompanyingPeriod
|
||||||
|
): array {
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
if ($person) {
|
||||||
|
$params['person_id'] = $person->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($accompanyingPeriod) {
|
||||||
|
$params['accompanying_period_id'] = $accompanyingPeriod->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $params;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||||
use Chill\ActivityBundle\Form\ActivityReasonCategoryType;
|
use Chill\ActivityBundle\Form\ActivityReasonCategoryType;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityReasonCategory controller.
|
||||||
|
*
|
||||||
|
*/
|
||||||
class ActivityReasonCategoryController extends AbstractController
|
class ActivityReasonCategoryController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all ActivityReasonCategory entities.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function indexAction()
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$entities = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->findAll();
|
||||||
|
|
||||||
|
return $this->render('ChillActivityBundle:ActivityReasonCategory:index.html.twig', array(
|
||||||
|
'entities' => $entities,
|
||||||
|
));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a new ActivityReasonCategory entity.
|
* Creates a new ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request)
|
||||||
{
|
{
|
||||||
@@ -35,19 +45,71 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory_show', ['id' => $entity->getId()]));
|
return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory_show', array('id' => $entity->getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReasonCategory:new.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReasonCategory:new.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
]);
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a form to create a ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
|
* @param ActivityReasonCategory $entity The entity
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Form\Form The form
|
||||||
|
*/
|
||||||
|
private function createCreateForm(ActivityReasonCategory $entity)
|
||||||
|
{
|
||||||
|
$form = $this->createForm(ActivityReasonCategoryType::class, $entity, array(
|
||||||
|
'action' => $this->generateUrl('chill_activity_activityreasoncategory_create'),
|
||||||
|
'method' => 'POST',
|
||||||
|
));
|
||||||
|
|
||||||
|
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a form to create a new ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function newAction()
|
||||||
|
{
|
||||||
|
$entity = new ActivityReasonCategory();
|
||||||
|
$form = $this->createCreateForm($entity);
|
||||||
|
|
||||||
|
return $this->render('ChillActivityBundle:ActivityReasonCategory:new.html.twig', array(
|
||||||
|
'entity' => $entity,
|
||||||
|
'form' => $form->createView(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds and displays a ActivityReasonCategory entity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function showAction($id)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$entity = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->find($id);
|
||||||
|
|
||||||
|
if (!$entity) {
|
||||||
|
throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('ChillActivityBundle:ActivityReasonCategory:show.html.twig', array(
|
||||||
|
'entity' => $entity,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing ActivityReasonCategory entity.
|
* Displays a form to edit an existing ActivityReasonCategory entity.
|
||||||
*
|
*
|
||||||
* @param mixed $id
|
|
||||||
*/
|
*/
|
||||||
public function editAction($id)
|
public function editAction($id)
|
||||||
{
|
{
|
||||||
@@ -61,64 +123,33 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all ActivityReasonCategory entities.
|
* Creates a form to edit a ActivityReasonCategory entity.
|
||||||
*/
|
*
|
||||||
public function indexAction()
|
* @param ActivityReasonCategory $entity The entity
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Form\Form The form
|
||||||
|
*/
|
||||||
|
private function createEditForm(ActivityReasonCategory $entity)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$form = $this->createForm(ActivityReasonCategoryType::class, $entity, array(
|
||||||
|
'action' => $this->generateUrl('chill_activity_activityreasoncategory_update', array('id' => $entity->getId())),
|
||||||
|
'method' => 'PUT',
|
||||||
|
));
|
||||||
|
|
||||||
$entities = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->findAll();
|
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReasonCategory:index.html.twig', [
|
return $form;
|
||||||
'entities' => $entities,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a form to create a new ActivityReasonCategory entity.
|
|
||||||
*/
|
|
||||||
public function newAction()
|
|
||||||
{
|
|
||||||
$entity = new ActivityReasonCategory();
|
|
||||||
$form = $this->createCreateForm($entity);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReasonCategory:new.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds and displays a ActivityReasonCategory entity.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function showAction($id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:ActivityReasonCategory')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find ActivityReasonCategory entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReasonCategory:show.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing ActivityReasonCategory entity.
|
* Edits an existing ActivityReasonCategory entity.
|
||||||
*
|
*
|
||||||
* @param mixed $id
|
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, $id)
|
public function updateAction(Request $request, $id)
|
||||||
{
|
{
|
||||||
@@ -136,50 +167,12 @@ class ActivityReasonCategoryController extends AbstractController
|
|||||||
if ($editForm->isValid()) {
|
if ($editForm->isValid()) {
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory_edit', ['id' => $id]));
|
return $this->redirect($this->generateUrl('chill_activity_activityreasoncategory_edit', array('id' => $id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReasonCategory:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
]);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form to create a ActivityReasonCategory entity.
|
|
||||||
*
|
|
||||||
* @param ActivityReasonCategory $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createCreateForm(ActivityReasonCategory $entity)
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ActivityReasonCategoryType::class, $entity, [
|
|
||||||
'action' => $this->generateUrl('chill_activity_activityreasoncategory_create'),
|
|
||||||
'method' => 'POST',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, ['label' => 'Create']);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form to edit a ActivityReasonCategory entity.
|
|
||||||
*
|
|
||||||
* @param ActivityReasonCategory $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createEditForm(ActivityReasonCategory $entity)
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ActivityReasonCategoryType::class, $entity, [
|
|
||||||
'action' => $this->generateUrl('chill_activity_activityreasoncategory_update', ['id' => $entity->getId()]),
|
|
||||||
'method' => 'PUT',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, ['label' => 'Update']);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
use Chill\ActivityBundle\Form\ActivityReasonType;
|
use Chill\ActivityBundle\Form\ActivityReasonType;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityReason controller.
|
||||||
|
*
|
||||||
|
*/
|
||||||
class ActivityReasonController extends AbstractController
|
class ActivityReasonController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all ActivityReason entities.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function indexAction()
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$entities = $em->getRepository('ChillActivityBundle:ActivityReason')->findAll();
|
||||||
|
|
||||||
|
return $this->render('ChillActivityBundle:ActivityReason:index.html.twig', array(
|
||||||
|
'entities' => $entities,
|
||||||
|
));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a new ActivityReason entity.
|
* Creates a new ActivityReason entity.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request)
|
||||||
{
|
{
|
||||||
@@ -35,19 +45,71 @@ class ActivityReasonController extends AbstractController
|
|||||||
$em->persist($entity);
|
$em->persist($entity);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activityreason', ['id' => $entity->getId()]));
|
return $this->redirect($this->generateUrl('chill_activity_activityreason', array('id' => $entity->getId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:new.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReason:new.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
]);
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a form to create a ActivityReason entity.
|
||||||
|
*
|
||||||
|
* @param ActivityReason $entity The entity
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Form\Form The form
|
||||||
|
*/
|
||||||
|
private function createCreateForm(ActivityReason $entity)
|
||||||
|
{
|
||||||
|
$form = $this->createForm(ActivityReasonType::class, $entity, array(
|
||||||
|
'action' => $this->generateUrl('chill_activity_activityreason_create'),
|
||||||
|
'method' => 'POST',
|
||||||
|
));
|
||||||
|
|
||||||
|
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a form to create a new ActivityReason entity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function newAction()
|
||||||
|
{
|
||||||
|
$entity = new ActivityReason();
|
||||||
|
$form = $this->createCreateForm($entity);
|
||||||
|
|
||||||
|
return $this->render('ChillActivityBundle:ActivityReason:new.html.twig', array(
|
||||||
|
'entity' => $entity,
|
||||||
|
'form' => $form->createView(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds and displays a ActivityReason entity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function showAction($id)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$entity = $em->getRepository('ChillActivityBundle:ActivityReason')->find($id);
|
||||||
|
|
||||||
|
if (!$entity) {
|
||||||
|
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('ChillActivityBundle:ActivityReason:show.html.twig', array(
|
||||||
|
'entity' => $entity,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a form to edit an existing ActivityReason entity.
|
* Displays a form to edit an existing ActivityReason entity.
|
||||||
*
|
*
|
||||||
* @param mixed $id
|
|
||||||
*/
|
*/
|
||||||
public function editAction($id)
|
public function editAction($id)
|
||||||
{
|
{
|
||||||
@@ -61,64 +123,33 @@ class ActivityReasonController extends AbstractController
|
|||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
$editForm = $this->createEditForm($entity);
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView()
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all ActivityReason entities.
|
* Creates a form to edit a ActivityReason entity.
|
||||||
*/
|
*
|
||||||
public function indexAction()
|
* @param ActivityReason $entity The entity
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Form\Form The form
|
||||||
|
*/
|
||||||
|
private function createEditForm(ActivityReason $entity)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$form = $this->createForm(ActivityReasonType::class, $entity, array(
|
||||||
|
'action' => $this->generateUrl('chill_activity_activityreason_update', array('id' => $entity->getId())),
|
||||||
|
'method' => 'PUT',
|
||||||
|
));
|
||||||
|
|
||||||
$entities = $em->getRepository('ChillActivityBundle:ActivityReason')->findAll();
|
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:index.html.twig', [
|
return $form;
|
||||||
'entities' => $entities,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a form to create a new ActivityReason entity.
|
|
||||||
*/
|
|
||||||
public function newAction()
|
|
||||||
{
|
|
||||||
$entity = new ActivityReason();
|
|
||||||
$form = $this->createCreateForm($entity);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:new.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds and displays a ActivityReason entity.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function showAction($id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:ActivityReason')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find ActivityReason entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:show.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edits an existing ActivityReason entity.
|
* Edits an existing ActivityReason entity.
|
||||||
*
|
*
|
||||||
* @param mixed $id
|
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, $id)
|
public function updateAction(Request $request, $id)
|
||||||
{
|
{
|
||||||
@@ -136,50 +167,12 @@ class ActivityReasonController extends AbstractController
|
|||||||
if ($editForm->isValid()) {
|
if ($editForm->isValid()) {
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activityreason', ['id' => $id]));
|
return $this->redirect($this->generateUrl('chill_activity_activityreason', array('id' => $id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', [
|
return $this->render('ChillActivityBundle:ActivityReason:edit.html.twig', array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView()
|
||||||
]);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form to create a ActivityReason entity.
|
|
||||||
*
|
|
||||||
* @param ActivityReason $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createCreateForm(ActivityReason $entity)
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ActivityReasonType::class, $entity, [
|
|
||||||
'action' => $this->generateUrl('chill_activity_activityreason_create'),
|
|
||||||
'method' => 'POST',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, ['label' => 'Create']);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form to edit a ActivityReason entity.
|
|
||||||
*
|
|
||||||
* @param ActivityReason $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createEditForm(ActivityReason $entity)
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ActivityReasonType::class, $entity, [
|
|
||||||
'action' => $this->generateUrl('chill_activity_activityreason_update', ['id' => $entity->getId()]),
|
|
||||||
'method' => 'PUT',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, ['label' => 'Update']);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,185 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
|
||||||
use Chill\ActivityBundle\Form\ActivityTypeType;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
class ActivityTypeController extends AbstractController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Creates a new ActivityType entity.
|
|
||||||
*/
|
|
||||||
public function createAction(Request $request)
|
|
||||||
{
|
|
||||||
$entity = new ActivityType();
|
|
||||||
$form = $this->createCreateForm($entity);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
|
|
||||||
if ($form->isValid()) {
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$em->persist($entity);
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activitytype_show', ['id' => $entity->getId()]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityType:new.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a form to edit an existing ActivityType entity.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function editAction($id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find ActivityType entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'edit_form' => $editForm->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists all ActivityType entities.
|
|
||||||
*/
|
|
||||||
public function indexAction()
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entities = $em->getRepository('ChillActivityBundle:ActivityType')->findAll();
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityType:index.html.twig', [
|
|
||||||
'entities' => $entities,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays a form to create a new ActivityType entity.
|
|
||||||
*/
|
|
||||||
public function newAction()
|
|
||||||
{
|
|
||||||
$entity = new ActivityType();
|
|
||||||
$form = $this->createCreateForm($entity);
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityType:new.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'form' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds and displays a ActivityType entity.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function showAction($id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find ActivityType entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityType:show.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Edits an existing ActivityType entity.
|
|
||||||
*
|
|
||||||
* @param mixed $id
|
|
||||||
*/
|
|
||||||
public function updateAction(Request $request, $id)
|
|
||||||
{
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$entity = $em->getRepository('ChillActivityBundle:ActivityType')->find($id);
|
|
||||||
|
|
||||||
if (!$entity) {
|
|
||||||
throw $this->createNotFoundException('Unable to find ActivityType entity.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$editForm = $this->createEditForm($entity);
|
|
||||||
$editForm->handleRequest($request);
|
|
||||||
|
|
||||||
if ($editForm->isValid()) {
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('chill_activity_activitytype_edit', ['id' => $id]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render('ChillActivityBundle:ActivityType:edit.html.twig', [
|
|
||||||
'entity' => $entity,
|
|
||||||
'edit_form' => $editForm->createView(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form to create a ActivityType entity.
|
|
||||||
*
|
|
||||||
* @param ActivityType $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createCreateForm(ActivityType $entity)
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ActivityTypeType::class, $entity, [
|
|
||||||
'action' => $this->generateUrl('chill_activity_activitytype_create'),
|
|
||||||
'method' => 'POST',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, ['label' => 'Create']);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form to edit a ActivityType entity.
|
|
||||||
*
|
|
||||||
* @param ActivityType $entity The entity
|
|
||||||
*
|
|
||||||
* @return \Symfony\Component\Form\Form The form
|
|
||||||
*/
|
|
||||||
private function createEditForm(ActivityType $entity)
|
|
||||||
{
|
|
||||||
$form = $this->createForm(ActivityTypeType::class, $entity, [
|
|
||||||
'action' => $this->generateUrl('chill_activity_activitytype_update', ['id' => $entity->getId()]),
|
|
||||||
'method' => 'PUT',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$form->add('submit', SubmitType::class, ['label' => 'Update']);
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class AdminActivityPresenceController extends CRUDController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $action
|
||||||
|
* @param \Doctrine\ORM\QueryBuilder|mixed $query
|
||||||
|
* @param Request $request
|
||||||
|
* @param PaginatorInterface $paginator
|
||||||
|
* @return \Doctrine\ORM\QueryBuilder|mixed
|
||||||
|
*/
|
||||||
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
|
{
|
||||||
|
/** @var \Doctrine\ORM\QueryBuilder $query */
|
||||||
|
return $query->orderBy('e.id', 'ASC');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class AdminActivityTypeCategoryController extends CRUDController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $action
|
||||||
|
* @param \Doctrine\ORM\QueryBuilder|mixed $query
|
||||||
|
* @param Request $request
|
||||||
|
* @param PaginatorInterface $paginator
|
||||||
|
* @return \Doctrine\ORM\QueryBuilder|mixed
|
||||||
|
*/
|
||||||
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
|
{
|
||||||
|
/** @var \Doctrine\ORM\QueryBuilder $query */
|
||||||
|
return $query->orderBy('e.ordering', 'ASC');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||||
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
class AdminActivityTypeController extends CRUDController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $action
|
||||||
|
* @param \Doctrine\ORM\QueryBuilder|mixed $query
|
||||||
|
* @param Request $request
|
||||||
|
* @param PaginatorInterface $paginator
|
||||||
|
* @return \Doctrine\ORM\QueryBuilder|mixed
|
||||||
|
*/
|
||||||
|
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||||
|
{
|
||||||
|
/** @var \Doctrine\ORM\QueryBuilder $query */
|
||||||
|
return $query->orderBy('e.ordering', 'ASC');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
|
* Copyright (C) 2015 Champs Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Controller;
|
namespace Chill\ActivityBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for activity configuration.
|
* Controller for activity configuration
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
* @author Champs Libres <info@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class AdminController extends AbstractController
|
class AdminController extends AbstractController
|
||||||
{
|
{
|
||||||
@@ -24,7 +35,7 @@ class AdminController extends AbstractController
|
|||||||
{
|
{
|
||||||
return $this->render('ChillActivityBundle:Admin:layout_activity.html.twig');
|
return $this->render('ChillActivityBundle:Admin:layout_activity.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirectToAdminIndexAction()
|
public function redirectToAdminIndexAction()
|
||||||
{
|
{
|
||||||
return $this->redirectToRoute('chill_main_admin_central');
|
return $this->redirectToRoute('chill_main_admin_central');
|
||||||
|
|||||||
@@ -1,33 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
|
||||||
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
use Faker\Factory as FakerFactory;
|
use Faker\Factory as FakerFactory;
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
|
||||||
|
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivityReason;
|
||||||
|
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivityType;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load reports into DB.
|
* Load reports into DB
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
class LoadActivity extends AbstractFixture implements ContainerAwareInterface, OrderedFixtureInterface
|
class LoadActivity extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
|
||||||
{
|
{
|
||||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
|
|
||||||
@@ -46,22 +57,54 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
|||||||
return 16400;
|
return 16400;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
/**
|
||||||
|
* Return a random scope
|
||||||
|
*
|
||||||
|
* @return \Chill\MainBundle\Entity\Scope
|
||||||
|
*/
|
||||||
|
private function getRandomScope()
|
||||||
{
|
{
|
||||||
$persons = $this->container->get('doctrine.orm.entity_manager')
|
$scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)];
|
||||||
->getRepository('ChillPersonBundle:Person')
|
return $this->getReference($scopeRef);
|
||||||
->findAll();
|
}
|
||||||
|
|
||||||
foreach ($persons as $person) {
|
/**
|
||||||
$activityNbr = mt_rand(0, 3);
|
* Return a random activityType
|
||||||
|
*
|
||||||
|
* @return \Chill\ActivityBundle\Entity\ActivityType
|
||||||
|
*/
|
||||||
|
private function getRandomActivityType()
|
||||||
|
{
|
||||||
|
$typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)];
|
||||||
|
return $this->getReference($typeRef);
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $activityNbr; ++$i) {
|
/**
|
||||||
echo 'Creating an activity type for : ' . $person . "\n";
|
* Return a random activityReason
|
||||||
$activity = $this->newRandomActivity($person);
|
*
|
||||||
$manager->persist($activity);
|
* @return \Chill\ActivityBundle\Entity\ActivityReason
|
||||||
}
|
*/
|
||||||
|
private function getRandomActivityReason(array $excludingIds)
|
||||||
|
{
|
||||||
|
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
|
||||||
|
|
||||||
|
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds)) {
|
||||||
|
// we have a reason which should be excluded. Find another...
|
||||||
|
return $this->getRandomActivityReason($excludingIds);
|
||||||
}
|
}
|
||||||
$manager->flush();
|
|
||||||
|
return $this->getReference($reasonRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a random user
|
||||||
|
*
|
||||||
|
* @return \Chill\MainBundle\Entity\User
|
||||||
|
*/
|
||||||
|
private function getRandomUser()
|
||||||
|
{
|
||||||
|
$userRef = array_rand(LoadUsers::$refs);
|
||||||
|
return $this->getReference($userRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newRandomActivity($person)
|
public function newRandomActivity($person)
|
||||||
@@ -73,11 +116,12 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
|||||||
->setDurationTime($this->faker->dateTime(36000))
|
->setDurationTime($this->faker->dateTime(36000))
|
||||||
->setType($this->getRandomActivityType())
|
->setType($this->getRandomActivityType())
|
||||||
->setScope($this->getRandomScope())
|
->setScope($this->getRandomScope())
|
||||||
->setAttendee($this->faker->boolean());
|
;
|
||||||
|
|
||||||
$usedId = [];
|
// ->setAttendee($this->faker->boolean())
|
||||||
|
|
||||||
for ($i = 0; mt_rand(0, 4) > $i; ++$i) {
|
$usedId = array();
|
||||||
|
for ($i = 0; $i < rand(0, 4); $i++) {
|
||||||
$reason = $this->getRandomActivityReason($usedId);
|
$reason = $this->getRandomActivityReason($usedId);
|
||||||
$usedId[] = $reason->getId();
|
$usedId[] = $reason->getId();
|
||||||
$activity->addReason($reason);
|
$activity->addReason($reason);
|
||||||
@@ -86,56 +130,24 @@ class LoadActivity extends AbstractFixture implements ContainerAwareInterface, O
|
|||||||
return $activity;
|
return $activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function load(ObjectManager $manager)
|
||||||
* Return a random activityReason.
|
|
||||||
*
|
|
||||||
* @return \Chill\ActivityBundle\Entity\ActivityReason
|
|
||||||
*/
|
|
||||||
private function getRandomActivityReason(array $excludingIds)
|
|
||||||
{
|
{
|
||||||
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
|
$persons = $this->container->get('doctrine.orm.entity_manager')
|
||||||
|
->getRepository('ChillPersonBundle:Person')
|
||||||
|
->findAll();
|
||||||
|
|
||||||
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds, true)) {
|
foreach($persons as $person) {
|
||||||
// we have a reason which should be excluded. Find another...
|
$activityNbr = rand(0,3);
|
||||||
return $this->getRandomActivityReason($excludingIds);
|
$ref = 'activity_'.$person->getFullnameCanonical();
|
||||||
|
|
||||||
|
for($i = 0; $i < $activityNbr; $i ++) {
|
||||||
|
print "Creating an activity type for : ".$person." (ref: ".$ref.") \n";
|
||||||
|
$activity = $this->newRandomActivity($person);
|
||||||
|
$manager->persist($activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setReference($ref, $activity);
|
||||||
}
|
}
|
||||||
|
$manager->flush();
|
||||||
return $this->getReference($reasonRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a random activityType.
|
|
||||||
*
|
|
||||||
* @return \Chill\ActivityBundle\Entity\ActivityType
|
|
||||||
*/
|
|
||||||
private function getRandomActivityType()
|
|
||||||
{
|
|
||||||
$typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)];
|
|
||||||
|
|
||||||
return $this->getReference($typeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a random scope.
|
|
||||||
*
|
|
||||||
* @return \Chill\MainBundle\Entity\Scope
|
|
||||||
*/
|
|
||||||
private function getRandomScope()
|
|
||||||
{
|
|
||||||
$scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)];
|
|
||||||
|
|
||||||
return $this->getReference($scopeRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a random user.
|
|
||||||
*
|
|
||||||
* @return \Chill\MainBundle\Entity\User
|
|
||||||
*/
|
|
||||||
private function getRandomUser()
|
|
||||||
{
|
|
||||||
$userRef = array_rand(LoadUsers::$refs);
|
|
||||||
|
|
||||||
return $this->getReference($userRef);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait;
|
||||||
|
use Chill\ActivityBundle\DataFixtures\ORM\LoadActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load notififications into database
|
||||||
|
*/
|
||||||
|
class LoadActivityNotifications extends AbstractFixture implements DependentFixtureInterface
|
||||||
|
{
|
||||||
|
use LoadAbstractNotificationsTrait;
|
||||||
|
|
||||||
|
public $notifs = [
|
||||||
|
[
|
||||||
|
'message' => 'Hello !',
|
||||||
|
'entityClass' => Activity::class,
|
||||||
|
'entityRef' => 'activity_gerard depardieu',
|
||||||
|
'sender' => 'center a_social',
|
||||||
|
'addressees' => [
|
||||||
|
'center a_administrative',
|
||||||
|
'center a_direction',
|
||||||
|
'multi_center'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getDependencies()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
LoadActivity::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,70 +1,81 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of LoadActivityReason.
|
* Description of LoadActivityReason
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterface
|
class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
public static $references = [];
|
|
||||||
|
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
{
|
{
|
||||||
return 16300;
|
return 16300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static $references = array();
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
$reasons = [
|
$reasons = [
|
||||||
[
|
[
|
||||||
'name' => ['fr' => 'Recherche logement', 'en' => 'Housing research', 'nl' => 'Woning zoektoch'],
|
'name' => ['fr' => 'Recherche logement', 'en' => 'Housing research', 'nl' => 'Woning zoektoch'],
|
||||||
'category' => 'cat_Housing', ],
|
'category' => 'cat_Housing'],
|
||||||
[
|
[
|
||||||
'name' => ['fr' => 'Problème avec propriétaire', 'en' => 'Landlord problems', 'nl' => 'Huisbaas problemen'],
|
'name' => ['fr' => 'Problème avec propriétaire', 'en' => 'Landlord problems', 'nl' => 'Huisbaas problemen'],
|
||||||
'category' => 'cat_Housing', ],
|
'category' => 'cat_Housing'],
|
||||||
[
|
[
|
||||||
'name' => ['fr' => 'Retard de payement', 'en' => 'Payement problems', 'nl' => 'Betalings vertragingen'],
|
'name' => ['fr' => 'Retard de payement', 'en' => 'Payement problems', 'nl' => 'Betalings vertragingen'],
|
||||||
'category' => 'cat_Housing', ],
|
'category' => 'cat_Housing'],
|
||||||
[
|
[
|
||||||
'name' => ['fr' => 'Explication législation', 'en' => 'Legislation explanation', 'nl' => 'Legislative uitleg'],
|
'name' => ['fr' => 'Explication législation', 'en' => 'Legislation explanation', 'nl' => 'Legislative uitleg'],
|
||||||
'category' => 'cat_Unemployment procedure', ],
|
'category' => 'cat_Unemployment procedure'],
|
||||||
[
|
[
|
||||||
'name' => ['fr' => 'Coaching entretien d\'activation', 'en' => 'Interview coaching', 'nl' => 'Interview coaching'],
|
'name' => ['fr' => 'Coaching entretien d\'activation', 'en' => 'Interview coaching', 'nl' => 'Interview coaching'],
|
||||||
'category' => 'cat_Unemployment procedure', ],
|
'category' => 'cat_Unemployment procedure'],
|
||||||
[
|
[
|
||||||
'name' => ['fr' => 'Récupération des allocations', 'en' => 'Allowance recovery', 'nl' => 'Terugwinning van de uitkeringen'],
|
'name' => ['fr' => 'Récupération des allocations', 'en' => 'Allowance recovery', 'nl' => 'Terugwinning van de uitkeringen'],
|
||||||
'category' => 'cat_Unemployment procedure', ],
|
'category' => 'cat_Unemployment procedure']
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($reasons as $r) {
|
foreach ($reasons as $r) {
|
||||||
echo 'Creating activity reason : ' . $r['name']['en'] . "\n";
|
print "Creating activity reason : " . $r['name']['en'] . "\n";
|
||||||
$activityReason = (new ActivityReason())
|
$activityReason = (new ActivityReason())
|
||||||
->setName(($r['name']))
|
->setName(($r['name']))
|
||||||
->setActive(true)
|
->setActive(true)
|
||||||
->setCategory($this->getReference($r['category']));
|
->setCategory($this->getReference($r['category']));
|
||||||
$manager->persist($activityReason);
|
$manager->persist($activityReason);
|
||||||
$reference = 'activity_reason_' . $r['name']['en'];
|
$reference = 'activity_reason_'.$r['name']['en'];
|
||||||
$this->addReference($reference, $activityReason);
|
$this->addReference($reference, $activityReason);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||||
/**
|
/**
|
||||||
* Description of LoadActivityReasonCategory.
|
* Description of LoadActivityReasonCategory
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtureInterface
|
class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
@@ -27,26 +37,27 @@ class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtu
|
|||||||
{
|
{
|
||||||
return 16200;
|
return 16200;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
$categs = [
|
$categs = [
|
||||||
['name' => ['fr' => 'Logement', 'en' => 'Housing', 'nl' => 'Woning']],
|
['name' =>
|
||||||
['name' => ['fr' => 'Démarches chômage', 'en' => 'Unemployment procedure', 'nl' => 'Werkloosheid werkwijze']],
|
['fr' => 'Logement', 'en' => 'Housing', 'nl' => 'Woning']],
|
||||||
|
['name' =>
|
||||||
|
['fr' => 'Démarches chômage', 'en' => 'Unemployment procedure', 'nl' => 'Werkloosheid werkwijze']],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($categs as $c) {
|
foreach ($categs as $c) {
|
||||||
echo 'Creating activity reason category : ' . $c['name']['en'] . "\n";
|
print "Creating activity reason category : " . $c['name']['en'] . "\n";
|
||||||
$activityReasonCategory = (new ActivityReasonCategory())
|
$activityReasonCategory = (new ActivityReasonCategory())
|
||||||
->setName(($c['name']))
|
->setName(($c['name']))
|
||||||
->setActive(true);
|
->setActive(true);
|
||||||
$manager->persist($activityReasonCategory);
|
$manager->persist($activityReasonCategory);
|
||||||
$this->addReference(
|
$this->addReference(
|
||||||
'cat_' . $c['name']['en'],
|
'cat_'.$c['name']['en'],
|
||||||
$activityReasonCategory
|
$activityReasonCategory);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,86 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of LoadActivityType.
|
* Description of LoadActivityType
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
class LoadActivityType extends AbstractFixture implements OrderedFixtureInterface
|
class LoadActivityType extends Fixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
public static $references = [];
|
|
||||||
|
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
{
|
{
|
||||||
return 16100;
|
return 16100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static $references = array();
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
$types = [
|
$types = [
|
||||||
['name' => ['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel']],
|
# Exange
|
||||||
['name' => ['fr' => 'Entretien', 'en' => 'Interview', 'nl' => 'Vraaggesprek']],
|
[
|
||||||
['name' => ['fr' => 'Inspection', 'en' => 'Inspection', 'nl' => 'Inspectie']],
|
'name' =>
|
||||||
|
['fr' => 'Entretien physique avec l\'usager'],
|
||||||
|
'category' => 'exchange' ],
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel'],
|
||||||
|
'category' => 'exchange' ],
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
['fr' => 'Courriel', 'en' => 'Email', 'nl' => 'Email'],
|
||||||
|
'category' => 'exchange' ],
|
||||||
|
# Meeting
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
['fr' => 'Point technique encadrant'],
|
||||||
|
'category' => 'meeting' ],
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
['fr' => 'Réunion avec des partenaires'],
|
||||||
|
'category' => 'meeting' ],
|
||||||
|
[
|
||||||
|
'name' =>
|
||||||
|
['fr' => 'Commission pluridisciplinaire et pluri-institutionnelle'],
|
||||||
|
'category' => 'meeting' ],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($types as $t) {
|
foreach ($types as $t) {
|
||||||
echo 'Creating activity type : ' . $t['name']['en'] . "\n";
|
print "Creating activity type : " . $t['name']['fr'] . " (cat:". $t['category'] . " \n";
|
||||||
$activityType = (new ActivityType())
|
$activityType = (new ActivityType())
|
||||||
->setName(($t['name']));
|
->setName(($t['name']))
|
||||||
|
->setCategory($this->getReference('activity_type_cat_'.$t['category']))
|
||||||
|
->setSocialIssuesVisible(1)
|
||||||
|
->setSocialActionsVisible(1);
|
||||||
$manager->persist($activityType);
|
$manager->persist($activityType);
|
||||||
$reference = 'activity_type_' . $t['name']['en'];
|
$reference = 'activity_type_'.$t['name']['fr'];
|
||||||
$this->addReference($reference, $activityType);
|
$this->addReference($reference, $activityType);
|
||||||
static::$references[] = $reference;
|
static::$references[] = $reference;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixtures for ActivityTypeCategory
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
|
*/
|
||||||
|
class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterface
|
||||||
|
{
|
||||||
|
public static $references = array();
|
||||||
|
|
||||||
|
public function getOrder()
|
||||||
|
{
|
||||||
|
return 16050;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load(ObjectManager $manager)
|
||||||
|
{
|
||||||
|
$categories = [
|
||||||
|
[
|
||||||
|
'name' => ['fr' => 'Échange avec usager', 'en' => 'Exchange with user'],
|
||||||
|
'ref' => 'exchange',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => ['fr' => 'Réunion', 'en' => 'Meeting'],
|
||||||
|
'ref' => 'meeting',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($categories as $cat) {
|
||||||
|
print "Creating activity type category : " . $cat['ref'] . "\n";
|
||||||
|
|
||||||
|
$newCat = (new ActivityTypeCategory())
|
||||||
|
->setName(($cat['name']));
|
||||||
|
|
||||||
|
$manager->persist($newCat);
|
||||||
|
$reference = 'activity_type_cat_'.$cat['ref'];
|
||||||
|
|
||||||
|
$this->addReference($reference, $newCat);
|
||||||
|
static::$references[] = $reference;
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,38 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2015 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
namespace Chill\ActivityBundle\DataFixtures\ORM;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
|
||||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
|
||||||
use Chill\MainBundle\Entity\RoleScope;
|
|
||||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||||
|
use Chill\MainBundle\Entity\RoleScope;
|
||||||
|
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
|
||||||
use function in_array;
|
/**
|
||||||
|
* Add a role CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE for all groups except administrative,
|
||||||
declare(strict_types=1);
|
* and a role CHILL_ACTIVITY_SEE for administrative
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
|
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
|
||||||
{
|
{
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
@@ -30,12 +40,12 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
|||||||
return 16000;
|
return 16000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
||||||
$permissionsGroup = $this->getReference($permissionsGroupRef);
|
$permissionsGroup = $this->getReference($permissionsGroupRef);
|
||||||
|
foreach (LoadScopes::$references as $scopeRef){
|
||||||
foreach (LoadScopes::$references as $scopeRef) {
|
|
||||||
$scope = $this->getReference($scopeRef);
|
$scope = $this->getReference($scopeRef);
|
||||||
//create permission group
|
//create permission group
|
||||||
switch ($permissionsGroup->getName()) {
|
switch ($permissionsGroup->getName()) {
|
||||||
@@ -43,48 +53,47 @@ class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterfac
|
|||||||
if ($scope->getName()['en'] === 'administrative') {
|
if ($scope->getName()['en'] === 'administrative') {
|
||||||
break 2; // we do not want any power on administrative
|
break 2; // we do not want any power on administrative
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'administrative':
|
case 'administrative':
|
||||||
case 'direction':
|
case 'direction':
|
||||||
if (in_array($scope->getName()['en'], ['administrative', 'social'], true)) {
|
if (in_array($scope->getName()['en'], array('administrative', 'social'))) {
|
||||||
break 2; // we do not want any power on social or administrative
|
break 2; // we do not want any power on social or administrative
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(
|
printf("Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s "
|
||||||
'Adding CHILL_ACTIVITY_UPDATE & CHILL_ACTIVITY_CREATE & CHILL_ACTIVITY_DELETE, and stats and list permissions to %s '
|
. "permission group, scope '%s' \n",
|
||||||
. "permission group, scope '%s' \n",
|
$permissionsGroup->getName(), $scope->getName()['en']);
|
||||||
$permissionsGroup->getName(),
|
|
||||||
$scope->getName()['en']
|
|
||||||
);
|
|
||||||
$roleScopeUpdate = (new RoleScope())
|
$roleScopeUpdate = (new RoleScope())
|
||||||
->setRole('CHILL_ACTIVITY_UPDATE')
|
->setRole('CHILL_ACTIVITY_UPDATE')
|
||||||
->setScope($scope);
|
->setScope($scope);
|
||||||
$permissionsGroup->addRoleScope($roleScopeUpdate);
|
$permissionsGroup->addRoleScope($roleScopeUpdate);
|
||||||
$roleScopeCreate = (new RoleScope())
|
$roleScopeCreate = (new RoleScope())
|
||||||
->setRole('CHILL_ACTIVITY_CREATE')
|
->setRole('CHILL_ACTIVITY_CREATE')
|
||||||
->setScope($scope);
|
->setScope($scope);
|
||||||
$permissionsGroup->addRoleScope($roleScopeCreate);
|
$permissionsGroup->addRoleScope($roleScopeCreate);
|
||||||
$roleScopeDelete = (new RoleScope())
|
$roleScopeDelete = (new RoleScope())
|
||||||
->setRole('CHILL_ACTIVITY_DELETE')
|
->setRole('CHILL_ACTIVITY_DELETE')
|
||||||
->setScope($scope);
|
->setScope($scope);
|
||||||
$permissionsGroup->addRoleScope($roleScopeDelete);
|
$permissionsGroup->addRoleScope($roleScopeDelete);
|
||||||
$roleScopeList = (new RoleScope())
|
$roleScopeList = (new RoleScope())
|
||||||
->setRole(ActivityStatsVoter::LISTS);
|
->setRole(ActivityStatsVoter::LISTS)
|
||||||
|
;
|
||||||
$permissionsGroup->addRoleScope($roleScopeList);
|
$permissionsGroup->addRoleScope($roleScopeList);
|
||||||
$roleScopeStat = (new RoleScope())
|
$roleScopeStat = (new RoleScope())
|
||||||
->setRole(ActivityStatsVoter::STATS);
|
->setRole(ActivityStatsVoter::STATS)
|
||||||
|
;
|
||||||
$permissionsGroup->addRoleScope($roleScopeStat);
|
$permissionsGroup->addRoleScope($roleScopeStat);
|
||||||
|
|
||||||
$manager->persist($roleScopeUpdate);
|
$manager->persist($roleScopeUpdate);
|
||||||
$manager->persist($roleScopeCreate);
|
$manager->persist($roleScopeCreate);
|
||||||
$manager->persist($roleScopeDelete);
|
$manager->persist($roleScopeDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$manager->flush();
|
$manager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DependencyInjection;
|
namespace Chill\ActivityBundle\DependencyInjection;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
||||||
use Symfony\Component\Config\FileLocator;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\DependencyInjection\Loader;
|
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader;
|
||||||
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that loads and manages your bundle configuration.
|
* This is the class that loads and manages your bundle configuration
|
||||||
*
|
*
|
||||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||||
*/
|
*/
|
||||||
@@ -37,12 +47,11 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
|
|
||||||
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
$container->setParameter('chill_activity.form.time_duration', $config['form']['time_duration']);
|
||||||
|
|
||||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
|
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
|
||||||
$loader->load('services.yaml');
|
$loader->load('services.yaml');
|
||||||
$loader->load('services/export.yaml');
|
$loader->load('services/export.yaml');
|
||||||
$loader->load('services/repositories.yaml');
|
$loader->load('services/repositories.yaml');
|
||||||
$loader->load('services/fixtures.yaml');
|
$loader->load('services/fixtures.yaml');
|
||||||
$loader->load('services/menu.yaml');
|
|
||||||
$loader->load('services/controller.yaml');
|
$loader->load('services/controller.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
@@ -52,32 +61,104 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
{
|
{
|
||||||
$this->prependRoutes($container);
|
$this->prependRoutes($container);
|
||||||
$this->prependAuthorization($container);
|
$this->prependAuthorization($container);
|
||||||
|
$this->prependCruds($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prependAuthorization(ContainerBuilder $container)
|
/* (non-PHPdoc)
|
||||||
{
|
|
||||||
$container->prependExtensionConfig('security', [
|
|
||||||
'role_hierarchy' => [
|
|
||||||
ActivityVoter::UPDATE => [ActivityVoter::SEE_DETAILS],
|
|
||||||
ActivityVoter::CREATE => [ActivityVoter::SEE_DETAILS],
|
|
||||||
ActivityVoter::DELETE => [ActivityVoter::SEE_DETAILS],
|
|
||||||
ActivityVoter::SEE_DETAILS => [ActivityVoter::SEE],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** (non-PHPdoc).
|
|
||||||
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
* @see \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface::prepend()
|
||||||
*/
|
*/
|
||||||
public function prependRoutes(ContainerBuilder $container)
|
public function prependRoutes(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
//add routes for custom bundle
|
//add routes for custom bundle
|
||||||
|
$container->prependExtensionConfig('chill_main', array(
|
||||||
|
'routing' => array(
|
||||||
|
'resources' => array(
|
||||||
|
'@ChillActivityBundle/config/routes.yaml'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prependAuthorization(ContainerBuilder $container)
|
||||||
|
{
|
||||||
|
$container->prependExtensionConfig('security', array(
|
||||||
|
'role_hierarchy' => array(
|
||||||
|
ActivityVoter::UPDATE => array(ActivityVoter::SEE_DETAILS),
|
||||||
|
ActivityVoter::CREATE => array(ActivityVoter::SEE_DETAILS),
|
||||||
|
ActivityVoter::DELETE => array(ActivityVoter::SEE_DETAILS),
|
||||||
|
ActivityVoter::SEE_DETAILS => array(ActivityVoter::SEE)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prependCruds(ContainerBuilder $container)
|
||||||
|
{
|
||||||
$container->prependExtensionConfig('chill_main', [
|
$container->prependExtensionConfig('chill_main', [
|
||||||
'routing' => [
|
'cruds' => [
|
||||||
'resources' => [
|
[
|
||||||
'@ChillActivityBundle/config/routes.yaml',
|
'class' => \Chill\ActivityBundle\Entity\ActivityType::class,
|
||||||
|
'name' => 'activity_type',
|
||||||
|
'base_path' => '/admin/activity/type',
|
||||||
|
'form_class' => \Chill\ActivityBundle\Form\ActivityTypeType::class,
|
||||||
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeController::class,
|
||||||
|
'actions' => [
|
||||||
|
'index' => [
|
||||||
|
'template' => '@ChillActivity/ActivityType/index.html.twig',
|
||||||
|
'role' => 'ROLE_ADMIN'
|
||||||
|
],
|
||||||
|
'new' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityType/new.html.twig',
|
||||||
|
],
|
||||||
|
'edit' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityType/edit.html.twig',
|
||||||
|
]
|
||||||
|
]
|
||||||
],
|
],
|
||||||
],
|
[
|
||||||
|
'class' => \Chill\ActivityBundle\Entity\ActivityTypeCategory::class,
|
||||||
|
'name' => 'activity_type_category',
|
||||||
|
'base_path' => '/admin/activity/type_category',
|
||||||
|
'form_class' => \Chill\ActivityBundle\Form\ActivityTypeCategoryType::class,
|
||||||
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityTypeCategoryController::class,
|
||||||
|
'actions' => [
|
||||||
|
'index' => [
|
||||||
|
'template' => '@ChillActivity/ActivityTypeCategory/index.html.twig',
|
||||||
|
'role' => 'ROLE_ADMIN'
|
||||||
|
],
|
||||||
|
'new' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityTypeCategory/new.html.twig',
|
||||||
|
],
|
||||||
|
'edit' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityTypeCategory/edit.html.twig',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'class' => \Chill\ActivityBundle\Entity\ActivityPresence::class,
|
||||||
|
'name' => 'activity_presence',
|
||||||
|
'base_path' => '/admin/activity/presence',
|
||||||
|
'form_class' => \Chill\ActivityBundle\Form\ActivityPresenceType::class,
|
||||||
|
'controller' => \Chill\ActivityBundle\Controller\AdminActivityPresenceController::class,
|
||||||
|
'actions' => [
|
||||||
|
'index' => [
|
||||||
|
'template' => '@ChillActivity/ActivityPresence/index.html.twig',
|
||||||
|
'role' => 'ROLE_ADMIN'
|
||||||
|
],
|
||||||
|
'new' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityPresence/new.html.twig',
|
||||||
|
],
|
||||||
|
'edit' => [
|
||||||
|
'role' => 'ROLE_ADMIN',
|
||||||
|
'template' => '@ChillActivity/ActivityPresence/edit.html.twig',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\DependencyInjection;
|
namespace Chill\ActivityBundle\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
|
|
||||||
use function is_int;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that validates and merges configuration from your app/config files.
|
* This is the class that validates and merges configuration from your app/config files
|
||||||
*
|
*
|
||||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
|
||||||
*/
|
*/
|
||||||
@@ -32,51 +19,53 @@ class Configuration implements ConfigurationInterface
|
|||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder('chill_activity');
|
$treeBuilder = new TreeBuilder('chill_activity');
|
||||||
$rootNode = $treeBuilder->getRootNode('chill_activity');
|
$rootNode = $treeBuilder->getRootNode('chill_activity');
|
||||||
|
|
||||||
$rootNode
|
$rootNode
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('form')
|
->arrayNode('form')
|
||||||
->canBeEnabled()
|
->canBeEnabled()
|
||||||
->children()
|
->children()
|
||||||
->arrayNode('time_duration')
|
->arrayNode('time_duration')
|
||||||
->isRequired()
|
->isRequired()
|
||||||
->requiresAtLeastOneElement()
|
->requiresAtLeastOneElement()
|
||||||
->defaultValue(
|
->defaultValue(
|
||||||
[
|
array(
|
||||||
['label' => '5 minutes', 'seconds' => 300],
|
[ 'label' => '5 minutes', 'seconds' => 300],
|
||||||
['label' => '10 minutes', 'seconds' => 600],
|
[ 'label' => '10 minutes', 'seconds' => 600],
|
||||||
['label' => '15 minutes', 'seconds' => 900],
|
[ 'label' => '15 minutes', 'seconds' => 900],
|
||||||
['label' => '20 minutes', 'seconds' => 1200],
|
[ 'label' => '20 minutes', 'seconds' => 1200],
|
||||||
['label' => '25 minutes', 'seconds' => 1500],
|
[ 'label' => '25 minutes', 'seconds' => 1500],
|
||||||
['label' => '30 minutes', 'seconds' => 1800],
|
[ 'label' => '30 minutes', 'seconds' => 1800],
|
||||||
['label' => '45 minutes', 'seconds' => 2700],
|
[ 'label' => '45 minutes', 'seconds' => 2700],
|
||||||
['label' => '1 hour', 'seconds' => 3600],
|
[ 'label' => '1 hour', 'seconds' => 3600],
|
||||||
['label' => '1 hour 15', 'seconds' => 4500],
|
[ 'label' => '1 hour 15', 'seconds' => 4500],
|
||||||
['label' => '1 hour 30', 'seconds' => 5400],
|
[ 'label' => '1 hour 30', 'seconds' => 5400],
|
||||||
['label' => '1 hour 45', 'seconds' => 6300],
|
[ 'label' => '1 hour 45', 'seconds' => 6300],
|
||||||
['label' => '2 hours', 'seconds' => 7200],
|
[ 'label' => '2 hours', 'seconds' => 7200],
|
||||||
]
|
)
|
||||||
)
|
)
|
||||||
->info('The intervals of time to show in activity form')
|
->info('The intervals of time to show in activity form')
|
||||||
->prototype('array')
|
|
||||||
->children()
|
->prototype('array')
|
||||||
->scalarNode('seconds')
|
->children()
|
||||||
->info('The number of seconds of this duration. Must be an integer.')
|
->scalarNode('seconds')
|
||||||
->cannotBeEmpty()
|
->info("The number of seconds of this duration. Must be an integer.")
|
||||||
->validate()
|
->cannotBeEmpty()
|
||||||
->ifTrue(static function ($data) {
|
->validate()
|
||||||
return !is_int($data);
|
->ifTrue(function($data) {
|
||||||
})->thenInvalid('The value %s is not a valid integer')
|
return !is_int($data);
|
||||||
->end()
|
})->thenInvalid("The value %s is not a valid integer")
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('label')
|
->end()
|
||||||
->cannotBeEmpty()
|
->scalarNode('label')
|
||||||
->info('The label to show into fields')
|
->cannotBeEmpty()
|
||||||
->end()
|
->info("The label to show into fields")
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
|
||||||
|
->end()
|
||||||
// ->validate()
|
// ->validate()
|
||||||
//
|
//
|
||||||
// ->ifTrue(function ($data) {
|
// ->ifTrue(function ($data) {
|
||||||
// // test this is an array
|
// // test this is an array
|
||||||
// if (!is_array($data)) {
|
// if (!is_array($data)) {
|
||||||
@@ -95,10 +84,11 @@ class Configuration implements ConfigurationInterface
|
|||||||
// })
|
// })
|
||||||
// ->thenInvalid("The data are invalid. The keys must be a string and the value integers")
|
// ->thenInvalid("The data are invalid. The keys must be a string and the value integers")
|
||||||
// ->end()
|
// ->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
|
||||||
->end();
|
->end()
|
||||||
|
->end();
|
||||||
|
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,333 +1,556 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\DocStoreBundle\Entity\Document;
|
||||||
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTime;
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* Class Activity
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository")
|
||||||
* @ORM\Table(name="activity")
|
* @ORM\Table(name="activity")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks()
|
||||||
* @UserCircleConsistency(
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "CHILL_ACTIVITY_SEE_DETAILS",
|
* "activity"=Activity::class
|
||||||
* getUserFunction="getUser",
|
* })
|
||||||
* path="scope")
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO : revoir
|
||||||
|
* @UserCircleConsistency(
|
||||||
|
* "CHILL_ACTIVITY_SEE_DETAILS",
|
||||||
|
* getUserFunction="getUser",
|
||||||
|
* path="scope")
|
||||||
|
*/
|
||||||
|
|
||||||
class Activity implements HasCenterInterface, HasScopeInterface
|
class Activity implements HasCenterInterface, HasScopeInterface
|
||||||
{
|
{
|
||||||
|
const SENTRECEIVED_SENT = 'sent';
|
||||||
|
const SENTRECEIVED_RECEIVED = 'received';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @ORM\Id
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $attendee;
|
private ?int $id = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
|
*/
|
||||||
|
private User $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="datetime")
|
||||||
|
*/
|
||||||
|
private \DateTime $date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="time", nullable=true)
|
||||||
|
*/
|
||||||
|
private ?\DateTime $durationTime = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="time", nullable=true)
|
||||||
|
*/
|
||||||
|
private ?\DateTime $travelTime = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityPresence")
|
||||||
|
*/
|
||||||
|
private ?ActivityPresence $attendee = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
|
||||||
|
*/
|
||||||
|
private Collection $reasons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue")
|
||||||
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue")
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
private Collection $socialIssues;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction")
|
||||||
|
* @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction")
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
private Collection $socialActions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
||||||
|
*/
|
||||||
|
private ActivityType $type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
||||||
|
*/
|
||||||
|
private ?Scope $scope = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||||
|
*/
|
||||||
|
private ?Person $person = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod")
|
||||||
|
* @Groups({"read"})
|
||||||
|
*/
|
||||||
|
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
||||||
*/
|
*/
|
||||||
private $comment;
|
private CommentEmbeddable $comment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DateTime
|
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||||
* @ORM\Column(type="datetime")
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $date;
|
private ?Collection $persons = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DateTime
|
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
|
||||||
* @ORM\Column(type="time")
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $durationTime;
|
private ?Collection $thirdParties = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @ORM\ManyToMany(targetEntity="Chill\DocStoreBundle\Entity\StoredObject")
|
||||||
*
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\Column(name="id", type="integer")
|
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private Collection $documents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Person
|
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
|
* @Groups({"read"})
|
||||||
*/
|
*/
|
||||||
private $person;
|
private ?Collection $users = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ActivityReason
|
* @ORM\Column(type="boolean", options={"default"=false})
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
|
|
||||||
*/
|
*/
|
||||||
private $reasons;
|
private bool $emergency = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Scope
|
* @ORM\Column(type="string", options={"default"=""})
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
|
||||||
*/
|
*/
|
||||||
private $scope;
|
private string $sentReceived = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ActivityType
|
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType")
|
|
||||||
*/
|
|
||||||
private $type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var User
|
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
|
||||||
*/
|
|
||||||
private $user;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Activity constructor.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->reasons = new ArrayCollection();
|
$this->reasons = new ArrayCollection();
|
||||||
$this->comment = new CommentEmbeddable();
|
$this->comment = new CommentEmbeddable();
|
||||||
|
$this->persons = new ArrayCollection();
|
||||||
|
$this->thirdParties = new ArrayCollection();
|
||||||
|
$this->documents = new ArrayCollection();
|
||||||
|
$this->users = new ArrayCollection();
|
||||||
|
$this->socialIssues = new ArrayCollection();
|
||||||
|
$this->socialActions = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getId(): ?int
|
||||||
* Add a reason.
|
|
||||||
*
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function addReason(ActivityReason $reason)
|
|
||||||
{
|
|
||||||
$this->reasons[] = $reason;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get attendee.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getAttendee()
|
|
||||||
{
|
|
||||||
return $this->attendee;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the center
|
|
||||||
* center is extracted from person.
|
|
||||||
*
|
|
||||||
* @return Center
|
|
||||||
*/
|
|
||||||
public function getCenter()
|
|
||||||
{
|
|
||||||
return $this->person->getCenter();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable
|
|
||||||
*/
|
|
||||||
public function getComment()
|
|
||||||
{
|
|
||||||
return $this->comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get date.
|
|
||||||
*
|
|
||||||
* @return DateTime
|
|
||||||
*/
|
|
||||||
public function getDate()
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get durationTime.
|
|
||||||
*
|
|
||||||
* @return DateTime
|
|
||||||
*/
|
|
||||||
public function getDurationTime()
|
|
||||||
{
|
|
||||||
return $this->durationTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId()
|
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setUser(User $user): self
|
||||||
* Get person.
|
|
||||||
*
|
|
||||||
* @return Person
|
|
||||||
*/
|
|
||||||
public function getPerson()
|
|
||||||
{
|
{
|
||||||
return $this->person;
|
$this->user = $user;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get reasons.
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function getReasons()
|
|
||||||
{
|
|
||||||
return $this->reasons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get scope.
|
|
||||||
*
|
|
||||||
* @return Scope
|
|
||||||
*/
|
|
||||||
public function getScope()
|
|
||||||
{
|
|
||||||
return $this->scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get type.
|
|
||||||
*
|
|
||||||
* @return ActivityType
|
|
||||||
*/
|
|
||||||
public function getType()
|
|
||||||
{
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user.
|
|
||||||
*
|
|
||||||
* @return User
|
|
||||||
*/
|
|
||||||
public function getUser()
|
|
||||||
{
|
|
||||||
return $this->user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeReason(ActivityReason $reason)
|
|
||||||
{
|
|
||||||
$this->reasons->removeElement($reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set attendee.
|
|
||||||
*
|
|
||||||
* @param bool $attendee
|
|
||||||
*
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setAttendee($attendee)
|
|
||||||
{
|
|
||||||
$this->attendee = $attendee;
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getUser(): User
|
||||||
* @param \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable $comment
|
|
||||||
*/
|
|
||||||
public function setComment($comment)
|
|
||||||
{
|
{
|
||||||
$this->comment = $comment;
|
return $this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setDate(\DateTime $date): self
|
||||||
* Set date.
|
|
||||||
*
|
|
||||||
* @param DateTime $date
|
|
||||||
*
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setDate($date)
|
|
||||||
{
|
{
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getDate(): \DateTime
|
||||||
* Set durationTime.
|
{
|
||||||
*
|
return $this->date;
|
||||||
* @param DateTime $durationTime
|
}
|
||||||
*
|
|
||||||
* @return Activity
|
public function setDurationTime(?\DateTime $durationTime): self
|
||||||
*/
|
|
||||||
public function setDurationTime($durationTime)
|
|
||||||
{
|
{
|
||||||
$this->durationTime = $durationTime;
|
$this->durationTime = $durationTime;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getDurationTime(): ?\DateTime
|
||||||
* Set person.
|
|
||||||
*
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setPerson(Person $person)
|
|
||||||
{
|
{
|
||||||
$this->person = $person;
|
return $this->durationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTravelTime(\DateTime $travelTime): self
|
||||||
|
{
|
||||||
|
$this->travelTime = $travelTime;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getTravelTime(): ?\DateTime
|
||||||
* Set scope.
|
|
||||||
*
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setScope(Scope $scope)
|
|
||||||
{
|
{
|
||||||
$this->scope = $scope;
|
return $this->travelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttendee(ActivityPresence $attendee): self
|
||||||
|
{
|
||||||
|
$this->attendee = $attendee;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getAttendee(): ?ActivityPresence
|
||||||
* Set type.
|
{
|
||||||
*
|
return $this->attendee;
|
||||||
* @return Activity
|
}
|
||||||
*/
|
|
||||||
public function setType(ActivityType $type)
|
public function addReason(ActivityReason $reason): self
|
||||||
|
{
|
||||||
|
$this->reasons->add($reason);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeReason(ActivityReason $reason): void
|
||||||
|
{
|
||||||
|
$this->reasons->removeElement($reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReasons(): Collection
|
||||||
|
{
|
||||||
|
return $this->reasons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReasons(?ArrayCollection $reasons): self
|
||||||
|
{
|
||||||
|
$this->reasons = $reasons;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialIssues(): Collection
|
||||||
|
{
|
||||||
|
return $this->socialIssues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSocialIssue(?SocialIssue $socialIssue): self
|
||||||
|
{
|
||||||
|
if (!$this->socialIssues->contains($socialIssue)) {
|
||||||
|
$this->socialIssues[] = $socialIssue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeSocialIssue(SocialIssue $socialIssue): self
|
||||||
|
{
|
||||||
|
$this->socialIssues->removeElement($socialIssue);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialActions(): Collection
|
||||||
|
{
|
||||||
|
return $this->socialActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSocialAction(?SocialAction $socialAction): self
|
||||||
|
{
|
||||||
|
if (!$this->socialActions->contains($socialAction)) {
|
||||||
|
$this->socialActions[] = $socialAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeSocialAction(SocialAction $socialAction): self
|
||||||
|
{
|
||||||
|
$this->socialActions->removeElement($socialAction);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function setType(ActivityType $type): self
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getType(): ActivityType
|
||||||
* Set user.
|
|
||||||
*
|
|
||||||
* @return Activity
|
|
||||||
*/
|
|
||||||
public function setUser(User $user)
|
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setScope(Scope $scope): self
|
||||||
|
{
|
||||||
|
$this->scope = $scope;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getScope(): ?Scope
|
||||||
|
{
|
||||||
|
return $this->scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPerson(?Person $person): self
|
||||||
|
{
|
||||||
|
$this->person = $person;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerson(): ?Person
|
||||||
|
{
|
||||||
|
return $this->person;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||||
|
{
|
||||||
|
return $this->accompanyingPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccompanyingPeriod(?AccompanyingPeriod $accompanyingPeriod): self
|
||||||
|
{
|
||||||
|
$this->accompanyingPeriod = $accompanyingPeriod;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the center
|
||||||
|
* center is extracted from person
|
||||||
|
*/
|
||||||
|
public function getCenter(): ?Center
|
||||||
|
{
|
||||||
|
if ($this->person instanceof Person) {
|
||||||
|
return $this->person->getCenter();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComment(): CommentEmbeddable
|
||||||
|
{
|
||||||
|
return $this->comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setComment(CommentEmbeddable $comment): self
|
||||||
|
{
|
||||||
|
$this->comment = $comment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a person to the person list
|
||||||
|
*/
|
||||||
|
public function addPerson(?Person $person): self
|
||||||
|
{
|
||||||
|
if (null !== $person) {
|
||||||
|
$this->persons[] = $person;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removePerson(Person $person): void
|
||||||
|
{
|
||||||
|
$this->persons->removeElement($person);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersons(): Collection
|
||||||
|
{
|
||||||
|
return $this->persons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonsAssociated(): array
|
||||||
|
{
|
||||||
|
if (null !== $this->accompanyingPeriod) {
|
||||||
|
$personsAssociated = [];
|
||||||
|
foreach ($this->accompanyingPeriod->getParticipations() as $participation) {
|
||||||
|
if ($this->persons->contains($participation->getPerson())) {
|
||||||
|
$personsAssociated[] = $participation->getPerson();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $personsAssociated;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonsNotAssociated(): array
|
||||||
|
{
|
||||||
|
if (null !== $this->accompanyingPeriod) {
|
||||||
|
$personsNotAssociated = [];
|
||||||
|
foreach ($this->persons as $person) {
|
||||||
|
if (!in_array($person, $this->getPersonsAssociated())) {
|
||||||
|
$personsNotAssociated[] = $person;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $personsNotAssociated;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersons(?Collection $persons): self
|
||||||
|
{
|
||||||
|
$this->persons = $persons;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addThirdParty(?ThirdParty $thirdParty): self
|
||||||
|
{
|
||||||
|
if (null !== $thirdParty) {
|
||||||
|
$this->thirdParties[] = $thirdParty;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeThirdParty(ThirdParty $thirdParty): void
|
||||||
|
{
|
||||||
|
$this->thirdParties->removeElement($thirdParty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThirdParties(): Collection
|
||||||
|
{
|
||||||
|
return $this->thirdParties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setThirdParties(?Collection $thirdParties): self
|
||||||
|
{
|
||||||
|
$this->thirdParties = $thirdParties;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addDocument(Document $document): self
|
||||||
|
{
|
||||||
|
$this->documents[] = $document;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeDocument(Document $document): void
|
||||||
|
{
|
||||||
|
$this->documents->removeElement($document);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDocuments(): Collection
|
||||||
|
{
|
||||||
|
return $this->documents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDocuments(Collection $documents): self
|
||||||
|
{
|
||||||
|
$this->documents = $documents;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addUser(?User $user): self
|
||||||
|
{
|
||||||
|
if (null !== $user) {
|
||||||
|
$this->users[] = $user;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeUser(User $user): void
|
||||||
|
{
|
||||||
|
$this->users->removeElement($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsers(): Collection
|
||||||
|
{
|
||||||
|
return $this->users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUsers(?Collection $users): self
|
||||||
|
{
|
||||||
|
$this->users = $users;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEmergency(): bool
|
||||||
|
{
|
||||||
|
return $this->getEmergency();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmergency(): bool
|
||||||
|
{
|
||||||
|
return $this->emergency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmergency(bool $emergency): self
|
||||||
|
{
|
||||||
|
$this->emergency = $emergency;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSentReceived(): string
|
||||||
|
{
|
||||||
|
return $this->sentReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSentReceived(?string $sentReceived): self
|
||||||
|
{
|
||||||
|
$this->sentReceived = (string) $sentReceived;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
97
src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php
Normal file
97
src/Bundle/ChillActivityBundle/Entity/ActivityPresence.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ActivityPresence
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity()
|
||||||
|
* @ORM\Table(name="activitytpresence")
|
||||||
|
* @ORM\HasLifecycleCallbacks()
|
||||||
|
*/
|
||||||
|
class ActivityPresence
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*/
|
||||||
|
private ?int $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json")
|
||||||
|
*/
|
||||||
|
private array $name = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private bool $active = true;
|
||||||
|
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(array $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): array
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get active
|
||||||
|
* return true if the category type is active.
|
||||||
|
*/
|
||||||
|
public function getActive(): bool
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is active
|
||||||
|
* return true if the category type is active
|
||||||
|
*/
|
||||||
|
public function isActive(): bool
|
||||||
|
{
|
||||||
|
return $this->getActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set active
|
||||||
|
* set to true if the category type is active
|
||||||
|
*/
|
||||||
|
public function setActive(bool $active): self
|
||||||
|
{
|
||||||
|
$this->active = $active;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,43 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
*
|
||||||
*
|
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
* For the full copyright and license information, please view
|
*
|
||||||
* the LICENSE file that was distributed with this source code.
|
* This program is free software: you can redistribute it and/or modify
|
||||||
*
|
* it under the terms of the GNU Affero General Public License as
|
||||||
* @see https://www.champs-libres.coop/
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* Class ActivityReason
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="activityreason")
|
* @ORM\Table(name="activityreason")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*/
|
*/
|
||||||
class ActivityReason
|
class ActivityReason
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var integer
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private $active = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ActivityReasonCategory
|
|
||||||
* @ORM\ManyToOne(
|
|
||||||
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
|
|
||||||
* inversedBy="reasons")
|
|
||||||
*/
|
|
||||||
private $category;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*
|
*
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
@@ -52,17 +49,86 @@ class ActivityReason
|
|||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get active.
|
* @var ActivityReasonCategory
|
||||||
*
|
* @ORM\ManyToOne(
|
||||||
* @return bool
|
* targetEntity="Chill\ActivityBundle\Entity\ActivityReasonCategory",
|
||||||
|
* inversedBy="reasons")
|
||||||
*/
|
*/
|
||||||
public function getActive()
|
private $category;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private $active = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
{
|
{
|
||||||
return $this->active;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get category.
|
* Set name
|
||||||
|
*
|
||||||
|
* @param array $name
|
||||||
|
* @return ActivityReason
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*
|
||||||
|
* @return array | string
|
||||||
|
*/
|
||||||
|
public function getName($locale = null)
|
||||||
|
{
|
||||||
|
if ($locale) {
|
||||||
|
if (isset($this->name[$locale])) {
|
||||||
|
return $this->name[$locale];
|
||||||
|
} else {
|
||||||
|
foreach ($this->name as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set category of the reason. If you set to the reason an inactive
|
||||||
|
* category, the reason will become inactive
|
||||||
|
*
|
||||||
|
* @param ActivityReasonCategory $category
|
||||||
|
* @return ActivityReason
|
||||||
|
*/
|
||||||
|
public function setCategory(ActivityReasonCategory $category)
|
||||||
|
{
|
||||||
|
if($this->category !== $category && ! $category->getActive()) {
|
||||||
|
$this->setActive(False);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->category = $category;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get category
|
||||||
*
|
*
|
||||||
* @return ActivityReasonCategory
|
* @return ActivityReasonCategory
|
||||||
*/
|
*/
|
||||||
@@ -72,46 +138,9 @@ class ActivityReason
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id.
|
* Set active
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getId()
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get name.
|
|
||||||
*
|
|
||||||
* @param mixed|null $locale
|
|
||||||
*
|
|
||||||
* @return array | string
|
|
||||||
*/
|
|
||||||
public function getName($locale = null)
|
|
||||||
{
|
|
||||||
if ($locale) {
|
|
||||||
if (isset($this->name[$locale])) {
|
|
||||||
return $this->name[$locale];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->name as $name) {
|
|
||||||
if (!empty($name)) {
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set active.
|
|
||||||
*
|
|
||||||
* @param bool $active
|
|
||||||
*
|
*
|
||||||
|
* @param boolean $active
|
||||||
* @return ActivityReason
|
* @return ActivityReason
|
||||||
*/
|
*/
|
||||||
public function setActive($active)
|
public function setActive($active)
|
||||||
@@ -122,33 +151,13 @@ class ActivityReason
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set category of the reason. If you set to the reason an inactive
|
* Get active
|
||||||
* category, the reason will become inactive.
|
|
||||||
*
|
*
|
||||||
* @return ActivityReason
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function setCategory(ActivityReasonCategory $category)
|
public function getActive()
|
||||||
{
|
{
|
||||||
if ($this->category !== $category && !$category->getActive()) {
|
return $this->active;
|
||||||
$this->setActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->category = $category;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set name.
|
|
||||||
*
|
|
||||||
* @param array $name
|
|
||||||
*
|
|
||||||
* @return ActivityReason
|
|
||||||
*/
|
|
||||||
public function setName($name)
|
|
||||||
{
|
|
||||||
$this->name = $name;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as
|
||||||
*
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
* @see https://www.champs-libres.coop/
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* Class ActivityReasonCategory
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="activityreasoncategory")
|
* @ORM\Table(name="activityreasoncategory")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*/
|
*/
|
||||||
class ActivityReasonCategory
|
class ActivityReasonCategory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var integer
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private $active = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*
|
*
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
@@ -45,15 +48,20 @@ class ActivityReasonCategory
|
|||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of ActivityReason.
|
* @var boolean
|
||||||
*
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private $active = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of ActivityReason
|
||||||
* @var ArrayCollection
|
* @var ArrayCollection
|
||||||
* @ORM\OneToMany(
|
* @ORM\OneToMany(
|
||||||
* targetEntity="Chill\ActivityBundle\Entity\ActivityReason",
|
* targetEntity="Chill\ActivityBundle\Entity\ActivityReason",
|
||||||
* mappedBy="category")
|
* mappedBy="category")
|
||||||
*/
|
*/
|
||||||
private $reasons;
|
private $reasons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityReasonCategory constructor.
|
* ActivityReasonCategory constructor.
|
||||||
*/
|
*/
|
||||||
@@ -61,29 +69,19 @@ class ActivityReasonCategory
|
|||||||
{
|
{
|
||||||
$this->reasons = new ArrayCollection();
|
$this->reasons = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return 'ActivityReasonCategory(' . $this->getName('x') . ')';
|
return 'ActivityReasonCategory('.$this->getName('x').')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get active.
|
* Get id
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return integer
|
||||||
*/
|
|
||||||
public function getActive()
|
|
||||||
{
|
|
||||||
return $this->active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get id.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
@@ -91,58 +89,9 @@ class ActivityReasonCategory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name.
|
* Set name
|
||||||
*
|
|
||||||
* @param mixed|null $locale
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getName($locale = null)
|
|
||||||
{
|
|
||||||
if ($locale) {
|
|
||||||
if (isset($this->name[$locale])) {
|
|
||||||
return $this->name[$locale];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->name as $name) {
|
|
||||||
if (!empty($name)) {
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Declare a category as active (or not). When a category is set
|
|
||||||
* as unactive, all the reason have this entity as category is also
|
|
||||||
* set as unactive.
|
|
||||||
*
|
|
||||||
* @param bool $active
|
|
||||||
*
|
|
||||||
* @return ActivityReasonCategory
|
|
||||||
*/
|
|
||||||
public function setActive($active)
|
|
||||||
{
|
|
||||||
if ($this->active !== $active && !$active) {
|
|
||||||
foreach ($this->reasons as $reason) {
|
|
||||||
$reason->setActive($active);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->active = $active;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set name.
|
|
||||||
*
|
*
|
||||||
* @param array $name
|
* @param array $name
|
||||||
*
|
|
||||||
* @return ActivityReasonCategory
|
* @return ActivityReasonCategory
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
@@ -151,4 +100,59 @@ class ActivityReasonCategory
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getName($locale = null)
|
||||||
|
{
|
||||||
|
if ($locale) {
|
||||||
|
if (isset($this->name[$locale])) {
|
||||||
|
return $this->name[$locale];
|
||||||
|
} else {
|
||||||
|
foreach ($this->name as $name) {
|
||||||
|
if (!empty($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
} else {
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a category as active (or not). When a category is set
|
||||||
|
* as unactive, all the reason have this entity as category is also
|
||||||
|
* set as unactive
|
||||||
|
*
|
||||||
|
* @param boolean $active
|
||||||
|
* @return ActivityReasonCategory
|
||||||
|
*/
|
||||||
|
public function setActive($active)
|
||||||
|
{
|
||||||
|
if($this->active !== $active && !$active) {
|
||||||
|
foreach ($this->reasons as $reason) {
|
||||||
|
$reason->setActive($active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->active = $active;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get active
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function getActive()
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,131 +1,822 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* Class ActivityType
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="activitytype")
|
* @ORM\Table(name="activitytype")
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*/
|
*/
|
||||||
class ActivityType
|
class ActivityType
|
||||||
{
|
{
|
||||||
/**
|
const FIELD_INVISIBLE = 0;
|
||||||
* @var bool
|
const FIELD_OPTIONAL = 1;
|
||||||
* @ORM\Column(type="boolean")
|
const FIELD_REQUIRED = 2;
|
||||||
*/
|
|
||||||
private $active = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
|
||||||
*
|
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
*/
|
*/
|
||||||
private $id;
|
private ?int $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
|
||||||
* @ORM\Column(type="json_array")
|
* @ORM\Column(type="json_array")
|
||||||
*/
|
*/
|
||||||
private $name;
|
private array $name = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get active
|
* @ORM\Column(type="boolean")
|
||||||
* return true if the type is active.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function getActive()
|
private bool $active = true;
|
||||||
{
|
|
||||||
return $this->active;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id.
|
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityTypeCategory")
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function getId()
|
private ?ActivityTypeCategory $category = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=2})
|
||||||
|
*/
|
||||||
|
private int $personVisible = self::FIELD_REQUIRED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $personLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=2})
|
||||||
|
*/
|
||||||
|
private int $userVisible = self::FIELD_REQUIRED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $userLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=2})
|
||||||
|
*/
|
||||||
|
private int $dateVisible = self::FIELD_REQUIRED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $dateLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $placeVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $placeLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $personsVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $personsLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $thirdPartiesVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $thirdPartiesLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $durationTimeVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $durationTimeLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $travelTimeVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $travelTimeLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $attendeeVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $attendeeLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $reasonsVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $reasonsLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $commentVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $commentLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $sentReceivedVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $sentReceivedLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $documentsVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $documentsLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $usersVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $usersLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $emergencyVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $emergencyLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $accompanyingPeriodVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $accompanyingPeriodLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $socialDataVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $socialDataLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $socialIssuesVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $socialIssuesLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||||
|
*/
|
||||||
|
private int $socialActionsVisible = self::FIELD_INVISIBLE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||||
|
*/
|
||||||
|
private string $socialActionsLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="float", options={"default"="0.0"})
|
||||||
|
*/
|
||||||
|
private float $ordering = 0.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name.
|
* Set name
|
||||||
*
|
|
||||||
* @param mixed|null $locale
|
|
||||||
*
|
|
||||||
* @return array | string
|
|
||||||
*/
|
*/
|
||||||
public function getName($locale = null)
|
public function setName(array $name): self
|
||||||
{
|
{
|
||||||
if ($locale) {
|
$this->name = $name;
|
||||||
if (isset($this->name[$locale])) {
|
|
||||||
return $this->name[$locale];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->name as $name) {
|
return $this;
|
||||||
if (!empty($name)) {
|
}
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*/
|
||||||
|
public function getName(): array
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is active
|
* Get active
|
||||||
* return true if the type is active.
|
* return true if the type is active.
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function isActive()
|
public function getActive(): bool
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is active
|
||||||
|
* return true if the type is active
|
||||||
|
*/
|
||||||
|
public function isActive(): bool
|
||||||
{
|
{
|
||||||
return $this->getActive();
|
return $this->getActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set active
|
* Set active
|
||||||
* set to true if the type is active.
|
* set to true if the type is active
|
||||||
*
|
|
||||||
* @param bool $active
|
|
||||||
*
|
|
||||||
* @return ActivityType
|
|
||||||
*/
|
*/
|
||||||
public function setActive($active)
|
public function setActive(bool $active): self
|
||||||
{
|
{
|
||||||
$this->active = $active;
|
$this->active = $active;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getCategory(): ?ActivityTypeCategory
|
||||||
* Set name.
|
|
||||||
*
|
|
||||||
* @param array $name
|
|
||||||
*
|
|
||||||
* @return ActivityType
|
|
||||||
*/
|
|
||||||
public function setName($name)
|
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
return $this->category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCategory(?ActivityTypeCategory $category): self
|
||||||
|
{
|
||||||
|
$this->category = $category;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonVisible(): int
|
||||||
|
{
|
||||||
|
return $this->personVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersonVisible(int $personVisible): self
|
||||||
|
{
|
||||||
|
$this->personVisible = $personVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonLabel(): string
|
||||||
|
{
|
||||||
|
return $this->personLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersonLabel(string $personLabel): self
|
||||||
|
{
|
||||||
|
$this->personLabel = $personLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserVisible(): int
|
||||||
|
{
|
||||||
|
return $this->userVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserVisible(int $userVisible): self
|
||||||
|
{
|
||||||
|
$this->userVisible = $userVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserLabel(): string
|
||||||
|
{
|
||||||
|
return $this->userLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUserLabel(string $userLabel): self
|
||||||
|
{
|
||||||
|
$this->userLabel = $userLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDateVisible(): int
|
||||||
|
{
|
||||||
|
return $this->dateVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDateVisible(int $dateVisible): self
|
||||||
|
{
|
||||||
|
$this->dateVisible = $dateVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDateLabel(): string
|
||||||
|
{
|
||||||
|
return $this->dateLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDateLabel(string $dateLabel): self
|
||||||
|
{
|
||||||
|
$this->dateLabel = $dateLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlaceVisible(): int
|
||||||
|
{
|
||||||
|
return $this->placeVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlaceVisible(int $placeVisible): self
|
||||||
|
{
|
||||||
|
$this->placeVisible = $placeVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPlaceLabel(): string
|
||||||
|
{
|
||||||
|
return $this->placeLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPlaceLabel(string $placeLabel): self
|
||||||
|
{
|
||||||
|
$this->placeLabel = $placeLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonsVisible(): int
|
||||||
|
{
|
||||||
|
return $this->personsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersonsVisible(int $personsVisible): self
|
||||||
|
{
|
||||||
|
$this->personsVisible = $personsVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonsLabel(): string
|
||||||
|
{
|
||||||
|
return $this->personsLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersonsLabel(string $personsLabel): self
|
||||||
|
{
|
||||||
|
$this->personsLabel = $personsLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThirdPartiesVisible(): int
|
||||||
|
{
|
||||||
|
return $this->thirdPartiesVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setThirdPartiesVisible(int $thirdPartiesVisible): self
|
||||||
|
{
|
||||||
|
$this->thirdPartiesVisible = $thirdPartiesVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThirdPartiesLabel(): string
|
||||||
|
{
|
||||||
|
return $this->thirdPartiesLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setThirdPartiesLabel(string $thirdPartiesLabel): self
|
||||||
|
{
|
||||||
|
$this->thirdPartiesLabel = $thirdPartiesLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDurationTimeVisible(): int
|
||||||
|
{
|
||||||
|
return $this->durationTimeVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDurationTimeVisible(int $durationTimeVisible): self
|
||||||
|
{
|
||||||
|
$this->durationTimeVisible = $durationTimeVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDurationTimeLabel(): string
|
||||||
|
{
|
||||||
|
return $this->durationTimeLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDurationTimeLabel(string $durationTimeLabel): self
|
||||||
|
{
|
||||||
|
$this->durationTimeLabel = $durationTimeLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTravelTimeVisible(): int
|
||||||
|
{
|
||||||
|
return $this->travelTimeVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTravelTimeVisible(int $TravelTimeVisible): self
|
||||||
|
{
|
||||||
|
$this->travelTimeVisible = $TravelTimeVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTravelTimeLabel(): string
|
||||||
|
{
|
||||||
|
return $this->travelTimeLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTravelTimeLabel(string $TravelTimeLabel): self
|
||||||
|
{
|
||||||
|
$this->travelTimeLabel = $TravelTimeLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttendeeVisible(): int
|
||||||
|
{
|
||||||
|
return $this->attendeeVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttendeeVisible(int $attendeeVisible): self
|
||||||
|
{
|
||||||
|
$this->attendeeVisible = $attendeeVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAttendeeLabel(): string
|
||||||
|
{
|
||||||
|
return $this->attendeeLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAttendeeLabel(string $attendeeLabel): self
|
||||||
|
{
|
||||||
|
$this->attendeeLabel = $attendeeLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReasonsVisible(): int
|
||||||
|
{
|
||||||
|
return $this->reasonsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReasonsVisible(int $reasonsVisible): self
|
||||||
|
{
|
||||||
|
$this->reasonsVisible = $reasonsVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getReasonsLabel(): string
|
||||||
|
{
|
||||||
|
return $this->reasonsLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReasonsLabel(string $reasonsLabel): self
|
||||||
|
{
|
||||||
|
$this->reasonsLabel = $reasonsLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommentVisible(): int
|
||||||
|
{
|
||||||
|
return $this->commentVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCommentVisible(int $commentVisible): self
|
||||||
|
{
|
||||||
|
$this->commentVisible = $commentVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCommentLabel(): string
|
||||||
|
{
|
||||||
|
return $this->commentLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCommentLabel(string $commentLabel): self
|
||||||
|
{
|
||||||
|
$this->commentLabel = $commentLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSentReceivedVisible(): int
|
||||||
|
{
|
||||||
|
return $this->sentReceivedVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSentReceivedVisible(int $sentReceivedVisible): self
|
||||||
|
{
|
||||||
|
$this->sentReceivedVisible = $sentReceivedVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSentReceivedLabel(): string
|
||||||
|
{
|
||||||
|
return $this->sentReceivedLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSentReceivedLabel(string $sentReceivedLabel): self
|
||||||
|
{
|
||||||
|
$this->sentReceivedLabel = $sentReceivedLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDocumentsVisible(): int
|
||||||
|
{
|
||||||
|
return $this->documentsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDocumentsVisible(int $documentsVisible): self
|
||||||
|
{
|
||||||
|
$this->documentsVisible = $documentsVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDocumentsLabel(): string
|
||||||
|
{
|
||||||
|
return $this->documentsLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDocumentsLabel(string $documentsLabel): self
|
||||||
|
{
|
||||||
|
$this->documentsLabel = $documentsLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsersVisible(): int
|
||||||
|
{
|
||||||
|
return $this->usersVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUsersVisible(int $usersVisible): self
|
||||||
|
{
|
||||||
|
$this->usersVisible = $usersVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsersLabel(): string
|
||||||
|
{
|
||||||
|
return $this->usersLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUsersLabel(string $usersLabel): self
|
||||||
|
{
|
||||||
|
$this->usersLabel = $usersLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmergencyVisible(): int
|
||||||
|
{
|
||||||
|
return $this->emergencyVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmergencyVisible(int $emergencyVisible): self
|
||||||
|
{
|
||||||
|
$this->emergencyVisible = $emergencyVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmergencyLabel(): string
|
||||||
|
{
|
||||||
|
return $this->emergencyLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEmergencyLabel(string $emergencyLabel): self
|
||||||
|
{
|
||||||
|
$this->emergencyLabel = $emergencyLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccompanyingPeriodVisible(): int
|
||||||
|
{
|
||||||
|
return $this->accompanyingPeriodVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): self
|
||||||
|
{
|
||||||
|
$this->accompanyingPeriodVisible = $accompanyingPeriodVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccompanyingPeriodLabel(): string
|
||||||
|
{
|
||||||
|
return $this->accompanyingPeriodLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): self
|
||||||
|
{
|
||||||
|
$this->accompanyingPeriodLabel = $accompanyingPeriodLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialDataVisible(): int
|
||||||
|
{
|
||||||
|
return $this->socialDataVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSocialDataVisible(int $socialDataVisible): self
|
||||||
|
{
|
||||||
|
$this->socialDataVisible = $socialDataVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialDataLabel(): string
|
||||||
|
{
|
||||||
|
return $this->socialDataLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSocialDataLabel(string $socialDataLabel): self
|
||||||
|
{
|
||||||
|
$this->socialDataLabel = $socialDataLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isVisible(string $field): bool
|
||||||
|
{
|
||||||
|
$property = $field.'Visible';
|
||||||
|
|
||||||
|
if (!property_exists($this, $property)) {
|
||||||
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::FIELD_INVISIBLE !== $this->$property;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isRequired(string $field): bool
|
||||||
|
{
|
||||||
|
$property = $field.'Visible';
|
||||||
|
|
||||||
|
if (!property_exists($this, $property)) {
|
||||||
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::FIELD_REQUIRED === $this->$property;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabel(string $field): ?string
|
||||||
|
{
|
||||||
|
$property = $field.'Label';
|
||||||
|
|
||||||
|
if (!property_exists($this, $property)) {
|
||||||
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->$property;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrdering(): float
|
||||||
|
{
|
||||||
|
return $this->ordering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrdering(float $ordering): self
|
||||||
|
{
|
||||||
|
$this->ordering = $ordering;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialIssuesVisible(): ?int
|
||||||
|
{
|
||||||
|
return $this->socialIssuesVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSocialIssuesVisible(int $socialIssuesVisible): self
|
||||||
|
{
|
||||||
|
$this->socialIssuesVisible = $socialIssuesVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialIssuesLabel(): ?string
|
||||||
|
{
|
||||||
|
return $this->socialIssuesLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSocialIssuesLabel(string $socialIssuesLabel): self
|
||||||
|
{
|
||||||
|
$this->socialIssuesLabel = $socialIssuesLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialActionsVisible(): ?int
|
||||||
|
{
|
||||||
|
return $this->socialActionsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSocialActionsVisible(int $socialActionsVisible): self
|
||||||
|
{
|
||||||
|
$this->socialActionsVisible = $socialActionsVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSocialActionsLabel(): ?string
|
||||||
|
{
|
||||||
|
return $this->socialActionsLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSocialActionsLabel(string $socialActionsLabel): self
|
||||||
|
{
|
||||||
|
$this->socialActionsLabel = $socialActionsLabel;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
123
src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
Normal file
123
src/Bundle/ChillActivityBundle/Entity/ActivityTypeCategory.php
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ActivityTypeCateogry
|
||||||
|
*
|
||||||
|
* @package Chill\ActivityBundle\Entity
|
||||||
|
* @ORM\Entity()
|
||||||
|
* @ORM\Table(name="activitytypecategory")
|
||||||
|
* @ORM\HasLifecycleCallbacks()
|
||||||
|
*/
|
||||||
|
class ActivityTypeCategory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\Column(name="id", type="integer")
|
||||||
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
|
*/
|
||||||
|
private ?int $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="json_array")
|
||||||
|
*/
|
||||||
|
private array $name = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private bool $active = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="float", options={"default"="0.0"})
|
||||||
|
*/
|
||||||
|
private float $ordering = 0.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set name
|
||||||
|
*/
|
||||||
|
public function setName(array $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name
|
||||||
|
*/
|
||||||
|
public function getName(): array
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get active
|
||||||
|
* return true if the category type is active.
|
||||||
|
*/
|
||||||
|
public function getActive(): bool
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is active
|
||||||
|
* return true if the category type is active
|
||||||
|
*/
|
||||||
|
public function isActive(): bool
|
||||||
|
{
|
||||||
|
return $this->getActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set active
|
||||||
|
* set to true if the category type is active
|
||||||
|
*/
|
||||||
|
public function setActive(bool $active): self
|
||||||
|
{
|
||||||
|
$this->active = $active;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrdering(): float
|
||||||
|
{
|
||||||
|
return $this->ordering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrdering(float $ordering): self
|
||||||
|
{
|
||||||
|
$this->ordering = $ordering;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,103 +1,107 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2016 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
|
||||||
use function array_key_exists;
|
/**
|
||||||
use function count;
|
*
|
||||||
|
*
|
||||||
class ActivityReasonAggregator implements
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
AggregatorInterface,
|
*/
|
||||||
|
class ActivityReasonAggregator implements AggregatorInterface,
|
||||||
ExportElementValidatedInterface
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $categoryRepository;
|
protected $categoryRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $reasonRepository;
|
protected $reasonRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $stringHelper;
|
protected $stringHelper;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityRepository $categoryRepository,
|
EntityRepository $categoryRepository,
|
||||||
EntityRepository $reasonRepository,
|
EntityRepository $reasonRepository,
|
||||||
TranslatableStringHelper $stringHelper
|
TranslatableStringHelper $stringHelper
|
||||||
) {
|
) {
|
||||||
$this->categoryRepository = $categoryRepository;
|
$this->categoryRepository = $categoryRepository;
|
||||||
$this->reasonRepository = $reasonRepository;
|
$this->reasonRepository = $reasonRepository;
|
||||||
$this->stringHelper = $stringHelper;
|
$this->stringHelper = $stringHelper;
|
||||||
}
|
|
||||||
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// add select element
|
// add select element
|
||||||
if ('reasons' === $data['level']) {
|
if ($data['level'] === 'reasons') {
|
||||||
$elem = 'reasons.id';
|
$elem = 'reasons.id';
|
||||||
$alias = 'activity_reasons_id';
|
$alias = 'activity_reasons_id';
|
||||||
} elseif ('categories' === $data['level']) {
|
} elseif ($data['level'] === 'categories') {
|
||||||
$elem = 'category.id';
|
$elem = 'category.id';
|
||||||
$alias = 'activity_categories_id';
|
$alias = 'activity_categories_id';
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('the data provided are not recognized');
|
throw new \RuntimeException('the data provided are not recognized');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect($elem . ' as ' . $alias);
|
$qb->addSelect($elem.' as '.$alias);
|
||||||
|
|
||||||
// make a jointure only if needed
|
// make a jointure only if needed
|
||||||
$join = $qb->getDQLPart('join');
|
$join = $qb->getDQLPart('join');
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(
|
(array_key_exists('activity', $join)
|
||||||
array_key_exists('activity', $join)
|
&&
|
||||||
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
!$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||||
)
|
)
|
||||||
|| (!array_key_exists('activity', $join))
|
OR
|
||||||
|
(! array_key_exists('activity', $join))
|
||||||
) {
|
) {
|
||||||
$qb->add(
|
$qb->add(
|
||||||
'join',
|
'join',
|
||||||
['activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons'),
|
array('activity' =>
|
||||||
],
|
new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')
|
||||||
true
|
),
|
||||||
);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// join category if necessary
|
// join category if necessary
|
||||||
if ('activity_categories_id' === $alias) {
|
if ($alias === 'activity_categories_id') {
|
||||||
// add join only if needed
|
// add join only if needed
|
||||||
if (!$this->checkJoinAlreadyDefined($qb->getDQLPart('join')['activity'], 'category')) {
|
if (!$this->checkJoinAlreadyDefined($qb->getDQLPart('join')['activity'], 'category')) {
|
||||||
$qb->join('reasons.category', 'category');
|
$qb->join('reasons.category', 'category');
|
||||||
@@ -114,107 +118,12 @@ class ActivityReasonAggregator implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn()
|
|
||||||
{
|
|
||||||
return 'activity';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
|
||||||
{
|
|
||||||
$builder->add('level', ChoiceType::class, [
|
|
||||||
'choices' => [
|
|
||||||
'By reason' => 'reasons',
|
|
||||||
'By category of reason' => 'categories',
|
|
||||||
],
|
|
||||||
'multiple' => false,
|
|
||||||
'expanded' => true,
|
|
||||||
'label' => 'Reason\'s level',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
|
||||||
{
|
|
||||||
// for performance reason, we load data from db only once
|
|
||||||
switch ($data['level']) {
|
|
||||||
case 'reasons':
|
|
||||||
$this->reasonRepository->findBy(['id' => $values]);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'categories':
|
|
||||||
$this->categoryRepository->findBy(['id' => $values]);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new RuntimeException(sprintf(
|
|
||||||
"the level data '%s' is invalid",
|
|
||||||
$data['level']
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return function ($value) use ($data) {
|
|
||||||
if ('_header' === $value) {
|
|
||||||
return 'reasons' === $data['level'] ?
|
|
||||||
'Group by reasons'
|
|
||||||
:
|
|
||||||
'Group by categories of reason';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($data['level']) {
|
|
||||||
case 'reasons':
|
|
||||||
/** @var \Chill\ActivityBundle\Entity\ActivityReason $r */
|
|
||||||
$r = $this->reasonRepository->find($value);
|
|
||||||
|
|
||||||
return $this->stringHelper->localize($r->getCategory()->getName())
|
|
||||||
. ' > '
|
|
||||||
. $this->stringHelper->localize($r->getName());
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'categories':
|
|
||||||
$c = $this->categoryRepository->find($value);
|
|
||||||
|
|
||||||
return $this->stringHelper->localize($c->getName());
|
|
||||||
|
|
||||||
break;
|
|
||||||
// no need for a default : the default was already set above
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
|
||||||
{
|
|
||||||
// add select element
|
|
||||||
if ('reasons' === $data['level']) {
|
|
||||||
return ['activity_reasons_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('categories' === $data['level']) {
|
|
||||||
return ['activity_categories_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException('the data provided are not recognised');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Aggregate by activity reason';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
|
||||||
{
|
|
||||||
if (null === $data['level']) {
|
|
||||||
$context->buildViolation("The reasons's level should not be empty")
|
|
||||||
->addViolation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a join between Activity and another alias.
|
* Check if a join between Activity and another alias
|
||||||
*
|
*
|
||||||
* @param Join[] $joins
|
* @param Join[] $joins
|
||||||
* @param string $alias the alias to search for
|
* @param string $alias the alias to search for
|
||||||
*
|
* @return boolean
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
private function checkJoinAlreadyDefined(array $joins, $alias)
|
private function checkJoinAlreadyDefined(array $joins, $alias)
|
||||||
{
|
{
|
||||||
@@ -226,4 +135,99 @@ class ActivityReasonAggregator implements
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function applyOn()
|
||||||
|
{
|
||||||
|
return 'activity';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
$builder->add('level', ChoiceType::class, array(
|
||||||
|
'choices' => array(
|
||||||
|
'By reason' => 'reasons',
|
||||||
|
'By category of reason' => 'categories'
|
||||||
|
),
|
||||||
|
'multiple' => false,
|
||||||
|
'expanded' => true,
|
||||||
|
'label' => 'Reason\'s level'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
|
{
|
||||||
|
if ($data['level'] === null) {
|
||||||
|
$context->buildViolation("The reasons's level should not be empty")
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return "Aggregate by activity reason";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
// for performance reason, we load data from db only once
|
||||||
|
switch ($data['level']) {
|
||||||
|
case 'reasons':
|
||||||
|
$this->reasonRepository->findBy(array('id' => $values));
|
||||||
|
break;
|
||||||
|
case 'categories':
|
||||||
|
$this->categoryRepository->findBy(array('id' => $values));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \RuntimeException(sprintf("the level data '%s' is invalid",
|
||||||
|
$data['level']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return function($value) use ($data) {
|
||||||
|
if ($value === '_header') {
|
||||||
|
return $data['level'] === 'reasons' ?
|
||||||
|
'Group by reasons'
|
||||||
|
:
|
||||||
|
'Group by categories of reason'
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($data['level']) {
|
||||||
|
case 'reasons':
|
||||||
|
/* @var $r \Chill\ActivityBundle\Entity\ActivityReason */
|
||||||
|
$r = $this->reasonRepository->find($value);
|
||||||
|
|
||||||
|
return $this->stringHelper->localize($r->getCategory()->getName())
|
||||||
|
." > "
|
||||||
|
. $this->stringHelper->localize($r->getName());
|
||||||
|
;
|
||||||
|
break;
|
||||||
|
case 'categories':
|
||||||
|
$c = $this->categoryRepository->find($value);
|
||||||
|
|
||||||
|
return $this->stringHelper->localize($c->getName());
|
||||||
|
break;
|
||||||
|
// no need for a default : the default was already set above
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryKeys($data)
|
||||||
|
{
|
||||||
|
// add select element
|
||||||
|
if ($data['level'] === 'reasons') {
|
||||||
|
return array('activity_reasons_id');
|
||||||
|
} elseif ($data['level'] === 'categories') {
|
||||||
|
return array ('activity_categories_id');
|
||||||
|
} else {
|
||||||
|
throw new \RuntimeException('the data provided are not recognised');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2016 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class ActivityTypeAggregator implements AggregatorInterface
|
class ActivityTypeAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
public const KEY = 'activity_type_aggregator';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $stringHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $typeRepository;
|
protected $typeRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
protected $stringHelper;
|
||||||
|
|
||||||
|
const KEY = 'activity_type_aggregator';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityRepository $typeRepository,
|
EntityRepository $typeRepository,
|
||||||
TranslatableStringHelper $stringHelper
|
TranslatableStringHelper $stringHelper
|
||||||
) {
|
) {
|
||||||
$this->typeRepository = $typeRepository;
|
$this->typeRepository = $typeRepository;
|
||||||
$this->stringHelper = $stringHelper;
|
$this->stringHelper = $stringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// add select element
|
// add select element
|
||||||
$qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY));
|
$qb->addSelect(sprintf('IDENTITY(activity.type) AS %s', self::KEY));
|
||||||
|
|
||||||
// add the "group by" part
|
// add the "group by" part
|
||||||
$groupBy = $qb->addGroupBy(self::KEY);
|
$groupBy = $qb->addGroupBy(self::KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a join between Activity and another alias
|
||||||
|
*
|
||||||
|
* @param Join[] $joins
|
||||||
|
* @param string $alias the alias to search for
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function checkJoinAlreadyDefined(array $joins, $alias)
|
||||||
|
{
|
||||||
|
foreach ($joins as $join) {
|
||||||
|
if ($join->getAlias() === $alias) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
@@ -68,49 +95,37 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
// no form required for this aggregator
|
// no form required for this aggregator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTitle()
|
||||||
|
{
|
||||||
|
return "Aggregate by activity type";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
// for performance reason, we load data from db only once
|
// for performance reason, we load data from db only once
|
||||||
$this->typeRepository->findBy(['id' => $values]);
|
$this->typeRepository->findBy(array('id' => $values));
|
||||||
|
|
||||||
return function ($value) {
|
return function($value) use ($data) {
|
||||||
if ('_header' === $value) {
|
if ($value === '_header') {
|
||||||
return 'Activity type';
|
return 'Activity type';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \Chill\ActivityBundle\Entity\ActivityType $r */
|
/* @var $r \Chill\ActivityBundle\Entity\ActivityType */
|
||||||
$t = $this->typeRepository->find($value);
|
$t = $this->typeRepository->find($value);
|
||||||
|
|
||||||
return $this->stringHelper->localize($t->getName());
|
return $this->stringHelper->localize($t->getName());
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data)
|
||||||
{
|
{
|
||||||
return [self::KEY];
|
return array(self::KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Aggregate by activity type';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a join between Activity and another alias.
|
|
||||||
*
|
|
||||||
* @param Join[] $joins
|
|
||||||
* @param string $alias the alias to search for
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function checkJoinAlreadyDefined(array $joins, $alias)
|
|
||||||
{
|
|
||||||
foreach ($joins as $join) {
|
|
||||||
if ($join->getAlias() === $alias) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
/**
|
* Copyright (C) 2019 Champs Libres Cooperative <info@champs-libres.coop>
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Aggregator;
|
namespace Chill\ActivityBundle\Export\Aggregator;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
|
||||||
use Closure;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class ActivityUserAggregator implements AggregatorInterface
|
class ActivityUserAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
public const KEY = 'activity_user_id';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityManagerInterface
|
* @var EntityManagerInterface
|
||||||
*/
|
*/
|
||||||
protected $em;
|
protected $em;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em)
|
const KEY = 'activity_user_id';
|
||||||
|
|
||||||
|
function __construct(EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
@@ -43,9 +53,9 @@ class ActivityUserAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// add select element
|
// add select element
|
||||||
$qb->addSelect(sprintf('IDENTITY(activity.user) AS %s', self::KEY));
|
$qb->addSelect(sprintf('IDENTITY(activity.user) AS %s', self::KEY));
|
||||||
|
|
||||||
// add the "group by" part
|
// add the "group by" part
|
||||||
$qb->addGroupBy(self::KEY);
|
$qb->addGroupBy(self::KEY);
|
||||||
}
|
}
|
||||||
@@ -60,17 +70,16 @@ class ActivityUserAggregator implements AggregatorInterface
|
|||||||
// nothing to add
|
// nothing to add
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, $values, $data): Closure
|
public function getLabels($key, $values, $data): \Closure
|
||||||
{
|
{
|
||||||
// preload users at once
|
// preload users at once
|
||||||
$this->em->getRepository(User::class)
|
$this->em->getRepository(User::class)
|
||||||
->findBy(['id' => $values]);
|
->findBy(['id' => $values]);
|
||||||
|
|
||||||
return function ($value) {
|
return function($value) {
|
||||||
switch ($value) {
|
switch ($value) {
|
||||||
case '_header':
|
case '_header':
|
||||||
return 'activity user';
|
return 'activity user';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $this->em->getRepository(User::class)->find($value)
|
return $this->em->getRepository(User::class)->find($value)
|
||||||
->getUsername();
|
->getUsername();
|
||||||
@@ -80,11 +89,11 @@ class ActivityUserAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data)
|
||||||
{
|
{
|
||||||
return [self::KEY];
|
return [ self::KEY ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Aggregate by activity user';
|
return "Aggregate by activity user";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +1,64 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2015 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Export;
|
namespace Chill\ActivityBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\ExportInterface;
|
use Chill\MainBundle\Export\ExportInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class CountActivity implements ExportInterface
|
class CountActivity implements ExportInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityManagerInterface
|
* @var EntityManagerInterface
|
||||||
*/
|
*/
|
||||||
protected $entityManager;
|
protected $entityManager;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManagerInterface $em
|
EntityManagerInterface $em
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
$this->entityManager = $em;
|
$this->entityManager = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllowedFormattersTypes()
|
|
||||||
{
|
|
||||||
return [\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
return 'Count activities by various parameters.';
|
return "Count activities by various parameters.";
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
|
||||||
{
|
|
||||||
if ('export_count_activity' !== $key) {
|
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
|
||||||
}
|
|
||||||
|
|
||||||
return static function ($value) {
|
|
||||||
return '_header' === $value ?
|
|
||||||
'Number of activities'
|
|
||||||
:
|
|
||||||
$value;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
|
||||||
{
|
|
||||||
return ['export_count_activity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResult($qb, $data)
|
|
||||||
{
|
|
||||||
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return 'Count activities';
|
return "Count activities";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
@@ -81,30 +66,61 @@ class CountActivity implements ExportInterface
|
|||||||
return 'activity';
|
return 'activity';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
|
||||||
{
|
{
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
$centers = array_map(static function ($el) {
|
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
||||||
return $el['center'];
|
|
||||||
}, $acl);
|
|
||||||
|
|
||||||
$qb->select('COUNT(activity.id) as export_count_activity')
|
$qb->select('COUNT(activity.id) as export_count_activity')
|
||||||
->from('ChillActivityBundle:Activity', 'activity')
|
->from('ChillActivityBundle:Activity', 'activity')
|
||||||
->join('activity.person', 'person');
|
->join('activity.person', 'person')
|
||||||
|
;
|
||||||
|
|
||||||
$qb->where($qb->expr()->in('person.center', ':centers'))
|
$qb->where($qb->expr()->in('person.center', ':centers'))
|
||||||
->setParameter('centers', $centers);
|
->setParameter('centers', $centers)
|
||||||
|
;
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supportsModifiers()
|
||||||
|
{
|
||||||
|
return array('person', 'activity');
|
||||||
|
}
|
||||||
|
|
||||||
public function requiredRole()
|
public function requiredRole()
|
||||||
{
|
{
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsModifiers()
|
public function getAllowedFormattersTypes()
|
||||||
{
|
{
|
||||||
return ['person', 'activity'];
|
return array(\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
if ($key !== 'export_count_activity') {
|
||||||
|
throw new \LogicException("the key $key is not used by this export");
|
||||||
|
}
|
||||||
|
|
||||||
|
return function($value) {
|
||||||
|
return $value === '_header' ?
|
||||||
|
'Number of activities'
|
||||||
|
:
|
||||||
|
$value
|
||||||
|
;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryKeys($data)
|
||||||
|
{
|
||||||
|
return array('export_count_activity');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResult($qb, $data)
|
||||||
|
{
|
||||||
|
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,69 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Export;
|
namespace Chill\ActivityBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\FormatterInterface;
|
|
||||||
use Chill\MainBundle\Export\ListInterface;
|
use Chill\MainBundle\Export\ListInterface;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
use Symfony\Component\Validator\Constraints\Callback;
|
use Symfony\Component\Validator\Constraints\Callback;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Chill\MainBundle\Export\FormatterInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
use function array_key_exists;
|
|
||||||
use function count;
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a list for all activities.
|
* Create a list for all activities
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class ListActivity implements ListInterface
|
class ListActivity implements ListInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var EntityManagerInterface
|
* @var EntityManagerInterface
|
||||||
*/
|
*/
|
||||||
protected $entityManager;
|
protected $entityManager;
|
||||||
|
|
||||||
protected $fields = [
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
|
protected $fields = array(
|
||||||
'id',
|
'id',
|
||||||
'date',
|
'date',
|
||||||
'durationTime',
|
'durationTime',
|
||||||
@@ -53,132 +74,115 @@ class ListActivity implements ListInterface
|
|||||||
'type_name',
|
'type_name',
|
||||||
'person_firstname',
|
'person_firstname',
|
||||||
'person_lastname',
|
'person_lastname',
|
||||||
'person_id',
|
'person_id'
|
||||||
];
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $translatableStringHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
TranslatableStringHelper $translatableStringHelper
|
TranslatableStringHelper $translatableStringHelper
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
$this->entityManager = $em;
|
$this->entityManager = $em;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @param FormBuilderInterface $builder
|
||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('fields', ChoiceType::class, [
|
$builder->add('fields', ChoiceType::class, array(
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'choices' => array_combine($this->fields, $this->fields),
|
'choices' => array_combine($this->fields, $this->fields),
|
||||||
'label' => 'Fields to include in export',
|
'label' => 'Fields to include in export',
|
||||||
'constraints' => [new Callback([
|
'constraints' => [new Callback(array(
|
||||||
'callback' => static function ($selected, ExecutionContextInterface $context) {
|
'callback' => function($selected, ExecutionContextInterface $context) {
|
||||||
if (count($selected) === 0) {
|
if (count($selected) === 0) {
|
||||||
$context->buildViolation('You must select at least one element')
|
$context->buildViolation('You must select at least one element')
|
||||||
->atPath('fields')
|
->atPath('fields')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
])],
|
))]
|
||||||
]);
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function getAllowedFormattersTypes()
|
public function getAllowedFormattersTypes()
|
||||||
{
|
{
|
||||||
return [FormatterInterface::TYPE_LIST];
|
return array(FormatterInterface::TYPE_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
return 'List activities';
|
return "List activities";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
switch ($key) {
|
switch ($key)
|
||||||
case 'date':
|
{
|
||||||
return static function ($value) {
|
case 'date' :
|
||||||
if ('_header' === $value) {
|
return function($value) {
|
||||||
return 'date';
|
if ($value === '_header') return 'date';
|
||||||
}
|
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||||
|
|
||||||
return $date->format('d-m-Y');
|
return $date->format('d-m-Y');
|
||||||
};
|
};
|
||||||
case 'attendee':
|
case 'attendee':
|
||||||
return static function ($value) {
|
return function($value) {
|
||||||
if ('_header' === $value) {
|
if ($value === '_header') return 'attendee';
|
||||||
return 'attendee';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value ? 1 : 0;
|
return $value ? 1 : 0;
|
||||||
};
|
};
|
||||||
case 'list_reasons':
|
case 'list_reasons' :
|
||||||
/** @var EntityRepository $activityReasonsRepository */
|
/* @var $activityReasonsRepository EntityRepository */
|
||||||
$activityRepository = $this->entityManager
|
$activityRepository = $this->entityManager
|
||||||
->getRepository('ChillActivityBundle:Activity');
|
->getRepository('ChillActivityBundle:Activity');
|
||||||
|
|
||||||
return function ($value) use ($activityRepository) {
|
return function($value) use ($activityRepository) {
|
||||||
if ('_header' === $value) {
|
if ($value === '_header') return 'activity reasons';
|
||||||
return 'activity reasons';
|
|
||||||
}
|
|
||||||
|
|
||||||
$activity = $activityRepository
|
$activity = $activityRepository
|
||||||
->find($value);
|
->find($value);
|
||||||
|
|
||||||
return implode(', ', array_map(function (ActivityReason $r) {
|
return implode(", ", array_map(function(ActivityReason $r) {
|
||||||
return '"' .
|
|
||||||
|
return '"'.
|
||||||
$this->translatableStringHelper->localize($r->getCategory()->getName())
|
$this->translatableStringHelper->localize($r->getCategory()->getName())
|
||||||
. ' > ' .
|
.' > '.
|
||||||
$this->translatableStringHelper->localize($r->getName())
|
$this->translatableStringHelper->localize($r->getName())
|
||||||
. '"';
|
.'"';
|
||||||
}, $activity->getReasons()->toArray()));
|
}, $activity->getReasons()->toArray()));
|
||||||
};
|
};
|
||||||
case 'circle_name':
|
case 'circle_name' :
|
||||||
return function ($value) {
|
return function($value) {
|
||||||
if ('_header' === $value) {
|
if ($value === '_header') return 'circle';
|
||||||
return 'circle';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->translatableStringHelper
|
return $this->translatableStringHelper
|
||||||
->localize(json_decode($value, true));
|
->localize(json_decode($value, true));
|
||||||
};
|
};
|
||||||
case 'type_name':
|
case 'type_name' :
|
||||||
return function ($value) {
|
return function($value) {
|
||||||
if ('_header' === $value) {
|
if ($value === '_header') return 'activity type';
|
||||||
return 'activity type';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->translatableStringHelper
|
return $this->translatableStringHelper
|
||||||
->localize(json_decode($value, true));
|
->localize(json_decode($value, true));
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return static function ($value) use ($key) {
|
return function($value) use ($key) {
|
||||||
if ('_header' === $value) {
|
if ($value === '_header') return $key;
|
||||||
return $key;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
};
|
};
|
||||||
@@ -205,76 +209,68 @@ class ListActivity implements ListInterface
|
|||||||
return 'activity';
|
return 'activity';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
|
||||||
{
|
{
|
||||||
$centers = array_map(static function ($el) {
|
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
||||||
return $el['center'];
|
|
||||||
}, $acl);
|
|
||||||
|
|
||||||
// throw an error if any fields are present
|
// throw an error if any fields are present
|
||||||
if (!array_key_exists('fields', $data)) {
|
if (!\array_key_exists('fields', $data)) {
|
||||||
throw new \Doctrine\DBAL\Exception\InvalidArgumentException('any fields '
|
throw new \Doctrine\DBAL\Exception\InvalidArgumentException("any fields "
|
||||||
. 'have been checked');
|
. "have been checked");
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->from('ChillActivityBundle:Activity', 'activity')
|
->from('ChillActivityBundle:Activity', 'activity')
|
||||||
->join('activity.person', 'person')
|
->join('activity.person', 'person')
|
||||||
->join('person.center', 'center')
|
->join('person.center', 'center')
|
||||||
->andWhere('center IN (:authorized_centers)')
|
->andWhere('center IN (:authorized_centers)')
|
||||||
->setParameter('authorized_centers', $centers);
|
->setParameter('authorized_centers', $centers);
|
||||||
|
;
|
||||||
|
|
||||||
foreach ($this->fields as $f) {
|
foreach ($this->fields as $f) {
|
||||||
if (in_array($f, $data['fields'], true)) {
|
if (in_array($f, $data['fields'])) {
|
||||||
switch ($f) {
|
switch ($f) {
|
||||||
case 'id':
|
case 'id':
|
||||||
$qb->addSelect('activity.id AS id');
|
$qb->addSelect('activity.id AS id');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'person_firstname':
|
case 'person_firstname':
|
||||||
$qb->addSelect('person.firstName AS person_firstname');
|
$qb->addSelect('person.firstName AS person_firstname');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'person_lastname':
|
case 'person_lastname':
|
||||||
$qb->addSelect('person.lastName AS person_lastname');
|
$qb->addSelect('person.lastName AS person_lastname');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'person_id':
|
case 'person_id':
|
||||||
$qb->addSelect('person.id AS person_id');
|
$qb->addSelect('person.id AS person_id');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'user_username':
|
case 'user_username':
|
||||||
$qb->join('activity.user', 'user');
|
$qb->join('activity.user', 'user');
|
||||||
$qb->addSelect('user.username AS user_username');
|
$qb->addSelect('user.username AS user_username');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'circle_name':
|
case 'circle_name':
|
||||||
$qb->join('activity.scope', 'circle');
|
$qb->join('activity.scope', 'circle');
|
||||||
$qb->addSelect('circle.name AS circle_name');
|
$qb->addSelect('circle.name AS circle_name');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'type_name':
|
case 'type_name':
|
||||||
$qb->join('activity.type', 'type');
|
$qb->join('activity.type', 'type');
|
||||||
$qb->addSelect('type.name AS type_name');
|
$qb->addSelect('type.name AS type_name');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'list_reasons':
|
case 'list_reasons':
|
||||||
// this is a trick... The reasons is filled with the
|
// this is a trick... The reasons is filled with the
|
||||||
// activity id which will be used to load reasons
|
// activity id which will be used to load reasons
|
||||||
$qb->addSelect('activity.id AS list_reasons');
|
$qb->addSelect('activity.id AS list_reasons');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$qb->addSelect(sprintf('activity.%s as %s', $f, $f));
|
$qb->addSelect(sprintf('activity.%s as %s', $f, $f));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,6 +281,7 @@ class ListActivity implements ListInterface
|
|||||||
|
|
||||||
public function supportsModifiers()
|
public function supportsModifiers()
|
||||||
{
|
{
|
||||||
return ['activity', 'person'];
|
return array('activity', 'person');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,109 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2015 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Export;
|
namespace Chill\ActivityBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\ExportInterface;
|
use Chill\MainBundle\Export\ExportInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use LogicException;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This export allow to compute stats on activity duration.
|
* This export allow to compute stats on activity duration.
|
||||||
*
|
*
|
||||||
* The desired stat must be given in constructor.
|
* The desired stat must be given in constructor.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class StatActivityDuration implements ExportInterface
|
class StatActivityDuration implements ExportInterface
|
||||||
{
|
{
|
||||||
public const SUM = 'sum';
|
/**
|
||||||
|
*
|
||||||
|
* @var EntityManagerInterface
|
||||||
|
*/
|
||||||
|
protected $entityManager;
|
||||||
|
|
||||||
|
const SUM = 'sum';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The action for this report.
|
* The action for this report.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $action;
|
protected $action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var EntityManagerInterface
|
* constructor
|
||||||
*/
|
*
|
||||||
protected $entityManager;
|
* @param EntityManagerInterface $em
|
||||||
|
|
||||||
/**
|
|
||||||
* constructor.
|
|
||||||
*
|
|
||||||
* @param string $action the stat to perform
|
* @param string $action the stat to perform
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManagerInterface $em,
|
EntityManagerInterface $em,
|
||||||
$action = 'sum'
|
$action = 'sum'
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
$this->entityManager = $em;
|
$this->entityManager = $em;
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllowedFormattersTypes()
|
|
||||||
{
|
|
||||||
return [\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
if (self::SUM === $this->action) {
|
if ($this->action === self::SUM) {
|
||||||
return 'Sum activities duration by various parameters.';
|
return "Sum activities duration by various parameters.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
|
||||||
{
|
|
||||||
if ('export_stat_activity' !== $key) {
|
|
||||||
throw new LogicException("the key {$key} is not used by this export");
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($this->action) {
|
|
||||||
case self::SUM:
|
|
||||||
$header = 'Sum of activities duration';
|
|
||||||
}
|
|
||||||
|
|
||||||
return static function ($value) use ($header) {
|
|
||||||
return '_header' === $value ?
|
|
||||||
$header
|
|
||||||
:
|
|
||||||
$value;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getQueryKeys($data)
|
|
||||||
{
|
|
||||||
return ['export_stat_activity'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResult($qb, $data)
|
|
||||||
{
|
|
||||||
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
if (self::SUM === $this->action) {
|
if ($this->action === self::SUM) {
|
||||||
return 'Sum activity duration';
|
return "Sum activity duration";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
@@ -111,34 +91,69 @@ class StatActivityDuration implements ExportInterface
|
|||||||
return 'activity';
|
return 'activity';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
|
||||||
{
|
{
|
||||||
$centers = array_map(static function ($el) {
|
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
||||||
return $el['center'];
|
|
||||||
}, $acl);
|
|
||||||
$qb = $this->entityManager->createQueryBuilder();
|
$qb = $this->entityManager->createQueryBuilder();
|
||||||
|
|
||||||
if (self::SUM === $this->action) {
|
if ($this->action === self::SUM) {
|
||||||
$select = 'SUM(activity.durationTime) AS export_stat_activity';
|
$select = "SUM(activity.durationTime) AS export_stat_activity";
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->select($select)
|
$qb->select($select)
|
||||||
->from('ChillActivityBundle:Activity', 'activity')
|
->from('ChillActivityBundle:Activity', 'activity')
|
||||||
->join('activity.person', 'person')
|
->join('activity.person', 'person')
|
||||||
->join('person.center', 'center')
|
->join('person.center', 'center')
|
||||||
->where($qb->expr()->in('center', ':centers'))
|
->where($qb->expr()->in('center', ':centers'))
|
||||||
->setParameter(':centers', $centers);
|
->setParameter(':centers', $centers)
|
||||||
|
;
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supportsModifiers()
|
||||||
|
{
|
||||||
|
return array('person', 'activity');
|
||||||
|
}
|
||||||
|
|
||||||
public function requiredRole()
|
public function requiredRole()
|
||||||
{
|
{
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsModifiers()
|
public function getAllowedFormattersTypes()
|
||||||
{
|
{
|
||||||
return ['person', 'activity'];
|
return array(\Chill\MainBundle\Export\FormatterInterface::TYPE_TABULAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
if ($key !== 'export_stat_activity') {
|
||||||
|
throw new \LogicException("the key $key is not used by this export");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($this->action) {
|
||||||
|
case self::SUM:
|
||||||
|
$header = "Sum of activities duration";
|
||||||
|
}
|
||||||
|
|
||||||
|
return function($value) use ($header) {
|
||||||
|
return $value === '_header' ?
|
||||||
|
$header
|
||||||
|
:
|
||||||
|
$value
|
||||||
|
;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryKeys($data)
|
||||||
|
{
|
||||||
|
return array('export_stat_activity');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResult($qb, $data)
|
||||||
|
{
|
||||||
|
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,52 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Filter;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\Export\FilterType;
|
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\Query\Expr;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
|
||||||
use Symfony\Component\Form\FormError;
|
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
|
use Symfony\Component\Form\FormError;
|
||||||
|
use Chill\MainBundle\Form\Type\Export\FilterType;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class ActivityDateFilter implements FilterInterface
|
class ActivityDateFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator)
|
function __construct(TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -43,18 +55,15 @@ class ActivityDateFilter implements FilterInterface
|
|||||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->between(
|
$clause = $qb->expr()->between('activity.date', ':date_from',
|
||||||
'activity.date',
|
':date_to');
|
||||||
':date_from',
|
|
||||||
':date_to'
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
$where->add($clause);
|
$where->add($clause);
|
||||||
} else {
|
} else {
|
||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
$qb->setParameter('date_from', $data['date_from']);
|
$qb->setParameter('date_from', $data['date_from']);
|
||||||
$qb->setParameter('date_to', $data['date_to']);
|
$qb->setParameter('date_to', $data['date_to']);
|
||||||
@@ -67,58 +76,55 @@ class ActivityDateFilter implements FilterInterface
|
|||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('date_from', DateType::class, [
|
$builder->add('date_from', DateType::class, array(
|
||||||
'label' => 'Activities after this date',
|
'label' => "Activities after this date",
|
||||||
'data' => new DateTime(),
|
'data' => new \DateTime(),
|
||||||
'attr' => ['class' => 'datepicker'],
|
'attr' => array('class' => 'datepicker'),
|
||||||
'widget' => 'single_text',
|
'widget'=> 'single_text',
|
||||||
'format' => 'dd-MM-yyyy',
|
'format' => 'dd-MM-yyyy',
|
||||||
]);
|
));
|
||||||
|
|
||||||
$builder->add('date_to', DateType::class, [
|
$builder->add('date_to', DateType::class, array(
|
||||||
'label' => 'Activities before this date',
|
'label' => "Activities before this date",
|
||||||
'data' => new DateTime(),
|
'data' => new \DateTime(),
|
||||||
'attr' => ['class' => 'datepicker'],
|
'attr' => array('class' => 'datepicker'),
|
||||||
'widget' => 'single_text',
|
'widget'=> 'single_text',
|
||||||
'format' => 'dd-MM-yyyy',
|
'format' => 'dd-MM-yyyy',
|
||||||
]);
|
));
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
$builder->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
|
||||||
/** @var \Symfony\Component\Form\FormInterface $filterForm */
|
/* @var $filterForm \Symfony\Component\Form\FormInterface */
|
||||||
$filterForm = $event->getForm()->getParent();
|
$filterForm = $event->getForm()->getParent();
|
||||||
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
||||||
|
|
||||||
if (true === $enabled) {
|
if ($enabled === true) {
|
||||||
// if the filter is enabled, add some validation
|
// if the filter is enabled, add some validation
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
$date_from = $form->get('date_from')->getData();
|
$date_from = $form->get('date_from')->getData();
|
||||||
$date_to = $form->get('date_to')->getData();
|
$date_to = $form->get('date_to')->getData();
|
||||||
|
|
||||||
// check that fields are not empty
|
// check that fields are not empty
|
||||||
if (null === $date_from) {
|
if ($date_from === null) {
|
||||||
$form->get('date_from')->addError(new FormError(
|
$form->get('date_from')->addError(new FormError(
|
||||||
$this->translator->trans('This field '
|
$this->translator->trans('This field '
|
||||||
. 'should not be empty')
|
. 'should not be empty')));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
if ($date_to === null) {
|
||||||
if (null === $date_to) {
|
|
||||||
$form->get('date_to')->addError(new FormError(
|
$form->get('date_to')->addError(new FormError(
|
||||||
$this->translator->trans('This field '
|
$this->translator->trans('This field '
|
||||||
. 'should not be empty')
|
. 'should not be empty')));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check that date_from is before date_to
|
// check that date_from is before date_to
|
||||||
if (
|
if (
|
||||||
(null !== $date_from && null !== $date_to)
|
($date_from !== null && $date_to !== null)
|
||||||
&& $date_from >= $date_to
|
&&
|
||||||
|
$date_from >= $date_to
|
||||||
) {
|
) {
|
||||||
$form->get('date_to')->addError(new FormError(
|
$form->get('date_to')->addError(new FormError(
|
||||||
$this->translator->trans('This date should be after '
|
$this->translator->trans('This date should be after '
|
||||||
. 'the date given in "Implied in an activity after '
|
. 'the date given in "Implied in an activity after '
|
||||||
. 'this date" field')
|
. 'this date" field')));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -126,16 +132,17 @@ class ActivityDateFilter implements FilterInterface
|
|||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
public function describeAction($data, $format = 'string')
|
||||||
{
|
{
|
||||||
return [
|
return array(
|
||||||
'Filtered by date of activity: only between %date_from% and %date_to%',
|
"Filtered by date of activity: only between %date_from% and %date_to%",
|
||||||
[
|
array(
|
||||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
"%date_from%" => $data['date_from']->format('d-m-Y'),
|
||||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
'%date_to%' => $data['date_to']->format('d-m-Y')
|
||||||
], ];
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return 'Filtered by date activity';
|
return "Filtered by date activity";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,83 +1,88 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2016 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Filter;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\Query\Expr;
|
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
|
|
||||||
use function array_key_exists;
|
/**
|
||||||
use function count;
|
*
|
||||||
|
*
|
||||||
class ActivityReasonFilter implements
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
ExportElementValidatedInterface,
|
*/
|
||||||
FilterInterface
|
class ActivityReasonFilter implements FilterInterface,
|
||||||
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The repository for activity reasons.
|
*
|
||||||
|
* @var TranslatableStringHelper
|
||||||
|
*/
|
||||||
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The repository for activity reasons
|
||||||
*
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $reasonRepository;
|
protected $reasonRepository;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $translatableStringHelper;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $helper,
|
TranslatableStringHelper $helper,
|
||||||
EntityRepository $reasonRepository
|
EntityRepository $reasonRepository
|
||||||
) {
|
) {
|
||||||
$this->translatableStringHelper = $helper;
|
$this->translatableStringHelper = $helper;
|
||||||
$this->reasonRepository = $reasonRepository;
|
$this->reasonRepository = $reasonRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$join = $qb->getDQLPart('join');
|
$join = $qb->getDQLPart('join');
|
||||||
$clause = $qb->expr()->in('reasons', ':selected_activity_reasons');
|
$clause = $qb->expr()->in('reasons', ':selected_activity_reasons');
|
||||||
//dump($join);
|
//dump($join);
|
||||||
// add a join to reasons only if needed
|
// add a join to reasons only if needed
|
||||||
if (
|
if (
|
||||||
(
|
(array_key_exists('activity', $join)
|
||||||
array_key_exists('activity', $join)
|
&&
|
||||||
&& !$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
!$this->checkJoinAlreadyDefined($join['activity'], 'reasons')
|
||||||
)
|
)
|
||||||
|| (!array_key_exists('activity', $join))
|
OR
|
||||||
|
(! array_key_exists('activity', $join))
|
||||||
) {
|
) {
|
||||||
$qb->add(
|
$qb->add(
|
||||||
'join',
|
'join',
|
||||||
['activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')],
|
array('activity' => new Join(Join::INNER_JOIN, 'activity.reasons', 'reasons')),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($where instanceof Expr\Andx) {
|
if ($where instanceof Expr\Andx) {
|
||||||
@@ -85,10 +90,27 @@ class ActivityReasonFilter implements
|
|||||||
} else {
|
} else {
|
||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
$qb->setParameter('selected_activity_reasons', $data['reasons']);
|
$qb->setParameter('selected_activity_reasons', $data['reasons']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a join between Activity and Reason is already defined
|
||||||
|
*
|
||||||
|
* @param Join[] $joins
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function checkJoinAlreadyDefined(array $joins, $alias)
|
||||||
|
{
|
||||||
|
foreach ($joins as $join) {
|
||||||
|
if ($join->getAlias() === $alias) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
@@ -99,63 +121,49 @@ class ActivityReasonFilter implements
|
|||||||
{
|
{
|
||||||
//create a local copy of translatableStringHelper
|
//create a local copy of translatableStringHelper
|
||||||
$helper = $this->translatableStringHelper;
|
$helper = $this->translatableStringHelper;
|
||||||
|
|
||||||
$builder->add('reasons', EntityType::class, [
|
$builder->add('reasons', EntityType::class, array(
|
||||||
'class' => 'ChillActivityBundle:ActivityReason',
|
'class' => 'ChillActivityBundle:ActivityReason',
|
||||||
'choice_label' => static function (ActivityReason $reason) use ($helper) {
|
'choice_label' => function (ActivityReason $reason) use ($helper) {
|
||||||
return $helper->localize($reason->getName());
|
return $helper->localize($reason->getName());
|
||||||
},
|
},
|
||||||
'group_by' => static function (ActivityReason $reason) use ($helper) {
|
'group_by' => function(ActivityReason $reason) use ($helper) {
|
||||||
return $helper->localize($reason->getCategory()->getName());
|
return $helper->localize($reason->getCategory()->getName());
|
||||||
},
|
},
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
|
||||||
{
|
|
||||||
// collect all the reasons'name used in this filter in one array
|
|
||||||
$reasonsNames = array_map(
|
|
||||||
function (ActivityReason $r) {
|
|
||||||
return '"' . $this->translatableStringHelper->localize($r->getName()) . '"';
|
|
||||||
},
|
|
||||||
$this->reasonRepository->findBy(['id' => $data['reasons']->toArray()])
|
|
||||||
);
|
|
||||||
|
|
||||||
return ['Filtered by reasons: only %list%',
|
|
||||||
['%list%' => implode(', ', $reasonsNames)], ];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Filter by reason';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
if (null === $data['reasons'] || count($data['reasons']) === 0) {
|
if ($data['reasons'] === null || count($data['reasons']) === 0) {
|
||||||
$context->buildViolation('At least one reason must be choosen')
|
$context->buildViolation("At least one reason must be choosen")
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getTitle()
|
||||||
* Check if a join between Activity and Reason is already defined.
|
|
||||||
*
|
|
||||||
* @param Join[] $joins
|
|
||||||
* @param mixed $alias
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function checkJoinAlreadyDefined(array $joins, $alias)
|
|
||||||
{
|
{
|
||||||
foreach ($joins as $join) {
|
return 'Filter by reason';
|
||||||
if ($join->getAlias() === $alias) {
|
}
|
||||||
return true;
|
|
||||||
}
|
public function addRole()
|
||||||
}
|
{
|
||||||
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
// collect all the reasons'name used in this filter in one array
|
||||||
|
$reasonsNames = array_map(
|
||||||
|
function(ActivityReason $r) {
|
||||||
|
return "\"".$this->translatableStringHelper->localize($r->getName())."\"";
|
||||||
|
},
|
||||||
|
$this->reasonRepository->findBy(array('id' => $data['reasons']->toArray()))
|
||||||
|
);
|
||||||
|
|
||||||
|
return array("Filtered by reasons: only %list%",
|
||||||
|
["%list%" => implode(", ", $reasonsNames)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,63 +1,67 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Filter;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\Query\Expr;
|
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
|
||||||
use function count;
|
/**
|
||||||
|
*
|
||||||
class ActivityTypeFilter implements
|
*
|
||||||
ExportElementValidatedInterface,
|
*/
|
||||||
FilterInterface
|
class ActivityTypeFilter implements FilterInterface,
|
||||||
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The repository for activity reasons.
|
* The repository for activity reasons
|
||||||
*
|
*
|
||||||
* @var EntityRepository
|
* @var EntityRepository
|
||||||
*/
|
*/
|
||||||
protected $typeRepository;
|
protected $typeRepository;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $helper,
|
TranslatableStringHelper $helper,
|
||||||
EntityRepository $typeRepository
|
EntityRepository $typeRepository
|
||||||
) {
|
) {
|
||||||
$this->translatableStringHelper = $helper;
|
$this->translatableStringHelper = $helper;
|
||||||
$this->typeRepository = $typeRepository;
|
$this->typeRepository = $typeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRole()
|
|
||||||
{
|
|
||||||
return new Role(ActivityStatsVoter::STATS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
@@ -68,10 +72,27 @@ class ActivityTypeFilter implements
|
|||||||
} else {
|
} else {
|
||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
$qb->setParameter('selected_activity_types', $data['types']);
|
$qb->setParameter('selected_activity_types', $data['types']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a join between Activity and Reason is already defined
|
||||||
|
*
|
||||||
|
* @param Join[] $joins
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function checkJoinAlreadyDefined(array $joins, $alias)
|
||||||
|
{
|
||||||
|
foreach ($joins as $join) {
|
||||||
|
if ($join->getAlias() === $alias) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function applyOn()
|
public function applyOn()
|
||||||
{
|
{
|
||||||
@@ -82,60 +103,46 @@ class ActivityTypeFilter implements
|
|||||||
{
|
{
|
||||||
//create a local copy of translatableStringHelper
|
//create a local copy of translatableStringHelper
|
||||||
$helper = $this->translatableStringHelper;
|
$helper = $this->translatableStringHelper;
|
||||||
|
|
||||||
$builder->add('types', EntityType::class, [
|
$builder->add('types', EntityType::class, array(
|
||||||
'class' => ActivityType::class,
|
'class' => ActivityType::class,
|
||||||
'choice_label' => static function (ActivityType $type) use ($helper) {
|
'choice_label' => function (ActivityType $type) use ($helper) {
|
||||||
return $helper->localize($type->getName());
|
return $helper->localize($type->getName());
|
||||||
},
|
},
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
|
||||||
{
|
|
||||||
// collect all the reasons'name used in this filter in one array
|
|
||||||
$reasonsNames = array_map(
|
|
||||||
function (ActivityType $t) {
|
|
||||||
return '"' . $this->translatableStringHelper->localize($t->getName()) . '"';
|
|
||||||
},
|
|
||||||
$this->typeRepository->findBy(['id' => $data['types']->toArray()])
|
|
||||||
);
|
|
||||||
|
|
||||||
return ['Filtered by activity type: only %list%',
|
|
||||||
['%list%' => implode(', ', $reasonsNames)], ];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return 'Filter by activity type';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
{
|
{
|
||||||
if (null === $data['types'] || count($data['types']) === 0) {
|
if ($data['types'] === null || count($data['types']) === 0) {
|
||||||
$context->buildViolation('At least one type must be choosen')
|
$context->buildViolation("At least one type must be choosen")
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getTitle()
|
||||||
* Check if a join between Activity and Reason is already defined.
|
|
||||||
*
|
|
||||||
* @param Join[] $joins
|
|
||||||
* @param mixed $alias
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function checkJoinAlreadyDefined(array $joins, $alias)
|
|
||||||
{
|
{
|
||||||
foreach ($joins as $join) {
|
return 'Filter by activity type';
|
||||||
if ($join->getAlias() === $alias) {
|
}
|
||||||
return true;
|
|
||||||
}
|
public function addRole()
|
||||||
}
|
{
|
||||||
|
return new Role(ActivityStatsVoter::STATS);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
public function describeAction($data, $format = 'string')
|
||||||
|
{
|
||||||
|
// collect all the reasons'name used in this filter in one array
|
||||||
|
$reasonsNames = array_map(
|
||||||
|
function(ActivityType $t) {
|
||||||
|
return "\"".$this->translatableStringHelper->localize($t->getName())."\"";
|
||||||
|
},
|
||||||
|
$this->typeRepository->findBy(array('id' => $data['types']->toArray()))
|
||||||
|
);
|
||||||
|
|
||||||
|
return array("Filtered by activity type: only %list%",
|
||||||
|
["%list%" => implode(", ", $reasonsNames)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,66 +1,79 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Filter;
|
namespace Chill\ActivityBundle\Export\Filter;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\Export\FilterType;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Chill\PersonBundle\Export\Declarations;
|
|
||||||
use DateTime;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Doctrine\ORM\Query\Expr;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
|
||||||
use Symfony\Component\Form\FormError;
|
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
|
use Symfony\Component\Form\FormError;
|
||||||
|
use Chill\MainBundle\Form\Type\Export\FilterType;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
|
|
||||||
use function count;
|
/**
|
||||||
|
*
|
||||||
class PersonHavingActivityBetweenDateFilter implements
|
*
|
||||||
ExportElementValidatedInterface,
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
FilterInterface
|
*/
|
||||||
|
class PersonHavingActivityBetweenDateFilter implements FilterInterface,
|
||||||
|
ExportElementValidatedInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var EntityRepository
|
*
|
||||||
*/
|
|
||||||
protected $activityReasonRepository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var TranslatorInterface
|
*
|
||||||
|
* @var EntityRepository
|
||||||
|
*/
|
||||||
|
protected $activityReasonRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
EntityRepository $activityReasonRepository,
|
EntityRepository $activityReasonRepository,
|
||||||
TranslatorInterface $translator
|
TranslatorInterface $translator
|
||||||
) {
|
) {
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->activityReasonRepository = $activityReasonRepository;
|
$this->activityReasonRepository = $activityReasonRepository;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function addRole()
|
public function addRole()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -70,26 +83,24 @@ class PersonHavingActivityBetweenDateFilter implements
|
|||||||
{
|
{
|
||||||
// create a query for activity
|
// create a query for activity
|
||||||
$sqb = $qb->getEntityManager()->createQueryBuilder();
|
$sqb = $qb->getEntityManager()->createQueryBuilder();
|
||||||
$sqb->select('person_person_having_activity.id')
|
$sqb->select("person_person_having_activity.id")
|
||||||
->from('ChillActivityBundle:Activity', 'activity_person_having_activity')
|
->from("ChillActivityBundle:Activity", "activity_person_having_activity")
|
||||||
->join('activity_person_having_activity.person', 'person_person_having_activity');
|
->join("activity_person_having_activity.person", "person_person_having_activity")
|
||||||
|
;
|
||||||
// add clause between date
|
// add clause between date
|
||||||
$sqb->where('activity_person_having_activity.date BETWEEN '
|
$sqb->where("activity_person_having_activity.date BETWEEN "
|
||||||
. ':person_having_activity_between_date_from'
|
. ":person_having_activity_between_date_from"
|
||||||
. ' AND '
|
. " AND "
|
||||||
. ':person_having_activity_between_date_to');
|
. ":person_having_activity_between_date_to");
|
||||||
// add clause activity reason
|
// add clause activity reason
|
||||||
$sqb->join(
|
$sqb->join('activity_person_having_activity.reasons',
|
||||||
'activity_person_having_activity.reasons',
|
'reasons_person_having_activity');
|
||||||
'reasons_person_having_activity'
|
|
||||||
);
|
|
||||||
$sqb->andWhere(
|
$sqb->andWhere(
|
||||||
$sqb->expr()->in(
|
$sqb->expr()->in(
|
||||||
'reasons_person_having_activity',
|
'reasons_person_having_activity',
|
||||||
':person_having_activity_reasons'
|
":person_having_activity_reasons")
|
||||||
)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
$where = $qb->getDQLPart('where');
|
$where = $qb->getDQLPart('where');
|
||||||
$clause = $qb->expr()->in('person.id', $sqb->getDQL());
|
$clause = $qb->expr()->in('person.id', $sqb->getDQL());
|
||||||
|
|
||||||
@@ -98,16 +109,12 @@ class PersonHavingActivityBetweenDateFilter implements
|
|||||||
} else {
|
} else {
|
||||||
$where = $qb->expr()->andX($clause);
|
$where = $qb->expr()->andX($clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->add('where', $where);
|
$qb->add('where', $where);
|
||||||
$qb->setParameter(
|
$qb->setParameter('person_having_activity_between_date_from',
|
||||||
'person_having_activity_between_date_from',
|
$data['date_from']);
|
||||||
$data['date_from']
|
$qb->setParameter('person_having_activity_between_date_to',
|
||||||
);
|
$data['date_to']);
|
||||||
$qb->setParameter(
|
|
||||||
'person_having_activity_between_date_to',
|
|
||||||
$data['date_to']
|
|
||||||
);
|
|
||||||
$qb->setParameter('person_having_activity_reasons', $data['reasons']);
|
$qb->setParameter('person_having_activity_reasons', $data['reasons']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,107 +125,104 @@ class PersonHavingActivityBetweenDateFilter implements
|
|||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('date_from', DateType::class, [
|
$builder->add('date_from', DateType::class, array(
|
||||||
'label' => 'Implied in an activity after this date',
|
'label' => "Implied in an activity after this date",
|
||||||
'data' => new DateTime(),
|
'data' => new \DateTime(),
|
||||||
'attr' => ['class' => 'datepicker'],
|
'attr' => array('class' => 'datepicker'),
|
||||||
'widget' => 'single_text',
|
'widget'=> 'single_text',
|
||||||
'format' => 'dd-MM-yyyy',
|
'format' => 'dd-MM-yyyy',
|
||||||
]);
|
));
|
||||||
|
|
||||||
$builder->add('date_to', DateType::class, [
|
$builder->add('date_to', DateType::class, array(
|
||||||
'label' => 'Implied in an activity before this date',
|
'label' => "Implied in an activity before this date",
|
||||||
'data' => new DateTime(),
|
'data' => new \DateTime(),
|
||||||
'attr' => ['class' => 'datepicker'],
|
'attr' => array('class' => 'datepicker'),
|
||||||
'widget' => 'single_text',
|
'widget'=> 'single_text',
|
||||||
'format' => 'dd-MM-yyyy',
|
'format' => 'dd-MM-yyyy',
|
||||||
]);
|
));
|
||||||
|
|
||||||
$builder->add('reasons', EntityType::class, [
|
$builder->add('reasons', EntityType::class, array(
|
||||||
'class' => 'ChillActivityBundle:ActivityReason',
|
'class' => 'ChillActivityBundle:ActivityReason',
|
||||||
'choice_label' => function (ActivityReason $reason) {
|
'choice_label' => function (ActivityReason $reason) {
|
||||||
return $this->translatableStringHelper
|
return $this->translatableStringHelper
|
||||||
->localize($reason->getName());
|
->localize($reason->getName());
|
||||||
},
|
},
|
||||||
'group_by' => function (ActivityReason $reason) {
|
'group_by' => function(ActivityReason $reason) {
|
||||||
return $this->translatableStringHelper
|
return $this->translatableStringHelper
|
||||||
->localize($reason->getCategory()->getName());
|
->localize($reason->getCategory()->getName());
|
||||||
},
|
},
|
||||||
'data' => $this->activityReasonRepository->findAll(),
|
'data' => $this->activityReasonRepository->findAll(),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
'label' => 'Activity reasons for those activities',
|
'label' => "Activity reasons for those activities"
|
||||||
]);
|
));
|
||||||
|
|
||||||
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
|
$builder->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
|
||||||
/** @var \Symfony\Component\Form\FormInterface $filterForm */
|
/* @var $filterForm \Symfony\Component\Form\FormInterface */
|
||||||
$filterForm = $event->getForm()->getParent();
|
$filterForm = $event->getForm()->getParent();
|
||||||
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
$enabled = $filterForm->get(FilterType::ENABLED_FIELD)->getData();
|
||||||
|
|
||||||
if (true === $enabled) {
|
if ($enabled === true) {
|
||||||
// if the filter is enabled, add some validation
|
// if the filter is enabled, add some validation
|
||||||
$form = $event->getForm();
|
$form = $event->getForm();
|
||||||
$date_from = $form->get('date_from')->getData();
|
$date_from = $form->get('date_from')->getData();
|
||||||
$date_to = $form->get('date_to')->getData();
|
$date_to = $form->get('date_to')->getData();
|
||||||
|
|
||||||
// check that fields are not empty
|
// check that fields are not empty
|
||||||
if (null === $date_from) {
|
if ($date_from === null) {
|
||||||
$form->get('date_from')->addError(new FormError(
|
$form->get('date_from')->addError(new FormError(
|
||||||
$this->translator->trans('This field '
|
$this->translator->trans('This field '
|
||||||
. 'should not be empty')
|
. 'should not be empty')));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
if ($date_to === null) {
|
||||||
if (null === $date_to) {
|
|
||||||
$form->get('date_to')->addError(new FormError(
|
$form->get('date_to')->addError(new FormError(
|
||||||
$this->translator->trans('This field '
|
$this->translator->trans('This field '
|
||||||
. 'should not be empty')
|
. 'should not be empty')));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check that date_from is before date_to
|
// check that date_from is before date_to
|
||||||
if (
|
if (
|
||||||
(null !== $date_from && null !== $date_to)
|
($date_from !== null && $date_to !== null)
|
||||||
&& $date_from >= $date_to
|
&&
|
||||||
|
$date_from >= $date_to
|
||||||
) {
|
) {
|
||||||
$form->get('date_to')->addError(new FormError(
|
$form->get('date_to')->addError(new FormError(
|
||||||
$this->translator->trans('This date '
|
$this->translator->trans('This date '
|
||||||
. 'should be after the date given in "Implied in an '
|
. 'should be after the date given in "Implied in an '
|
||||||
. 'activity after this date" field')
|
. 'activity after this date" field')));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validateForm($data, ExecutionContextInterface $context)
|
||||||
|
{
|
||||||
|
if ($data['reasons'] === null || count($data['reasons']) === 0) {
|
||||||
|
$context->buildViolation("At least one reason must be choosen")
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function describeAction($data, $format = 'string')
|
public function describeAction($data, $format = 'string')
|
||||||
{
|
{
|
||||||
return [
|
return array(
|
||||||
'Filtered by person having an activity between %date_from% and '
|
"Filtered by person having an activity between %date_from% and "
|
||||||
. '%date_to% with reasons %reasons_name%',
|
. "%date_to% with reasons %reasons_name%",
|
||||||
[
|
array(
|
||||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
"%date_from%" => $data['date_from']->format('d-m-Y'),
|
||||||
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
'%date_to%' => $data['date_to']->format('d-m-Y'),
|
||||||
'%reasons_name%' => implode(', ', array_map(
|
"%reasons_name%" => implode(", ", array_map(
|
||||||
function (ActivityReason $r) {
|
function (ActivityReason $r) {
|
||||||
return '"' . $this->translatableStringHelper->
|
return '"'.$this->translatableStringHelper->
|
||||||
localize($r->getName()) . '"';
|
localize($r->getName()).'"';
|
||||||
},
|
},
|
||||||
$data['reasons']
|
$data['reasons']))
|
||||||
)),
|
));
|
||||||
], ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return 'Filtered by person having an activity in a period';
|
return "Filtered by person having an activity in a period";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
|
||||||
{
|
|
||||||
if (null === $data['reasons'] || count($data['reasons']) === 0) {
|
|
||||||
$context->buildViolation('At least one reason must be choosen')
|
|
||||||
->addViolation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/Bundle/ChillActivityBundle/Form/ActivityPresenceType.php
Normal file
33
src/Bundle/ChillActivityBundle/Form/ActivityPresenceType.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityPresence;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
|
||||||
|
class ActivityPresenceType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('name', TranslatableStringFormType::class)
|
||||||
|
->add('active', ChoiceType::class, array(
|
||||||
|
'choices' => array(
|
||||||
|
'Yes' => true,
|
||||||
|
'No' => false
|
||||||
|
),
|
||||||
|
'expanded' => true
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'data_class' => ActivityPresence::class
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,31 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
|
||||||
class ActivityReasonCategoryType extends AbstractType
|
class ActivityReasonCategoryType extends AbstractType
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param FormBuilderInterface $builder
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('name', TranslatableStringFormType::class)
|
->add('name', TranslatableStringFormType::class)
|
||||||
->add('active', CheckboxType::class, ['required' => false]);
|
->add('active', CheckboxType::class, array('required' => false))
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,9 +27,9 @@ class ActivityReasonCategoryType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Chill\ActivityBundle\Entity\ActivityReasonCategory',
|
'data_class' => 'Chill\ActivityBundle\Entity\ActivityReasonCategory'
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,40 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;
|
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
use Chill\ActivityBundle\Form\Type\TranslatableActivityReasonCategory;
|
||||||
|
|
||||||
class ActivityReasonType extends AbstractType
|
class ActivityReasonType extends AbstractType
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param FormBuilderInterface $builder
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('name', TranslatableStringFormType::class)
|
->add('name', TranslatableStringFormType::class)
|
||||||
->add('active', CheckboxType::class, ['required' => false])
|
->add('active', CheckboxType::class, array('required' => false))
|
||||||
->add('category', TranslatableActivityReasonCategory::class);
|
->add('category', TranslatableActivityReasonCategory::class)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param OptionsResolver $resolver
|
||||||
|
*/
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Chill\ActivityBundle\Entity\ActivityReason',
|
'data_class' => 'Chill\ActivityBundle\Entity\ActivityReason'
|
||||||
]);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,87 +1,81 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
|
use Chill\ActivityBundle\Entity\ActivityPresence;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||||
|
use Chill\MainBundle\Form\Type\ChillCollectionType;
|
||||||
use Chill\MainBundle\Form\Type\CommentType;
|
use Chill\MainBundle\Form\Type\CommentType;
|
||||||
use Chill\MainBundle\Form\Type\ScopePickerType;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Form\Type\UserPickerType;
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
use DateInterval;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use DateTime;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use DateTimeZone;
|
|
||||||
use Doctrine\Persistence\ObjectManager;
|
|
||||||
use RuntimeException;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||||
use Symfony\Component\Form\FormEvent;
|
use Symfony\Component\Form\FormEvent;
|
||||||
use Symfony\Component\Form\FormEvents;
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||||
|
use Chill\MainBundle\Form\Type\ScopePickerType;
|
||||||
use function in_array;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
|
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
|
||||||
|
use Chill\PersonBundle\Templating\Entity\SocialIssueRender;
|
||||||
|
use Chill\PersonBundle\Templating\Entity\SocialActionRender;
|
||||||
|
|
||||||
class ActivityType extends AbstractType
|
class ActivityType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
protected User $user;
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $authorizationHelper;
|
|
||||||
|
|
||||||
/**
|
protected AuthorizationHelper $authorizationHelper;
|
||||||
* @var ObjectManager
|
|
||||||
*/
|
|
||||||
protected $om;
|
|
||||||
|
|
||||||
protected $timeChoices;
|
protected ObjectManager $om;
|
||||||
|
|
||||||
/**
|
protected TranslatableStringHelper $translatableStringHelper;
|
||||||
* @var TranslatableStringHelper
|
|
||||||
*/
|
|
||||||
protected $translatableStringHelper;
|
|
||||||
|
|
||||||
/**
|
protected SocialIssueRender $socialIssueRender;
|
||||||
* the user running this form.
|
|
||||||
*
|
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
protected $user;
|
|
||||||
|
|
||||||
public function __construct(
|
protected SocialActionRender $socialActionRender;
|
||||||
|
|
||||||
|
protected array $timeChoices;
|
||||||
|
|
||||||
|
public function __construct (
|
||||||
TokenStorageInterface $tokenStorage,
|
TokenStorageInterface $tokenStorage,
|
||||||
AuthorizationHelper $authorizationHelper,
|
AuthorizationHelper $authorizationHelper,
|
||||||
ObjectManager $om,
|
ObjectManager $om,
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
array $timeChoices
|
array $timeChoices,
|
||||||
|
SocialIssueRender $socialIssueRender,
|
||||||
|
SocialActionRender $socialActionRender
|
||||||
) {
|
) {
|
||||||
if (!$tokenStorage->getToken()->getUser() instanceof User) {
|
if (!$tokenStorage->getToken()->getUser() instanceof User) {
|
||||||
throw new RuntimeException('you should have a valid user');
|
throw new \RuntimeException("you should have a valid user");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
$this->om = $om;
|
$this->om = $om;
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->timeChoices = $timeChoices;
|
$this->timeChoices = $timeChoices;
|
||||||
|
$this->socialIssueRender = $socialIssueRender;
|
||||||
|
$this->socialActionRender = $socialActionRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
// handle times choices
|
// handle times choices
|
||||||
$timeChoices = [];
|
$timeChoices = [];
|
||||||
@@ -96,104 +90,301 @@ class ActivityType extends AbstractType
|
|||||||
'placeholder' => 'Choose the duration',
|
'placeholder' => 'Choose the duration',
|
||||||
];
|
];
|
||||||
|
|
||||||
$builder
|
/** @var \Chill\ActivityBundle\Entity\ActivityType $activityType */
|
||||||
->add('date', ChillDateType::class, [
|
$activityType = $options['activityType'];
|
||||||
'required' => true,
|
|
||||||
])
|
if (!$activityType->isActive()) {
|
||||||
->add('durationTime', ChoiceType::class, $durationTimeOptions)
|
throw new \InvalidArgumentException('Activity type must be active');
|
||||||
->add('attendee', ChoiceType::class, [
|
}
|
||||||
'expanded' => true,
|
|
||||||
'required' => false,
|
// TODO revoir la gestion des center au niveau du form des activité.
|
||||||
'choices' => [
|
if ($options['center']) {
|
||||||
'present' => true,
|
$builder->add('scope', ScopePickerType::class, [
|
||||||
'not present' => false,
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->add('user', UserPickerType::class, [
|
|
||||||
'center' => $options['center'],
|
'center' => $options['center'],
|
||||||
'role' => $options['role'],
|
'role' => $options['role']
|
||||||
])
|
|
||||||
->add('scope', ScopePickerType::class, [
|
|
||||||
'center' => $options['center'],
|
|
||||||
'role' => $options['role'],
|
|
||||||
])
|
|
||||||
->add('reasons', TranslatableActivityReason::class, [
|
|
||||||
'multiple' => true,
|
|
||||||
'required' => false,
|
|
||||||
])
|
|
||||||
->add('type', TranslatableActivityType::class, [
|
|
||||||
'placeholder' => 'Choose a type',
|
|
||||||
'active_only' => true,
|
|
||||||
])
|
|
||||||
->add('comment', CommentType::class, [
|
|
||||||
'required' => false,
|
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$builder->get('durationTime')
|
/** @var ? \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod */
|
||||||
->addModelTransformer($durationTimeTransformer);
|
$accompanyingPeriod = NULL;
|
||||||
|
if ($options['accompanyingPeriod']) {
|
||||||
|
$accompanyingPeriod = $options['accompanyingPeriod'];
|
||||||
|
}
|
||||||
|
|
||||||
$builder->get('durationTime')
|
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
||||||
->addEventListener(
|
$builder->add('socialIssues', HiddenType::class);
|
||||||
FormEvents::PRE_SET_DATA,
|
$builder->get('socialIssues')
|
||||||
static function (FormEvent $formEvent) use (
|
->addModelTransformer(new CallbackTransformer(
|
||||||
|
function (iterable $socialIssuesAsIterable): string {
|
||||||
|
$socialIssueIds = [];
|
||||||
|
foreach ($socialIssuesAsIterable as $value) {
|
||||||
|
$socialIssueIds[] = $value->getId();
|
||||||
|
}
|
||||||
|
return implode(',', $socialIssueIds);
|
||||||
|
},
|
||||||
|
function (?string $socialIssuesAsString): array {
|
||||||
|
if (null === $socialIssuesAsString) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return array_map(
|
||||||
|
fn(string $id): ?SocialIssue => $this->om->getRepository(SocialIssue::class)->findOneBy(['id' => (int) $id]),
|
||||||
|
explode(',', $socialIssuesAsString)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
|
||||||
|
$builder->add('socialActions', HiddenType::class);
|
||||||
|
$builder->get('socialActions')
|
||||||
|
->addModelTransformer(new CallbackTransformer(
|
||||||
|
function (iterable $socialActionsAsIterable): string {
|
||||||
|
$socialActionIds = [];
|
||||||
|
foreach ($socialActionsAsIterable as $value) {
|
||||||
|
$socialActionIds[] = $value->getId();
|
||||||
|
}
|
||||||
|
return implode(',', $socialActionIds);
|
||||||
|
},
|
||||||
|
function (?string $socialActionsAsString): array {
|
||||||
|
if (null === $socialActionsAsString) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return array_map(
|
||||||
|
fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]),
|
||||||
|
explode(',', $socialActionsAsString)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('date')) {
|
||||||
|
$builder->add('date', ChillDateType::class, [
|
||||||
|
'label' => $activityType->getLabel('date'),
|
||||||
|
'required' => $activityType->isRequired('date'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('durationTime')) {
|
||||||
|
$durationTimeOptions['label'] = $activityType->getLabel('durationTime');
|
||||||
|
$durationTimeOptions['required'] = $activityType->isRequired('durationTime');
|
||||||
|
|
||||||
|
$builder->add('durationTime', ChoiceType::class, $durationTimeOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('travelTime')) {
|
||||||
|
$durationTimeOptions['label'] = $activityType->getLabel('travelTime');
|
||||||
|
$durationTimeOptions['required'] = $activityType->isRequired('travelTime');
|
||||||
|
|
||||||
|
$builder->add('travelTime', ChoiceType::class, $durationTimeOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('attendee')) {
|
||||||
|
$builder->add('attendee', EntityType::class, [
|
||||||
|
'label' => $activityType->getLabel('attendee'),
|
||||||
|
'required' => $activityType->isRequired('attendee'),
|
||||||
|
'expanded' => true,
|
||||||
|
'class' => ActivityPresence::class,
|
||||||
|
'choice_label' => function (ActivityPresence $activityPresence) {
|
||||||
|
return $this->translatableStringHelper->localize($activityPresence->getName());
|
||||||
|
},
|
||||||
|
'query_builder' => function (EntityRepository $er) {
|
||||||
|
return $er->createQueryBuilder('a')
|
||||||
|
->where('a.active = true');
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('user') && $options['center']) {
|
||||||
|
$builder->add('user', UserPickerType::class, [
|
||||||
|
'label' => $activityType->getLabel('user'),
|
||||||
|
'required' => $activityType->isRequired('user'),
|
||||||
|
'center' => $options['center'],
|
||||||
|
'role' => $options['role']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('reasons')) {
|
||||||
|
$builder->add('reasons', EntityType::class, [
|
||||||
|
'label' => $activityType->getLabel('reasons'),
|
||||||
|
'required' => $activityType->isRequired('reasons'),
|
||||||
|
'class' => ActivityReason::class,
|
||||||
|
'multiple' => true,
|
||||||
|
'choice_label' => function (ActivityReason $activityReason) {
|
||||||
|
return $this->translatableStringHelper->localize($activityReason->getName());
|
||||||
|
},
|
||||||
|
'attr' => array('class' => 'select2 '),
|
||||||
|
'query_builder' => function (EntityRepository $er) {
|
||||||
|
return $er->createQueryBuilder('a')
|
||||||
|
->where('a.active = true');
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('comment')) {
|
||||||
|
$builder->add('comment', CommentType::class, [
|
||||||
|
'label' => empty($activityType->getLabel('comment'))
|
||||||
|
? 'activity.comment' : $activityType->getLabel('comment'),
|
||||||
|
'required' => $activityType->isRequired('comment'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('persons')) {
|
||||||
|
$builder->add('persons', HiddenType::class);
|
||||||
|
$builder->get('persons')
|
||||||
|
->addModelTransformer(new CallbackTransformer(
|
||||||
|
function (iterable $personsAsIterable): string {
|
||||||
|
$personIds = [];
|
||||||
|
foreach ($personsAsIterable as $value) {
|
||||||
|
$personIds[] = $value->getId();
|
||||||
|
}
|
||||||
|
return implode(',', $personIds);
|
||||||
|
},
|
||||||
|
function (?string $personsAsString): array {
|
||||||
|
return array_map(
|
||||||
|
fn(string $id): ?Person => $this->om->getRepository(Person::class)->findOneBy(['id' => (int) $id]),
|
||||||
|
explode(',', $personsAsString)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('thirdParties')) {
|
||||||
|
$builder->add('thirdParties', HiddenType::class);
|
||||||
|
$builder->get('thirdParties')
|
||||||
|
->addModelTransformer(new CallbackTransformer(
|
||||||
|
function (iterable $thirdpartyAsIterable): string {
|
||||||
|
$thirdpartyIds = [];
|
||||||
|
foreach ($thirdpartyAsIterable as $value) {
|
||||||
|
$thirdpartyIds[] = $value->getId();
|
||||||
|
}
|
||||||
|
return implode(',', $thirdpartyIds);
|
||||||
|
},
|
||||||
|
function (?string $thirdpartyAsString): array {
|
||||||
|
return array_map(
|
||||||
|
fn(string $id): ?ThirdParty => $this->om->getRepository(ThirdParty::class)->findOneBy(['id' => (int) $id]),
|
||||||
|
explode(',', $thirdpartyAsString)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('documents')) {
|
||||||
|
$builder->add('documents', ChillCollectionType::class, [
|
||||||
|
'entry_type' => StoredObjectType::class,
|
||||||
|
'label' => $activityType->getLabel('documents'),
|
||||||
|
'required' => $activityType->isRequired('documents'),
|
||||||
|
'allow_add' => true,
|
||||||
|
'button_add_label' => 'activity.Insert a document',
|
||||||
|
'button_remove_label' => 'activity.Remove a document'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('users')) {
|
||||||
|
$builder->add('users', HiddenType::class);
|
||||||
|
$builder->get('users')
|
||||||
|
->addModelTransformer(new CallbackTransformer(
|
||||||
|
function (iterable $usersAsIterable): string {
|
||||||
|
$userIds = [];
|
||||||
|
foreach ($usersAsIterable as $value) {
|
||||||
|
$userIds[] = $value->getId();
|
||||||
|
}
|
||||||
|
return implode(',', $userIds);
|
||||||
|
},
|
||||||
|
function (?string $usersAsString): array {
|
||||||
|
return array_map(
|
||||||
|
fn(string $id): ?User => $this->om->getRepository(User::class)->findOneBy(['id' => (int) $id]),
|
||||||
|
explode(',', $usersAsString)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('emergency')) {
|
||||||
|
$builder->add('emergency', CheckboxType::class, [
|
||||||
|
'label' => $activityType->getLabel('emergency'),
|
||||||
|
'required' => $activityType->isRequired('emergency'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($activityType->isVisible('sentReceived')) {
|
||||||
|
$builder->add('sentReceived', ChoiceType::class, [
|
||||||
|
'label' => $activityType->getLabel('sentReceived'),
|
||||||
|
'required' => $activityType->isRequired('sentReceived'),
|
||||||
|
'choices' => [
|
||||||
|
'Sent' => Activity::SENTRECEIVED_SENT,
|
||||||
|
'Received' => Activity::SENTRECEIVED_RECEIVED,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (['durationTime', 'travelTime'] as $fieldName) {
|
||||||
|
if (!$activityType->isVisible($fieldName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->get($fieldName)
|
||||||
|
->addModelTransformer($durationTimeTransformer);
|
||||||
|
|
||||||
|
$builder->get($fieldName)
|
||||||
|
->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $formEvent) use (
|
||||||
$timeChoices,
|
$timeChoices,
|
||||||
$builder,
|
$builder,
|
||||||
$durationTimeTransformer,
|
$durationTimeTransformer,
|
||||||
$durationTimeOptions
|
$durationTimeOptions,
|
||||||
|
$fieldName
|
||||||
) {
|
) {
|
||||||
// set the timezone to GMT, and fix the difference between current and GMT
|
// set the timezone to GMT, and fix the difference between current and GMT
|
||||||
// the datetimetransformer will then handle timezone as GMT
|
// the datetimetransformer will then handle timezone as GMT
|
||||||
$timezoneUTC = new DateTimeZone('GMT');
|
$timezoneUTC = new \DateTimeZone('GMT');
|
||||||
/** @var DateTime $data */
|
/* @var $data \DateTime */
|
||||||
$data = $formEvent->getData() === null ?
|
$data = $formEvent->getData() === NULL ?
|
||||||
DateTime::createFromFormat('U', 300) :
|
\DateTime::createFromFormat('U', 300) :
|
||||||
$formEvent->getData();
|
$formEvent->getData();
|
||||||
$seconds = $data->getTimezone()->getOffset($data);
|
$seconds = $data->getTimezone()->getOffset($data);
|
||||||
$data->setTimeZone($timezoneUTC);
|
$data->setTimeZone($timezoneUTC);
|
||||||
$data->add(new DateInterval('PT' . $seconds . 'S'));
|
$data->add(new \DateInterval('PT'.$seconds.'S'));
|
||||||
|
|
||||||
// test if the timestamp is in the choices.
|
// test if the timestamp is in the choices.
|
||||||
// If not, recreate the field with the new timestamp
|
// If not, recreate the field with the new timestamp
|
||||||
if (!in_array($data->getTimestamp(), $timeChoices, true)) {
|
if (!in_array($data->getTimestamp(), $timeChoices)) {
|
||||||
// the data are not in the possible values. add them
|
// the data are not in the possible values. add them
|
||||||
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
$timeChoices[$data->format('H:i')] = $data->getTimestamp();
|
||||||
$form = $builder->create(
|
$form = $builder->create($fieldName, ChoiceType::class, array_merge(
|
||||||
'durationTime',
|
$durationTimeOptions, [
|
||||||
ChoiceType::class,
|
'choices' => $timeChoices,
|
||||||
array_merge(
|
'auto_initialize' => false
|
||||||
$durationTimeOptions,
|
]
|
||||||
[
|
));
|
||||||
'choices' => $timeChoices,
|
|
||||||
'auto_initialize' => false,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$form->addModelTransformer($durationTimeTransformer);
|
$form->addModelTransformer($durationTimeTransformer);
|
||||||
$formEvent->getForm()->getParent()->add($form->getForm());
|
$formEvent->getForm()->getParent()->add($form->getForm());
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param OptionsResolverInterface $resolver
|
|
||||||
*/
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => 'Chill\ActivityBundle\Entity\Activity',
|
'data_class' => Activity::class
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$resolver
|
$resolver
|
||||||
->setRequired(['center', 'role'])
|
->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod'])
|
||||||
->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center')
|
->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center'])
|
||||||
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role');
|
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
|
||||||
|
->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
|
||||||
|
->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null'])
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getBlockPrefix(): string
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBlockPrefix()
|
|
||||||
{
|
{
|
||||||
return 'chill_activitybundle_activity';
|
return 'chill_activitybundle_activity';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
|
||||||
|
class ActivityTypeCategoryType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->add('name', TranslatableStringFormType::class)
|
||||||
|
->add('active', ChoiceType::class, array(
|
||||||
|
'choices' => array(
|
||||||
|
'Yes' => true,
|
||||||
|
'No' => false
|
||||||
|
),
|
||||||
|
'expanded' => true
|
||||||
|
))
|
||||||
|
->add('ordering', NumberType::class, [
|
||||||
|
'required' => true,
|
||||||
|
'scale' => 5
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(array(
|
||||||
|
'data_class' => ActivityTypeCategory::class
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form;
|
namespace Chill\ActivityBundle\Form;
|
||||||
|
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
|
||||||
|
use Chill\ActivityBundle\Form\Type\ActivityFieldPresence;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
|
|
||||||
class ActivityTypeType extends AbstractType
|
class ActivityTypeType extends AbstractType
|
||||||
{
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
@@ -28,27 +30,42 @@ class ActivityTypeType extends AbstractType
|
|||||||
->add('active', ChoiceType::class, [
|
->add('active', ChoiceType::class, [
|
||||||
'choices' => [
|
'choices' => [
|
||||||
'Yes' => true,
|
'Yes' => true,
|
||||||
'No' => false,
|
'No' => false
|
||||||
],
|
],
|
||||||
'expanded' => true,
|
'expanded' => true
|
||||||
]);
|
])
|
||||||
|
->add('category', EntityType::class, [
|
||||||
|
'class' => ActivityTypeCategory::class,
|
||||||
|
'choice_label' => function (ActivityTypeCategory $activityTypeCategory) {
|
||||||
|
return $this->translatableStringHelper->localize($activityTypeCategory->getName());
|
||||||
|
},
|
||||||
|
])
|
||||||
|
->add('ordering', NumberType::class, [
|
||||||
|
'required' => true,
|
||||||
|
'scale' => 5
|
||||||
|
])
|
||||||
|
;
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'persons', 'user', 'date', 'place', 'persons',
|
||||||
|
'thirdParties', 'durationTime', 'travelTime', 'attendee',
|
||||||
|
'reasons', 'comment', 'sentReceived', 'documents',
|
||||||
|
'emergency', 'accompanyingPeriod', 'socialData', 'users'
|
||||||
|
];
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$builder
|
||||||
|
->add($field.'Visible', ActivityFieldPresence::class)
|
||||||
|
->add($field.'Label', TextType::class, [
|
||||||
|
'required' => false,
|
||||||
|
'empty_data' => '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param OptionsResolverInterface $resolver
|
|
||||||
*/
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults(array(
|
||||||
'data_class' => 'Chill\ActivityBundle\Entity\ActivityType',
|
'data_class' => \Chill\ActivityBundle\Entity\ActivityType::class
|
||||||
]);
|
));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getBlockPrefix()
|
|
||||||
{
|
|
||||||
return 'chill_activitybundle_activitytype';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class ActivityFieldPresence extends AbstractType
|
||||||
|
{
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return ChoiceType::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(
|
||||||
|
array(
|
||||||
|
'choices' => [
|
||||||
|
'Invisible' => ActivityType::FIELD_INVISIBLE,
|
||||||
|
'Optional' => ActivityType::FIELD_OPTIONAL,
|
||||||
|
'Required' => ActivityType::FIELD_REQUIRED,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,40 +1,53 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2020, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form\Type;
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
|
||||||
use Chill\ActivityBundle\Templating\Entity\ActivityReasonRender;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Chill\ActivityBundle\Templating\Entity\ActivityReasonRender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FormType to choose amongst activity reasons.
|
* FormType to choose amongst activity reasons
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class TranslatableActivityReason extends AbstractType
|
class TranslatableActivityReason extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var ActivityReasonRender
|
|
||||||
*/
|
|
||||||
protected $reasonRender;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var ActivityReasonRender
|
||||||
|
*/
|
||||||
|
protected $reasonRender;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $translatableStringHelper,
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
@@ -44,30 +57,6 @@ class TranslatableActivityReason extends AbstractType
|
|||||||
$this->reasonRender = $reasonRender;
|
$this->reasonRender = $reasonRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$resolver->setDefaults(
|
|
||||||
[
|
|
||||||
'class' => 'ChillActivityBundle:ActivityReason',
|
|
||||||
'choice_label' => function (ActivityReason $choice) {
|
|
||||||
return $this->reasonRender->renderString($choice, []);
|
|
||||||
},
|
|
||||||
'group_by' => function (ActivityReason $choice): ?string {
|
|
||||||
if (null !== $category = $choice->getCategory()) {
|
|
||||||
return $this->translatableStringHelper->localize($category->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
'query_builder' => static function (EntityRepository $er) {
|
|
||||||
return $er->createQueryBuilder('r')
|
|
||||||
->where('r.active = true');
|
|
||||||
},
|
|
||||||
'attr' => ['class' => ' select2 '],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'translatable_activity_reason';
|
return 'translatable_activity_reason';
|
||||||
@@ -77,4 +66,28 @@ class TranslatableActivityReason extends AbstractType
|
|||||||
{
|
{
|
||||||
return EntityType::class;
|
return EntityType::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults(
|
||||||
|
array(
|
||||||
|
'class' => 'ChillActivityBundle:ActivityReason',
|
||||||
|
'choice_label' => function(ActivityReason $choice) {
|
||||||
|
return $this->reasonRender->renderString($choice, []);
|
||||||
|
},
|
||||||
|
'group_by' => function(ActivityReason $choice): ?string {
|
||||||
|
if (null !== $category = $choice->getCategory()) {
|
||||||
|
return $this->translatableStringHelper->localize($category->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
'query_builder' => function (EntityRepository $er) {
|
||||||
|
return $er->createQueryBuilder('r')
|
||||||
|
->where('r.active = true');
|
||||||
|
},
|
||||||
|
'attr' => [ 'class' => ' select2 ']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form\Type;
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of TranslatableActivityReasonCategory.
|
* Description of TranslatableActivityReasonCategory
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class TranslatableActivityReasonCategory extends AbstractType
|
class TranslatableActivityReasonCategory extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -34,21 +47,6 @@ class TranslatableActivityReasonCategory extends AbstractType
|
|||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
|
||||||
$resolver->setDefaults(
|
|
||||||
[
|
|
||||||
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
|
||||||
'choice_label' => 'name[' . $locale . ']',
|
|
||||||
'query_builder' => static function (EntityRepository $er) {
|
|
||||||
return $er->createQueryBuilder('c')
|
|
||||||
->where('c.active = true');
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'translatable_activity_reason_category';
|
return 'translatable_activity_reason_category';
|
||||||
@@ -58,4 +56,19 @@ class TranslatableActivityReasonCategory extends AbstractType
|
|||||||
{
|
{
|
||||||
return EntityType::class;
|
return EntityType::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$locale = $this->requestStack->getCurrentRequest()->getLocale();
|
||||||
|
$resolver->setDefaults(
|
||||||
|
array(
|
||||||
|
'class' => 'ChillActivityBundle:ActivityReasonCategory',
|
||||||
|
'choice_label' => 'name['.$locale.']',
|
||||||
|
'query_builder' => function (EntityRepository $er) {
|
||||||
|
return $er->createQueryBuilder('c')
|
||||||
|
->where('c.active = true');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Chill is a software for social workers.
|
* Chill is a software for social workers
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||||
* the LICENSE file that was distributed with this source code.
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Form\Type;
|
namespace Chill\ActivityBundle\Form\Type;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\ActivityType;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of TranslatableActivityType.
|
* Description of TranslatableActivityType
|
||||||
|
*
|
||||||
|
* @author Champs-Libres Coop
|
||||||
*/
|
*/
|
||||||
class TranslatableActivityType extends AbstractType
|
class TranslatableActivityType extends AbstractType
|
||||||
{
|
{
|
||||||
protected $activityTypeRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @var TranslatableStringHelper
|
* @var TranslatableStringHelper
|
||||||
*/
|
*/
|
||||||
protected $translatableStringHelper;
|
protected $translatableStringHelper;
|
||||||
|
|
||||||
|
protected $activityTypeRepository;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
TranslatableStringHelper $helper,
|
TranslatableStringHelper $helper,
|
||||||
EntityRepository $activityTypeRepository
|
EntityRepository $activityTypeRepository
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
$this->translatableStringHelper = $helper;
|
$this->translatableStringHelper = $helper;
|
||||||
$this->activityTypeRepository = $activityTypeRepository;
|
$this->activityTypeRepository = $activityTypeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
|
|
||||||
{
|
|
||||||
/** @var \Doctrine\ORM\QueryBuilder $qb */
|
|
||||||
$qb = $options['query_builder'];
|
|
||||||
|
|
||||||
if (true === $options['active_only']) {
|
|
||||||
$qb->where($qb->expr()->eq('at.active', ':active'));
|
|
||||||
$qb->setParameter('active', true, \Doctrine\DBAL\Types\Type::BOOLEAN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
|
||||||
{
|
|
||||||
$resolver->setDefaults(
|
|
||||||
[
|
|
||||||
'class' => 'ChillActivityBundle:ActivityType',
|
|
||||||
'active_only' => true,
|
|
||||||
'query_builder' => $this->activityTypeRepository
|
|
||||||
->createQueryBuilder('at'),
|
|
||||||
'choice_label' => function (ActivityType $type) {
|
|
||||||
return $this->translatableStringHelper->localize($type->getName());
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBlockPrefix()
|
public function getBlockPrefix()
|
||||||
{
|
{
|
||||||
return 'translatable_activity_type';
|
return 'translatable_activity_type';
|
||||||
@@ -75,4 +64,30 @@ class TranslatableActivityType extends AbstractType
|
|||||||
{
|
{
|
||||||
return EntityType::class;
|
return EntityType::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options) {
|
||||||
|
/* @var $qb \Doctrine\ORM\QueryBuilder */
|
||||||
|
$qb = $options['query_builder'];
|
||||||
|
|
||||||
|
if ($options['active_only'] === true) {
|
||||||
|
$qb->where($qb->expr()->eq('at.active', ':active'));
|
||||||
|
$qb->setParameter('active', true, \Doctrine\DBAL\Types\Type::BOOLEAN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
|
||||||
|
$resolver->setDefaults(
|
||||||
|
array(
|
||||||
|
'class' => 'ChillActivityBundle:ActivityType',
|
||||||
|
'active_only' => true,
|
||||||
|
'query_builder' => $this->activityTypeRepository
|
||||||
|
->createQueryBuilder('at'),
|
||||||
|
'choice_label' => function (ActivityType $type) {
|
||||||
|
return $this->translatableStringHelper->localize($type->getName());
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Menu;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Knp\Menu\MenuItem;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
||||||
|
{
|
||||||
|
protected TokenStorageInterface $tokenStorage;
|
||||||
|
|
||||||
|
protected AuthorizationHelper $authorizationHelper;
|
||||||
|
|
||||||
|
protected TranslatorInterface $translator;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
AuthorizationHelper $authorizationHelper,
|
||||||
|
TranslatorInterface $translator
|
||||||
|
) {
|
||||||
|
$this->translator = $translator;
|
||||||
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
|
$this->tokenStorage = $tokenStorage;
|
||||||
|
}
|
||||||
|
public static function getMenuIds(): array
|
||||||
|
{
|
||||||
|
return ['accompanyingCourse'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
|
{
|
||||||
|
$period = $parameters['accompanyingCourse'];
|
||||||
|
|
||||||
|
if (AccompanyingPeriod::STEP_DRAFT !== $period->getStep()) {
|
||||||
|
$menu->addChild($this->translator->trans('Activity list'), [
|
||||||
|
'route' => 'chill_activity_activity_list',
|
||||||
|
'routeParameters' => [
|
||||||
|
'accompanying_period_id' => $period->getId(),
|
||||||
|
]])
|
||||||
|
->setExtras(['order' => 40]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Menu;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Knp\Menu\MenuItem;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
|
||||||
|
|
||||||
class MenuBuilder implements LocalMenuBuilderInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $authorizationHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
protected $tokenStorage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
TokenStorageInterface $tokenStorage,
|
|
||||||
TranslatorInterface $translator,
|
|
||||||
AuthorizationHelper $authorizationHelper
|
|
||||||
) {
|
|
||||||
$this->tokenStorage = $tokenStorage;
|
|
||||||
$this->translator = $translator;
|
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
||||||
{
|
|
||||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
|
||||||
$person = $parameters['person'];
|
|
||||||
$user = $this->tokenStorage->getToken()->getUser();
|
|
||||||
$roleSee = new Role(ActivityVoter::SEE);
|
|
||||||
$roleAdd = new Role(ActivityVoter::CREATE);
|
|
||||||
|
|
||||||
if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) {
|
|
||||||
$menu->addChild($this->translator->trans('Activity list'), [
|
|
||||||
'route' => 'chill_activity_activity_list',
|
|
||||||
'routeParameters' => [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 201,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->authorizationHelper->userHasAccess($user, $person, $roleAdd)) {
|
|
||||||
$menu->addChild($this->translator->trans('Add a new activity'), [
|
|
||||||
'route' => 'chill_activity_activity_new',
|
|
||||||
'routeParameters' => [
|
|
||||||
'person_id' => $person->getId(),
|
|
||||||
],
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 200,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
|
||||||
{
|
|
||||||
return ['person'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,69 +1,68 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
/**
|
* Copyright (C) 2018 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* the LICENSE file that was distributed with this source code.
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* @see https://www.champs-libres.coop/
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
namespace Chill\ActivityBundle\Menu;
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Menu;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Knp\Menu\MenuItem;
|
use Knp\Menu\MenuItem;
|
||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var AuthorizationCheckerInterface
|
*
|
||||||
*/
|
|
||||||
protected $authorizationChecker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatorInterface
|
* @var TranslatorInterface
|
||||||
*/
|
*/
|
||||||
protected $translator;
|
protected $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var AuthorizationCheckerInterface
|
||||||
|
*/
|
||||||
|
protected $authorizationChecker;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AuthorizationCheckerInterface $authorizationChecker,
|
AuthorizationCheckerInterface $authorizationChecker,
|
||||||
TranslatorInterface $translator
|
TranslatorInterface $translator)
|
||||||
) {
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->authorizationChecker = $authorizationChecker;
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||||
$person = $parameters['person'];
|
$person = $parameters['person'];
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {
|
if ($this->authorizationChecker->isGranted(ActivityVoter::SEE, $person)) {
|
||||||
$menu->addChild(
|
$menu->addChild(
|
||||||
$this->translator->trans('Activity list'),
|
$this->translator->trans('Activity list'), [
|
||||||
[
|
|
||||||
'route' => 'chill_activity_activity_list',
|
'route' => 'chill_activity_activity_list',
|
||||||
'routeParameters' => ['person_id' => $person->getId()],
|
'routeParameters' => [ 'person_id' => $person->getId() ],
|
||||||
]
|
])
|
||||||
)
|
->setExtra('order', 201)
|
||||||
->setExtra('order', 201);
|
;
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(ActivityVoter::CREATE, $person)) {
|
|
||||||
$menu->addChild(
|
|
||||||
$this->translator->trans('Add a new activity'),
|
|
||||||
[
|
|
||||||
'route' => 'chill_activity_activity_new',
|
|
||||||
'routeParameters' => ['person_id' => $person->getId()],
|
|
||||||
]
|
|
||||||
)
|
|
||||||
->setExtra('order', 200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Repository;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\ActivityBundle\Repository\ActivityRepository;
|
||||||
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Doctrine\ORM\Query\Expr\Orx;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
|
||||||
|
final class ActivityACLAwareRepository
|
||||||
|
{
|
||||||
|
private AuthorizationHelper $authorizationHelper;
|
||||||
|
|
||||||
|
private TokenStorageInterface $tokenStorage;
|
||||||
|
|
||||||
|
private ActivityRepository $repository;
|
||||||
|
|
||||||
|
private EntityManagerInterface $em;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
AuthorizationHelper $authorizationHelper,
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
ActivityRepository $repository,
|
||||||
|
EntityManagerInterface $em
|
||||||
|
) {
|
||||||
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
|
$this->tokenStorage = $tokenStorage;
|
||||||
|
$this->repository = $repository;
|
||||||
|
$this->em = $em;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function queryTimelineIndexer(string $context, array $args = []): array
|
||||||
|
{
|
||||||
|
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||||
|
|
||||||
|
$from = $this->getFromClauseCenter($args);
|
||||||
|
[$where, $parameters] = $this->getWhereClause($context, $args);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $metadataActivity->getTableName()
|
||||||
|
.'.'.$metadataActivity->getColumnName('id'),
|
||||||
|
'type' => 'activity',
|
||||||
|
'date' => $metadataActivity->getTableName()
|
||||||
|
.'.'.$metadataActivity->getColumnName('date'),
|
||||||
|
'FROM' => $from,
|
||||||
|
'WHERE' => $where,
|
||||||
|
'parameters' => $parameters
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFromClauseCenter(array $args): string
|
||||||
|
{
|
||||||
|
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||||
|
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||||
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
|
|
||||||
|
return $metadataActivity->getTableName().' JOIN '
|
||||||
|
.$metadataPerson->getTableName().' ON '
|
||||||
|
.$metadataPerson->getTableName().'.'.
|
||||||
|
$associationMapping['joinColumns'][0]['referencedColumnName']
|
||||||
|
.' = '
|
||||||
|
.$associationMapping['joinColumns'][0]['name']
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getWhereClause(string $context, array $args): array
|
||||||
|
{
|
||||||
|
$where = '';
|
||||||
|
$parameters = [];
|
||||||
|
|
||||||
|
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
||||||
|
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
||||||
|
$activityToPerson = $metadataActivity->getAssociationMapping('person')['joinColumns'][0]['name'];
|
||||||
|
$activityToScope = $metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'];
|
||||||
|
$personToCenter = $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'];
|
||||||
|
|
||||||
|
|
||||||
|
// acls:
|
||||||
|
$role = new Role(ActivityVoter::SEE);
|
||||||
|
$reachableCenters = $this->authorizationHelper->getReachableCenters($this->tokenStorage->getToken()->getUser(),
|
||||||
|
$role);
|
||||||
|
|
||||||
|
if (count($reachableCenters) === 0) {
|
||||||
|
// insert a dummy condition
|
||||||
|
return 'FALSE = TRUE';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($context === 'person') {
|
||||||
|
// we start with activities having the person_id linked to person
|
||||||
|
$where .= sprintf('%s = ? AND ', $activityToPerson);
|
||||||
|
$parameters[] = $person->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// we add acl (reachable center and scopes)
|
||||||
|
$where .= '('; // first loop for the for centers
|
||||||
|
$centersI = 0; // like centers#i
|
||||||
|
foreach ($reachableCenters as $center) {
|
||||||
|
// we pass if not in centers
|
||||||
|
if (!\in_array($center, $args['centers'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// we get all the reachable scopes for this center
|
||||||
|
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
|
||||||
|
// we get the ids for those scopes
|
||||||
|
$reachablesScopesId = array_map(
|
||||||
|
function(Scope $scope) { return $scope->getId(); },
|
||||||
|
$reachableScopes
|
||||||
|
);
|
||||||
|
|
||||||
|
// if not the first center
|
||||||
|
if ($centersI > 0) {
|
||||||
|
$where .= ') OR (';
|
||||||
|
}
|
||||||
|
|
||||||
|
// condition for the center
|
||||||
|
$where .= sprintf(' %s.%s = ? ', $metadataPerson->getTableName(), $personToCenter);
|
||||||
|
$parameters[] = $center->getId();
|
||||||
|
|
||||||
|
// begin loop for scopes
|
||||||
|
$where .= ' AND (';
|
||||||
|
$scopesI = 0; //like scope#i
|
||||||
|
|
||||||
|
foreach ($reachablesScopesId as $scopeId) {
|
||||||
|
if ($scopesI > 0) {
|
||||||
|
$where .= ' OR ';
|
||||||
|
}
|
||||||
|
$where .= sprintf(' %s.%s = ? ', $metadataActivity->getTableName(), $activityToScope);
|
||||||
|
$parameters[] = $scopeId;
|
||||||
|
$scopesI ++;
|
||||||
|
}
|
||||||
|
// close loop for scopes
|
||||||
|
$where .= ') ';
|
||||||
|
$centersI++;
|
||||||
|
}
|
||||||
|
// close loop for centers
|
||||||
|
$where .= ')';
|
||||||
|
|
||||||
|
return [$where, $parameters];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
||||||
|
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Repository;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method AccompanyingPeriodParticipation|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method AccompanyingPeriodParticipation[] findAll()
|
||||||
|
* @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class ActivityRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, Activity::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findByPersonImplied($person, array $scopes, $orderBy = [ 'date' => 'DESC'], $limit = 100, $offset = 0)
|
||||||
|
{
|
||||||
|
$qb = $this->createQueryBuilder('a');
|
||||||
|
$qb->select('a');
|
||||||
|
|
||||||
|
$qb
|
||||||
|
// TODO add acl
|
||||||
|
//->where($qb->expr()->in('a.scope', ':scopes'))
|
||||||
|
//->setParameter('scopes', $scopes)
|
||||||
|
->andWhere(
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->eq('a.person', ':person'),
|
||||||
|
':person MEMBER OF a.persons'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
->setParameter('person', $person)
|
||||||
|
;
|
||||||
|
|
||||||
|
foreach ($orderBy as $k => $dir) {
|
||||||
|
$qb->addOrderBy('a.'.$k, $dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $qb->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
@import '~ChillMainSass/custom/config/colors';
|
|
||||||
@import '~ChillMainSass/custom/mixins/entity';
|
|
||||||
|
|
||||||
.chill-entity.chill-entity__activity-reason {
|
|
||||||
@include entity($chill-pink, white);
|
|
||||||
}
|
|
||||||
|
|
||||||
.activity {
|
|
||||||
color: $chill-green;
|
|
||||||
}
|
|
||||||
@@ -1 +1 @@
|
|||||||
require('./activity/activity.scss');
|
require('./scss/chillactivity.scss');
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
@import '~ChillMainSass/custom/config/colors';
|
||||||
|
@import '~ChillMainSass/custom/mixins/entity';
|
||||||
|
|
||||||
|
.chill-entity.chill-entity__activity-reason {
|
||||||
|
@include entity($chill-pink, white);
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity {
|
||||||
|
color: $chill-green;
|
||||||
|
}
|
||||||
|
|
||||||
|
// exceptions for flex-bloc in concerned-groups
|
||||||
|
div.flex-bloc.concerned-groups {
|
||||||
|
margin-top: 1em;
|
||||||
|
div.item-bloc {
|
||||||
|
flex-grow: 0; flex-shrink: 0; flex-basis: 25%; //4 blocs
|
||||||
|
ul.list-content {
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 0;
|
||||||
|
li {
|
||||||
|
margin-bottom: 0.2em;
|
||||||
|
a {
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
color: #ffffffab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.person div.item-bloc {
|
||||||
|
flex-basis: 33%; //3 blocs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// exceptions for flex-table in list-records
|
||||||
|
div.flex-table.list-records {
|
||||||
|
div.item-bloc {
|
||||||
|
div.item-row.main {
|
||||||
|
div.item-col {
|
||||||
|
&:first-child {
|
||||||
|
flex-basis: 27%;
|
||||||
|
}
|
||||||
|
ul.list-content {
|
||||||
|
li.social-issues, li.social-actions {
|
||||||
|
.badge-primary {
|
||||||
|
font-variant: small-caps;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 88%;
|
||||||
|
margin-bottom: 0.2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
li.social-issues .badge-primary {
|
||||||
|
background-color: var(--chill-orange);
|
||||||
|
}
|
||||||
|
li.social-actions .badge-primary {
|
||||||
|
background-color: var(--chill-green);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
div.item-row.details {
|
||||||
|
flex-direction: row;
|
||||||
|
& > div.item-col {
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-self: center;
|
||||||
|
&:nth-child(1) {
|
||||||
|
flex-grow: 1; flex-shrink: 0; flex-basis: 30%;
|
||||||
|
}
|
||||||
|
&:nth-child(2) {
|
||||||
|
flex-grow: 0; flex-shrink: 1; flex-basis: 70%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:only-child {
|
||||||
|
flex-grow: 0; flex-shrink: 0; flex-basis: 100%;
|
||||||
|
& > div.concerned-groups {
|
||||||
|
flex-grow: 0; flex-shrink: 0; flex-basis: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column; // TODO pas fini
|
||||||
|
div.group {
|
||||||
|
flex-grow: 1; flex-shrink: 0; flex-basis: 30%;
|
||||||
|
h4 {}
|
||||||
|
ul.list-content {
|
||||||
|
li {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
div.concerned-groups {
|
||||||
|
font-size: 85%;
|
||||||
|
h4 {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ul.list-content {
|
||||||
|
list-style-type: none;
|
||||||
|
padding-left: 1em;
|
||||||
|
margin: 0 0;
|
||||||
|
li {
|
||||||
|
margin-bottom: 0.2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
div.duration {
|
||||||
|
font-size: smaller;
|
||||||
|
padding-left: 1em;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
div.activity-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 12px;
|
||||||
|
div.bloc {
|
||||||
|
width: 200px;
|
||||||
|
align-self: flex-end;
|
||||||
|
height: 140px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<concerned-groups></concerned-groups>
|
||||||
|
<social-issues-acc></social-issues-acc>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ConcernedGroups from './components/ConcernedGroups.vue';
|
||||||
|
import SocialIssuesAcc from './components/SocialIssuesAcc.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "App",
|
||||||
|
components: {
|
||||||
|
ConcernedGroups,
|
||||||
|
SocialIssuesAcc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { getSocialIssues } from 'ChillPersonAssets/vuejs/AccompanyingCourse/api.js';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load socialActions by socialIssue (id)
|
||||||
|
*/
|
||||||
|
const getSocialActionByIssue = (id) => {
|
||||||
|
const url = `/api/1.0/person/social/social-action/by-social-issue/${id}.json`;
|
||||||
|
return fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
getSocialIssues,
|
||||||
|
getSocialActionByIssue
|
||||||
|
};
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<template>
|
||||||
|
<teleport to="#add-persons">
|
||||||
|
|
||||||
|
<div class="flex-bloc concerned-groups" :class="getContext">
|
||||||
|
<persons-bloc
|
||||||
|
v-for="bloc in contextPersonsBlocs"
|
||||||
|
v-bind:key="bloc.key"
|
||||||
|
v-bind:bloc="bloc"
|
||||||
|
v-bind:setPersonsInBloc="setPersonsInBloc">
|
||||||
|
</persons-bloc>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<add-persons
|
||||||
|
buttonTitle="activity.add_persons"
|
||||||
|
modalTitle="activity.add_persons"
|
||||||
|
v-bind:key="addPersons.key"
|
||||||
|
v-bind:options="addPersons.options"
|
||||||
|
@addNewPersons="addNewPersons"
|
||||||
|
ref="addPersons">
|
||||||
|
</add-persons>
|
||||||
|
|
||||||
|
</teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
|
||||||
|
import PersonsBloc from './ConcernedGroups/PersonsBloc.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "ConcernedGroups",
|
||||||
|
components: {
|
||||||
|
AddPersons,
|
||||||
|
PersonsBloc
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
personsBlocs: [
|
||||||
|
{ key: 'persons',
|
||||||
|
title: 'activity.bloc_persons',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
|
{ key: 'personsAssociated',
|
||||||
|
title: 'activity.bloc_persons_associated',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
|
{ key: 'personsNotAssociated',
|
||||||
|
title: 'activity.bloc_persons_not_associated',
|
||||||
|
persons: [],
|
||||||
|
included: false
|
||||||
|
},
|
||||||
|
{ key: 'thirdparty',
|
||||||
|
title: 'activity.bloc_thirdparty',
|
||||||
|
persons: [],
|
||||||
|
included: true
|
||||||
|
},
|
||||||
|
{ key: 'users',
|
||||||
|
title: 'activity.bloc_users',
|
||||||
|
persons: [],
|
||||||
|
included: true
|
||||||
|
},
|
||||||
|
],
|
||||||
|
addPersons: {
|
||||||
|
key: 'activity',
|
||||||
|
options: {
|
||||||
|
type: ['person', 'thirdparty'], // TODO add 'user'
|
||||||
|
priority: null,
|
||||||
|
uniq: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
persons: state => state.activity.persons,
|
||||||
|
thirdParties: state => state.activity.thirdParties,
|
||||||
|
users: state => state.activity.users,
|
||||||
|
accompanyingCourse: state => state.activity.accompanyingPeriod
|
||||||
|
}),
|
||||||
|
getContext() {
|
||||||
|
return (this.accompanyingCourse) ? "accompanyingCourse" : "person";
|
||||||
|
},
|
||||||
|
contextPersonsBlocs() {
|
||||||
|
return this.personsBlocs.filter(bloc => bloc.included !== false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setPersonsInBloc();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setPersonsInBloc() {
|
||||||
|
let groups;
|
||||||
|
if (this.accompanyingCourse) {
|
||||||
|
groups = this.splitPersonsInGroups();
|
||||||
|
}
|
||||||
|
this.personsBlocs.forEach(bloc => {
|
||||||
|
if (this.accompanyingCourse) {
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'personsAssociated':
|
||||||
|
bloc.persons = groups.personsAssociated;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
case 'personsNotAssociated':
|
||||||
|
bloc.persons = groups.personsNotAssociated;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'persons':
|
||||||
|
bloc.persons = this.persons;
|
||||||
|
bloc.included = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (bloc.key) {
|
||||||
|
case 'thirdparty':
|
||||||
|
bloc.persons = this.thirdParties;
|
||||||
|
break;
|
||||||
|
case 'users':
|
||||||
|
bloc.persons = this.users;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, groups);
|
||||||
|
},
|
||||||
|
splitPersonsInGroups() {
|
||||||
|
let personsAssociated = [];
|
||||||
|
let personsNotAssociated = this.persons;
|
||||||
|
let participations = this.getCourseParticipations();
|
||||||
|
this.persons.forEach(person => {
|
||||||
|
participations.forEach(participation => {
|
||||||
|
if (person.id === participation.id) {
|
||||||
|
//console.log(person.id);
|
||||||
|
personsAssociated.push(person);
|
||||||
|
personsNotAssociated = personsNotAssociated.filter(p => p !== person);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
'personsAssociated': personsAssociated,
|
||||||
|
'personsNotAssociated': personsNotAssociated
|
||||||
|
};
|
||||||
|
},
|
||||||
|
getCourseParticipations() {
|
||||||
|
let participations = [];
|
||||||
|
this.accompanyingCourse.participations.forEach(participation => {
|
||||||
|
if (!participation.endDate) {
|
||||||
|
participations.push(participation.person);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return participations;
|
||||||
|
},
|
||||||
|
addNewPersons({ selected, modal }) {
|
||||||
|
console.log('@@@ CLICK button addNewPersons', selected);
|
||||||
|
selected.forEach(function(item) {
|
||||||
|
this.$store.dispatch('addPersonsInvolved', item);
|
||||||
|
}, this
|
||||||
|
);
|
||||||
|
this.$refs.addPersons.resetSearch(); // to cast child method
|
||||||
|
modal.showModal = false;
|
||||||
|
this.setPersonsInBloc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<li>
|
||||||
|
<span class="badge badge-primary" :title="person.text">
|
||||||
|
<span class="chill_denomination">
|
||||||
|
{{ textCutted }}
|
||||||
|
</span>
|
||||||
|
<a class="fa fa-fw fa-times"
|
||||||
|
@click.prevent="$emit('remove', person)">
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "PersonBadge",
|
||||||
|
props: ['person'],
|
||||||
|
computed: {
|
||||||
|
textCutted() {
|
||||||
|
let more = (this.person.text.length > 15) ?'…' : '';
|
||||||
|
return this.person.text.slice(0,15) + more;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ['remove'],
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<template>
|
||||||
|
<div class="item-bloc">
|
||||||
|
<div class="item-row">
|
||||||
|
<div class="item-col">
|
||||||
|
<h4>{{ $t(bloc.title) }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="item-col">
|
||||||
|
<ul class="list-content">
|
||||||
|
<person-badge
|
||||||
|
v-for="person in bloc.persons"
|
||||||
|
v-bind:key="person.id"
|
||||||
|
v-bind:person="person"
|
||||||
|
@remove="removePerson">
|
||||||
|
</person-badge>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import PersonBadge from './PersonBadge.vue';
|
||||||
|
export default {
|
||||||
|
name:"PersonsBloc",
|
||||||
|
components: {
|
||||||
|
PersonBadge
|
||||||
|
},
|
||||||
|
props: ['bloc', 'setPersonsInBloc'],
|
||||||
|
methods: {
|
||||||
|
removePerson(item) {
|
||||||
|
console.log('@@ CLICK remove person: item', item);
|
||||||
|
this.$store.dispatch('removePersonInvolved', item);
|
||||||
|
this.setPersonsInBloc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,214 @@
|
|||||||
|
<template>
|
||||||
|
<teleport to="#social-issues-acc">
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="grid-4 clear">
|
||||||
|
<label>{{ $t('activity.social_issues') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="grid-8">
|
||||||
|
|
||||||
|
<check-social-issue
|
||||||
|
v-for="issue in socialIssuesList"
|
||||||
|
v-bind:key="issue.id"
|
||||||
|
v-bind:issue="issue"
|
||||||
|
v-bind:selection="socialIssuesSelected"
|
||||||
|
@updateSelected="updateIssuesSelected">
|
||||||
|
</check-social-issue>
|
||||||
|
|
||||||
|
<div class="my-3">
|
||||||
|
<VueMultiselect
|
||||||
|
name="otherIssues"
|
||||||
|
label="text"
|
||||||
|
track-by="id"
|
||||||
|
open-direction="bottom"
|
||||||
|
v-bind:close-on-select="true"
|
||||||
|
v-bind:preserve-search="false"
|
||||||
|
v-bind:reset-after="true"
|
||||||
|
v-bind:hide-selected="true"
|
||||||
|
v-bind:taggable="false"
|
||||||
|
v-bind:multiple="false"
|
||||||
|
v-bind:searchable="true"
|
||||||
|
v-bind:allow-empty="true"
|
||||||
|
v-bind:show-labels="false"
|
||||||
|
v-bind:loading="issueIsLoading"
|
||||||
|
v-bind:placeholder="$t('activity.choose_other_social_issue')"
|
||||||
|
v-bind:options="socialIssuesOther"
|
||||||
|
v-model="value"
|
||||||
|
@select="addIssueInList">
|
||||||
|
</VueMultiselect>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="grid-4 clear">
|
||||||
|
<label>{{ $t('activity.social_actions') }}</label>
|
||||||
|
</div>
|
||||||
|
<div class="grid-8">
|
||||||
|
|
||||||
|
<div v-if="actionIsLoading === true">
|
||||||
|
<i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<check-social-action
|
||||||
|
v-if="socialIssuesSelected.length || socialActionsSelected.length"
|
||||||
|
v-for="action in socialActionsList"
|
||||||
|
v-bind:key="action.id"
|
||||||
|
v-bind:action="action"
|
||||||
|
v-bind:selection="socialActionsSelected"
|
||||||
|
@updateSelected="updateActionsSelected">
|
||||||
|
</check-social-action>
|
||||||
|
|
||||||
|
<span v-else class="inline-choice chill-no-data-statement mt-3">
|
||||||
|
{{ $t('activity.select_first_a_social_issue') }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { readonly } from 'vue';
|
||||||
|
import VueMultiselect from 'vue-multiselect';
|
||||||
|
import CheckSocialIssue from './SocialIssuesAcc/CheckSocialIssue.vue';
|
||||||
|
import CheckSocialAction from './SocialIssuesAcc/CheckSocialAction.vue';
|
||||||
|
import { getSocialIssues, getSocialActionByIssue } from '../api.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "SocialIssuesAcc",
|
||||||
|
components: {
|
||||||
|
CheckSocialIssue,
|
||||||
|
CheckSocialAction,
|
||||||
|
VueMultiselect
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
issueIsLoading: false,
|
||||||
|
actionIsLoading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
socialIssuesList() {
|
||||||
|
return this.$store.state.activity.accompanyingPeriod.socialIssues;
|
||||||
|
},
|
||||||
|
socialIssuesSelected() {
|
||||||
|
return this.$store.state.activity.socialIssues;
|
||||||
|
},
|
||||||
|
socialIssuesOther() {
|
||||||
|
return this.$store.state.socialIssuesOther;
|
||||||
|
},
|
||||||
|
socialActionsList() {
|
||||||
|
return this.$store.state.socialActionsList;
|
||||||
|
},
|
||||||
|
socialActionsSelected() {
|
||||||
|
return this.$store.state.activity.socialActions;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
/* Load others issues in multiselect
|
||||||
|
*/
|
||||||
|
this.issueIsLoading = true;
|
||||||
|
getSocialIssues().then(response => new Promise((resolve, reject) => {
|
||||||
|
this.$store.commit('updateIssuesOther', response.results);
|
||||||
|
|
||||||
|
/* Add in list the issues already associated (if not yet listed)
|
||||||
|
*/
|
||||||
|
this.socialIssuesSelected.forEach(issue => {
|
||||||
|
if (this.socialIssuesList.filter(i => i.id === issue.id).length !== 1) {
|
||||||
|
this.$store.commit('addIssueInList', issue);
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
/* Remove from multiselect the issues that are not yet in checkbox list
|
||||||
|
*/
|
||||||
|
this.socialIssuesList.forEach(issue => {
|
||||||
|
this.$store.commit('removeIssueInOther', issue);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
/* Filter issues
|
||||||
|
*/
|
||||||
|
this.$store.commit('filterList', 'issues');
|
||||||
|
|
||||||
|
/* Add in list the actions already associated (if not yet listed)
|
||||||
|
*/
|
||||||
|
this.socialActionsSelected.forEach(action => {
|
||||||
|
this.$store.commit('addActionInList', action);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
/* Filter issues
|
||||||
|
*/
|
||||||
|
this.$store.commit('filterList', 'actions');
|
||||||
|
|
||||||
|
this.issueIsLoading = false;
|
||||||
|
resolve();
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
/* When choosing an issue in multiselect, add it in checkboxes (as selected),
|
||||||
|
remove it from multiselect, and add socialActions concerned
|
||||||
|
*/
|
||||||
|
addIssueInList(value) {
|
||||||
|
//console.log('addIssueInList', value);
|
||||||
|
this.$store.commit('addIssueInList', value);
|
||||||
|
this.$store.commit('removeIssueInOther', value);
|
||||||
|
this.$store.dispatch('addIssueSelected', value);
|
||||||
|
this.updateActionsList();
|
||||||
|
},
|
||||||
|
/* Update value for selected issues checkboxes
|
||||||
|
*/
|
||||||
|
updateIssuesSelected(issues) {
|
||||||
|
//console.log('updateIssuesSelected', issues);
|
||||||
|
this.$store.dispatch('updateIssuesSelected', issues);
|
||||||
|
this.updateActionsList();
|
||||||
|
},
|
||||||
|
/* Update value for selected actions checkboxes
|
||||||
|
*/
|
||||||
|
updateActionsSelected(actions) {
|
||||||
|
//console.log('updateActionsSelected', actions);
|
||||||
|
this.$store.dispatch('updateActionsSelected', actions);
|
||||||
|
},
|
||||||
|
/* Add socialActions concerned: after reset, loop on each issue selected
|
||||||
|
to get social actions concerned
|
||||||
|
*/
|
||||||
|
updateActionsList() {
|
||||||
|
//console.log('updateActionsList');
|
||||||
|
this.resetActionsList();
|
||||||
|
this.socialIssuesSelected.forEach(item => {
|
||||||
|
|
||||||
|
this.actionIsLoading = true;
|
||||||
|
getSocialActionByIssue(item.id)
|
||||||
|
.then(actions => new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
actions.results.forEach(action => {
|
||||||
|
this.$store.commit('addActionInList', action);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.$store.commit('filterList', 'actions');
|
||||||
|
|
||||||
|
this.actionIsLoading = false;
|
||||||
|
resolve();
|
||||||
|
}));
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
/* Reset socialActions List: flush list and restore selected actions
|
||||||
|
*/
|
||||||
|
resetActionsList() {
|
||||||
|
this.$store.commit('resetActionsList');
|
||||||
|
this.socialActionsSelected.forEach(item => {
|
||||||
|
this.$store.commit('addActionInList', item);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
||||||
|
<style lang="scss">
|
||||||
|
span.multiselect__single {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<span class="inline-choice">
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
v-model="selected"
|
||||||
|
name="action"
|
||||||
|
v-bind:id="action.id"
|
||||||
|
v-bind:value="action"
|
||||||
|
/>
|
||||||
|
<label class="inline" v-bind:for="action.id">
|
||||||
|
{{ action.text }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</span><br>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "CheckSocialAction",
|
||||||
|
props: [ 'action', 'selection' ],
|
||||||
|
emits: [ 'updateSelected' ],
|
||||||
|
computed: {
|
||||||
|
selected: {
|
||||||
|
set(value) {
|
||||||
|
this.$emit('updateSelected', value);
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return this.selection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<span class="inline-choice">
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
v-model="selected"
|
||||||
|
name="issue"
|
||||||
|
v-bind:id="issue.id"
|
||||||
|
v-bind:value="issue"
|
||||||
|
/>
|
||||||
|
<label class="inline" v-bind:for="issue.id">
|
||||||
|
{{ issue.text }}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</span><br>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "CheckSocialIssue",
|
||||||
|
props: [ 'issue', 'selection' ],
|
||||||
|
emits: [ 'updateSelected' ],
|
||||||
|
computed: {
|
||||||
|
selected: {
|
||||||
|
set(value) {
|
||||||
|
this.$emit('updateSelected', value);
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return this.selection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||||
|
|
||||||
|
const appMessages = {
|
||||||
|
fr: {
|
||||||
|
activity: {
|
||||||
|
//
|
||||||
|
social_issues: "Problématiques sociales",
|
||||||
|
choose_other_social_issue: "Ajouter une autre problématique sociale...",
|
||||||
|
social_actions: "Actions d'accompagnement",
|
||||||
|
select_first_a_social_issue: "Sélectionnez d'abord une problématique sociale",
|
||||||
|
|
||||||
|
//
|
||||||
|
add_persons: "Ajouter des personnes concernées",
|
||||||
|
bloc_persons: "Usagers",
|
||||||
|
bloc_persons_associated: "Usagers du parcours",
|
||||||
|
bloc_persons_not_associated: "Tiers non-pro.",
|
||||||
|
bloc_thirdparty: "Tiers professionnels",
|
||||||
|
bloc_users: "T(M)S",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(appMessages.fr, personMessages.fr);
|
||||||
|
|
||||||
|
export {
|
||||||
|
appMessages
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { createApp } from 'vue';
|
||||||
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
||||||
|
import { appMessages } from './i18n'
|
||||||
|
import store from './store'
|
||||||
|
|
||||||
|
import App from './App.vue';
|
||||||
|
|
||||||
|
const i18n = _createI18n(appMessages);
|
||||||
|
|
||||||
|
const app = createApp({
|
||||||
|
template: `<app></app>`,
|
||||||
|
})
|
||||||
|
.use(store)
|
||||||
|
.use(i18n)
|
||||||
|
.component('app', App)
|
||||||
|
.mount('#activity');
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
import 'es6-promise/auto';
|
||||||
|
import { createStore } from 'vuex';
|
||||||
|
|
||||||
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
//console.log('window.activity', window.activity);
|
||||||
|
|
||||||
|
const addIdToValue = (string, id) => {
|
||||||
|
let array = string ? string.split(',') : [];
|
||||||
|
array.push(id.toString());
|
||||||
|
let str = array.join();
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeIdFromValue = (string, id) => {
|
||||||
|
let array = string.split(',');
|
||||||
|
array = array.filter(el => el !== id.toString());
|
||||||
|
let str = array.join();
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
|
||||||
|
const store = createStore({
|
||||||
|
strict: debug,
|
||||||
|
state: {
|
||||||
|
activity: window.activity,
|
||||||
|
socialIssuesOther: [],
|
||||||
|
socialActionsList: [],
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
|
||||||
|
// SocialIssueAcc
|
||||||
|
addIssueInList(state, issue) {
|
||||||
|
//console.log('add issue list', issue.id);
|
||||||
|
state.activity.accompanyingPeriod.socialIssues.push(issue);
|
||||||
|
},
|
||||||
|
addIssueSelected(state, issue) {
|
||||||
|
//console.log('add issue selected', issue.id);
|
||||||
|
state.activity.socialIssues.push(issue);
|
||||||
|
},
|
||||||
|
updateIssuesSelected(state, issues) {
|
||||||
|
//console.log('update issues selected', issues);
|
||||||
|
state.activity.socialIssues = issues;
|
||||||
|
},
|
||||||
|
updateIssuesOther(state, payload) {
|
||||||
|
//console.log('update issues other');
|
||||||
|
state.socialIssuesOther = payload;
|
||||||
|
},
|
||||||
|
removeIssueInOther(state, issue) {
|
||||||
|
//console.log('remove issue other', issue.id);
|
||||||
|
state.socialIssuesOther = state.socialIssuesOther.filter(i => i.id !== issue.id);
|
||||||
|
},
|
||||||
|
resetActionsList(state) {
|
||||||
|
//console.log('reset list actions');
|
||||||
|
state.socialActionsList = [];
|
||||||
|
},
|
||||||
|
addActionInList(state, action) {
|
||||||
|
//console.log('add action list', action.id);
|
||||||
|
state.socialActionsList.push(action);
|
||||||
|
},
|
||||||
|
updateActionsSelected(state, actions) {
|
||||||
|
//console.log('update actions selected', actions);
|
||||||
|
state.activity.socialActions = actions;
|
||||||
|
},
|
||||||
|
filterList(state, list) {
|
||||||
|
const filterList = (list) => {
|
||||||
|
// remove duplicates entries
|
||||||
|
list = list.filter((value, index) => list.findIndex(array => array.id === value.id) === index);
|
||||||
|
// alpha sort
|
||||||
|
list.sort((a,b) => (a.text > b.text) ? 1 : ((b.text > a.text) ? -1 : 0));
|
||||||
|
return list;
|
||||||
|
};
|
||||||
|
if (list === 'issues') {
|
||||||
|
state.activity.accompanyingPeriod.socialIssues = filterList(state.activity.accompanyingPeriod.socialIssues);
|
||||||
|
}
|
||||||
|
if (list === 'actions') {
|
||||||
|
state.socialActionsList = filterList(state.socialActionsList);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// ConcernedGroups
|
||||||
|
addPersonsInvolved(state, payload) {
|
||||||
|
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
||||||
|
switch (payload.result.type) {
|
||||||
|
case 'person':
|
||||||
|
state.activity.persons.push(payload.result);
|
||||||
|
break;
|
||||||
|
case 'thirdparty':
|
||||||
|
state.activity.thirdParties.push(payload.result);
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
state.activity.users.push(payload.result);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
removePersonInvolved(state, payload) {
|
||||||
|
//console.log('### mutation removePersonInvolved', payload.type);
|
||||||
|
switch (payload.type) {
|
||||||
|
case 'person':
|
||||||
|
state.activity.persons = state.activity.persons.filter(person => person !== payload);
|
||||||
|
break;
|
||||||
|
case 'thirdparty':
|
||||||
|
state.activity.thirdParties = state.activity.thirdParties.filter(thirdparty => thirdparty !== payload);
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
state.activity.users = state.activity.users.filter(user => user !== payload);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
addIssueSelected({ commit }, issue) {
|
||||||
|
let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
|
||||||
|
aSocialIssues.value = addIdToValue(aSocialIssues.value, issue.id);
|
||||||
|
commit('addIssueSelected', issue);
|
||||||
|
},
|
||||||
|
updateIssuesSelected({ commit }, payload) {
|
||||||
|
let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
|
||||||
|
aSocialIssues.value = '';
|
||||||
|
payload.forEach(item => {
|
||||||
|
aSocialIssues.value = addIdToValue(aSocialIssues.value, item.id);
|
||||||
|
});
|
||||||
|
commit('updateIssuesSelected', payload);
|
||||||
|
},
|
||||||
|
updateActionsSelected({ commit }, payload) {
|
||||||
|
let aSocialActions = document.getElementById("chill_activitybundle_activity_socialActions");
|
||||||
|
aSocialActions.value = '';
|
||||||
|
payload.forEach(item => {
|
||||||
|
aSocialActions.value = addIdToValue(aSocialActions.value, item.id);
|
||||||
|
});
|
||||||
|
commit('updateActionsSelected', payload);
|
||||||
|
},
|
||||||
|
addPersonsInvolved({ commit }, payload) {
|
||||||
|
//console.log('### action addPersonsInvolved', payload.result.type);
|
||||||
|
switch (payload.result.type) {
|
||||||
|
case 'person':
|
||||||
|
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
||||||
|
aPersons.value = addIdToValue(aPersons.value, payload.result.id);
|
||||||
|
break;
|
||||||
|
case 'thirdparty':
|
||||||
|
let aThirdParties = document.getElementById("chill_activitybundle_activity_thirdParties");
|
||||||
|
aThirdParties.value = addIdToValue(aThirdParties.value, payload.result.id);
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
let aUsers = document.getElementById("chill_activitybundle_activity_users");
|
||||||
|
aUsers.value = addIdToValue(aUsers.value, payload.result.id);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
commit('addPersonsInvolved', payload);
|
||||||
|
},
|
||||||
|
removePersonInvolved({ commit }, payload) {
|
||||||
|
//console.log('### action removePersonInvolved', payload);
|
||||||
|
switch (payload.type) {
|
||||||
|
case 'person':
|
||||||
|
let aPersons = document.getElementById("chill_activitybundle_activity_persons");
|
||||||
|
aPersons.value = removeIdFromValue(aPersons.value, payload.id);
|
||||||
|
break;
|
||||||
|
case 'thirdparty':
|
||||||
|
let aThirdParties = document.getElementById("chill_activitybundle_activity_thirdParties");
|
||||||
|
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
||||||
|
break;
|
||||||
|
case 'user':
|
||||||
|
let aUsers = document.getElementById("chill_activitybundle_activity_users");
|
||||||
|
aUsers.value = removeIdFromValue(aUsers.value, payload.id);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
commit('removePersonInvolved', payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default store;
|
||||||
@@ -1,40 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
|
|
||||||
class AppKernel extends Kernel
|
class AppKernel extends Kernel
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getCacheDir()
|
|
||||||
{
|
|
||||||
return sys_get_temp_dir() . '/ActivityBundle/cache';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getLogDir()
|
|
||||||
{
|
|
||||||
return sys_get_temp_dir() . '/ActivityBundle/logs';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function registerBundles()
|
public function registerBundles()
|
||||||
{
|
{
|
||||||
return [
|
return array(
|
||||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||||
new Chill\CustomFieldsBundle\ChillCustomFieldsBundle(),
|
new Chill\CustomFieldsBundle\ChillCustomFieldsBundle(),
|
||||||
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||||
@@ -47,12 +20,28 @@ class AppKernel extends Kernel
|
|||||||
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
|
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
|
||||||
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
||||||
new Symfony\Bundle\MonologBundle\MonologBundle(),
|
new Symfony\Bundle\MonologBundle\MonologBundle(),
|
||||||
//add here all the required bundle (some bundle are not required)
|
#add here all the required bundle (some bundle are not required)
|
||||||
];
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||||
{
|
{
|
||||||
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
|
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getCacheDir()
|
||||||
|
{
|
||||||
|
return sys_get_temp_dir().'/ActivityBundle/cache';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLogDir()
|
||||||
|
{
|
||||||
|
return sys_get_temp_dir().'/ActivityBundle/logs';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Composer\Autoload\ClassLoader;
|
|
||||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
|
use Composer\Autoload\ClassLoader;
|
||||||
|
|
||||||
/** @var ClassLoader $loader */
|
/** @var ClassLoader $loader */
|
||||||
$loader = require __DIR__ . '/../../../../../vendor/autoload.php';
|
$loader = require __DIR__.'/../../../../../vendor/autoload.php';
|
||||||
|
|
||||||
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
|
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,18 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Chill is a software for social workers.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view
|
|
||||||
* the LICENSE file that was distributed with this source code.
|
|
||||||
*
|
|
||||||
* @see https://www.champs-libres.coop/
|
|
||||||
*/
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Symfony\Component\Debug\Debug;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Debug\Debug;
|
||||||
|
|
||||||
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
|
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
|
||||||
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
|
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
|
||||||
@@ -20,20 +9,18 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
|
|
||||||
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
||||||
// Feel free to remove this, extend it, or make something more sophisticated.
|
// Feel free to remove this, extend it, or make something more sophisticated.
|
||||||
if (
|
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||||
isset($_SERVER['HTTP_CLIENT_IP'])
|
|
||||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||||
|| !(\in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1'], true) || \PHP_SAPI === 'cli-server')
|
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
|
||||||
) {
|
) {
|
||||||
header('HTTP/1.0 403 Forbidden');
|
header('HTTP/1.0 403 Forbidden');
|
||||||
|
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||||
exit('You are not allowed to access this file. Check ' . basename(__FILE__) . ' for more information.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$loader = require_once __DIR__ . '/../app/bootstrap.php.cache';
|
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
|
||||||
Debug::enable();
|
Debug::enable();
|
||||||
|
|
||||||
require_once __DIR__ . '/../app/AppKernel.php';
|
require_once __DIR__.'/../app/AppKernel.php';
|
||||||
|
|
||||||
$kernel = new AppKernel('dev', true);
|
$kernel = new AppKernel('dev', true);
|
||||||
$kernel->loadClassCache();
|
$kernel->loadClassCache();
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
{% macro href(pathname, key, value) %}
|
||||||
|
{% set parms = { (key): value } %}
|
||||||
|
{{ path(pathname, parms) }}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% if context == 'person' %}
|
||||||
|
{% set blocs = [
|
||||||
|
{ 'title': 'Others persons'|trans,
|
||||||
|
'items': entity.persons,
|
||||||
|
'path' : 'chill_person_view',
|
||||||
|
'key' : 'person_id'
|
||||||
|
},
|
||||||
|
{ 'title': 'Third parties'|trans,
|
||||||
|
'items': entity.thirdParties,
|
||||||
|
'path' : 'chill_3party_3party_show',
|
||||||
|
'key' : 'thirdparty_id'
|
||||||
|
},
|
||||||
|
{ 'title': 'Users concerned'|trans,
|
||||||
|
'items': entity.users,
|
||||||
|
'path' : 'admin_user_show',
|
||||||
|
'key' : 'id'
|
||||||
|
},
|
||||||
|
] %}
|
||||||
|
{% else %}
|
||||||
|
{% set blocs = [
|
||||||
|
{ 'title': 'Persons in accompanying course'|trans,
|
||||||
|
'items': entity.personsAssociated,
|
||||||
|
'path' : 'chill_person_view',
|
||||||
|
'key' : 'person_id'
|
||||||
|
},
|
||||||
|
{ 'title': 'Third persons'|trans,
|
||||||
|
'items': entity.personsNotAssociated,
|
||||||
|
'path' : 'chill_person_view',
|
||||||
|
'key' : 'person_id'
|
||||||
|
},
|
||||||
|
{ 'title': 'Third parties'|trans,
|
||||||
|
'items': entity.thirdParties,
|
||||||
|
'path' : 'chill_3party_3party_show',
|
||||||
|
'key' : 'thirdparty_id'
|
||||||
|
},
|
||||||
|
{ 'title': 'Users concerned'|trans,
|
||||||
|
'items': entity.users,
|
||||||
|
'path' : 'admin_user_show',
|
||||||
|
'key' : 'id'
|
||||||
|
},
|
||||||
|
] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if (with_display == 'bloc') %}
|
||||||
|
<div class="{{ context }} flex-bloc concerned-groups">
|
||||||
|
{% for bloc in blocs %}
|
||||||
|
<div class="item-bloc">
|
||||||
|
<div class="item-row">
|
||||||
|
<div class="item-col">
|
||||||
|
<h4>{{ bloc.title }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="item-col">
|
||||||
|
<ul class="list-content">
|
||||||
|
{% for item in bloc.items %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||||
|
<span class="badge badge-primary">
|
||||||
|
{{ item|chill_entity_render_box({'only_denomination': true}) }}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if (with_display == 'row') %}
|
||||||
|
<div class="concerned-groups">
|
||||||
|
{% for bloc in blocs %}
|
||||||
|
<div class="group">
|
||||||
|
{% if bloc.items|length > 0 %}
|
||||||
|
<h4>{{ bloc.title }}</h4>
|
||||||
|
<ul class="list-content">
|
||||||
|
{% for item in bloc.items %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
|
||||||
|
<span class="badge badge-primary">
|
||||||
|
{{ item|chill_entity_render_box({'only_denomination': true}) }}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
||||||
|
|
||||||
|
{% block title 'Remove activity'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'Remove activity'|trans,
|
||||||
|
'confirm_question' : 'Are you sure you want to remove the activity about "%name%" ?'|trans({ '%name%' : accompanyingCourse.id } ),
|
||||||
|
'cancel_route' : 'chill_activity_activity_list',
|
||||||
|
'cancel_parameters' : { 'accompanying_course_id' : accompanyingCourse.id, 'id' : activity.id },
|
||||||
|
'form' : delete_form
|
||||||
|
} ) }}
|
||||||
|
{% endblock %}
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
{% block title 'Remove activity'|trans %}
|
{% block title 'Remove activity'|trans %}
|
||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
|
|
||||||
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
{{ include('@ChillMain/Util/confirmation_template.html.twig',
|
||||||
{
|
{
|
||||||
'title' : 'Remove activity'|trans,
|
'title' : 'Remove activity'|trans,
|
||||||
@@ -15,5 +14,4 @@
|
|||||||
'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id },
|
'cancel_parameters' : { 'person_id' : activity.person.id, 'id' : activity.id },
|
||||||
'form' : delete_form
|
'form' : delete_form
|
||||||
} ) }}
|
} ) }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,59 +1,107 @@
|
|||||||
{#
|
<h1>{{ "Update activity"|trans ~ ' :' }}
|
||||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
<span style="font-size: 70%; text-transform: lowercase; margin-left: 1em;">
|
||||||
*
|
{{ entity.type.name|localize_translatable_string }}
|
||||||
* This program is free software: you can redistribute it and/or modify
|
</span>
|
||||||
* it under the terms of the GNU Affero General Public License as
|
</h1>
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#}
|
|
||||||
{% extends "@ChillPerson/layout.html.twig" %}
|
|
||||||
|
|
||||||
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
{{ form_start(edit_form) }}
|
||||||
|
{{ form_errors(edit_form) }}
|
||||||
|
|
||||||
{% block title 'Update activity'|trans %}
|
{%- if edit_form.emergency is defined -%}
|
||||||
|
{{ form_row(edit_form.emergency) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% block personcontent %}
|
{%- if edit_form.sentReceived is defined -%}
|
||||||
<h1>{{ "Update activity"|trans }}</h1>
|
{{ form_row(edit_form.sentReceived) }}
|
||||||
|
{% endif %}
|
||||||
{{ form_start(edit_form) }}
|
|
||||||
|
|
||||||
|
{%- if edit_form.user is defined -%}
|
||||||
{{ form_row(edit_form.user) }}
|
{{ form_row(edit_form.user) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if edit_form.scope is defined -%}
|
||||||
{{ form_row(edit_form.scope) }}
|
{{ form_row(edit_form.scope) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h2>{{ 'Activity data'|trans }}</h2>
|
{%- if edit_form.socialIssues is defined -%}
|
||||||
{{ form_row(edit_form.date) }}
|
{{ form_row(edit_form.socialIssues) }}
|
||||||
{{ form_row(edit_form.durationTime) }}
|
{% endif %}
|
||||||
{{ form_row(edit_form.type) }}
|
|
||||||
{{ form_row(edit_form.attendee) }}
|
{%- if edit_form.socialActions is defined -%}
|
||||||
|
{{ form_row(edit_form.socialActions) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="social-issues-acc"></div>
|
||||||
|
|
||||||
|
{%- if edit_form.reasons is defined -%}
|
||||||
{{ form_row(edit_form.reasons) }}
|
{{ form_row(edit_form.reasons) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if edit_form.persons is defined -%}
|
||||||
|
{{ form_widget(edit_form.persons) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if edit_form.thirdParties is defined -%}
|
||||||
|
{{ form_widget(edit_form.thirdParties) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if edit_form.users is defined -%}
|
||||||
|
{{ form_widget(edit_form.users) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="add-persons"></div>
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if edit_form.date is defined -%}
|
||||||
|
{{ form_row(edit_form.date) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
.. location
|
||||||
|
|
||||||
|
{%- if edit_form.durationTime is defined -%}
|
||||||
|
{{ form_row(edit_form.durationTime) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if edit_form.travelTime is defined -%}
|
||||||
|
{{ form_row(edit_form.travelTime) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if edit_form.comment is defined -%}
|
||||||
|
.. public and private
|
||||||
{{ form_row(edit_form.comment) }}
|
{{ form_row(edit_form.comment) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form_widget(edit_form) }}
|
{%- if edit_form.documents is defined -%}
|
||||||
<ul class="record_actions sticky-form-buttons">
|
{{ form_row(edit_form.documents) }}
|
||||||
<li class="cancel">
|
{% endif %}
|
||||||
<a href="{{ path('chill_activity_activity_show', { 'id': entity.id, 'person_id': entity.person.id } ) }}" class="sc-button bt-cancel">
|
|
||||||
{{ 'Cancel'|trans }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<button class="sc-button bt-update" type="submit">{{ 'Save activity'|trans }}</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
{{ form_end(edit_form) }}
|
|
||||||
|
|
||||||
{# {{ form(delete_form) }} #}
|
{%- if edit_form.attendee is defined -%}
|
||||||
{% endblock %}
|
{{ form_row(edit_form.attendee) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% block js %}
|
.. status
|
||||||
<script type="text/javascript">
|
|
||||||
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
{% set person_id = null %}
|
||||||
</script>
|
{% if entity.person %}
|
||||||
{% endblock %}
|
{% set person_id = entity.person.id %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% set accompanying_course_id = null %}
|
||||||
|
{% if accompanyingCourse %}
|
||||||
|
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a href="{{ path('chill_activity_activity_show', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id } ) }}" class="sc-button bt-cancel">
|
||||||
|
{{ 'Cancel'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="sc-button bt-update" type="submit">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{ form_end(edit_form) }}
|
||||||
|
|
||||||
|
{# {{ form(delete_form) }} #}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
||||||
|
|
||||||
|
{% block title 'Update activity'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
|
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.addEventListener('DOMContentLoaded', function (e) {
|
||||||
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]',
|
||||||
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
|
});
|
||||||
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
|
</script>
|
||||||
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
{#
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
{% extends "@ChillPerson/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
||||||
|
|
||||||
|
{% block title 'Update activity'|trans %}
|
||||||
|
|
||||||
|
{% block personcontent %}
|
||||||
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
|
{% include 'ChillActivityBundle:Activity:edit.html.twig' %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.addEventListener('DOMContentLoaded', function (e) {
|
||||||
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ edit_form.vars.form.vars.name }}"]',
|
||||||
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
|
});
|
||||||
|
window.activity = {{ activity_json|json_encode|raw }};
|
||||||
|
</script>
|
||||||
|
{{ encore_entry_script_tags('vue_activity') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
|
{{ encore_entry_link_tags('vue_activity') }}
|
||||||
|
{% endblock %}
|
||||||
@@ -1,87 +1,197 @@
|
|||||||
{#
|
{% set person_id = null %}
|
||||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
{% if person %}
|
||||||
*
|
{% set person_id = person.id %}
|
||||||
* This program is free software: you can redistribute it and/or modify
|
{% endif %}
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#}
|
|
||||||
{% extends "@ChillPerson/layout.html.twig" %}
|
|
||||||
|
|
||||||
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
{% set accompanying_course_id = null %}
|
||||||
|
{% if accompanyingCourse %}
|
||||||
|
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% block title %}{{ 'Activity list' |trans }}{% endblock title %}
|
<h2>{{ 'Activity list' |trans }}</h2>
|
||||||
|
|
||||||
{% block personcontent %}
|
{% if activities|length == 0 %}
|
||||||
<h2>{{ 'Activity list' |trans }}</h2>
|
<p class="chill-no-data-statement">
|
||||||
|
{{ "There isn't any activities."|trans }}
|
||||||
|
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="sc-button bt-create button-small"></a>
|
||||||
|
</p>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
{% if activities|length == 0 %}
|
<div class="flex-table list-records context-{{ context }}">
|
||||||
<p class="chill-no-data-statement">
|
<!--
|
||||||
{{ "There isn't any activities."|trans }}
|
<thead>
|
||||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person.id}) }}" class="sc-button bt-create button-small"></a>
|
<tr>
|
||||||
</p>
|
<th class="chill-red">{{'Date' | trans }}</th>
|
||||||
{% else %}
|
<th class="chill-green">{{'Duration Time' | trans }}</th>
|
||||||
<table class="records_list">
|
<th class="chill-orange">{{'Reasons' | trans}}</th>
|
||||||
<thead>
|
<th>{{'Type' | trans}}</th>
|
||||||
<tr>
|
<th> </th>
|
||||||
<th class="chill-red">{{'Date' | trans }}</th>
|
</tr>
|
||||||
<th class="chill-green">{{'Duration Time' | trans }}</th>
|
</thead>
|
||||||
<th class="chill-orange">{{'Reasons' | trans}}</th>
|
-->
|
||||||
<th>{{'Type' | trans}}</th>
|
{% for activity in activities %}
|
||||||
<th> </th>
|
{% set t = activity.type %}
|
||||||
</tr>
|
<div class="item-bloc">
|
||||||
</thead>
|
<div class="item-row main">
|
||||||
<tbody>
|
<div class="item-col">
|
||||||
{% for activity in activities %}
|
|
||||||
<tr>
|
{% if activity.date %}
|
||||||
<td>{% if activity.date %}{{ activity.date|format_date('long') }}{% endif %}</td>
|
<h3>{{ activity.date|format_date('long') }}</h3>
|
||||||
<td>{{ activity.durationTime|date('H:i') }}</td>
|
|
||||||
<td>
|
|
||||||
{% if activity.comment.comment is not empty %}
|
|
||||||
{{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- if activity.reasons is empty -%}
|
|
||||||
{{ 'No reason associated'|trans }}
|
<div class="duration">
|
||||||
{%- else -%}
|
{% if t.durationTimeVisible > 0 %}
|
||||||
{% for r in activity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}
|
<p>
|
||||||
{%- endif -%}
|
<i class="fa fa-fw fa-hourglass-end"></i>
|
||||||
</td>
|
{{ activity.durationTime|date('H:i') }}
|
||||||
<td>{{ activity.type.name | localize_translatable_string }}</td>
|
</p>
|
||||||
<td>
|
{% endif %}
|
||||||
|
|
||||||
|
{% if activity.travelTime and t.travelTimeVisible %}
|
||||||
|
<p>
|
||||||
|
<i class="fa fa-fw fa-car"></i>
|
||||||
|
{{ activity.travelTime|date('H:i') }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
|
||||||
|
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path(
|
||||||
|
"chill_person_accompanying_course_index",
|
||||||
|
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
|
||||||
|
) }}"
|
||||||
|
>
|
||||||
|
<i class="fa fa-random"></i>
|
||||||
|
{{ activity.accompanyingPeriod.id }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="item-col">
|
||||||
|
<ul class="list-content">
|
||||||
|
{% if activity.user and t.userVisible %}
|
||||||
|
<li>
|
||||||
|
<b>{{ 'by'|trans }}{{ activity.user.usernameCanonical }}</b>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<b>{{ activity.type.name | localize_translatable_string }}</b>
|
||||||
|
|
||||||
|
{% if activity.attendee is not null and t.attendeeVisible %}
|
||||||
|
{% if activity.attendee %}
|
||||||
|
{{ '→ ' ~ 'present'|trans|capitalize }}
|
||||||
|
{% else %}
|
||||||
|
{{ '→ ' ~ 'not present'|trans|capitalize }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<b>{{ 'location'|trans ~ ': ' }}</b>
|
||||||
|
Domicile de l'usager
|
||||||
|
{#
|
||||||
|
{% if activity.location %}{{ activity.location }}{% endif %}
|
||||||
|
#}
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{%- if t.reasonsVisible -%}
|
||||||
|
<li>
|
||||||
|
{%- if activity.reasons is empty -%}
|
||||||
|
<span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span>
|
||||||
|
{%- else -%}
|
||||||
|
{% for r in activity.reasons %}
|
||||||
|
{{ r|chill_entity_render_box }}
|
||||||
|
{% endfor %}
|
||||||
|
{%- endif -%}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if t.socialIssuesVisible %}
|
||||||
|
<li class="social-issues">
|
||||||
|
{%- if activity.socialIssues is empty -%}
|
||||||
|
<span class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</span>
|
||||||
|
{%- else -%}
|
||||||
|
{% for r in activity.socialIssues %}
|
||||||
|
{{ r|chill_entity_render_box }}
|
||||||
|
{% endfor %}
|
||||||
|
{%- endif -%}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if t.socialActionsVisible -%}
|
||||||
|
<li class="social-actions">
|
||||||
|
{%- if activity.socialActions is empty -%}
|
||||||
|
<span class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</span>
|
||||||
|
{%- else -%}
|
||||||
|
{% for r in activity.socialActions %}
|
||||||
|
<span class="badge badge-primary">{{ r.title|localize_translatable_string }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{%- endif -%}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person.id }) }}" class="sc-button bt-show "></a>
|
<a href="{{ path('chill_activity_activity_show', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}" class="sc-button bt-show "></a>
|
||||||
</li>
|
</li>
|
||||||
|
{# TOOD
|
||||||
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
||||||
|
#}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_edit', { 'id': activity.id, 'person_id': person.id }) }}" class="sc-button bt-update "></a>
|
<a href="{{ path('chill_activity_activity_edit', { 'id': activity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id }) }}" class="sc-button bt-update "></a>
|
||||||
</li>
|
</li>
|
||||||
|
{# TOOD
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if is_granted('CHILL_ACTIVITY_DELETE', activity) %}
|
{% if is_granted('CHILL_ACTIVITY_DELETE', activity) %}
|
||||||
|
#}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_delete', { 'id': activity.id, 'person_id' : person.id } ) }}" class="sc-button bt-delete "></a>
|
<a href="{{ path('chill_activity_activity_delete', { 'id': activity.id, 'person_id' : person_id, 'accompanying_period_id': accompanying_course_id } ) }}" class="sc-button bt-delete "></a>
|
||||||
</li>
|
</li>
|
||||||
|
{#
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
#}
|
||||||
</tr>
|
</ul>
|
||||||
{% endfor %}
|
</div>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
|
||||||
{% endif %}
|
{%
|
||||||
|
if activity.comment.comment is not empty
|
||||||
|
or activity.persons|length > 0
|
||||||
|
or activity.thirdParties|length > 0
|
||||||
|
or activity.users|length > 0
|
||||||
|
%}
|
||||||
|
<div class="item-row details">
|
||||||
|
<div class="item-col">
|
||||||
|
|
||||||
<ul class="record_actions">
|
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
|
||||||
<li>
|
</div>
|
||||||
<a href="{{ path('chill_activity_activity_new', {'person_id': person.id}) }}" class="sc-button bt-create">
|
|
||||||
{{ 'Add a new activity' | trans }}
|
{% if activity.comment.comment is not empty %}
|
||||||
</a>
|
<div class="item-col comment">
|
||||||
</li>
|
{{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
|
||||||
</ul>
|
</div>
|
||||||
{% endblock %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if context != 'person' %}
|
||||||
|
{# TODO set this condition in configuration #}
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_activity_activity_new', {'person_id': person_id, 'accompanying_period_id': accompanying_course_id}) }}" class="sc-button bt-create">
|
||||||
|
{{ 'Add a new activity' | trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'Activity list' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'accompanyingCourse'} %}
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{#
|
||||||
|
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#}
|
||||||
|
{% extends "@ChillPerson/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_activity_activity_list' %}
|
||||||
|
|
||||||
|
{% block title %}{{ 'Activity list' |trans }}{% endblock title %}
|
||||||
|
|
||||||
|
{% block personcontent %}
|
||||||
|
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'person'} %}
|
||||||
|
{% endblock %}
|
||||||
@@ -1,50 +1,105 @@
|
|||||||
{#
|
<h1>{{ "Activity creation"|trans ~ ' :' }}
|
||||||
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
|
<span style="font-size: 70%; text-transform: lowercase; margin-left: 1em;">
|
||||||
*
|
{{ entity.type.name|localize_translatable_string }}
|
||||||
* This program is free software: you can redistribute it and/or modify
|
</span>
|
||||||
* it under the terms of the GNU Affero General Public License as
|
</h1>
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#}
|
|
||||||
{% extends "@ChillPerson/layout.html.twig" %}
|
|
||||||
|
|
||||||
{% set activeRouteKey = 'chill_activity_activity_new' %}
|
{{ form_start(form) }}
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
{% block title 'Activity creation' |trans %}
|
|
||||||
|
|
||||||
{% block personcontent %}
|
{%- if form.emergency is defined -%}
|
||||||
<h2 class="chill-red">{{ "Activity creation"|trans }}</h1>
|
{{ form_row(form.emergency) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{%- if form.sentReceived is defined -%}
|
||||||
|
{{ form_row(form.sentReceived) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.user is defined -%}
|
||||||
{{ form_row(form.user) }}
|
{{ form_row(form.user) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.scope is defined -%}
|
||||||
{{ form_row(form.scope) }}
|
{{ form_row(form.scope) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
{%- if form.socialIssues is defined -%}
|
||||||
|
{{ form_row(form.socialIssues) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ form_row(form.date) }}
|
{%- if form.socialActions is defined -%}
|
||||||
{{ form_row(form.durationTime) }}
|
{{ form_row(form.socialActions) }}
|
||||||
{{ form_row(form.type) }}
|
{% endif %}
|
||||||
{{ form_row(form.attendee) }}
|
|
||||||
|
<div id="social-issues-acc"></div>
|
||||||
|
|
||||||
|
{%- if form.reasons is defined -%}
|
||||||
{{ form_row(form.reasons) }}
|
{{ form_row(form.reasons) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if form.persons is defined -%}
|
||||||
|
{{ form_widget(form.persons) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.thirdParties is defined -%}
|
||||||
|
{{ form_widget(form.thirdParties) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.users is defined -%}
|
||||||
|
{{ form_widget(form.users) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="add-persons"></div>
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if form.date is defined -%}
|
||||||
|
{{ form_row(form.date) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
.. location
|
||||||
|
|
||||||
|
{%- if form.durationTime is defined -%}
|
||||||
|
{{ form_row(form.durationTime) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.travelTime is defined -%}
|
||||||
|
{{ form_row(form.travelTime) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.comment is defined -%}
|
||||||
|
.. public and private
|
||||||
{{ form_row(form.comment) }}
|
{{ form_row(form.comment) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="grid-12 centered sticky-form-buttons">
|
{%- if form.documents is defined -%}
|
||||||
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add a new activity'|trans }}</button>
|
{{ form_row(form.documents) }}
|
||||||
</div>
|
{% endif %}
|
||||||
{{ form_end(form) }}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block js %}
|
{%- if form.attendee is defined -%}
|
||||||
<script type="text/javascript">
|
{{ form_row(form.attendee) }}
|
||||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]', '{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
{% endif %}
|
||||||
</script>
|
|
||||||
{% endblock %}
|
.. status
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a
|
||||||
|
class="sc-button bt-cancel"
|
||||||
|
{%- if context == 'person' -%}
|
||||||
|
href="{{ chill_return_path_or('chill_activity_activity_list', { 'person_id': person.id } )}}"
|
||||||
|
{%- else -%}
|
||||||
|
href="{{ chill_return_path_or('chill_activity_activity_list', { 'accompanying_period_id': accompanyingCourse.id } )}}"
|
||||||
|
{%- endif -%}
|
||||||
|
>
|
||||||
|
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="sc-button bt-create" type="submit">
|
||||||
|
{{ 'Create'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user